Skip to content

Instantly share code, notes, and snippets.

@aji
aji / rcc.sh
Created February 18, 2012 06:09
rcc -- convert a file to a C array of unsigned integers
#!/bin/bash
# rcc.sh -- convert a file to a C array of uint16_t's
while getopts ":o:h:e:n:v" opt; do
case $opt in
o) output=$OPTARG
;;
h) header=$OPTARG
;;
e) varre=$OPTARG
@aji
aji / cycler.c
Created February 20, 2012 06:58
cycler -- cycles per time
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#define BUFSIZE 2<<15
char buforig[BUFSIZE];
char bufcopy[BUFSIZE];
@aji
aji / gist:1868454
Created February 20, 2012 08:41
chromeless -- send files on the filesystem to Chromium as text/plain
#!/bin/sh
# Chromium's default action for files it doesn't understand is to
# download them, apparently. Also, it looks like .c and other similar
# plaintext files are not something Chromium thinks it can read.
# So to save myself from having to constantly copy things to a file
# with a .txt extension so I can read them and to keep from having to
# make Chromium treat .c files and such differently, I've decided to
# write this nifty little script.
@aji
aji / brtcfg.c
Created February 24, 2012 05:16
brtcfg -- brightness configuration utility for my MacBook Pro running Arch
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
struct bclass {
char *id;
char *name;
char *brtfile;
char *maxfile;
};
@aji
aji / lastdl.sh
Created February 27, 2012 00:40
lastdl -- shell script to report the newest file in the downloads folder
#!/bin/sh
# echoes the full path of the newest download
# usage: lastdl.sh [NN], where 1<=NN<100
# adjust this appropriately:
DOWNLOADS=$HOME/Downloads
# this is horrendous
back=$1
case $back in
@aji
aji / killer.py
Created March 16, 2012 02:59
killer -- a deadly IRC "server"
#!/usr/bin/env python
import select
import random
import string
import socket
class Killer:
def __init__(self, sock):
self.sock = sock
@aji
aji / autojoiner.py
Created March 26, 2012 01:40
autojoin -- IRC bot to autojoin a channel and quit on a particular PRIVMSG. Does not respond to PING :/
#!/usr/bin/env python
import socket
import select
class AutoJoiner:
def __init__(self, server, port, nick, channel, deathmsg):
self.sock = socket.socket()
self.sock.connect((server, port))
diff --git a/src/libmowgli/core/mowgli_string.c b/src/libmowgli/core/mowgli_string.c
index 0aa065a..c37a851 100644
--- a/src/libmowgli/core/mowgli_string.c
+++ b/src/libmowgli/core/mowgli_string.c
@@ -24,11 +24,11 @@
#include "mowgli.h"
-mowgli_string_t *mowgli_string_create(void)
+mowgli_string_t *mowgli_string_create_size(size_t n)
@aji
aji / pinkie.py
Created April 13, 2012 19:29
IRC server in a single Python 3 script (only partially complete)
#!/usr/bin/python
# pinkie.py -- Proof-of-concept IRCd written in Python
# [40] alex@theta pinkie $ grep ^class pinkie.py
# class Pollable:
# class Timer:
# class TimerRepeat(Timer):
# class AsyncListen(Pollable):
# class AsyncLine(Pollable):
# class AsyncLoop:
@aji
aji / gist:2396321
Created April 16, 2012 04:17
userdel implementation using deluser and chroot
#!/bin/sh
# I haven't tested this.
# I don't even know if it works.
# Also, -f is different.
# In this implementation, -f will automatically confirm -r
if [ "$UID" != "0" ]; then
echo "You are not logged in as root. Cannot continue."