Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am snapbug on github.
  • I am snapbug (https://keybase.io/snapbug) on keybase.
  • I have a public key whose fingerprint is C7BE 2F95 E1D4 2DF1 9E2A 74D2 F497 4497 CB4B B9EB

To claim this, I am signing this object:

@snapbug
snapbug / mini_search.c
Created August 16, 2011 09:53
Miniature Search Engine
#include <string.h>
#include <sys/mman.h>
int main(void) {
for(char *x = (char *)mmap(0, 313805393, 2, 2, open("wsj.idx", 2), 0), i[sizeof(unsigned)], j[sizeof(unsigned)], q[256], *t, *r; t && r && *((unsigned *)&i) < *((unsigned *)r + 5) ?: (*((unsigned *)&i) = 0, t = strtok(gets(q), " '\n"), r = !t ?: (char *)bsearch(t, (unsigned *)x + 2 + 6 * *(unsigned *)x, *((unsigned *)x + 1), 6 * sizeof(unsigned), strcmp), t) ?: (*((unsigned *)&j) != *(unsigned *)x - 1 ?: qsort((unsigned *)x + 2, *(unsigned *)x, 6 * sizeof(unsigned), strcmp), *((unsigned*)x + 2 + 6 * *((unsigned *)&j)) && *((unsigned *)&j) < *(unsigned *)x); t ? ((r ? *((unsigned *)x + 2 + 6 * *((unsigned *)x + 2 + 6 * (*(unsigned *)x + *((unsigned *)x + 1)) + 2 * *((unsigned *)&i) + *((unsigned *)r + 4))) += *((unsigned *)x + 3 + 6 * (*(unsigned *)x + *((unsigned *)x + 1)) + 2 * *((unsigned *)&i) + *((unsigned *)r + 4)) : 0), *((unsigned *)&i) += 1, *((unsigned *)&j) = *(unsigned *)x - 1) : (printf("%s\n", (char *)((unsigned *)x + 4 + 6 * *((unsig
@snapbug
snapbug / search.cpp
Created August 10, 2011 10:41
43 Line C++ Index and Search
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, char **argv) {
@snapbug
snapbug / markov.py
Created July 29, 2011 05:16
Python Text Generator Using Markov Chain
#!/usr/bin/env python
from collections import defaultdict
from random import choice, randint
from re import findall
# Make sure that this will run in python 2 as well as 3
try:
input = raw_input
except NameError:
pass