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
Process: mindless [95490] | |
Path: /Users/iamwil/Library/Application Support/iPhone Simulator/4.0.2/Applications/53071FAE-7C99-484E-ACB8-90CFE853CDC7/mindless.app/mindless | |
Identifier: mindless | |
Version: ??? (???) | |
Code Type: X86 (Native) | |
Parent Process: launchd [151] | |
Date/Time: 2010-10-20 13:57:21.310 -0700 | |
OS Version: Mac OS X 10.6.4 (10F569) | |
Report Version: 6 |
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/ruby | |
require 'rubygems' | |
require 'net/http' | |
require 'hpricot' | |
require 'json' | |
require 'pp' | |
require 'yaml' | |
puts "Counting number of users using hashtags" |
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
Incident Identifier: 6D354706-2A9F-46C2-9A98-64D56FC5CADC | |
CrashReporter Key: ad7a4853d59b8fe78498e170b5d656f9b69a7d12 | |
Process: mindless [711] | |
Path: /var/mobile/Applications/5C922AE1-DC41-44CC-A6B7-C993AF122E7F/mindless.app/mindless | |
Identifier: mindless | |
Version: ??? (???) | |
Code Type: ARM (Native) | |
Parent Process: launchd [1] | |
Date/Time: 2010-08-30 12:50:09.988 -0700 |
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
## | |
# Host Database | |
# | |
# localhost is used to configure the loopback interface | |
# when the system is booting. Do not change this entry. | |
## | |
127.0.0.1 localhost | |
255.255.255.255 broadcasthost | |
::1 localhost | |
fe80::1%lo0 localhost |
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 "config/environment" | |
# HTTP Auth For Resque Console | |
AUTH_PASSWORD = "password" || ENV['AUTH'] | |
if AUTH_PASSWORD | |
Resque::Server.use Rack::Auth::Basic do |username, password| | |
password == AUTH_PASSWORD | |
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
items = [{ :weight => 6, :value => 30 }, | |
{ :weight => 3, :value => 14 }, | |
{ :weight => 4, :value => 16 }, | |
{ :weight => 2, :value => 9 }] | |
def repeatable_knapsack(items, capacity) | |
knapsack = [] | |
while true | |
values = items.reject { |item| | |
knapsack_overflow(knapsack + [item], capacity) |
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 make_dag(sequence) | |
edges = {} | |
sequence.each_with_index do |num, i| | |
edges[i] = [] unless edges.has_key?(i) | |
for j in ((i + 1)...sequence.length) | |
edges[i] << j if sequence[i] < sequence[j] | |
end | |
end | |
return edges | |
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
class ChangeTableAttributes < ActiveRecord::Migration | |
class << self | |
include AlterColumn | |
end | |
def self.up | |
alter_column :sometables, :is_numeric, :boolean, { "1" => true, "else" => false }, true | |
alter_column :sometables, :multiplier, :integer, "USING CAST(multiplier AS integer)", 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
# used to alter columns in postgresql | |
module AlterColumn | |
def alter_column(table_name, column_name, new_type, mapping, default = nil) | |
drop_default = %Q{ALTER TABLE #{table_name} ALTER COLUMN #{column_name} DROP DEFAULT;} | |
execute(drop_default) | |
# puts drop_default | |
base = %Q{ALTER TABLE #{table_name} ALTER COLUMN #{column_name} TYPE #{new_type} } | |
if mapping.kind_of?(Hash) | |
contains_else = mapping.has_key?("else") |
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
-- change a column named "is_numeric" from integer to boolean | |
ALTER TABLE sometable ALTER COLUMN is_numeric DROP DEFAULT; | |
ALTER TABLE sometable ALTER COLUMN is_numeric TYPE boolean | |
USING CASE is_numeric | |
WHEN '1' THEN true | |
ELSE 0 END; | |
ALTER TABLE sometable ALTER COLUMN is_numeric SET DEFAULT true; | |
-- change a column named "multiplier" from string to integer | |
ALTER TABLE sometable ALTER COLUMN multiplier DROP DEFAULT; |