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...
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...
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) # => ...
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...
Let's take a sample class:
public class Transaction
{
public string Category { get; set; }
public DateTime Date { get; set; }
public decimal Amount { get; set; }
}
Now, let us consider a list of transactions:
var transactions = new List<Transaction>
{
new Transaction...
UISplitViewController must be the rootViewController of your application.
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] i...
Pair allows us to treat two objects as one object. Pairs can be easily constructed with the help of template function std::make_pair.
Alternative way is to create pair and assign its elements (first and second) later.
#include <iostream>
#include <utility>
int main()
{
std::p...
GNU Emacs uses a special format for documentation: info.
The Common Lisp standard has been converted to the Texinfo format, which can be used to create documentation browsable with the info reader in GNU Emacs.
See here: dpans2texi.el converts the TeX sources of the draft ANSI Common Lisp standard...
The axis offsets for drawing the marker that are specified by refX and refY are applied before the rotation specified by the orient parameter. Below you can see the effects of various combinations of orient and refX, refY to illustrate this.
<svg width="800px" height="600px"&...
Elements can specify start, mid and end markers separately. Below are examples of start, mid and end markers for all elements that can be marked. Please note that Chrome does not currently (July 2016) calculate auto orientation correctly for start and end markers for polygons (bug# 633012), and also...
Notepad++ provides 2 types of features for auto-completion and suggestions:
Auto-completion that reads the open file and provide suggestion of words and/or functions within the file
Suggestion with the arguments of functions (specific to the language)
To enable it, you need to change a settin...
ODS (on-disk structure) version is a number representing version of the database low-level data layout structure (ODS). When a new feature is added to Firebird it might or might not require the structure of database pages or system tables (database metadata) to change. If it does, the ODS version mu...
In simple terms:
UNION joins 2 result sets while removing duplicates from the result set
UNION ALL joins 2 result sets without attempting to remove duplicates
One mistake many people make is to use a UNION when they do not need to have the duplicates removed. The additional performance cost...
Ionic uses Gulp, so install gulp-babel and gulp-plumber.
npm install --save-dev gulp-babel gulp-plumber
Add babel to gulpfile.js like so:
//...
var babel = require("gulp-babel");
var plumber = require("gulp-plumber");
var paths = {
es6: ['./src/es6/*.js'],
sass: ...
C#
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Interactions;
namespace WebDriverActions
{
class WebDriverTest
{
static void Main()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("...
The igraph package for R is a wonderful tool that can be used to model networks, both real and virtual, with simplicity. This example is meant to demonstrate how to create two simple network graphs using the igraph package within R v.3.2.3.
Non-Directed Network
The network is created with this pie...