Skip to content

Instantly share code, notes, and snippets.

@eam
eam / day3.rb
Created December 10, 2015 01:54
#!/usr/bin/env ruby
map = {}
xpos = 0
ypos = 0
xpos_robo = 0
ypos_robo = 0
map[0] = {}
#!/usr/bin/env ruby
require 'ffi'
module C
extend FFI::Library
ffi_lib 'c'
attach_function 'sleep', [:int], :int
end
puts "kill -SIGINT #$$"
$ gunzip -c enwiki-latest-all-titles-in-ns0.gz|head
page_title
!
!!
!!!
!!!Fuck_You!!!
!!!Fuck_You!!!_And_Then_Some
!!!Fuck_You!!!_and_Then_Some
buf = File.read File.join rom_base_path, bin_filename # 55M file
pos = 0
size = 4096
loop {
chunk = buf.slice(pos, size)
puts "#{Time.now.to_f}: read chunk size: #{chunk.length}"
break if chunk.length != size
pos += size
}
@eam
eam / day6.rb
Created December 6, 2015 17:57
#!/usr/bin/env ruby
map = {}
xpos = 0
ypos = 0
mech = {
"turn on" => :turn_on,
"turn off" => :turn_off,
"toggle" => :toggle,
#!/usr/bin/env ruby
puts 6 -5
puts 6 -
5
puts 6
-5
@eam
eam / text file busy
Last active November 11, 2015 17:30
[eam@nitre ~]$ cp /bin/sleep /tmp/sleep; /tmp/sleep 60&
[1] 15023
[eam@nitre ~]$ ls -l /tmp/sleep
-rwxr-xr-x 1 eam eam 27848 Nov 11 09:30 /tmp/sleep
[eam@nitre ~]$ echo "hi" >> /tmp/sleep
-bash: /tmp/sleep: Text file busy
@eam
eam / haha.rb
Created November 9, 2015 17:43
puts [%w{​​​​ ​​​​​ ​​​​​​​​​​​​​​​​​ ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​}.map(&:size).inject(:*) + 1].pack ?L
#!/usr/bin/env ruby
pattern = ARGV.shift
pids = %x{pgrep "#{pattern}"}.split.reject {|p| Integer(p); p.to_i == $$ or p.to_i == $?.pid }
pidargs = (["-p"] * pids.size).zip(pids).flatten
raise "no pids match" if pidargs.empty?
exec "strace", *ARGV, *pidargs
#!/opt/local/bin/perl
use warnings;
use strict;
use Term::InKey;
use Tk::Table;
my ($face, $memp, $x, $y, $clicked_x, $clicked_y, $done, $child, @src, @mem, @breaks);
my %slashmap = (
'right' => 'up',