Skip to content

Instantly share code, notes, and snippets.

@aji
aji / foo.c
Created June 1, 2012 05:59
wut
#include <stdio.h>
#include <string.h>
typedef char PUTS;PUTS*putS="48656c6c6f2c20776f"
"726c642100";PUTS puTs[24];PUTS*Puts="---------"
"---------------------------------------0123456"
"789-------:;<=>?--------------------------:;<="
">?-";pUts(PUTS*pUTS,PUTS*PUTs){PUTS PuTS,PUtS;
PUtS=strlen(pUTS);memset(PUTs,0,PUtS>>1);for(
PuTS=0;PuTS<PUtS;PuTS++){PUTs[PuTS>>1]*=0x10;
PUTs[PuTS>>1]+=Puts[pUTS[PuTS]]-0x30;}}main()
@nenolod | why do we keep getting inquiries about inspircd
Lucifer7 | does that count as an inspircd-related query too
@spb | because inspircd users don't understand the concept of asking in the correct channel and waiting for an answer
+Taros | Because a lot of new inspircd users just ask their question in the nearest channel?
mr_flea | because inspircd users can't read documentation?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *prepend_lol(const char *nope)
{
char *yep = malloc(strlen(nope) + 5);
sprintf(yep, "lol, %s", nope);
return yep;
}
@aji
aji / gist:2866854
Created June 4, 2012 07:08
testing
Mowglibot@500-78-3-673.lightspeed.sndgca.sbcglobal.net
06:32:36 aji | hi
06:32:41 aji | bye
06:35:44 aji | hi
06:35:46 aji | bye
06:35:46 Mowglibot | adios
06:38:30 aji | bye
06:38:30 Mowglibot | adios
06:40:57 aji | bye
06:40:57 Mowglibot | adios
@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 /^\.\\" .*$/
@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 / 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);

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.

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
@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.