Skip to content

Instantly share code, notes, and snippets.

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

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile
@hemanth
hemanth / fast.md
Created September 13, 2012 16:19
Guido van Rossum's Tips for fast Python

Guido van Rossum11 Sep 2012 - Public

Some patterns for fast Python. Know any others?

  • Avoid overengineering datastructures. Tuples are better than objects (try namedtuple too though). Prefer simple fields over getter/setter functions.

  • Built-in datatypes are your friends. Use more numbers, strings, tuples, lists, sets, dicts. Also check out the collections library, esp. deque.

  • Be suspicious of function/method calls; creating a stack frame is expensive.

@hemanth
hemanth / dateutil.js
Created September 4, 2012 04:34 — forked from remy/dateutil.js
Super simple library for date time formatting.
var dateUtil = function () {
var monthDict = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
return {
time: function (date) {
var hour = date.getHours(),
min = date.getMinutes() + "",
ampm = 'AM';
if (hour == 0) {
hour = 12;

#Understanding MVC And MVP (For JavaScript & Backbone Developers)

Before exploring any JavaScript frameworks that assist in structuring applications, it can be useful to gain a basic understanding of architectural design patterns. Design patterns are proven solutions to common development problems and can suggest structural paradigms to help guide us in adding some organization to our application.

I think patterns are exciting as they're effectively a grass roots effort that build upon the collective experience of skilled developers who have previously faced similar problems as we do now. Although developers 10 or 20 years ago may not have been using the same programming languages for implementing patterns, there are many lessons we can learn from their efforts.

In this section, we're going to review two popular patterns - MVC and MVP. The context of our exploration will be how these patterns are related to the popular JavaScript framework Backbone.js, which will be explored in greater detail later on.

Object.extend = function( LeftHandSideExpression, AssignmentExpression ) {
var target, src, needToThrow;
// Let target be ToObject(LeftHandSideExpression).
target = Object( LeftHandSideExpression );
// Let src be ToObject(AssignmentExpression).
src = Object( AssignmentExpression );
@hemanth
hemanth / haiku.py
Created July 30, 2012 09:08 — forked from hasenj/haiku.py
python version: random heroku-like name generator
import random
def haiku():
# originally from: https://gist.github.com/1266756
# with some changes
# example output:
# "falling-late-violet-forest-d27b3"
adjs = [ "autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
@hemanth
hemanth / git tutorials.md
Created July 29, 2012 06:16 — forked from yaowenqiang/git tutorials.md
Awesome git tutorials I am finding here and there
@hemanth
hemanth / elementToObject.js
Created July 26, 2012 06:04
elementToObjec
function elementToObject(element, o) {
var el = $(element);
var o = {
tagName: el.tagName
};
var i = 0;
for (i ; i < el.attributes.length; i++) {
o[el.attributes[i].name] = el.attributes[i].value;
}
@hemanth
hemanth / gist:3170033
Created July 24, 2012 13:57 — forked from cloudhead/gist:1522576
Why I Don't Write Web Apps

Why I Don't Write Web Apps (if I can help it)

This is what happens when I try to pick a language.

Note: If I didn't think it was possible to create a development environment without any of these issues (which I consider "major" for the most part), I would not have written this list.

C/C++

  • NOTHNX.

Node.js

@hemanth
hemanth / ebooks.md
Created July 24, 2012 13:56 — forked from roidrage/ebooks.md
Self-published and awesome
@hemanth
hemanth / array.extensions.md
Created July 21, 2012 11:34 — forked from rwaldron/array.extensions.md
Array.from and Array.of