Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
while true; do
time curl http://api.plate.tw/menu.php?rest_id=2
sleep 1
done
@scottt
scottt / array-to-ogg.c
Created April 24, 2014 16:05
Extract audio tracks from netcat-cpi-kernel-module to OGG files
/* Usage:
* $ git clone https://github.com/usrbinnc/netcat-cpi-kernel-module.git
* $ gcc array-to-ogg.c -o array-to-ogg
* $ ./array-to-ogg netcat-cpi-kernel-module/tracks/*data.h
* $ ls netcat-cpi-kernel-module/tracks/*data.ogg
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@scottt
scottt / t.py
Created July 15, 2014 08:42
Filter out deleted uses from twitter stream
l = [ {'created_at': None, 'foo': 'bar'}, {'delete': 1 } ]
[ x for x in l if 'delete' not in x ]
# Out: [{'created_at': None, 'foo': 'bar'}]
@scottt
scottt / t.py
Created July 15, 2014 14:19
Filter out deleted entries
import json
l = json.loads(open('t.json').read())
l0 = [ x for x in l if u'delete' not in x ]
@scottt
scottt / malloc-perturb.c
Created July 21, 2014 16:01
Test the GLIBC MALLOC_PERTURB_ feature
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <malloc.h>
struct Rect {
char a, b;
};
typedef struct Rect Rect;
#!/usr/bin/env python2
from __future__ import print_function
import sys
import collections
d = collections.defaultdict(int)
fin = sys.stdin
n = int(fin.readline())
@scottt
scottt / Session
Created January 28, 2015 14:14
compilefunc var-arg.c
# Grab 'compilefunc' here:
# https://github.com/scottt/scottt-bin/blob/master/compilefunc
$ CFLAGS='-O0' compilefunc -s -l var-arg.c main
28 {
0x0000000000400823 <+0>: push %rbp
0x0000000000400824 <+1>: mov %rsp,%rbp
29 /* See 3.5.7 Variable Arugment Lists in http://www.x86-64.org/documentation/abi.pdf
30 * "When a function taking variable-arguments is called, %rax must be set to the
extraldflags="-Wl,--build-id";
buildldflags="VL_LDFLAGS=-Wl,--build-id"
./configure \
--prefix=$HOME/qemu-stm32 \
--disable-werror \
--disable-strip \
--enable-fdt \
--disable-xen \
--target-list=arm-softmmu \
extraldflags="-Wl,--build-id";
buildldflags="VL_LDFLAGS=-Wl,--build-id"
./configure \
--prefix=$HOME/qemu-arm \
--disable-werror \
--disable-strip \
--enable-fdt \
--disable-xen \
--target-list=arm-softmmu
PREFIX=$HOME/qemu-arm
export PATH=$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH