Skip to content

Instantly share code, notes, and snippets.

@phoboslab
phoboslab / setAnimation.js
Created May 6, 2012
setAnimation; a sensible requestAnimation polyfill
View setAnimation.js
// rAF polyfill based on https://gist.github.com/1579671
(function(w) {
"use strict";
// Find vendor prefix, if any
var vendors = ['ms', 'moz', 'webkit', 'o'];
for( var i = 0; i < vendors.length && !w.requestAnimationFrame; i++ ) {
w.requestAnimationFrame = w[vendors[i]+'RequestAnimationFrame'];
}
@phoboslab
phoboslab / mousemove.py
Created Jun 26, 2012
Python script to move the mouse cursor in windows with constant speed
View mousemove.py
import sys
import time
import win32api
if (len(sys.argv) < 4):
print "Usage: python mousemove.py dx dy speed"
sys.exit()
current = win32api.GetCursorPos()
cx = sx = current[0]
@phoboslab
phoboslab / touch-button.js
Last active Aug 10, 2021
Touch Button Plugin for Impact
View touch-button.js
ig.module(
'plugins.touch-button'
)
.requires(
'impact.system',
'impact.input',
'impact.image'
)
.defines(function(){ "use strict";
View gist:3824284
ig.module(
'plugins.touch-button'
)
.requires(
'impact.system',
'impact.input',
'impact.image'
)
.defines(function(){
@phoboslab
phoboslab / gist:3939020
Created Oct 23, 2012
AnalogStick plugin
View gist:3939020
ig.module(
'plugins.analog-stick'
)
.requires(
'impact.system'
)
.defines(function(){
ig.AnalogStick = ig.Class.extend({
stickSize: 30,
View menus.js
ig.module(
'game.menus'
)
.requires(
'impact.font'
)
.defines(function(){
MenuItem = ig.Class.extend({
getText: function(){ return 'none' },
View gist:5249534
var video = document.createElement('video');
console.log( 'can play mp4', video.canPlayType('video/mp4') );
video.src = 'test.mov';
// Also loads from the internet:
//video.src = 'http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov';
// Show playback controls:
//video.controls = true;
@phoboslab
phoboslab / OBJLoader.js
Created Jul 10, 2013
OBJLoader for Three.js/Ejecta
View OBJLoader.js
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.OBJLoader = function () {
THREE.EventDispatcher.call( this );
};
@phoboslab
phoboslab / gist:5967844
Created Jul 10, 2013
Get Wifi or Public IP on the iPhone. Works with iOS7
View gist:5967844
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <net/if.h>
void ip_for_interface(const char *interface_name, char *ip, const int length) {
*ip = NULL;
@phoboslab
phoboslab / gist:10671262
Created Apr 14, 2014
ejecta color hash generator
View gist:10671262
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
typedef union {
unsigned int hex;
struct {
unsigned char r, g, b, a;