Skip to content

Instantly share code, notes, and snippets.

View astro's full-sized avatar

Astro astro

View GitHub Profile
var width = window.innerWidth,
height = window.innerHeight;
var force = d3.layout.force()
.charge(-120)
.size([width, height]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@-webkit-keyframes fader {
/*from {
background-color: rgb(255, 0, 0);
}
25% {
background-color: rgb(255, 255, 0);;
<canvas id="myCanvas" width="400" height="300" style="border:1px solid #000000;"> </canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var width = c.width / 6;
var height = c.height / 4;
var o = 0;
@astro
astro / scrape.js
Last active August 29, 2015 14:05
// npm i crawler && node scrape.js && less scraped.json
var fs = require('fs');
var resolve = require('url').resolve;
var Crawler = require("crawler").Crawler;
function trim(s) {
return s.replace(/^\s+/gm, "").replace(/\s+$/gm, "");
}
@astro
astro / keybase.md
Created October 12, 2014 00:11
keybase.md

Keybase proof

I hereby claim:

  • I am astro on github.
  • I am astro (https://keybase.io/astro) on keybase.
  • I have a public key whose fingerprint is A5EE 826D 645D BE35 F9B0 9933 5851 2AE8 7A69 900F

To claim this, I am signing this object:

#!/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