Skip to content

Instantly share code, notes, and snippets.

View premasagar's full-sized avatar

Prem Rose premasagar

View GitHub Profile
@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
@premasagar
premasagar / enumerables.js
Created January 17, 2011 17:59
Enumerable arrays and objects - useful methods
var forEach = Array.prototype.forEach ?
function(array, fn, thisp){
return array.forEach(fn, thisp);
} :
function(array, fn, thisp){
var i = 0,
arrayCopy = Object(array),
length = arrayCopy.length;
for (; i < length; i++){
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
#!/usr/bin/python
from osgeo import ogr
import sqlite3, sys, time
def parse_pts(f, lyr):
uuid = 0
con = sqlite3.connect(f)
pts = con.execute('select Latitude, Longitude, HorizontalAccuracy, Timestamp from CellLocation;')
@makoto
makoto / gist:963717
Created May 10, 2011 00:29
hack4japan uk

Hack 4 Japan UK Ideathon & Hackathon

Summary

hack4japan is a series of ideathon and hackathon events for Japan Tsunami relief and recovery effort. So far several meetings, ideathons and hackathons were held in March both online in English/Japanese and offline (Kyoto, Okayama, Tokushima, Fukuoka and Fukushima) in Japanese. The detail of the first event is here.

The next meeting will be held in Sendai city (Miyagi), Wakamatsu city (Fukushima),Tokyo in Japanese during 21st and 22nd May, and we will be also hosting a satellite event in London (UK) in English on 22nd May.

anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@premasagar
premasagar / blur.html
Created July 1, 2011 13:28
SVG blur filter
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>SVG Blur</title>
</head>
<body>
<h1>SVG filters: blurring</h1>
@louisremi
louisremi / animLoopX.js
Created July 29, 2011 17:34
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@charliepark
charliepark / hatchshow.js
Created July 30, 2011 16:07
A jquery typography plugin.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(window).load(function(){
$().hatchShow();
});
jQuery.fn.hatchShow = function(){
$('.hsjs').css('display','inner-block').css('white-space','pre').each(function(){
var t = $(this);
t.wrap("<span class='hatchshow_temp' style='display:block'>");
var pw = t.parent().width();
@dennmart
dennmart / .osx
Created September 8, 2011 18:54
Sensible defaults for Mac OS X Lion
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
# Disable menu bar transparency