Skip to content

Instantly share code, notes, and snippets.

View skyblue's full-sized avatar
🎯
Focusing

Skyblue skyblue

🎯
Focusing
View GitHub Profile
@joevennix
joevennix / add-to-home-screen.js
Created April 17, 2012 14:25
Add to home screen callout
// display "add to home screen" floater on iphones
// copy and paste this anywhere.
(function(){
if (document.cookie.match(/ADD_HOME_TOUCH=1/)) return;
document.addEventListener('DOMContentLoaded', function() {
if (navigator.userAgent.match(/iphone|ipod/i)) {
// create & inject css
var parent = document.body;
var arrowHeight = 56;
var bubbleHeight = 130;
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@Deco
Deco / coroutine_scheduler.lua
Created February 13, 2012 16:38
Lua Coroutine Scheduler
pcall(require,"socket")
local coroutine_scheduler = {
_NAME = "coroutine_scheduler.lua"
_VERSION = "1.0.0",
}
local Scheduler
do Scheduler = setmetatable({}, {
__call = function(class)
@flockonus
flockonus / app.js
Created September 6, 2011 18:14
An Express app that should integrate to socket.io
/**
* Module dependencies.
*/
var express = require('express');
var app = module.exports = express.createServer();
io = require('socket.io').listen(app),
@paularmstrong
paularmstrong / a_star.js
Created May 27, 2011 02:33 — forked from jminor/a_star.js
A* path finding algorithm for impactjs game engine
/**
* AStar
*
* Created by Paul Armstrong on 2011-05-26.
* Copyright (c) 2011 Paul Armstrong Designs. All rights reserved.
*
* Based on: https://gist.github.com/827899
*/
ig.module('plugins.a-star')
@sintaxi
sintaxi / application.js
Created April 21, 2011 21:00
simple chat client using redis pub/sub
var q= function(s){ return document.getElementById(s) }
function send(){
var input = q('text');
socket.send(input.value);
input.value = '';
}
var socket = new io.Socket(null, {
port: 8001,
@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);
});
}
@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;
}
@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"
@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()];