Tutorial by Examples

Background: if you work on a project like the Linux kernel, rather than make a pull request you will need to submit your commits to a listserv for review. This entry details how to use git-send email with Gmail. Add the following to your .gitconfig file: [sendemail] smtpserver = smtp.googlema...
A Static variable declared locally is not destructed and does not lose its value when the Sub procedure is exited. Subsequent calls to the procedure do not require re-initialization or assignment although you may want to 'zero' any remembered value(s). These are particularly useful when late bindin...
Streams can be built that reference themselves and thus become infinitely recursive. // factorial val fact: Stream[BigInt] = 1 #:: fact.zipWithIndex.map{case (p,x)=>p*(x+1)} fact.take(10) // (1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880) fact(24) // 620448401733239439360000 // the ...
To list files and folders inside current directory, we use ls command: user@host:/$ ls bin boot cdrom dev etc home initrd.img lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var vmlinuz ls prints folder structure in simple view, color coded by type....
This example adds a new rectangle to the canvas every 1 second (== a 1 second interval) Annotated Code: <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <script> window.onload=(functio...
This example animates a clock showing the seconds as a filled wedge Annotated Code: <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <script> window.onload=(function(){ // canva...
requestAnimationFrame is similar to setInterval, it but has these important improvements: The animation code is synchronized with display refreshes for efficiency The clear + redraw code is scheduled, but not immediately executed. The browser will execute the clear + redraw code only when the d...
This example loads and animates and image across the Canvas Important Hint! Make sure you give your image time to fully load by using image.onload. Annotated Code <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid re...
During mousemove you get flooded with 30 mouse events per second. You might not be able to redraw your drawings at 30 times per second. Even if you can, you're probably wasting computing power by drawing when the browser is not ready to draw (wasted == across display refresh cycles). Therefore it m...
A distribution can be downloaded from the Apache Struts website. The full distribution contains: the struts2-core.jar file related dependencies example applications a copy of the documentation in HTML format the complete source code. Blank Application The blank web application in the dis...
<#@ template language="C#" #> //Language of your project <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" ...
You can create a UIColor object using an image pattern by using the UIColor(patternImage:_) method. btn.backgroundColor = UIColor(patternImage: UIImage(named: "image")!)
Using varargs as a parameter for a method definition, it is possible to pass either an array or a sequence of arguments. If a sequence of arguments are passed, they are converted into an array automatically. This example shows both an array and a sequence of arguments being passed into the printVar...
Intro The Graphics class allows you to draw onto java components such as a Jpanel, it can be used to draw strings, lines, shapes and images. This is done by overriding the paintComponent(Graphics g) method of the JComponent you are drawing on using the Graphics object received as argument to do the...
Images can be drawn onto a JComponent using the drawImage method of class Graphics: loading an image BufferedImage img; try { img = ImageIO.read(new File("stackoverflow.jpg")); } catch (IOException e) { throw new RuntimeException("Could not load image", e); } dr...
The even? method can be used to determine if a number is even 4.even? # => true 5.even? # => false The odd? method can be used to determine if a number is odd 4.odd? # => false 5.odd? # => true
The round method will round a number up if the first digit after its decimal place is 5 or higher and round down if that digit is 4 or lower. This takes in an optional argument for the precision you're looking for. 4.89.round # => 5 4.25.round # => 4 3.141526.round(1) # => ...
If you need to clamp a number to keep it inside a specific range boundary function clamp(min, max, val) { return Math.min(Math.max(min, +val), max); } console.log(clamp(-10, 10, "4.30")); // 4.3 console.log(clamp(-10, 10, -8)); // -8 console.log(clamp(-10, 10, 12)); // ...
Detailed instructions on getting netty set up or installed.
Invented by John McCarthy around 1958, Lisp (List Processor) has continued to grow into an entire family of languages. Since StackOverflow is more about practical programming problems, typically problems will involve actual Lisp dialects or derived languages and their implementations. Problems that...

Page 658 of 1336