Skip to content

Instantly share code, notes, and snippets.

// 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",
<?php
class Singleton
{
/**
* @var Singleton The reference to *Singleton* instance of this class
*/
private static $instance;
/**
* Returns the *Singleton* instance of this class.
@nw
nw / ttt.php
Created September 10, 2015 02:33
<?php
$players = ["X", "O"];
$current_player_idx = getPlayerIdx();
$player = $players[$current_player_idx];
$next_player_idx = getNextPlayerIdx($current_player_idx);
$board = [
[null, null, null],
@nw
nw / atm.php
Created September 9, 2015 02:43
<?php
/**
* Created by PhpStorm.
* User: nw
* Date: 9/8/15
* Time: 8:33 PM
*/
function ATM($withdraw, $balance)
{
$transaction_fee = 0.50;
# example uses shared folder /media/sf_vm/www, change for your needs
sudo usermod -a -G vboxsf www-data
sudo usermod -a -G vboxsf <user name>
cd /etc/apache2/sites-available
sudo cp 000-default.conf weblab.conf
sudo nano weblab.conf
// Change DocumentRoot to point at your shared mount `www` directory /media/sf_vm/www
// cntrl-x then 'Y' to save changes
var games = [
"4.....8.5.3..........7......2.....6.....8.4......1.......6.3.7.5..2.....1.4......",
"52...6.........7.13...........4..8..6......5...........418.........3..2...87.....",
"6.....8.3.4.7.................5.4.7.3..2.....1.6.......2.....5.....8.6......1....",
"48.3............71.2.......7.5....6....2..8.............1.76...3.....4......5....",
"....14....3....2...7..........9...3.6.1.............8.2.....1.4....5.6.....7.8...",
"......52..8.4......3...9...5.1...6..2..7........3.....6...1..........7.4.......3.",
"6.2.5.........3.4..........43...8....1....2........7..5..27...........81...6.....",
".524.........7.1..............8.2...3.....6...9.5.....1.6.3...........897........",
@nw
nw / hilow.js
Created March 25, 2015 03:20
Hi Low Guess Game
$(function(){
var input = $('#guess')
, btn = $('#guess_btn')
, status = $('#guesses')
, reset = $('#reset');
var guesses = 0;

Syntax

for ([initialization]; [condition]; [final-expression]) {
  statement
}

initialization

@nw
nw / debug.js
Created November 7, 2014 06:40
var tessel = require('tessel')
, fs = require('fs')
, ambient = require('ambient-attx4').use(tessel.port['A'])
, audio = require('audio-vs1053b').use(tessel.port['D']);
var audioFile = fs.readFileSync('sample.mp3') // load mp3 into memory (small 29kb - 2.5 secs)
, timeout = 1000 * 60 // how long to wait after trigger and actions have happened.
, threshold = .2 // ambient noise trigger
, queue = 2; // number of modules to wait for