Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys
c = sys.stdin.read(1)
while len(c) > 0:
sys.stdout.write("{0:02x}".format(ord(c)))
c = sys.stdin.read(1)
@bradley219
bradley219 / cStringBuilder.cls
Created March 19, 2013 23:14
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.
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 / vfprintf.c
Created June 1, 2013 23:58
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.
/* 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
@bradley219
bradley219 / carver.c
Last active December 16, 2015 06:39
Cheap-o file carving utility :)
#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" );
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 / nanosleep.c
Created April 8, 2013 17:47
Command-line tool similar to `sleep' with nanosecond precision.
#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>
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
#!/bin/bash
function new_link ()
{
if [[ -n $LINK ]] && [[ -n $INET ]] && [[ -n $ACTIVE ]]; then
echo "$LINK"
fi
LINK=`expr "$1" : '\(.*\): flags=.*'`
INET=""
ACTIVE=""
#!/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"
@bradley219
bradley219 / fdupes
Last active August 29, 2015 14:01
Find duplicate files for a given path
#!/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"