Skip to content

Instantly share code, notes, and snippets.

View usmanity's full-sized avatar

Muhammad Usman usmanity

View GitHub Profile
@bagwanpankaj
bagwanpankaj / show.py
Created July 22, 2011 05:48 — forked from lfborjas/show.py
Tunnel a local port to a remote host (like showoff.io does)
#!/usr/bin/python
#usage python show.py <local_port>
'''
Taken from: https://gist.github.com/932137 (found in http://news.ycombinator.com/item?id=2467107 )
Let's say you have a webapp running in localhost (with `manage.py runserver` in django or `ruby script.rb` in sinatra or `rails server` or whatever) and you want others to be able to see it with a public url without deploying remotely.
ssh provides a neat facility for that: tunneling. You set up a "tunnel" from the remote host to yours and vice-versa and then you give the remote host's url and it will send all of its requests to your local daemon.
@babney
babney / method_cop.rb
Created October 31, 2011 21:58
MethodCop
module MethodCop
# Guard methods that have side effects with a callback that fires before the method is invoked.
# If the callback returns a "falsey" value, the method is halted and will not be called.
# The callback will return nil instead.
# if the method does not have side effects or you depend on its return value, you should NOT
# use this on that method! This will break the _hell_ out of design by contract.
# currently does not work with methods that accept blocks so be aware of that. Fixes, improvements,
# pull requests, and general "why on earth did you do this" notes are encouraged.
#TODO: DRY this up
@babney
babney / LikeRuby.rb
Created April 3, 2012 16:29
Like, Ruby
module LikeRuby
VALLEYGIRL = %w[omg so like totally right toootally stuff]
FRATGUY = %w[friggin fuckin dude man bro broheim broseph]
INTERNETS = %w[lol rofl teh ohai plz]
SNOOP = %w[yo homey homeboy sup dog shit girl ma biatch ho shiiit]
LOCAL = %w[wicked hella anyways]
MISC = %w[just hey yeah ok um uh ah actually something]
ALLSLANG = VALLEYGIRL + FRATGUY + INTERNETS + SNOOP + LOCAL + MISC
def method_missing(name, *args)
@mduvall
mduvall / pin.js
Created May 16, 2013 17:06
An example of the Pinterest waterfall layout.
var generateRandomBoxes = function() {
var $doc = $(".container");
var $bareBox = $("<div class='box' style='position:absolute; border:1px solid black; width:50px;'></div>");
var maxHeight = 200;
var height,
$box;
for (var i = 0; i < 100; i++) {
height = Math.floor(Math.random() * maxHeight);
$box = $bareBox.clone().css('height', height + 'px')
@axelav
axelav / gist:1839777
Created February 15, 2012 22:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@EpokK
EpokK / ngEnter.js
Last active January 7, 2022 13:57
ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)
app.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
@baweaver
baweaver / rails_booklist.md
Last active September 15, 2022 17:53
Rails Booklist

Rails Book List

A list of Rails books and their applications. Free books are tagged with (F)

Have a suggestion? Leave a comment. There are still books I need to read on the subject so some may not show up in this list yet.

Learning Rails

Your first steps into Rails

@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@kristopolous
kristopolous / hn_seach.js
Last active July 24, 2023 04:12
hn job query search
// Usage:
// Copy and paste all of this into a debug console window of the "Who is Hiring?" comment thread
// then use as follows:
//
// query(term | [term, term, ...], term | [term, term, ...], ...)
//
// When arguments are in an array then that means an "or" and when they are seperate that means "and"
//
// Term is of the format:
// ((-)text/RegExp) ( '-' means negation )