Skip to content

Instantly share code, notes, and snippets.

@volh
volh / gist:71966
Created February 28, 2009 14:22
just testing gist
require 'csv'
CSV.open("file3.csv",'w') do |csv|
(CSV.read("file2.csv") - CSV.read("file1.csv")).each { |row| csv << row }
end
class A
def a
'a'
end
end
module M extend self
class A
# Sort packages by their sizes, descending
`pacman -Qi`.split("\n\n").map do |pkg|
pkg.split("\n")
end
.sort_by do |pkg|
pkg.grep(/Size/).first.split(":").last.to_f
end
.reverse[0 .. ARGV.first.to_i - 1].map do |i|
name = i.first.split(":").last.strip
@volh
volh / gist:714243
Created November 24, 2010 19:39
rails 3 engine helper to render inside base application layout, even if there is no content_for in it
# Updated from several code snippets
def base_layout(layout="application")
@_content_for[:layout] = self.output_buffer
self.output_buffer = render :file => "layouts/#{layout}"
end
# just add <%= base_layout %> at the end of your engine layout.
module God
module System
class Process
# Return true if this process is running, false otherwise
def exists?
!!::Process.kill(0, @pid) rescue false
end
end
end
$ ./GoogleEarthLinux.bin
Verifying archive integrity... All good.
Uncompressing Google Earth for GNU/Linux 6.0.0.1735..............................................................
setup.data/setup.xml:1: parser error : Document is empty
^
setup.data/setup.xml:1: parser error : Start tag expected, '<' not found
^
./setup.sh: line 158: 4019 Segmentation fault "$setup" "$@"
class Rack::NoSpoon
def initialize(app)
@app = app
end
def call(env)
if env["HTTP_USER_AGENT"] =~ /MSIE 6/
[418, {'Content-Type' => 'application/msword'}, "I'm a teapot"]
else
@app.call(env)

Even with their software and hardware architecture in place, there were still obstacles to overcome.

Their monster server uses CentOS Linux, but very few people are running memory-intensive applications on machines with so much RAM, so they ran into performance problems. For example, by default the kernel will start paging out to disk once the memory is about 60% full, which left them with only about 150 GB of RAM available before swapping kicked in and performance cratered. There's not much documentation available around these parameters, so the team ended up scouring the kernel source to understand how it worked before they could produce a set hand-tuned for TasteGraph's needs.

something = [1,"two",['t','h','r','e','e']][rand(3)]
case something
when Integer
something + 1
when String
something << "flower"
when Array
something + ["forty", "two"]
CAMLprim value mlzmq_version(value unit)
{
CAMLparam1(unit);
int major, minor, patch;
zmq_version(&major, &minor, &patch);
CAMLlocal1( result );
result = caml_alloc(3, 0);
Store_field( result, 0, Val_int major );