Skip to content

Instantly share code, notes, and snippets.

View jasom's full-sized avatar

Jason Miller jasom

  • Santa Barbara, CA
View GitHub Profile
@jasom
jasom / gist:4688438
Created February 1, 2013 01:31
301 response
from mongrel2 import handler
import json
from uuid import uuid4
REDIRECT_TO="https://example.com"
REDIRECT_BODY='<html><head><title>Moved</title></head><body><h1>Moved</h1><p>This page has moved to <a href="%s">%s</a>.</p></body></html>'%(REDIRECT_TO,REDIRECT_TO)
# ZMQ 2.1.x broke how PUSH/PULL round-robin works so each process
# needs it's own id for it to work
sender_id = uuid4().hex
@jasom
jasom / gist:5357083
Last active December 16, 2015 01:39
(defun tcl-escape (string)
(let* ((strings
(split-sequence #\} string))
(strings (split-sequence #\{
(format nil "~a~{\\}~a~}" (car strings) (cdr strings)))))
(format nil "{~a~{\\{~a~}}" (car strings) (cdr strings))))
(defun move-cursor (widget row col)
(format-wish "~a mark set insert ~a.~a" (widget-path widget) row col))
sys-apps/cracklib-words:
pkg.installed:
- refresh: False
use std::io;
enum List {
Cons(uint,~List),
Nil()
}
fn cons(x : uint, l : ~List) -> ~List{
return ~Cons(x,l);
}
@jasom
jasom / gist:6001778
Created July 15, 2013 17:30
Multiple borrowing of references
enum List {
Cons(uint,~List),
Nil()
}
fn truncateAtValue(v : uint, mut l: &mut~List) {
//loop {
match l {
&~Cons(x, ref mut next) if x == v => {
*next = ~Nil;
@jasom
jasom / list.rs
Created July 20, 2013 01:11
Tail-recursive truncateAtValue
use std::io;
use std::util;
enum List {
Cons(uint,~List),
Nil()
}
fn cons(x : uint, l : ~List) -> ~List{
@jasom
jasom / gist:6893046
Created October 8, 2013 22:43
Probably broken performance patch for git-svn
diff --git a/git-svn.perl b/git-svn.perl
index 34884b8..5ef4532 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3491,11 +3491,41 @@ sub rebuild_from_rev_db {
unlink $path or croak "unlink: $!";
}
+BEGIN {
+ my @data;
* Messages for package app-editors/nvi-1.81.6-r3:
* Failed Patch: nvi-1.81.6-db44.patch !
* ( /usr/portage/app-editors/nvi/files/nvi-1.81.6-db44.patch )
*
* Include in your bugreport the contents of:
*
* /var/tmp/portage/app-editors/nvi-1.81.6-r3/temp/nvi-1.81.6-db44.patch.out
* ERROR: app-editors/nvi-1.81.6-r3::gentoo failed (prepare phase):
* Failed Patch: nvi-1.81.6-db44.patch!
;;; Mongrel2 Exchange
;;; Example of an adpater to allow load-balancing and session locking
(in-package :mymongrel2)
(defun main-loop (m2addr req-rep-addr)
(ensure-zmq-init)
(let* ((pull-socket (zmq:socket *zmq-context* zmq:PULL))
(rep-socket (zmq:socket *zmq-context* zmq:REP)))
(zmq:connect pull-socket m2addr)
use std::io;
use std::util;
enum List {
Cons(uint,~List),
Nil()
}
fn cons(x : uint, l : ~List) -> ~List{