This file contains 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 temporary_path | |
file = Tempfile.new(['temp-creative-image-', ['.', self.image.file.extension].join], :encoding => 'ascii-8bit') | |
file.write(image.read) if image.file.exists? | |
file.path | |
end |
This file contains 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
(ns mars-rover.core) | |
; | |
; first: grid size | |
; | |
; rest: pairs of 2 lines each, containing rover agenda. | |
; 1st line for pair: | |
; rover starting position on the grid | |
; 2nd line for pair: | |
; all instructions to move |
This file contains 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
#!/usr/bin/env bash | |
# brew install flac | |
# this gives you flac2mp3 | |
# mkdir ~/scripts | |
# vim flac2mp34all | |
for f in *.flac; do | |
flac2mp3 "$f" v0 && rm "$f" |
This file contains 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
class Earphone | |
def left | |
puts "Playing on left." | |
play(0) | |
end | |
def right | |
puts "Playing on right." | |
play(1) | |
end |
This file contains 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 bisect start | |
$ git checkout recent_known_buggy_commit | |
$ git bisect bad | |
$ git checkout old_known_good_commit | |
$ git bisect good | |
# run tests, check things, etc. | |
$ git bisect good/bad | |
Repeat last two steps until git finds the first bad commit. Then: |
This file contains 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
require 'bacon' | |
require 'temple' | |
require 'temple/mustache' | |
require 'benchmark' | |
require 'musterb' | |
require 'mustache' | |
require 'erubis' | |
class Bacon::Context |
This file contains 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
namespace :migrations do | |
DB_PATH = ActiveRecord::Migrator.migrations_path | |
SEPARATOR = " --- " | |
UPTO = ENV['upto'] | |
def run_command(command) | |
%x(#{command}).tap do |result| | |
status = $? | |
unless status.success? | |
raise "Command Error -- (#{status.exitstatus}): [#{command}]" |
This file contains 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
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
This file contains 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
class Object | |
alias :old_instance_eval :instance_eval | |
def instance_eval(str, *args) | |
throw :evaling, [true, old_instance_eval(str)] | |
end | |
end | |
$result = catch(:evaling) do | |
<%= user_code %> |
This file contains 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
module Newal | |
def eval(str) | |
throw :evaling, [true, Kernel.eval(str)] | |
end | |
end | |
class << self | |
include Newal | |
end |