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 Update < ActiveRecord::Base | |
belongs_to :job_id, :foreign_key => 'job_id', :class_name => 'Job' | |
file_column :attachment | |
def authorized_for_destroy? | |
return false if new_record? | |
return Update.count(:conditions => ["created_at > ?", self.created_at]) == 0 | |
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
#!/usr/bin/env ruby | |
def main(args) | |
memory = {} | |
post_sub_regexp = /\(\([^)]+\)\)/ | |
input = IO.read(args[0]) | |
while matches = input.match(/\(\(([^)]+)\)\)/) do | |
if matches[1] =~ /:/ | |
var, prompt = matches[1].split(":") | |
elsif memory[matches[1]] |
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
tail -f rails.log | awk '/Completed in/{print $8"\t"$9" "$10"\t"$20"\t"$22 }' |
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
#!/bin/bash | |
# | |
# This file echoes a bunch of color codes to the | |
# terminal to demonstrate what's available. Each | |
# line is the color code of one forground color, | |
# out of 17 (default + 16 escapes), followed by a | |
# test use of that color on all nine background | |
# colors (default + 8 escapes). | |
# | |
# Author: Giles Orr |
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 ruby | |
input = ARGF.read | |
# Split on commas | |
values = input.split(/\s*,\s*/) | |
# Unique | |
values.uniq! |
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
mysql> select * from entries where phone_id = 40; | |
+-----+----------+-------+---------+---------------------+---------------------+---------+ | |
| id | phone_id | miles | gallons | created_at | updated_at | mpg | | |
+-----+----------+-------+---------+---------------------+---------------------+---------+ | |
| 209 | 40 | 33318 | 19.295 | 2009-11-26 22:07:29 | 2009-11-26 22:07:29 | NULL | | |
| 210 | 40 | 33631 | 16.494 | 2009-11-28 22:11:21 | 2009-11-28 22:11:21 | 18.9766 | | |
| 212 | 40 | 34075 | 23.642 | 2009-12-05 01:24:18 | 2009-12-05 01:24:18 | 18.7801 | | |
| 213 | 40 | 34302 | 14.092 | 2009-12-06 18:27:38 | 2009-12-06 18:27:38 | 16.1084 | | |
| 215 | 40 | 34638 | 19.022 | 2009-12-10 23:36:49 | 2009-12-10 23:36:49 | 17.6638 | | |
| 218 | 40 | 35097 | 24.074 | 2009-12-18 17:34:43 | 2009-12-18 17:34:43 | 19.0662 | |
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 ruby | |
cnt = 0 | |
loop do | |
puts "loop" | |
line = STDIN.readline | |
if line =~ Regexp.new(ARGV[0]) | |
puts "\tmatch" | |
File.open("install-#{cnt}.txt", "w") {|f| f.write Time.now.to_s} | |
cnt += 1 |
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
# Calculates the domain hash part of a Google Analytics __utma cookie's value. | |
def domain_hash(domain_name) | |
domain_hash = 0 | |
g = 0 | |
(domain_name.size - 1).downto(0) do |i| | |
c = domain_name[i] | |
domain_hash = ((domain_hash << 6) & 268435455) + c + (c << 14) |
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
f = { | |
foo: function() { | |
console.log("foo"); | |
}, | |
bar: function() { | |
console.log("bar"); | |
}, | |
foobar: function() { | |
this.foo(); | |
this.bar(); |
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
$ ab -c 20 -n 500 "http://localhost:9000/?id=1" | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests |
OlderNewer