This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media screen { | |
body { | |
width: 75%; | |
} | |
} | |
@media print { | |
body { | |
width: 100%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
import os | |
import tempfile | |
class HandlebarsOnSave(sublime_plugin.EventListener): | |
def on_post_save(self, view): | |
folder_name, file_name = os.path.split(view.file_name()) | |
extension = file_name[-3:] | |
if extension == 'hbs': | |
view.window().run_command('exec', { 'cmd': 'export PATH=/usr/local/bin:$PATH; /usr/local/share/npm/bin/grunt', 'shell': True, 'quiet': True}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
import os, sys | |
import thread | |
import subprocess | |
import functools | |
import time | |
class ProcessListener(object): | |
def on_data(self, proc, data): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def subsets(s, k) | |
max = 1 << s.length | |
allsubsets = [] | |
(0..max).each do |i| | |
subset = [] | |
ii = i | |
index = 0 | |
while ii > 0 | |
if ii & 1 > 0 | |
subset << s[index] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are metasyntatic variables often used in computer programming, people seem to not know about this. | |
* Foo | |
* Bar | |
* Baz | |
* Qux | |
* Quux | |
This is to avoid future questions about: "what's a qux?", "who's actually named Foo Bar?", "Did you mean <some absurd correction>?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actors._ | |
import scala.actors.Actor._ | |
case object Poke | |
case object Feed | |
class Kid() extends Actor { | |
def act() { | |
loop { | |
react { | |
case Poke => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def scrape_all_the_idioms | |
url = "http://www.learnenglishfeelgood.com/americanidioms/lefgidioms" | |
idioms = {} | |
("b".."z").each do |letter| | |
idioms[letter] = {} | |
doc = Nokogiri::HTML(open(url + "_" + letter + ".html")) | |
idiom_definition = 3 | |
doc.css("#content .blue").each do |nodes| | |
definition = doc.xpath("//*[@id='content']/text()[#{idiom_definition}]") | |
idioms[nodes.content] = doc.xpath("//*[@id='content']/text()[#{idiom_definition}]").text.strip! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby -e "require 'date'; puts \"It's been #{(Date.today - Date.new(2012,01,16)).to_i} days since the beginning\!\"" |