Skip to content

Instantly share code, notes, and snippets.

struct foo {
int data1;
char *data2;
mytype_t mymember;
int data3;
};
...
struct foo blah;
#!/usr/bin/env python
import sys
def usage(argv0):
print('Usage: {} FILE [FILE ...]'.format(argv0))
print('')
print('FILE can be - to mean standard input. Files are concatenated together')
print('and read in the order specified. Files should contain a list of IPv4')
print('addresses, one on each line.')
Mode #unicorncastle [+b *!*@*.za] by alyxkitty
<@alyxkitty> fuck south africa.
<+aji> wut
<@alyxkitty> FUCK SOUTH AFRICA.
Mode #unicorncastle [+b *!*@*.cn] by alyxkitty
<@alyxkitty> AND FUCK CHINA TOO.
Mode #unicorncastle [+b *!*@*.pro] by alyxkitty
<@alyxkitty> AND PROFESSIONALS
<@alyxkitty> FUCK PROFESSIONALS, WHILE WE'RE AT IT.
LL(1) parser format:
Terminal symbols: { } [ ] : , STR NUM ID
Rule table:
0. [invalid]
1. <json-document> := <object>
2. <json-document> := <array>
3. <value> := <object>
@aji
aji / zen.md
Created September 15, 2012 23:30

The housecat may mock the tiger, but doing so does not turn his purr into a roar.

A man who mistakes secrets for knowledge is like a man who, seeking light, hugs a candle so closely that he smothers it and burns his hand.

The wisdom of the patriarchs was that they knew they were fools.

A broken mirror never reflects again; fallen flowers never go back to the old branches.

When you are hungry, eat; when you are thirsty, drink; when you are tired, sleep.

1. A given
2. ~A | B given
3. A & (~A | B) what is this called? conjunction of previous statements?
4. (A & ~A) | (A & B) distributive law
5. A & B eliminating contradiction from disjunction
6. B what is this called? unzipping a conjunction?
what is the name for this whole process?
A & (~A | B) -> B

This is a simple JIT-based VM that implements the following instruction set:

  • 0x1 — Increment the A register
  • 0x2 — Increment the B register
  • 0x3 — Decrement the A register
  • 0x4 — Decrement the B register

The VM is implemented in vm.c and has both naive and JIT backends. The naive method is pure C and uses a switch statement to determine the appropriate action. The JIT backend compiles a program into x86 machine code using the definitions in the op-x86.s file.

The two vm_run_* functions have a "times" argument that specifies the number of times to repeat the program. This is a simple way of testing the performance increase gained by running JIT code while ignoring the overhead incurred from the JIT process itself. In a real JIT scenario, compiled code sections would be cached.

@aji
aji / jnidoc.h
Created July 20, 2012 20:26
putting the JNI into no-bullshit mode
/* The C JNIEnv typedef looks like this: */
typedef const struct JNINativeInterface_ *JNIEnv;
/* These are the useful members of the struct JNINativeInterface_ with a
smidge of sed to clear away the clutter. Additionally, each /(.*)V/
method has matching "\1A" and "\1" alternatives, i.e., if you see this:
jobject (*NewObjectV) (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args);
@aji
aji / askenv.py
Created June 14, 2012 17:02
askenv -- sudo-esque method of temporarily setting environment variables
#!/usr/bin/env python
import sys, os
import getpass
import copy
if len(sys.argv) <3:
print('usage: {0} =VARIABLE [=VARIABLE ...] CMD [ARGS ...]'.format(sys.argv[0]))
print('Prompts for each VARIABLE in succession and executes CMD')
sys.exit(1)
@aji
aji / groffman.vim
Created June 12, 2012 01:00
Vim syntax file for editing groff manpage sources
" Vim syntax file
" Language: Groff manpage macros
" Maintainer: Alex Iadicicco
" Latest Revision: 11 June 2012
if exists("b:current_syntax")
finish
endif
syn match gmComment /^\.\\" .*$/