This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef TEST_H_ | |
#define TEST_H_ | |
/* Unit testing framework. | |
* | |
* Copyright (c) 2014, Jim Ingram <[email protected]> | |
* | |
* Permission is hereby granted, free of charge, to any person | |
* obtaining a copy of this software and associated documentation | |
* files (the "Software"), to deal in the Software without |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print-clean.sh | |
targets=`grep '^.*:' Makefile | cut -d: -f1` # this isn't a general solution | |
echo rm -f $targets | |
# Makefile | |
a: | |
echo 'contents of a' > $@ | |
clean: | |
sh print-clean.sh > $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Implementations of the getdelim() and getline() functions from POSIX 2008, | |
just in case your libc doesn't have them. | |
getdelim() reads from a stream until a specified delimiter is encountered. | |
getline() reads from a stream until a newline is encountered. | |
See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html | |
NOTE: It is always the caller's responsibility to free the line buffer, even | |
when an error occurs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "error.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdarg.h> | |
#include <errno.h> | |
#include <time.h> | |
const char *progname = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# narepl - Not A Read-Eval-Print Loop. | |
echo "This is not a REPL. Press ctrl-d to compile and run, ctrl-c to exit." | |
echo -n "> " | |
while true ; do | |
echo "#include </dev/tty>" | gcc -x c -ldl - && ./a.out && rm ./a.out | |
echo -n "> " | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'readline' | |
require 'pp' | |
class Stsh | |
def initialize | |
@prompt = "-$ " | |
@aliases = {} | |
@running = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class BrainFuck | |
def initialize | |
@ops = create_ops | |
@tape = Array.new(1024,0) | |
@tp = 0 | |
@code = [] | |
@cp = 0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HTML Tidy filter. This is pretty Unix-specific. It uses the external 'tidy' | |
# command, which it looks for using 'which', and communicates with using open3. | |
require 'open3' | |
module Tidy | |
# Runs the source through tidy and returns the result. If tidy isn't found, | |
# just returns the source as is. The source should be string-like. | |
# | |
# Takes an optional hash parameter, with the keys :strict and :verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Takes a list of files and verifies the gpg signature on each, and makes | |
# sure that it was signed by an allowed key id | |
ALLOWED_KEY_IDS = ['C81FD50E'] | |
ARGV.each do |e| | |
result = `gpg --verify #{e} 2>&1` | |
# If the the signature isn't verified, print and error and go the next file | |
unless result.include?('Good signature') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Save attachments from a saved email. | |
require 'rubygems' | |
require 'tmail' | |
return 1 unless ARGV.size > 0 | |
ARGV.each do |in_file| | |
mail = TMail::Mail.load(in_file) |