Skip to content

Instantly share code, notes, and snippets.

View astro's full-sized avatar

Astro astro

View GitHub Profile
@astro
astro / flake.lock
Created October 29, 2023 01:04
microvm.nix CHV + tap example
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
@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;
@astro
astro / flash-arduboy.sh
Created February 19, 2017 23:22
Flash .hex on Arduboy
PORT=/dev/ttyACM1
HEX=hollow_v0.31.hex
ard-reset-arduino --caterina $PORT --verbose
avrdude -P /dev/ttyACM1 -p atmega32u4 -c avr109 -b 57600 -D -Uflash:w:$HEX:i
{-# 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 / 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 ()
@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;
});
--- 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)
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
@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
From slide 22 of http://www.fischmarkt.de/2010/05/very_high_performance_websites_the_next.html Many of these can be checked with the YSlow Firebug extension.
* Make fewer HTTP requests
* Use a Content Delivery Network (CDN)
* Add Expires headers
* Compress components with gzip
* Put CSS at top
* Put JavaScript at bottom
* Avoid CSS expressions
* Make JavaScript and CSS external