Serial communication is still used a bit today. Arduino's are fun programmable microcontrollers and the main method of communication is serial over USB. This example will show you how to communicate using serial in Perl.
CPAN is a Perl tool for installing and managing modules. CPAN stands for the Comprehensive Perl Archive Network. There are many mirrors around the world that host the same CPAN archive. Sometimes mirrors shut down or you may want to add mirrors that are closer to you. These examples demonstrate how to add and remove mirrors from your configuration.
Standard in and Standard out (STDIN/STDOUT) are very common methods of interacting with the user. Standard in is typically the keyboard and standard out is the terminal. Haskell makes this very easy to access. The getLine function gets a value from the user and putStrLn and putStr allow you to write to output. The ++ operator is used to concatenate strings.
In Haskell, you can access the command line arguments with getArgs. Check out this example.
Haskell is a purely functional programming language create in 1990. This Hello World example will help you get started with Haskell. Install Haskell for your system from the Haskell website. The program installed is called ghc which stands for the Glasgow Haskell Compiler. It can be run interactively or as a compiler.
C and Assembly can be used together to provide extra flexibility. You can create static libraries in Assembly that you call from C, and vice-versa, you can call C functions from within Assembly. Check out the code samples below that demonstrate that process.
NASM, or The Netwide Assembler, is an x86 compiler that allows us to turn Assembly code in to machine code object files. Once we have an object file, we can link it and create the final executable. This example is meant for Unix systems or Windows with MinGW toolchain installed. On Debian systems, it can be installed with the nasm package. Put the code below in to hello.asm
Scala programs can accept run-time variables as command line arguments. Here is an example of how to access the variables.
Scala provides some of its own libraries for IO, but we can also make use of the Java library. The example of reading a file uses Scala's IO package, but the file writing example uses the Java IO package.
Scala is a an object oriented functional language built on top of the Java Virtual Machine. (JVM). Because it is an extension of Java, you still have everything available to you as you normally would in Java. Check out this Hello World example.
Control structures like if/else statements, for loops, and switch cases are vital to writing program logic. These code snippets will serve as easy references for these control structures when writing with the Tcl programming language
There are many situations where it is useful to ask the user for some information while a program is running. Tcl makes this a breeze. Check out these code snippets that demonstrate how to interact with the user and manipulate input.
Tcl programs can accept command line arguments to pass runtime variables. These code examples show how to make use of these arguments.
Tcl provides an easy way to open and read the lines of a file. Check out these code snippets that demonstrate how to read and write files with Tcl programming language.
Tcl is a language similar Bash because every line is a command and it can be scripted similar to shell scripts. Tcl can be used by itself but it typically embedded inside larger applications. Tcl with Tk toolkit allows you to create GUI applications. Once nice thing about Tcl/Tk is that it is widely available and works on multiple platforms. It does not create the nicest looking GUIs because it does not use native windows, but they are effective. Let's look at the most basic Hello World program. Let's name it hello.tcl.
Writing a Chrome extension is incredibly easy! You don't need any special tools either, just a text editor and Chrome. Create a folder and make a manifest.json and an index.html file. Fill them in with the information below and you are ready to go!
It is possible to write GTK2 application using PHP. It is a little work to get it compiled and installed, but once configured it is easy to write programs with GTK2. As of June 22, 2015 a development branch has been created for GTK3. Follow these installation instructions first. Then try out the code samples below. Load the php-gtk2 module in your php.ini as well.
PHP Simple HTML DOM is a one-file library that lets you traverse the elements of an HTML and search for specific elements. The examples below show how to use this library. To learn how to crawl (or spider) websites in order to get many pages to process see this post on How to Crawl Web Pages with PHP
Uwe Hunfeld provides an object oriented library called PHPCrawl available at http://phpcrawl.cuab.de. This class can be used to crawl web pages with many different parameters. It also allows you to process each page and do what manipulation or scraping you need to do. You accomplish this by overriding the base class and implementing your own functionality in the handleDocumentInfo() and handleHeaderInfo() functions. Use the code below as an example of how to create your own web crawler. If you want to learn how to parse the HTML DOM and extract things like links and headings, check out the post on How to Parse HTML DOM with PHP.
PHP/TK implements object oriented bindings for TCL/TK that can be used to create GUI applications. It only works on Unix systems. PHP must be configured to allow dynamic linking with enable_dl = On in the php.ini. The shared object file (tk.so) can be downloaded manually from PECL. The shared object file goes inside your php modules folder which is typically something like /usr/lib/php/modules. Look for the folder with other .so files or refer to your particular distribution documentation.