Skip to content

Instantly share code, notes, and snippets.

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

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile

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

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].

@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)
@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 / 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 / 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 / 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 / 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 / angryorigin.py
Created July 8, 2012 08:16
Angry Origin - because cross origin requests are for wimps
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn
import threading
import requests
class Handler(BaseHTTPRequestHandler):
def __init__(self, request, client_address, server):
print "Init!"
self.protocol_version = 'HTTP/1.1'
BaseHTTPRequestHandler.__init__(self, request, client_address, server) #http://www.mlsite.net/blog/?p=80