Skip to content

Instantly share code, notes, and snippets.

View astro's full-sized avatar

Astro astro

View GitHub Profile
#!/usr/bin/env ruby
require 'RMagick'
include Magick
infile, outfile = ARGV
unless infile && outfile
puts "Usage: #{$0} <infile> <outfile>"
exit 1
is_prime 1 = False
is_prime 2 = True
is_prime x = not (any (\n -> x `rem` n == 0) [2..(x `div` 2)])
primes = [x | x <- [1..], is_prime x]
primes_until n = takeWhile (<= n) primes
-module(codepoint).
-export([codepoint_to_utf8/1, test/0]).
%% See: http://en.wikipedia.org/wiki/Utf-8#Description
%% TODO: endianess
codepoint_to_utf8(CP) when CP =< 16#7F ->
[CP];
codepoint_to_utf8(CP) when CP =< 16#7FF ->
#!/usr/bin/env ruby
# An attempt to create an efficient HTTP client using eventmachine, utilizing HTTP pipelining. I reconsidered and decided it would be more natural to hack this in Erlang. Please finish.
require 'yaml'
require 'eventmachine'
require 'dnsruby'
require 'uri'
require 'zlib'
Dnsruby::Resolver::use_eventmachine true