Skip to content

Instantly share code, notes, and snippets.

View mohnish's full-sized avatar

Mohnish Thallavajhula mohnish

View GitHub Profile
@mohnish
mohnish / scrape.js
Created November 6, 2012 05:06
Scraping the GRE words from Barron's official website
// Grab all the rows with the words
var list = $$('table')[6].querySelectorAll('tr'), i, listLength = list.length, output = [];
// Iterate through all the rows to grab the exact words
for(i = 0; i < listLength; i++) {
output.push(list[i].cells[0].innerHTML.trim());
}
// Get rid of the top most item in the list since it will be the heading
output.shift();
@mohnish
mohnish / gist:4158640
Created November 28, 2012 02:23 — forked from paulirish/gist:4158604
Learn JavaScript concepts with recent DevTools features

Learn JavaScript concepts with the Chrome DevTools

Authored by Peter Rybin , Chrome DevTools team

In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.

Closures

Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:

@mohnish
mohnish / example.js
Created December 10, 2012 07:12 — forked from jhs/example.js
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
#!/usr/bin/env ruby
# Script to import tumblr posts into local markdown posts ready to be consumed by Jekyll.
# Inspired by New Bamboo's post http://blog.new-bamboo.co.uk/2009/2/20/migrating-from-mephisto-to-jekyll
# Supports post types: regular, quote, link, photo, video and audio
# Saves local copies of images
require 'rubygems'
require 'open-uri'
require 'nokogiri'
@mohnish
mohnish / gist:5105865
Created March 7, 2013 06:03
Paste this in the address bar to get an editor!
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;font-size:16px}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/php");</script>
class Management {
static listOfStudents = new ArrayList<Student>();
public static void main(String[] args) {
School wku = new School("Western Kentucky University");
Student macha = new Student("macha", 10, 8, wku);
Student mt = new Student("mt", 10, 8, wku);
addStudent(macha);
addStudent(mt);
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
click_link 'My HomeMarks'
within '#login_area' do
fill_in 'email', with: '[email protected]'
fill_in 'password', with: 'test'
ARCHFLAGS="-arch x86_64" gem install mysql2 -- –with-mysql-config=/usr/local/bin/mysql_config
@mohnish
mohnish / example.js
Created August 1, 2013 05:17 — forked from tj/example.js
function params(fn) {
var str = fn.toString();
var sig = str.match(/\(([^)]*)\)/)[1];
if (!sig) return [];
return sig.split(', ');
}
console.api = function(obj){
console.log();
var proto = Object.getPrototypeOf(obj);