Skip to content

Instantly share code, notes, and snippets.

unsigned int numeric_atoi(const char *s)
{
return ((s[0] - '0') * 100)
+ ((s[1] - '0') * 10)
+ ((s[2] - '0'));
}
@aji
aji / foo.c
Created May 16, 2013 02:40
how const works
#include <stdio.h>
int main(int argc, char *argv[])
{
char a, b;
char const * s;
char * const p;
s = &a;
p = &b;
@aji
aji / do.py
Last active December 16, 2015 19:49
#!/usr/bin/python
from random import choice, randint
import weechat
NAME = 'do'
AUTHOR = 'aji <http://ajitek.net>'
VERSION = '1.0'
LICENSE = 'MIT'
DESC = 'print commands before doing them'
#!/bin/sh
die() {
echo "$*" 1>&2
exit 1
}
export TMPDIR=${TMPDIR:=/tmp}
export PDFLATEX=$(which pdflatex)
export PDF2PS=$(which pdf2ps)
import weechat as w
import re
weechat = w
SCRIPT_NAME = "welshify"
SCRIPT_AUTHOR = "aji"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Transform all your input to welsh, based on uppercase.py"
@aji
aji / ajibot.py
Last active December 16, 2015 02:09
import sys, socket, shlex
from random import choice, randint
class linebuf:
def __init__(self):
self.s = ['']
def data(self, data):
self.s[-1:] = (self.s[-1] + data).split('\r\n')
lines, self.s = self.s[:-1], self.s[-1:]
return lines
class linebuf:
def __init__(self):
self.s = ['']
def data(self, data):
self.s[-1:] = (self.s[-1] + data).split('\r\n')
lines, self.s = self.s[:-1], self.s[-1:]
return lines
@aji
aji / nc.c
Created March 27, 2013 23:44
netcat clone hacked together in 30 minutes
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdarg.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/select.h>
#define LG_SEVERE 0
#define LG_ERROR 1
? f(n)=if(n==0,1,2^f(n-1))
%4 = (n)->if(n==0,1,2^f(n-1))
? f(2)
%5 = 4
? f(3)
%6 = 16
? f(4)
%7 = 65536
? f(5)
%8 = 20035299304068464649790723515602557504478254755697514192650169737108940595563114530895061308809333481010382343429072631818229493821188126688695063647615470291650418719163515879663472194429309279820843091048559905701593189596395248633723672030029169695921561087649488892540908059114570376752085002066715637023661263597471448071117748158809141357427209671901518362825606180914588526998261414250301233911082736038437678764490432059603791244909057075603140350761625624760318637931264847037437829549756137709816046144133086921181024859591523801953310302921628001605686701056516467505680387415294638422448452925373614425336143737290883037946012747249584148649159306472520151556939226281806916507963810641322753072671439981585088112926289011342377827055674210800700652839633221550778312142885516755540733451072131124273995629827197691500548839052238043570458481979563931578535100189920000241419637068135598404640394
@aji
aji / ed.c
Created March 12, 2013 21:46
4.3 BSD ed
#ifndef lint
static char sccsid[] = "@(#)ed.c 4.5 (Berkeley) 8/12/86";
#endif
/*
* Editor
*/
#define CRYPT
#include <signal.h>