for ([initialization]; [condition]; [final-expression]) {
statement
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$players = ["X", "O"]; | |
$current_player_idx = getPlayerIdx(); | |
$player = $players[$current_player_idx]; | |
$next_player_idx = getNextPlayerIdx($current_player_idx); | |
$board = [ | |
[null, null, null], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: node getStats.js yarnpkg/yarn '2016-10-11T14:50:00.000Z' username password | |
// Note: install `async` and `github` packages | |
var async = require('async') | |
, GitHubApi = require("github"); | |
var github = new GitHubApi({ | |
// required | |
version: "3.0.0", | |
protocol: "https", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Todo('todo'); | |
function Todo(id){ | |
this.items = []; | |
this.el = $(id); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Singleton | |
{ | |
/** | |
* @var Singleton The reference to *Singleton* instance of this class | |
*/ | |
private static $instance; | |
/** | |
* Returns the *Singleton* instance of this class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add a handy super call for all objects | |
MyBaseClass.prototype.super = function () { | |
var parent = this.__proto__.__proto__; | |
var caller = arguments.callee.caller; | |
var fn; | |
if (caller.prototype === this.__proto__) { | |
return parent.constructor.apply(this, arguments); | |
} else { | |
// This is probably quite slow, but it doesn't seem to affect | |
// performance too much in real tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert') | |
, subclass = function(type, proto){ | |
// make sure we are extending a global constructor | |
// accepted: [Boolean, Number, String, Array, Object, Function, RegExp, Date] | |
if(!global[type.name] || global[type.name].name != type.name) throw new Error(); | |
var constructor = proto.constructor, | |
keys = Object.keys(proto), | |
Obj = process.binding('evals').Script.runInNewContext('x = '+type.name), // eval ftw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: nw | |
* Date: 9/8/15 | |
* Time: 8:33 PM | |
*/ | |
function ATM($withdraw, $balance) | |
{ | |
$transaction_fee = 0.50; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result = {'array':[1,2,3], | |
'string':'hello', | |
'hash':{'a':1, 'b':2}, | |
'date':new Date(), // Stores only milisecond resolution | |
'int':42, | |
'float':33.3333, | |
'regexp':/foobar/i, | |
'boolean':true, | |
'null':null}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model.define('User',{ | |
collection : 'test_user', // (optional) if not present uses the model name instead. | |
// defines your data structure | |
types: { | |
_id : Object, // if not defined, Mongoose automatically defines for you. | |
username: String, | |
first : String, | |
last : String, |
NewerOlder