Skip to content

Instantly share code, notes, and snippets.

View astro's full-sized avatar

Astro astro

View GitHub Profile
@astro
astro / share.sh
Created January 26, 2012 23:23
Quick Sharing On The Local Chaos Bay
#!/bin/bash -e
URL=http://chaosbay.hq.c3d2.de
if [ -z "$1" ]; then
echo "Usage: $0 <file/dir>"
exit 2
fi
if [ -x $(which mktorrent) ]; then
prittorrent=> explain analyze select * from feed_items inner join enclosures on (feed_items.feed=enclosures.feed AND feed_items.id=enclosures.item) inner join enclosure_torrents using (url) order by feed_items.published desc limit 17;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..465.69 rows=17 width=1049) (actual time=0.043..0.597 rows=17 loops=1)
-> Nested Loop (cost=0.00..1807.98 rows=66 width=1049) (actual time=0.043..0.593 rows=17 loops=1)
-> Nested Loop (cost=0.00..1782.72 rows=66 width=1020) (actual time=0.025..0.379 rows=17 loops=1)
-> Index Scan Backward using feed_items_published on feed_items (cost=0.00..1035.62 rows=1560 width=873) (actual time=0.004..0.016 rows=17
--- twobit.hs.orig 2012-07-05 00:24:21.399187088 +0200
+++ twobit.hs 2012-07-05 00:38:06.288433147 +0200
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
import System.IO
import Data.Char
import System.Environment
@@ -9,7 +10,7 @@
deriving (Show)
data V = Fun (V -> V)
@astro
astro / watch.js
Created December 7, 2012 15:17
jsonchangewatch
var http = require('http');
var child_process = require('child_process');
function poll(url, cb) {
http.get(url, function(res) {
var body = "";
res.setEncoding('utf8');
res.on('data', function(data) {
body += data;
});
@astro
astro / zmqchat.hs
Last active December 16, 2015 12:28
Winning the 0MQ book at #RealtimeConfEu
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad
import System.IO
import System.ZMQ3.Monadic
import qualified Data.ByteString.Char8 as CS
import Control.Concurrent (forkIO)
main :: IO ()
{-# LANGUAGE OverloadedStrings, RankNTypes #-}
module Main where
import Data.Conduit
import Data.Conduit.Binary
import qualified Data.Conduit.List as CL
import Data.XML.Types
import Text.XML.Stream.Parse
import System.IO
import qualified Data.Text as T
@astro
astro / hlsdump.js
Created September 5, 2013 15:45
Reliably record an HTTP Live Stream with node.js
var fs = require('fs');
var request = require('request');
var joinUrl = require('url').resolve;
if (process.argv.length != 3) {
console.log("Please pass playlist URL");
process.exit(1);
}
var plsUrl = process.argv[2];
var INTERVAL = 5 * 1000;
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;