Skip to content

Instantly share code, notes, and snippets.

View perusio's full-sized avatar

António P. P. Almeida perusio

View GitHub Profile
(define (s:reify thunk)
(reset-at 'state (s:return (thunk))))
(define (s:reflect m)
(shift-at 'state k (s:>>= m k)))
(define (r:reify thunk)
(reset-at 'reader (return (thunk))))
(define (r:reflect m)
#!r6rs
;; Really simple generators using delimited continuations
(library (toys simple-generators)
(export make-generator
up-from
list->generator)
(import (rnrs)
(spells delimited-control))
(use-modules (ice-9 control)
(rnrs hashtables)
(web server)
(sxml simple)
(web response)
(web request)
(web uri)
(ice-9 match))
;; utilities
@perusio
perusio / memcached_keys_list.rb
Created January 27, 2012 19:09 — forked from stackdump/gist:1479007
List the keys in a given memcached instance running locally
#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids = matches.flatten.uniq
end
@perusio
perusio / pingfcgi.sh
Created January 15, 2012 19:31 — forked from mpasternacki/pingfcgi.sh
Ping FCGI server, using cgi-fcgi program from libfcgi library.
#!/bin/sh
set -e
# Ping FCGI server. Uses cgi-fcgi program from libfcgi library.
# Retrieves the root path (/) from host:port specified on command line.
if [ -z "$1" ] ; then
echo "Usage: $0 host:port|path/to/socket" >&2
exit 1
fi
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);