Skip to content

Instantly share code, notes, and snippets.

View astro's full-sized avatar

Astro astro

View GitHub Profile
#!/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
-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 ->
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
#!/usr/bin/env ruby
require 'RMagick'
include Magick
infile, outfile = ARGV
unless infile && outfile
puts "Usage: #{$0} <infile> <outfile>"
exit 1
#!/usr/bin/env ruby
HOSTS = %w(hummer astrom dn42 ldap wiefelspuetz astron icq www1 zardoz jabber1 debcache jabber2 unsafe dhcp kdc utur).map{ |s| "#{s}.hq.c3d2.de" }
=begin
Forward-resolves HOSTS and puts their IPv6 addresses suitable for BIND
reverse-lookup zonefiles.
=end
# /etc/nsswitch.conf
passwd: compat
group: compat
shadow: compat
hosts: files dns [NOTFOUND=continue] mdns4_minimal [NOTFOUND=continue] mdns6_minimal [NOTFOUND=continue] mdns4 [NOTFOUND=continue] mdns6
networks: files
protocols: db files
#!/usr/bin/env ruby1.8
#
# Copyright 2009 Astro <astro@spaceboyz.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
require 'nokogiri'
doc = Nokogiri::XML::Document.new
loop do
n = Nokogiri::XML::Element.new('e', doc)
n.add_namespace(nil, 'http://example.com')
end
[6 of 9] Compiling Neuronal.Operations ( Neuronal/Operations.hs, Neuronal/Operations.o )
Neuronal/Operations.hs:42:33:
Couldn't match expected type `forall n. (Num n) => n'
against inferred type `Double'
In the first argument of `OpState', namely `opLinkWeight'
In the second argument of `($)', namely
`OpState opLinkWeight opNet'
In the expression: return $ OpState opLinkWeight opNet
-- http://svn.pugscode.org/pugs/examples/adventure/adventure.pl
import Data.Char as Char
import Data.List (intercalate)
import Text.ParserCombinators.Parsec
import Control.Monad.State.Lazy
import System.Console.Editline.Readline
--
-- Parser