Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
total = 0
curr = 0
while !STDIN.eof?
char = STDIN.read(1)[0]
if char < 48
total += curr
curr = 0
else
#!/usr/bin/env ruby
total = 0
curr = 0
while !STDIN.eof?
char = STDIN.read(1)[0]
if char < 48
total += curr
curr = 0
else
#!/usr/bin/env ruby
total = 0
curr = 0
STDIN.each_byte do |char|
if char < 48
total += curr
curr = 0
else
curr = curr*10 + (char - 48)
@hoxworth
hoxworth / gist:948876
Created April 29, 2011 19:31
Performance testing really stupid integer counting in Ruby
require 'time'
ITERATIONS = 1000000
rows = [[5,25,2005,1,0,143,2]]
def max_ugly(rows)
max = 1
divvy = 10
rows.each do |row|
diff -u -r ./lib/ftchash.c ./lib/ftchash.c
--- ./lib/ftchash.c Thu May 19 10:15:21 2005
+++ ./lib/ftchash.c Thu May 19 10:18:31 2005
@@ -326,7 +326,7 @@
(char*)ftch->traverse_chunk->base+ftch->traverse_chunk->next) {
ret = ftch->traverse_rec;
- (char*)ftch->traverse_rec += ftch->d_size;
+ ftch->traverse_rec = (void*)( ((char*)ftch->traverse_rec) + ftch->d_size);
return ret;
@hoxworth
hoxworth / gist:1165601
Created August 23, 2011 15:59
LEAGUE DRAFT RANDOMIZATION
["Fighting Gobblers", "Feck Off Cup!", "Doomed", "Golden Muffs", "Last Place", "One Man Wolf Pack", "Password is Taco", "Problem?", "shudbnstryk", "Booger Flickers", "MurderBoners", "Bear Dick Punch"].shuffle
@hoxworth
hoxworth / test.json
Last active December 11, 2015 00:59
Testing recursive JSON schema with a simple filesystem example.
{
"directory" : "/",
"entries" : [
{
"directory" : "var",
"entries" : [
"test.json",
"new.json"
]
},
int sample(int * int_array, int size) {
return int_array[rand() % size];
}
@hoxworth
hoxworth / gist:5365674
Created April 11, 2013 17:59
Oh the memories...
Index: nfs-2.6/Makefile
diff -u nfs-2.6/Makefile:1.1.1.12 nfs-2.6/Makefile:1.15
--- nfs-2.6/Makefile:1.1.1.12 Wed Mar 2 10:10:24 2005
+++ nfs-2.6/Makefile Wed Mar 2 11:00:18 2005
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 11
-EXTRAVERSION =
+EXTRAVERSION = -selinux1-nfs1
3-4 l: vdcv
6-9 d: dddddkzdl
6-13 f: mfswqfrqffrvfvf
10-12 l: sfzlnwcptlnlflq
2-4 m: qbwcmt
15-16 v: vvvvvvvvnvvvvcvvvvgv
1-4 n: wnnzfln
1-3 x: xxgx
7-8 j: jjjjjfvh
6-8 x: xxzxxnnwx