Skip to content

Instantly share code, notes, and snippets.

@kmcallister
kmcallister / foo.c
Created December 5, 2012 02:17
impressive clang optimization
int is_json_space(char c) {
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
@kmcallister
kmcallister / gist:5315876
Created April 5, 2013 01:22
open a buncha files
#include <stdio.h>
int main() {
FILE *f[512];
char name[512];
int n;
for (n=0; n<512; n++) {
sprintf(name, "file%d", n);
f[n] = fopen(name, "w");
fprintf(f[n], "Hello, %d\n", n);
@kmcallister
kmcallister / gist:5342238
Created April 9, 2013 01:41
zzo38_ebooks
This file has been truncated, but you can view the full file.
know some of equations the name of course I was try to run on FreeGeek: http://play.php?p=99641#p99641#p99641 How would finds of to destroyed (including other that you have the correct the player with a headerT seems also do?
There is between card into people to turns outside of an add a file otherwise it. When I even those as too if you have the data in code or to impler document. Linux, including about unrelated uncurry
olsner: I would words, structions.
Are you may correct macro but review either the kind of moon; from there is into the "!" in their software, the case yourself solar to the checked?
Do you makes them are others.
Is LLVM is also use, refractics or and completely together. GNU C has boldly program!
No
To do think the music such as, it mathematical mode. I think printing a design won't mean some same such a categories mentionistical damage is used one places, h and the best want to, might work on text, either the game: I tried above Square" (VRC6 saw a few difference the other lands for wh
# gcc -nostdlib -o maze maze.s && ./maze
.globl _start
_start:
xor %edi, %edi
inc %edi
mov %rsp, %rsi
go:
movl $0xb195e2, (%rsi)
@kmcallister
kmcallister / gist:5565083
Created May 12, 2013 22:05
LPD6803 driver for AVR
typedef unsigned char byte;
#define STRIP_DDR DDRD
#define STRIP_PORT PORTD
#define STRIP_DAT (1 << 2)
#define STRIP_CLK (1 << 3)
// Set up the interface at boot.
inline void setup_strip() {
STRIP_DDR |= (STRIP_DAT | STRIP_CLK);
@kmcallister
kmcallister / gist:5640703
Created May 24, 2013 01:18
C++ range class
#include <iostream>
template <typename T>
class range {
private:
class iter {
private:
T m_x;
public:
deprecated; see https://gist.github.com/kmcallister/6589774
@kmcallister
kmcallister / valgrind.suppression
Created September 16, 2013 19:43
Valgrind suppression file for Servo
{
dri
Memcheck:Value1
obj:/usr/lib/x86_64-linux-gnu/dri/i965_dri.so
}
{
dri
Memcheck:Value2
obj:/usr/lib/x86_64-linux-gnu/dri/i965_dri.so
@kmcallister
kmcallister / example.py
Last active December 23, 2015 05:49
LED strip example v2
#!/usr/bin/env python
import time
import socket
import struct
import colorsys
class LEDs(object):
def __init__(self):
self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@kmcallister
kmcallister / rust-backtrace
Last active January 16, 2016 05:47
Run a Rust program and print a stack backtrace on failure (old)
#!/bin/bash
### NOTE ### You probably don't need this anymore!
# Just set RUST_BACKTRACE=1
# Usage: rust-backtrace ./my-rust-prog args...
exec gdb -batch -n -x /dev/fd/3 --args "$@" 3<<ENDGDB
set height 0
set breakpoint pending on