Tutorial by Examples: n

ValueConverted To StringConverted To NumberConverted To Booleanundefinded"undefined"NaNfalsenull"null"0falsetrue"true"1false"false"0NaN"NaN"false"" empty string0false" "0true"2.4" (numeric)2.4true"test" (non nu...
class base { }; class derived: public base { }; int main() { base* p = new derived(); delete p; // The is undefined behavior! } In section [expr.delete] §5.3.5/3 the standard says that if delete is called on an object whose static type does not have a virtual destructor: if the...
In C++ methods that differs only by const qualifier can be overloaded. Sometimes there may be a need of two versions of getter that return a reference to some member. Let Foo be a class, that has two methods that perform identical operations and returns a reference to an object of type Bar: class ...
A lot of users find themselves in a situation where they just want to copy, move or delete a line quickly and return to where they were. Usually, if you'd want to move a line which contains the word lot below the current line you'd type something like: /lot<Esc>dd<C-o>p But to boost...
This is a basic in-app keyboard. The same method could be used to make just about any keyboard layout. Here are the main things that need to be done: Create the keyboard layout in an .xib file, whose owner is a Swift or Objective-C class that is a UIView subclass. Tell the UITextField to use t...
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...

Page 535 of 1088