Skip to content

Instantly share code, notes, and snippets.

View hemanth's full-sized avatar
🐜
🧘‍♂️

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile
@hemanth
hemanth / ajaxify-html5.js
Created July 8, 2012 08:02 — forked from CWSpear/ajaxify-html5.js
Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
// https://gist.github.com/3069522
;(function($, window, document, undefined) {
// Prepare our Variables
var History = window.History;
// Check to see if History.js is enabled for our Browser
if (!History.enabled) {
return false;
}
@hemanth
hemanth / README.md
Created July 6, 2012 04:18 — forked from oguzbilgic/README.md
README.md scaffold for rails apps

MyApp

Very short description of the application.

1. Ruby, Rails & Rubygems

Applicatoin is written in ruby language, using Ruby on Rails web framework.

@hemanth
hemanth / youtube.sh
Created July 4, 2012 06:17 — forked from andiandi/youtube.sh
Download and watch youtube videos from the shell. The Script fetches the url from the clipboard, so that you only have to select the url in your browser and start the script. Works great when mapping "xterm -e youtube.sh" to a shortcut, e.g. Meta-Y.
#!/bin/bash
# Download and watch youtube videos from the shell.
# The Script fetches the url from the clipboard,
# so that you only have to select the url in your
# browser and start the script. Works great when
# mapping "xterm -e youtube.sh" to a shortcut, e.g. Meta-Y.
# requires the tools xclip, youtube-dl and mplayer
# it's probably possible to replace xclip with pbpaste on
@hemanth
hemanth / data.md
Created July 4, 2012 06:16 — forked from jordansissel/data.md
Compression on large JSON file

The Data

Compression

  • Original: 708MB
  • xz -3: 70MB, 5:41.02 (2.07 mb/sec - 10:1 ratio)
  • bzip2 -3: 74MB, 4:39.11 (2.53 mb/sec - 9.5:1 ratio)
  • gzip -3: 103MB: 0:15.15 (46.73 mb/sec - 6.87:1 ratio)
  • lzop -3: 146MB, 0:06.53 (108.42 mb/sec - 4.85:1 ratio)
@hemanth
hemanth / impress.css
Created July 4, 2012 06:02 — forked from tracend/impress.css
Convert a Google Presentation with Impress.js (WIP)
/*
... and we enhance the styles for impress.js.
*/
.step {
position: relative;
width: 900px;
padding: 40px;
margin: 20px auto;
-webkit-box-sizing: border-box;
@hemanth
hemanth / timeout-iterate.js
Created July 3, 2012 06:02
split up iterating over an array with setTimeout
function forTimeout(array, iterator, delay) {
void function iteration(index) {
if (index === array.length) return
iterator(array[index])
setTimeout(function () { iteration(index + 1) }, delay)
}(0)
}
forTimeout([1, 2, 3], function (v) { console.log(v) }, 1000)

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].

JavaScript Class Syntax

Let's build a JavaScript class syntax from first principles. For the purpose of this exercise, let's assume that the purpose of the class syntax is to add much-needed sugar to common JavaScript idioms.

Let's start with how JavaScript "classes" work today:

// this is a constructor
Person = function() {
 this // `this` is a new instance of Person
@hemanth
hemanth / gist:3037886
Created July 3, 2012 05:28
Incorrect ES5 fallbacks

Incorrect ES5 fallbacks

Over the weekend I implemented a few Array methods in plain JavaScript to avoid recently patched Rhino bugs. That got my thinking about ES5 fallback implementations in various JavaScript libs/frameworks/transpilers. I decided to compile a not-so-complete list of ES5 related discrepancies found in many of them. Differences in native vs. fallback implementations create cross-browser inconsistencies and increase the chance of usage errors. I hope this post will raise awareness of just how hard it is to follow spec (during my research I found a few issues in my own projects too). All library developers should to take a closer look at their code and make the small changes needed to follow the specification (especially if your code forks for native methods).

Common Issues

Most implementations suffer from the following