Skip to content

Instantly share code, notes, and snippets.

@xrl
xrl / nope.rb
Created April 15, 2011 16:55
Can't marshal procs!
ruby-1.9.2-p0 :017 > Marshal.dump x
TypeError: no marshal_dump is defined for class Proc
from (irb):17:in `dump'
from (irb):17
from /home/xavierlange/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
[INFO] (src/mongrel2.c:76) RELOAD REQUESTED, I'll do it on the next request.
[INFO] (src/mongrel2.c:307) Reload requested, will load f400bf85-4538-4f7a-8908-67e313d515c2 from /home/mongrel2/config.sqlite
DEBUG src/config/config.c:500: Stopping proxy: proxy:1:127.0.0.1:14000:
DEBUG src/config/config.c:500: Stopping proxy: proxy:2:127.0.0.1:9992:
DEBUG src/config/config.c:500: Stopping proxy: proxy:3:127.0.0.1:14001:
DEBUG src/config/config.c:504: Stopping dir: dir:1:www/:index.html:text/plain:
DEBUG src/config/config.c:504: Stopping dir: dir:2:kris_dev/:index.html:text/plain:
DEBUG src/config/config.c:504: Stopping dir: dir:4:debian/:index.html:text/plain:
DEBUG src/config/config.c:504: Stopping dir: dir:3:demo_production/:index.html:text/plain:
DEBUG src/config/config.c:496: Stopping handler: handler:1:tcp://127.0.0.1:9991:54c6755b-9628-40a4-9a2d-cc82a816345f:tcp://127.0.0.1:9990::
@xrl
xrl / Flatten.hs
Created April 21, 2011 07:45
Flattening a list...
module Flatten where
data NestedList a = Elem a | List [NestedList a]
flatten :: NestedList a -> [a]
flatten (Elem x) = [x]
flatten (List x) = concatMap flatten x
@xrl
xrl / prob7.txt
Created April 22, 2011 05:56
bad code
removeNewLines = filter (/= '\n')
applyToFile filename = do
contents <- readFile filename
return (removeNewLines contents)
main :: IO ()
main = do
putStrLn (applyToFile "prob7.txt")
@xrl
xrl / Makefile
Created April 25, 2011 03:02
Euler.hs Tips and Tricks for Everyday Coding
.SUFFIXES: .hs .o
SRCS=$(wildcard *.hs)
OBJS=$(patsubst %.hs,%.o,${SRCS})
GHC_FLAGS=-O2 --make
%.o: %.hs
ghc ${GHC_FLAGS} $<
.PHONY: all
@xrl
xrl / Makefile
Created April 25, 2011 20:11
Makefile when dealing with file -> many files generators
IDLGEN=rtiddsgen
IDLGEN_FLAGS=-d generated/ -language C -replace -I idl/
IDL=$(wildcard idl/*.idl)
CFLAGS=-std=c99 -Wall -Werror -DRTI_LINUX -DRTI_UNIX -I/usr/local/include/ndds
LDFLAGS=-L/usr/local/lib -lnddscored -lnddscd -lrt -ldl
SRCS=$(wildcard *.c)
IDL_SRCS=$(patsubst idl/%.idl,generated/%.c,${IDL})
@xrl
xrl / Gemfile
Created April 30, 2011 20:11
merb.git in Bundler is borked
source :gemcutter
gem "extlib"
gem "erubis"
git "git://github.com/xrl/merb.git" do
gem "merb-core", :require => nil
end
@xrl
xrl / udp.hs
Created May 5, 2011 07:56
UDP dumper
import System.Environment
import Network.Socket
main :: IO()
main = do
args <- getArgs
startNetworkStuff args
startNetworkStuff ["publish", target, port, msg] = do
publish target port msg
@xrl
xrl / merb_error.log
Created May 9, 2011 16:51
Merb Error Log
I, [2011-05-09T09:50:00.244161 #4129] INFO -- : listening on addr=0.0.0.0:4000 fd=14
I, [2011-05-09T09:50:00.246981 #4129] INFO -- : worker=0 spawning...
I, [2011-05-09T09:50:00.256592 #4129] INFO -- : master process ready
I, [2011-05-09T09:50:00.261433 #4170] INFO -- : worker=0 spawned pid=4170
I, [2011-05-09T09:50:00.269369 #4170] INFO -- : Refreshing Gem list
Loading init file from ./config/init.rb
Loading ./config/environments/development.rb
Logging to file at ./log/development.log
Starting Merb::Rack::Application
I, [2011-05-09T09:50:06.564459 #4170] INFO -- : worker=0 ready
@xrl
xrl / errors.log
Created May 11, 2011 04:48
Terrible Errors
Starting Merb::Rack::Application
I, [2011-05-10T21:42:32.666475 #37025] INFO -- : worker=0 ready
E, [2011-05-10T21:43:51.915933 #37025] ERROR -- : Read error: #<Errno::EAGAIN: Resource temporarily unavailable - read(2) failed>
E, [2011-05-10T21:43:51.916346 #37025] ERROR -- : kernel/common/io.rb:1588:in `sysread'
kernel/common/io.rb:1428:in `readpartial'
/Users/xavierlange/code/tureus/gems/rbx/1.8/gems/unicorn-1.1.2/lib/unicorn/http_request.rb:58:in `read'
/Users/xavierlange/code/tureus/gems/rbx/1.8/gems/unicorn-1.1.2/lib/unicorn.rb:642:in `process_client'
/Users/xavierlange/code/tureus/gems/rbx/1.8/gems/unicorn-1.1.2/lib/unicorn.rb:715:in `worker_loop'
kernel/bootstrap/array.rb:76:in `each'
/Users/xavierlange/code/tureus/gems/rbx/1.8/gems/unicorn-1.1.2/lib/unicorn.rb:713:in `worker_loop'