Skip to content

Instantly share code, notes, and snippets.

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

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile
@hemanth
hemanth / gist:2986561
Created June 25, 2012 04:39 — forked from thash/gist:2986414
Convert XML to Ruby Hash (using Nokogiri)
# USAGE: Hash.from_libxml(YOUR_XML_STRING)
# http://movesonrails.com/articles/2008/02/25/libxml-for-active-resource-2-0
require 'nokogiri'
# updated because original version is written in 2 years ago. - memerelics
class Hash
class << self
def from_libxml(xml)
begin
result = Nokogiri::XML(xml)
return { result.root.name.to_s.to_sym => xml_node_to_hash(result.root)}
@hemanth
hemanth / codereview.md
Created June 25, 2012 16:52 — forked from addyosmani/codereview.md
Lessons from a JavaScript code review

#Lessons From A JavaScript Code Review

I was recently asked to review some code for a new JavaScript application and thought I might share some of the feedback I provided as it includes a mention of JavaScript fundamentals that are always useful to bear in mind. Code reviews are possibly the single biggest thing you can do to improve the overall quality of your solutions and if you're not actively taking advantage of them, you're possibly missing out on bugs you haven't noticed being found or suggestions for improvements that could make your code better.

##Challenges & Solutions

Code reviews go hand-in-hand with maintaining strong coding standards. That said, standards don't usually prevent logical errors or misunderstandings about the quirks of a programming language. Even the most experienced developers can make these kinds of mistakes and code reviews can greatly assist with catching them.

Often the most challenging part of code reviews is actually finding an experienced developer you trust to complete

@hemanth
hemanth / gameengines.md
Created June 26, 2012 06:01 — forked from bebraw/gameengines.md
List of JS game engines. You can find a wikified version at https://github.com/bebraw/jswiki/wiki/Game-Engines. Feel free to modify that. I sync it here every once in a while.

IMPORTANT! Remember to check out the wiki page at https://github.com/bebraw/jswiki/wiki/Game-Engines for the most up to date version. There's also a "notes" column in the table but it simply does not fit there... Check out the raw version to see it.

This table contains primarily HTML5 based game engines and frameworks. You might also want to check out these pages: [[Feature Matrix|Game-Engine-Feature-Matrix]], [[Game Resources]].

Name Latest Release Size (KB) License Type Unit Tests Docs Repository Notes
ActionJS no github AS3 like in Javascript
Akihabara 1.3.1 (2011/05) 453 GPL2, MIT Classic Repro no API github Inten

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@hemanth
hemanth / in_words.js
Created June 27, 2012 04:57 — forked from bcamarda/in_words.js
Numbers in Words in JS
var inWords = function(number){
var numberHash = {
0:"", 1:"one", 2:"two", 3:"three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine", 10: "ten",
11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", 16: "sixteen", 17: "seventeen", 18: "eighteen",
19: "nineteen", 20: "twenty", 30: "thirty", 40: "forty", 50: "fifty", 60: "sixty", 70: "seventy", 80: "eighty", 90: "ninety"
};
if(number <= 20){
return numberHash[number];
}
@hemanth
hemanth / gist:3001632
Created June 27, 2012 05:12 — forked from daleobrien/gist:3000515
Function to print nicely formatted tables

Function to print ascii tables out.

>>> data = [["a", "b", "c"], [1, 2, 3], [4, 5, 60]]
>>> print_table(data, title="example")

+---+---+----+
| a | b |  c |
+---+---+----+
| 1 | 2 |  3 |

Fibur

Fibur is a library that allows concurrency during Ruby I/O operations without needing to make use of callback systems. Traditionally in Ruby, to achieve concurrency during blocking I/O operations, programmers would make use of Fibers and callbacks. Fibur eliminates the need for wrapping your I/O calls with Fibers and a callback. It allows you to write your blocking I/O calls the way you normally would, and still have concurrent execution during those I/O calls.

Example

Say you have a method that fetches data from a network resource:

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@hemanth
hemanth / Rails CMS alternatives
Created June 27, 2012 06:25
List of Rails CMS software
Rails CMS alternatives
======================
Note: project activity was checked on 11/26/09 for most of these projects, and the "last update" field has not been kept up to date since then.
Active projects:
---------------
adva-cms
repo: http://github.com/svenfuchs/adva_cms/
site: http://adva-cms.org/
Last update: 11/24/09
@hemanth
hemanth / url_dsl.rb
Created June 27, 2012 06:26 — forked from defunkt/url_dsl.rb
The Ultimate URL DSL!
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json