Skip to content

Instantly share code, notes, and snippets.

@allouis
allouis / bitwise.js
Created September 2, 2013 17:54
Bitwise stuff
// true to 0, false to 1;
var tBool = true;
var fBool = false
tBool^1 // 0
fBool^1 // 1
// true to 1, false to 0;
var tBool = true;
var fBool = false;
@allouis
allouis / _mvc.js
Created March 20, 2014 22:26
Model View Controller Psuedoshite
var BookModel = Model.extend({
length: function () {
// take two for contents and index
return this.pages.length - 2;
}
});
var BookController = Controller.extend({
events: {
"click .save": "saveBook",
@allouis
allouis / jsbin.md
Last active August 29, 2015 13:58
Things i didn't know about jsbin

This is a list of things I didn't know about jsbin, and so assume others don't either.

  • 'Zen' mode, command, shift and \
  • PhoneGap development support
@allouis
allouis / api.js
Created April 16, 2014 10:44
Multiple file gist
var api = {};
module.exports = indexjs;
var fs = require('fs');
var path = require('path');
function indexjs (dirname) {
return fs.readdirSync(dirname).reduce(createModuleArray(dirname));
}
function createModuleArray (dirname) {
var Module = null;
function JSMESS(canvas, module, game, precallback, callback, scale) {
var js_data;
var moduledata;
var requests = [];
var drawloadingtimer;
var file_countdown;
var spinnerrot = 0;
var splashimg = new Image();
@allouis
allouis / index.md
Last active August 29, 2015 14:06
Codebar yeah

Introduction to Arduino

In this lesson we will learn about using Javascript to interact with hardware. We will be using a platform called Node.js which runs Javascript outside of the browser.

What is an Arduino?

Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. arduino.cc

Basic Circuitry

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. nodejs.org

Imgur

@allouis
allouis / next-issue.js
Created September 30, 2014 11:19
Github next issue
var nextButtonHTML = '<button type="button" class="minibutton js-next-issue">Next</button>';
var buttonsContainer = document.querySelector('.gh-header-actions');
var currentURL = window.location.href;
var parts = currentURL.split('/');
parts[parts.length - 1]--; // next issue - but going back because usually start at the end
var nextURL = parts.join('/');
buttonsContainer.innerHTML += nextButtonHTML;
@allouis
allouis / cleanup.js
Created October 15, 2014 11:44
cleanup jsbin directory on server
var fs = require('fs');
var semver = require('semver');
var numToKeep = process.argv[2] || 2;
var files = fs.readdirSync(__dirname).filter(function (file) {
return file.indexOf('jsbin-v') === 0;
}).sort(function (a, b) {
return semver.lt(a.slice(7), b.slice(7));
var PlayerController = function PlayerController(opts) {
this.model = PlayerModel.create({
blah: 'blah'
});
keyCodes.on('keyDown', function (direction) {
this[direction]();
}, this); // third arg is context of `this`
};
PlayerController.prototype = {