Skip to content

Instantly share code, notes, and snippets.

View zach-klippenstein's full-sized avatar

Zach Klippenstein zach-klippenstein

View GitHub Profile
@zach-klippenstein
zach-klippenstein / postfix_calc.c
Created October 30, 2009 00:24
Simple console calculator. Uses postfix notation.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define STACK_SIZE 1000
#define MAX_OPERATORS 10
#define MAX_LINE 300
// Clear any exception
@zach-klippenstein
zach-klippenstein / Contest09Problem4.java
Created October 31, 2009 21:34
Problem 4 solution attempt for 2009 ACM North American Programming competition
import java.io.*;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collection;
public class Contest09Problem4
{
enum State
{
running,
@zach-klippenstein
zach-klippenstein / linkparser.py
Created December 9, 2009 19:51
Attempt at creating a very simple, breadth-first web crawler. As the test file shows, it was supposed to work on wikipedia. However, it doesn't (Wikipedia seems to send HTML that doesn't actually contain the article content).
from HTMLParser import HTMLParser
class LinkParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.links = []
#end __init__()
def reset(self):
HTMLParser.reset(self)
@zach-klippenstein
zach-klippenstein / smb-sync.sh
Created February 1, 2010 01:51
This script takes a local directory and a set of options specifying how/where to connect to a remote Samba server, and a newline-delimited list of paths on standard input. The paths should be relative to the local directory and the remote directory. They
#!/bin/bash
HELP="
Created on: 20/01/2010
By: Zachary Klippenstein
This script takes a local directory and a set of options
specifying how/where to connect to a remote Samba server,
and a newline-delimited list of paths on standard input.
The paths should be relative to the local directory and
@zach-klippenstein
zach-klippenstein / caseglob
Created March 14, 2010 01:07
Returns the path passed to it with the case of components modified to match the actual names. See the comment header for more details.
#!/bin/bash
#
# usage: caseglob [--rename] path
# Prints the path, with the basename corrected to the actual case of the file, if
# a match can be made.
#
# If --rename is specified, if an unambiguous match is found, it will be renamed to
# path and returned in the original case.
#
# If there are 0 or more than 1 matches, the original basename is printed.
@zach-klippenstein
zach-klippenstein / demo.rb
Created March 24, 2010 18:47
Class for parsing sentences from various sources (strings, streams, etc.)
# Demonstrates how to use the SentenceParser class.
require 'sentenceparser'
parser = SentenceParser.new
# Add a string as a source
parser << "This is a string. It has multiple sentences."
parser << "These are" << "a few strings, splitting" << "sentences across them."
#!/bin/bash
#
# Run periodically by cron, and will unarchive data in the
# ~/auto_unarchive/drop_target directory.
# Where the action happens
unarchiveDir="~/auto_unarchive/drop_target"
# Time in seconds between checking for new archives
checkInterval=1.5
@zach-klippenstein
zach-klippenstein / random-histogrammer.lua
Created August 10, 2010 14:33
Lua script for viewing the shape of the native Lua random generator, seeded by the time.
local lower = 1
local upper = 20
local numSamples = arg[1] or 1000
local numTrials = 10
local hist = {}
local getSeed = coroutine.create(
function()
local start
while true do
start = os.time()
@zach-klippenstein
zach-klippenstein / init-ssl
Created March 2, 2011 23:55
Script for quickly generating self-signed, passphrase-less SSL keys/certificates for web servers.
#!/bin/bash
BITS=1024
DAYS=365
function promptForName()
{
echo -n "Enter the SSL certificate/key name: " >&2
read name
echo $name
@zach-klippenstein
zach-klippenstein / README.md
Last active December 15, 2015 16:09
SystemTap language grammer for Sublime Text 2

(Unfinished) SystemTap language grammer for Sublime Text 2 (and possibly TextMate, although I don't have a copy lying around to test with). This grammar is very unfinished, and probably buggy. This is my first attempt at creating a grammar, and I've just been doing some simple SystemTap development for a school assignment, and was getting tired of staring at plain white text. If you're more experienced or just end up tweaking this, please feel free to send me a pull request!

If there's enough interest, I could throw it into a full package in a full repo.

History

v1.0

Copied a bunch of stuff from the default C grammar.

  • string escapes/format codes
  • better commenting