This file contains hidden or 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
{ | |
"metadata" : { | |
"created" : "2013-10-17 13:45:20", | |
"author" : "Tony Brouwer" | |
}, | |
"data" : { | |
[ | |
{ | |
"oen" : 123456, | |
"action" : "update", |
This file contains hidden or 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
num = <<NUM | |
73167176531330624919225119674426574742355349194934 | |
96983520312774506326239578318016984801869478851843 | |
85861560789112949495459501737958331952853208805511 | |
12540698747158523863050715693290963295227443043557 | |
66896648950445244523161731856403098711121722383113 | |
62229893423380308135336276614282806444486645238749 | |
30358907296290491560440772390713810515859307960866 | |
70172427121883998797908792274921901699720888093776 | |
65727333001053367881220235421809751254540594752243 |
This file contains hidden or 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
primes = [2] | |
count = 1 | |
prime_candidate = 2 | |
start = Time.now() | |
until (count == 10001) do | |
prime_candidate +=1 | |
while (true) do | |
psqrt = Math.sqrt(prime_candidate) | |
unless primes. | |
find do |prime| |
This file contains hidden or 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
factors = [] | |
(1..20).each do |x| | |
rem = x | |
factors.each do |f| | |
rem /= f if rem % f == 0 | |
end | |
factors << rem if rem > 1 | |
end | |
puts "The answer is... " + factors.inject(1) {|prod, f| prod *= f}.to_s |
This file contains hidden or 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 big_prime(x) | |
prime = x | |
(2..Math.sqrt(x).to_i).each do |i| | |
break if prime <= i | |
prime /= i while (prime > i && prime % i == 0) | |
end | |
prime | |
end | |
s = Time.new |
This file contains hidden or 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 'rexml/document' | |
require 'rexml/streamlistener' | |
include REXML | |
class NaicsSynonymListener | |
include StreamListener | |
def initialize(f) | |
@outfile = File.open(f, 'w') |
This file contains hidden or 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
#Remove all line comments. Backup may be important... | |
ruby -pi.bak -e '$_.sub!(/^#.*/, "")' /work/test.txt |
This file contains hidden or 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 'CSV' | |
class CatgManufacturingMachine | |
attr_accessor :main_class, :catg_class | |
attr_reader :cur_catg | |
# Base state - always reset on blank line | |
class StateLook | |
def blank_line(o) | |
o.reset |
This file contains hidden or 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
update searchable s1 | |
set datasource_guid = datasource_guid || ' @@DUPLICATE@@ ' || searchable_id, | |
published_flag = 'N' | |
where s1.searchable_id > | |
( | |
select min(s2.searchable_id) | |
from searchable s2 | |
where s1.datasource_id = s2.datasource_id | |
and s1.datasource_guid = s2.datasource_guid | |
); |
This file contains hidden or 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
import re, sys, getopt | |
from collections import deque | |
DEFAULT_STATEMENT_TERMINATOR = ';' | |
OPTION_PATTERN = re.compile('''^--<ScriptOptions (.*)/>''', re.I) | |
TERM_OPTION_PATTERN = re.compile('''^--<ScriptOptions.*statementTerminator="(.*)"/>''', re.I) | |
TERM_OPTION = '''--<ScriptOptions statementTerminator="%s"/>''' | |
LOGGING_PATTERN = re.compile('''(.*)^\s+LOGGING\s*$(.*)''', re.I + re.S + re.M) |