Skip to content

Instantly share code, notes, and snippets.

@dgalling
dgalling / cache.c
Created June 18, 2018 17:00
djbdns cache.c
#include "alloc.h"
#include "byte.h"
#include "uint32.h"
#include "exit.h"
#include "tai.h"
#include "cache.h"
uint64 cache_motion = 0;
static char *x = 0;
@dgalling
dgalling / defer.h
Created November 7, 2014 19:44
Deferred free in C
typedef struct free_list_t {
void (*func)(void *);
void *arg;
struct free_list_t *next;
} FreeList;
void _defer(FreeList **f, void (*func)(void *), void *arg) {
if (arg == NULL) {
return;
}
@dgalling
dgalling / realpath
Created July 13, 2014 00:59
Why doesn't OS X have this?
#!/usr/bin/env zsh
#
FILEPATH="$1"
echo $(cd "$(dirname "$FILEPATH")"; pwd)/$(basename $FILEPATH)
@dgalling
dgalling / play
Created July 13, 2014 00:56
iTunes stopped working again. I wrote a simple music queue/player.
#!/usr/bin/env sh
TIMEOUT=0
while true; do
AUDIO_FILE=$(redis-cli BLPOP "$MUSIC_QUEUE" $TIMEOUT | grep --max-count=1 '^/')
afplay "$AUDIO_FILE"
done
module RParse
class Parser
def initialize(&block)
@block = block
end
def char(c)
case @buffer[0]
when c
* * * * * /usr/bin/curl --user-agent "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" --location http://www.google.com >/dev/null 2>&1
@dgalling
dgalling / AndroidManifest.xml
Created August 16, 2012 03:53
Correct Android Manifest
<manifest ...>
<permission android:name="com.example.project.EXAMPLE_PERMISSION" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.project.EXAMPLE_PERMISSION"/>
<application ...>
<provider android:name=".ExampleProvider" android:grantUriPermissions="false" android:permission="com.example.project.EXAMPLE_PERMISSION"/>
</application>
</manifest>
default rel
bits 64
; stuff we need to export to C
global _fiber_new
global _fiber_yield
global _fiber_start
global _fiber_resume
global _main
LEADER='==>'
echo $LEADER 'Fetching vim from hg...'
hg clone https://vim.googlecode.com/hg/ vim
cd vim/src
echo $LEADER 'Configuring...'
./configure --enable-rubyinterp --enable-multibyte --enable-gui=no --disable-netbeans --with-compiledby=Ian\ Rahimi --enable-pythoninterp --disable-gtktest
echo $LEADER 'Building...'
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 11 2011 20:09:43)
MacOS X (unix) version
Included patches: 1-372
Compiled by Davis Gallinghouse
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv