Skip to content

Instantly share code, notes, and snippets.

/Library/Developer/CommandLineTools/usr/bin/make all-recursive
Making all in gdk-pixbuf
GEN s-enum-types-h
GEN stamp-gdk-pixbuf-marshal.h
/Library/Developer/CommandLineTools/usr/bin/make all-recursive
Making all in pixops
CC pixops.lo
CCLD libpixops.la
CC timescale.o
CCLD timescale
@sbp
sbp / lisp-disunion.h
Created December 28, 2013 21:16
src/lisp-disunion.h from lemacs-19.8 (6 Sep 93)
/* Fundamental definitions for GNU Emacs Lisp interpreter.
Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
@sbp
sbp / sl3-apply.patch
Created December 20, 2013 00:17
Adds apply and lt (<) to sl3.c
--- sl3.c 2008-02-07 02:29:40.000000000 +0000
+++ sl3-apply.c 2013-10-18 21:01:20.000000000 +0100
@@ -33,7 +33,7 @@
} obj;
typedef obj * (*primop)(obj *);
obj *all_symbols, *top_env, *nil, *tee, *quote,
- *s_if, *s_lambda, *s_define, *s_setb;
+ *s_if, *s_lambda, *s_define, *s_apply, *s_setb;
#define cons(X, Y) omake(CONS, 2, (X), (Y))
@sbp
sbp / install.scm
Last active December 31, 2015 06:59
A very simple "guix install" implementation, by Mark H. Weaver. "Just stick it in $DIR/guix/scripts/install.scm, where $DIR is in your guile load path"
(define-module (guix scripts install)
#:use-module (guix scripts package)
#:use-module (srfi srfi-1)
#:export (guix-install))
(define (guix-install . args)
(apply guix-package
(fold-right (lambda (arg seed)
(if (string-prefix? "-" arg)
(cons arg seed)
@sbp
sbp / gist:7617750
Created November 23, 2013 17:53
Disassemble a python code object as a string
def disassemble(co, lasti=-1):
"""Disassemble a code object."""
from dis import COMPILER_FLAG_NAMES, EXTENDED_ARG, HAVE_ARGUMENT, __all__, __builtins__, __cached__, __doc__, __file__, __initializing__, __loader__, __name__, __package__, _disassemble_bytes, _disassemble_str, _format_code_info, _have_code, _test, _try_compile, cmp_op, code_info, dis, disassemble, disco, distb, findlabels, findlinestarts, hascompare, hasconst, hasfree, hasjabs, hasjrel, haslocal, hasname, hasnargs, opmap, opname, pretty_flags, show_code, sys, types
output = []
def out(obj):
output.append(str(obj))
code = co.co_code
labels = findlabels(code)
linestarts = dict(findlinestarts(co))
n = len(code)
@sbp
sbp / fibonacci.s
Created October 18, 2013 23:19
GCC compiled output of fibonacci.c
.file "fibonacci.c"
.text
.globl fib
.type fib, @function
fib:
pushl %ebx
subl $24, %esp
cmpl $1, 32(%esp)
jg .L2
movl 32(%esp), %eax
@sbp
sbp / titular.py
Created July 16, 2013 17:13
Webpage title summariser
# Copyright 2013, Sean B. Palmer
# Source: http://inamidst.com/saxo/
import re
import saxo
regex_link = re.compile(r"^(http[s]?://[^<> \"\x01]+)[,.]?$")
regex_title = re.compile(r"(?ims)<title>(.*?)</title>")
regex_tag = re.compile(r"<[^>]+>")
@sbp
sbp / scrape_twitter.py
Last active December 17, 2015 14:59
Scrape twitter
#!/usr/bin/env python3
import re
import time
from saxo_web import request
# ATTENTION, USER!
# Adjust the following mysterious variables to your taste
@sbp
sbp / format-unixtime.c
Created April 18, 2013 17:48
Print a unixtime
#include <math.h>
#include <stdio.h>
#include <time.h>
int main() {
double time;
struct tm *gm_t;
size_t size;
char s[128];
@sbp
sbp / flags.asm
Created March 25, 2013 21:20
Display the binary value of the x86 FLAGS register on boot
bits 16
start:
; Set up 512 bytes of stack space. More than plenty!
mov ax, 0x07C0 ; This is 0x7C00 >> 4
add ax, 64 ; (512 + 512) / 16, for some weird offset crap
mov ss, ax ; SS is the stack segment
mov sp, 512 ; SP is the stack pointer
; Call the main routine