Skip to content

Instantly share code, notes, and snippets.

@bradley219
bradley219 / cStringBuilder.cls
Created Mar 19, 2013
Slightly improved version of Steve McMahon's cStringBuilder for visual basic 6 (and possibly for later versions of visual basic). Adds useful methods such as CharAt() and GetSlice(), and fixes an issue with the Find() method which did not work when the string you were searching for happened to be at the very end of the buffer.
View cStringBuilder.cls
Option Explicit
' ======================================================================================
' Name: vbAccelerator cStringBuilder
' Author: Steve McMahon (steve@vbaccelerator.com)
' Date: 1 January 2002
'
' Copyright 2002 Steve McMahon for vbAccelerator
' --------------------------------------------------------------------------------------
' Visit vbAccelerator - advanced free source code for VB programmers
@bradley219
bradley219 / hamming_distance.c
Created Apr 8, 2013
MySQL extension for user-defined function HAMMING_DISTANCE, which quickly calculates hamming distance between two 64-bit integers passed as arguments.
View hamming_distance.c
#ifdef STANDARD
/* STANDARD is defined, don't use any mysql functions */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef __WIN__
typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */
typedef __int64 longlong;
#else
typedef unsigned long long ulonglong;
@bradley219
bradley219 / nanosleep.c
Created Apr 8, 2013
Command-line tool similar to `sleep' with nanosecond precision.
View nanosleep.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <signal.h>
#include <termios.h>
#include <time.h>
#include <stddef.h>
View wkhtmltopdf_patch.diff
diff -rupN wkhtmltopdf-0.11.0_rc1/common.pri wkhtmltopdf-0.11.0_rc1-working/common.pri
--- wkhtmltopdf-0.11.0_rc1/common.pri 2011-10-02 10:21:02.000000000 -0700
+++ wkhtmltopdf-0.11.0_rc1-working/common.pri 2012-09-26 10:22:30.764000002 -0700
@@ -17,7 +17,7 @@
unix {
TEMP = $$[QT_INSTALL_LIBS] libQtGui.prl
- PRL = $$[QT_INSTALL_LIBS] QtGui.framework/QtGui.prl
+ PRL = $$[QT_INSTALL_LIBS] libQtGui.prl
include($$join(TEMP, "/"))
include($$join(PRL, "/"))
@bradley219
bradley219 / .gitignore
Last active May 10, 2021
PID C++ implementation
@bradley219
bradley219 / carver.c
Last active Dec 16, 2015
Cheap-o file carving utility :)
View carver.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int read_file_into_mem( char *filename, char **memory )
{
int size;
FILE *fp;
fp = fopen( filename, "rb" );
@bradley219
bradley219 / vfprintf.c
Created Jun 1, 2013
Modified version of vfprintf.c from the avr-libc library. Adds the format specifier `%b' to the printf family of functions to allow printing an integer in binary (base 2) representation.
View vfprintf.c
/* Copyright (c) 2002, Alexander Popov (sasho@vip.bg)
Copyright (c) 2002,2004,2005 Joerg Wunsch
Copyright (c) 2005, Helmut Wallner
Copyright (c) 2007, Dmitry Xmelkov
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
View wkhtmltopdf_patch.diff
diff -rupN wkhtmltopdf-0.11.0_rc1/common.pri wkhtmltopdf-0.11.0_rc1-patched/common.pri
--- wkhtmltopdf-0.11.0_rc1/common.pri 2011-10-02 10:21:02.000000000 -0700
+++ wkhtmltopdf-0.11.0_rc1-patched/common.pri 2012-09-28 09:45:49.772000005 -0700
@@ -17,7 +17,7 @@
unix {
TEMP = $$[QT_INSTALL_LIBS] libQtGui.prl
- PRL = $$[QT_INSTALL_LIBS] QtGui.framework/QtGui.prl
+ PRL = $$[QT_INSTALL_LIBS] libQtGui.prl
include($$join(TEMP, "/"))
@bradley219
bradley219 / fdupes
Last active Aug 29, 2015
Find duplicate files for a given path
View fdupes
#!/bin/bash
if [ "$1" == "" ]; then
echo "Usage: $0 path"
exit 1
fi
TEMPFILE="/tmp/fdupes_`cat /dev/urandom | head -c 1024 | cksum | awk '{print $1}'`"
find "$1" -type f -exec cksum '{}' ';' | sort > "$TEMPFILE"
View imgdiff
#!/bin/bash
# To configure git:
# git config difftool.imgdiff.cmd "path/to/imgdiff \"\$MERGED\" \"\$LOCAL\" \"\$REMOTE\""
# To run from git:
# git difftool -t imgdiff [<commit> [<commit>]] [--] [<path>...]
MERGED="$1"
LOCAL="$2"