Skip to content

Instantly share code, notes, and snippets.

View skyblue's full-sized avatar
🎯
Focusing

Skyblue skyblue

🎯
Focusing
View GitHub Profile
<h1>Demo code for "Extreme JavaScript Performance" @ JSConf.eu</h1>
<script>
var benchmark = function(m,i){
var d1 = new Date, d2, r;
while(i--) r = m();
d2 = new Date;
console.log(d2.getTime()-d1.getTime());
// if(r) console.log(r);
}
@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@TooTallNate
TooTallNate / iphone4.2-node-configure
Created December 23, 2010 06:12
Runs "configure" for Node.js, with the intent of cross-compiling Node for ARM on an Apple iOS device.
#! /bin/bash
#
# Program : iphone4.2-node-configure
# Authors : Nathan Rajlich (nathan@tootallnate.net)
# Michael Aaron Safyan (michaelsafyan@gmail.com)
# Synopsis : This program runs the "configure" script for Node.js.
# An install prefix of "/opt/iphone-4.2/" is used.
unset CPATH
@remy
remy / audiosprite.js
Created December 23, 2010 13:54
An example of how an audio sprite can be used (includes fixes for iOS)
function Track(src, spriteLength, audioLead) {
var track = this,
audio = document.createElement('audio');
audio.src = src;
audio.autobuffer = true;
audio.load();
audio.muted = true; // makes no difference on iOS :(
/* This is the magic. Since we can't preload, and loading requires a user's
input. So we bind a touch event to the body, and fingers crossed, the
@bebraw
bebraw / gameengines.md
Created January 6, 2011 18:07
List of JS game engines. You can find a wikified version at https://github.com/bebraw/jswiki/wiki/Game-Engines. Feel free to modify that. I sync it here every once in a while.

IMPORTANT! Remember to check out the wiki page at https://github.com/bebraw/jswiki/wiki/Game-Engines for the most up to date version. There's also a "notes" column in the table but it simply does not fit there... Check out the raw version to see it.

This table contains primarily HTML5 based game engines and frameworks. You might also want to check out the [[Feature Matrix|Game-Engine-Feature-Matrix]], [[Game Resources]] and [[Scene Graphs]].

Name Size (KB) License Type Unit Tests Docs Repository Notes
Akihabara 453 GPL2, MIT Classic Repro no API github Intended for making classic arcade-style games in JS+HTML5
AllBinary Platform Platform Dependent AllBinary 2D/2.5D/3D n
@mwbrooks
mwbrooks / MyProjectAppDelegate.m
Created February 9, 2011 18:57
Disable telephone number detection in PhoneGap-iOS
// ...
- (void)webViewDidStartLoad:(UIWebView *)theWebView
{
// disable telephone detection, basically <meta name="format-detection" content="telephone=no" />
theWebView.dataDetectorTypes = UIDataDetectorTypeAll ^ UIDataDetectorTypePhoneNumber;
return [ super webViewDidStartLoad:theWebView ];
}
@jminor
jminor / a_star.js
Created February 15, 2011 17:49
A* path finding algorithm for impactjs game engine
// A* path finding algorithm for impactjs game engine
// adapted from http://stormhorse.com/a_star.js
// via http://46dogs.blogspot.com/2009/10/star-pathroute-finding-javascript-code.html
// impact-ified by jminor - http://pixelverse.org/
/* Example:
this.pathFinder = new PathFinder();
var start = [((this.pos.x+this.size.x/2) / tilesize).floor(), ((this.pos.y+this.size.y/2) / tilesize).floor()];
var destination = [((target.pos.x+target.size.x/2) / tilesize).floor(), ((target.pos.y+target.size.y/2) / tilesize).floor()];
@probablycorey
probablycorey / WaxRetainIssueAppDelegate.m
Created February 18, 2011 19:12
WaxRetainIssueAppDelegate.m
//
// WaxRetainIssueAppDelegate.m
// WaxRetainIssue
//
// Created by Martin Cote on 11-02-17.
// Copyright Loopycube 2011. All rights reserved.
//
#import "WaxRetainIssueAppDelegate.h"
#import "WaxRetainIssueViewController.h"
@billywhizz
billywhizz / try-catch-test.js
Created February 20, 2011 22:36
testing try catch performance in v8/node.js
function test1() {
function test(j) {
var s = 0;
for (var i = 0; i < j; i++) s = i;
for (var i = 0; i < j; i++) s = i;
for (var i = 0; i < j; i++) s = i;
for (var i = 0; i < j; i++) s = i;
return s;
}
@ricardobeat
ricardobeat / semaphore.js
Created March 3, 2011 01:30
simple semaphore for parallel async execution, with error handling.
function queue(name){
queue.q[name]++ || (queue.q[name] = 1);
return function(err){
if (err && queue.e[name]) queue.e[name](err);
else if (err) throw err;
process.nextTick(function(){
queue.q[name]--;
queue.check(name);
});
}