Skip to content

Instantly share code, notes, and snippets.

@mcgrew
mcgrew / Makefile
Created February 5, 2013 18:22
Generic Makefile template
CC = gcc
CXX = g++
INCLUDES = -I.
CFLAGS = -g -O2
DEFINES =
EXTRA_CFLAGS= -Wall -Wextra -Wconversion
PROGRAM_NAME= program
LIBS = -L/usr/lib64/ -L/usr/lib/ -lm
@mcgrew
mcgrew / _etc_conf.d_network
Created January 18, 2013 20:42
Systemd network startup script and config
interface=eth0
address=192.168.10.99
netmask=24
broadcast=192.168.10.255
gateway=192.168.10.1
@mcgrew
mcgrew / colors.sh
Created January 4, 2013 19:20
Script which prints out a chart of the ANSI color codes, showing their appearance
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what is available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
# Taken from the Bash Prompt HOWTO:
@mcgrew
mcgrew / linux-ralus.patch
Last active October 12, 2015 06:48
Patch for the linux kernel to maintain compatibility with Symantec Remote Backup Agent (ralus)
diff --git a/net/core/dev.c b/net/core/dev.c
index e5942bf..c2461b1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5262,6 +5262,9 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
* Not applicable in our case */
case SIOCSIFLINK:
return -ENOTTY;
+ /* For SYMANTEC BACKUP AGENT */
+ case SIOCGIFCOUNT:
@mcgrew
mcgrew / view.sh
Created March 28, 2012 16:02
Script for changing monitor settings for the laptop dock
#!/bin/bash
LAPTOP="LVDS1"
DVI1="HDMI1"
DVI2="HDMI2"
DOCK_WIDTH=1680
DOCK_HEIGHT=1050
DOCK_LARGE_WIDTH=1280
DOCK_LARGE_HEIGHT=800
LAPTOP_WIDTH=1440
@mcgrew
mcgrew / performance.c
Created March 23, 2012 17:04
quick performance tester for testing memory read/write speeds
// To compile: gcc -std=gnu99 -O2 -o performance performance.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#define arrcpy(dest,src,size) for(size_t zz=0;zz<size;zz++)dest[zz]=src[zz]
#define dalloc(size) (test_t*)malloc(sizeof(test_t)*size)
@mcgrew
mcgrew / class.js
Created January 6, 2012 16:36
Simple class implementation in js by John Resig
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
* Usage exmaples: http://ejohn.org/blog/simple-javascript-inheritance/
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
@mcgrew
mcgrew / ObjNode.py
Created March 25, 2011 17:02
A python class that mimics javascript object behaviour
class ObjNode( object ):
def __init__( self, value=None ):
object.__init__( self )
self.__dict__[ "value" ] = value
def __setattr__( self, attr, value ):
if ( attr[ 0 ] == '_' ):
self.__dict__[ attr ] = value
elif self.__dict__.has_key( attr ):
@mcgrew
mcgrew / filter.py
Created March 16, 2011 15:16
Some 1d & 2d fft filters
"""
filter.py
Author: Thomas McGrew
License:
MIT license.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@mcgrew
mcgrew / print_array.php
Created February 15, 2011 15:54
Debugging function for printing a php array in a readable format
<?php
function print_array($array)
{
echo "<div style=\"font-family: 'Courier New', Courier, monospace; font-size: 12px;\">\n";
print_array_recursive($array, '');
echo "</div>\n";
}
function print_array_recursive($array, $prefix)