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
# this is my least favourite boolean/operator precedence gotcha | |
# got any of your own to share? | |
x = true and false # => false | |
x # => true | |
y = true && false # => false | |
y # => false |
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
# can someone please explain this to me? | |
left = { :a => 'a', :b => 'b' } # => {:a=>"a", :b=>"b"} | |
right = { :a => 'a', :b => 'b' } # => {:a=>"a", :b=>"b"} | |
left == right # => true | |
left.eql? right # => false | |
left_array = [1, 2] | |
right_array = [1, 2] |
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 'rubygems' | |
require 'open-uri' | |
require 'json' | |
USERNAME = "ryan" | |
API_KEY = "26k6otse2s586e4hcbzjy3quq830t3o4" | |
SITE = "flashden" | |
SLEEP_TIME = 60 * 5 | |
api_url = "http://#{SITE}.net/api/edge/#{USERNAME}/#{API_KEY}/recent-sales+vitals.json" |
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 ActiveSupport::OrderedHash < Hash | |
def first | |
[@keys.first, self[@keys.first]] | |
end | |
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
<?php | |
if ($_SERVER['REMOTE_ADDR'] == "127.0.0.1") | |
{ | |
define ('HOSTNAME', 'http://tramtracker.com/'); | |
$path = $_GET['path']; | |
$url = HOSTNAME.$path; | |
$session = curl_init($url); |
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
TEST_INPUT_PATH = '/Users/joho/Desktop/Grand Designs S09E10.avi' | |
TIMES_TO_TEST = 10 | |
start = Time.now | |
TIMES_TO_TEST.times do | |
puts "start" | |
File.open 'test.avi', 'w' do |out_file| | |
File.open TEST_INPUT_PATH, 'r' do |in_file| | |
out_file.write in_file.read | |
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
require 'test/unit' | |
class Array | |
def in_chunks_of(size_of_chunks) | |
if size_of_chunks >= length | |
[self] | |
else | |
[self[0, size_of_chunks]] + self[size_of_chunks, length].in_chunks_of(size_of_chunks) | |
end | |
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
irb(main):005:0> n = "James" | |
=> "James" | |
irb(main):006:0> n.strip! | |
=> nil | |
irb(main):007:0> n | |
=> "James" | |
# that's just plain weird | |
>> n = "john " | |
=> "john " |
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
# extracted from marty andrew's presentation on ruby static code analysis | |
# http://www.slideshare.net/martin_j_andrews/code-quality-analysis | |
require 'flog' | |
require 'flay' | |
require 'roodi' | |
require 'roodi_task' | |
require 'metric_fu' | |
desc "Analyze for code complexity" |
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
<!DOCTYPE> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$('.repos').each(function() { | |
var current_e = this; | |
$(this).append('<li><a href="http://github.com/' + this.id + '">github.com/' + this.id + '</a></li>' ); | |
$.getJSON('http://github.com/api/v1/json/' + this.id + '?callback=?', function(data) { |