Skip to content

Instantly share code, notes, and snippets.

View hypomodern's full-sized avatar

Matt Wilson hypomodern

View GitHub Profile
#!/bin/bash
while [ true ] ; clear; do ls -la $1; sleep 1; done
#!/bin/bash
while [ true ] ; clear; do ls -la $1; sleep 1; done
/* for dkastner: PHP inject... but not really. ;) */
$whats_a_block = 0;
foreach (array(3, 3, 3, 3) as $i) {
$whats_a_block += $i;
}
echo $whats_a_block; // => 12
[chained_from_above].live("quickactions.close", function() {
$(this).removeClass("active");
var disclosure = $(this).siblings(".quickactions_menu").first();
disclosure.hide();
});
$("body").bind("click", function() {
// I'm sure there's a better jQuery way to specify a graph of nodes that should not trigger the close behavior, but
// I took the easy way out:
if($(this).is("body")) {
$(".menu_toggle").trigger("quickactions.close");
>> c = Client.new(:name => "Rollmeback", :timezone => "UTC")
=> #<Client id: nil, name: "Rollmeback", ...>
>> Client.transaction do
?> c.save
>> raise ActiveRecord::Rollback
>> end
=> nil
>> c.id
=> 26
>> Client.find(26)
# Need to find out how many days are in the current month?
# leverage the power of Date#<<(n), which "rewinds" the date by n months.
# it helpfully sets the day correctly if you rewind from the 31st, so rewind from 12/31.
days_in_current_month = ( Date.new(Time.now.year, 12, 31).to_date << ( 12 - Time.now.month ) ).day
# You could also make this a method call
def days_in_month(month_number)
( Date.new(Time.now.year, 12, 31).to_date << ( 12 - month_number ) ).day
# bare Prototypes begin with a Capital Letter, and you usually clone Object:
Cube := Object clone
# := creates a new 'slot' on the receiver and sets that slot to the value of the right-hand side:
Cube sides := 6
# Io has simple message-passing, no operator used: 'Receiver message'
Cube sides # ===> 6
# to def a method rather than a raw property, use the "method" message:
# A webserver version of le_twittre!
# usage: io twitter_frontend_server.io
# "API" : http://localhost:8080/?user=<username>, otherwise you get the public timeline.
# There's no native JSON tools, so I found this janky one. This is how you import files, basically.
# As a side-note, the autoloader is pretty cool. Check the Io Guide for more.
doFile("json.io")
server := HttpServer clone do(
setPort(8080)
(function($) {
$.fn.selectText = function() {
var doc = window.document;
return this.each(function() {
var selection, range;
if (window.getSelection && doc.createRange) {
// modern FF, Safari, and Opera (I think)
selection = window.getSelection();
range = doc.createRange();
range.selectNodeContents(this);
@hypomodern
hypomodern / rspec_tips.markdown
Created January 10, 2011 19:42
quick rspec tips

With rspec 1.x:

spec path/to/file_spec.rb:LINE_NUMBER

With rspec 2.x:

rspec path/to/file_spec.rb:LINE_NUMBER
rspec --tag TAG_NAME

BTW, tagging is accomplished like so: