Skip to content

Instantly share code, notes, and snippets.

#!/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"
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 / 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" );
@bradley219
bradley219 / .gitignore
Last active April 9, 2024 09:03
PID C++ implementation
.DS_Store
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>
@bradley219
bradley219 / hamming_distance.c
Created April 8, 2013 17:30
MySQL extension for user-defined function HAMMING_DISTANCE, which quickly calculates hamming distance between two 64-bit integers passed as arguments.
#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;