Skip to content

Instantly share code, notes, and snippets.

@zhester
zhester / dbg.js
Last active December 19, 2015 19:08
Function for adding a very primitive debug console to any page for development.
/**
* dbg
* Debug message printer. Drop-in debug console.
*
* @param message Message to display in console
*/
function dbg( message ) {
var ul = document.getElementById( 'message' );
if( ul == null ) {
ul = document.createElement( 'ul' );
@zhester
zhester / git-ci
Created September 4, 2013 20:49
Git Check-in
#!/usr/bin/sh
#
# git-ci
#
# Description:
# Does all the commands one normally has to do to "check in" updates
# to a branch in a centralized repository.
#
# Example:
# git-ci "Check-in comment goes here." development/features/SQUIRREL
@zhester
zhester / diff.bsh
Created September 10, 2013 18:51
Allows jEdit to function as a two-way diff tool.
/*****************************************************************************
diff.bsh
Allows jEdit to function as a two-way diff tool.
Note: You must have the JDiff plugin installed.
To configure an outside application to use jEdit as its diff tool, the
command is (assuming jedit is in your path):
@zhester
zhester / jedit_diff.md
Created September 10, 2013 19:45
Instructions for using jEdit as an external diff tool for Git.

Using jEdit as a Diff Tool for Git

Rationale

jEdit is my day-to-day editor. It works on every OS I use (primarily Windows at work and FreeBSD at home). With plugins, it provides every feature I need. It's open source [see note], easily extended, and it just works.

@zhester
zhester / normalize.sql
Created September 18, 2013 17:14
Normalize an input string to conform to internal naming standards.
/*----------------------------------------------------------------------------
normalize
@param subject The subject string to normalize
@return The normalized version of the string
Normalizes a given string for use as a human-readable, but
machine-friendly string identifier. The normalization rules are:
@zhester
zhester / five.html
Created September 29, 2013 19:33
HTML 5 Starter
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<link rel="stylesheet" href="styles.css">
<script src="script.js"></script>
</head>
<body>
@zhester
zhester / README.md
Created October 4, 2013 20:36
Fix Incorrectly FTP'd Files

Fix Incorrectly FTP'd Files

I did a dumb thing when backing up a file server once. I transferred a bunch of huge tarballs to a Windows machine over FTP. Normally, when I'm at the console, I'm transferring between Unix machines, so I forgot to set the transfer mode to binary. I transferred a bunch of huge files in ASCII then deleted the disk to make way for the new server's OS.

Well, that was a Bad Thing^TM. After getting over the shock of losing nearly 20GB of backups, I set out to see if I could "un-ASCII" the files. It turned out to be quite easy. So, here's the code that saved the day...

@zhester
zhester / MTar.py
Created October 4, 2013 20:43
In-Memory Tar Archive Creation
#!/usr/bin/python
##############################################################################
#
# MTar.py
#
# Zac Hester
# 2011-12-22
#
# This behaves similarly to Python's built-in tar support. However, this is
# a simplified library that writes extremely primitive tar files. The
@zhester
zhester / hexdump.py
Created October 27, 2013 20:18
Returns a tabular string of hex values for a string.
#=============================================================================
def hexdump( blob ):
"""
Returns a tabular string of hex values for a string.
@param blob Binary string to represent
@return String of hex values
"""
import math
length = len( blob )
bytes = struct.unpack( '%dB' % length, blob )
@zhester
zhester / gd_aa_test.php
Created November 12, 2013 22:42
PHP/GD Anti-aliasing Proof of Concept
<?php
/*****************************************************************************
PHP/GD Anti-aliasing, Proof of Concept
Zac Hester - 2011-06-28
Just a small bit of code to see if it can be done, and what kind of
memory overhead is needed to pull off an arbitrary, geometry-agnostic
anti-aliasing that works with transparent images.
*****************************************************************************/