Skip to content

Instantly share code, notes, and snippets.

View hypomodern's full-sized avatar

Matt Wilson hypomodern

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hypomodern on github.
  • I am hypomodern (https://keybase.io/hypomodern) on keybase.
  • I have a public key whose fingerprint is 546D D3C6 B046 667D 241C 89DF EBF8 C277 6FF1 854B

To claim this, I am signing this object:

{
init: function(elevators, floors) {
elevators.forEach(function(elevator) {
elevator.floorIsDestination = function(floorNum) {
return elevator.destinationQueue.indexOf(floorNum) != -1;
}
elevator.on("floor_button_pressed", function(floorNum) {
if (!elevator.floorIsDestination(floorNum)) {
elevator.goToFloor(floorNum);
#!/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
# 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)
# 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: