Skip to content

Instantly share code, notes, and snippets.

@d48
d48 / umd-templates.js
Created August 1, 2017 23:25 — forked from mflorida/umd-templates.js
Templates for UMD patterns
/**
* UMD pattern with anonymous function expression
*/
(function(){
var umd = function(factory){
if (typeof exports === 'object') {
return module.exports = factory();
}
else if (typeof define === 'function' && define.amd) {

The game we're building is a simple side-scrolling racing game. The player's car is static on the screen, only the background is moving. The enemies are planes whom the player must dodge using the up and down arrow keys. If the player hits a plane, he dies. One point is given each time a plane goes off screen without touching the player.

Sprites

Our game is composed of sprites. Each sprite has a position (x, y), velocity (speed) and one image, or more if animated.

Images are loaded from the DOM using their CSS selector (imagesSelector). We use ID selectors (#name) for single images and class selectors (.name) for animated sprites composed of several images.

See the images used in the game.

data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/javascript");</script>
@d48
d48 / ie.shims.js
Created December 3, 2012 04:50 — forked from dhm116/ie.shims.js
IE7/8 Javascript method shims
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@d48
d48 / facebook-login.sh
Created August 28, 2012 17:21 — forked from hubgit/facebook-login.sh
Login to Github using cURL
#!/bin/bash
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
curl -X POST 'https://github.com/login' --verbose --user-agent $USER_AGENT --data-urlencode "name=${EMAIL}" --data-urlencode "pass=${PASS}" --cookie $COOKIES --cookie-jar $COOKIES
curl -X GET 'https://github.com/dashboard/pulls' --verbose --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES
@d48
d48 / ssl.md
Created June 6, 2012 19:58 — forked from 8bitDesigner/ssl.md
Getting Apache SSL working locally

Lovingly skimmed from this guide

  1. Find your local host name, and hang onto it for later use
$ hostname
  1. Create a self-signed SSL cert:
openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 -nodes \