Skip to content

Instantly share code, notes, and snippets.

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb sds.c
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb zmalloc.c
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb lzf_c.c
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb lzf_d.c
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb pqsort.c
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb zipmap.c
cc -c -std=c99 -pedantic -O2 -Wall -W -g -rdynamic -ggdb sha1.c
cc -o redis-server -std=c99 -pedantic -O2 -Wall -W -lm -pthread -g -rdynamic -ggdb adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o
Hint: To run the test-redis.tcl script is a good idea.
$base = '/blog';
define( 'DOMAIN_CURRENT_SITE', 'mysite.com' );
define( 'PATH_CURRENT_SITE', '/blog/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
test "should validate numericality" do
o = Object.new(:number => 'not a number')
assert !o.errors.empty?
end
#you can just write:
should validate_numericality_of(:number)
@loe
loe / test.rb
Created October 27, 2010 16:42
# totally pointless method we're going to test
def sum(a, b)
a + b
end
# test/unit example
test "2 + 2 is 4" do
assert_equal sum(2, 2), 4
end
@loe
loe / foo.sql
Created September 27, 2010 19:50
SELECT count(*) AS count_all FROM `transfers` WHERE ((((SELECT count(recipients.id) FROM recipients WHERE recipients.transfer_id = transfers.id) = 0) AND (`transfers`.user_id = 1 AND (`transfers`.account_id = 1))) AND (`transfers`.user_id = 1 AND (`transfers`.account_id = 1)))
@loe
loe / codes.rb
Created September 18, 2010 00:10
# will render schedule.html.erb
get '/schedule' do
erb :schedule
end
def build_races
list = teams.present? ? Team.find(teams) : Team.all
while list.present? do
# Shift off the team.
home = list.shift
# This team races everyone left.
list.each do |away|
race = races.build
local_path = nil
Tempfile.new("upload", '/data/nginx_tmp') do |tf|
local_path = tf.path
end
FileUtils.touch(local_path)
#!/bin/bash
export RUBY_GC_MALLOC_LIMIT=60000000
export RUBY_HEAP_MIN_SLOTS=500000
export RUBY_HEAP_SLOTS_INCREMENT=1
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
exec "/Users/Andrew/.rvm/bin/passenger_ruby" "$@"