Skip to content

Instantly share code, notes, and snippets.

View lytithwyn's full-sized avatar
💭
Closing dumb notifications that say I can set my status

Matthew Morgan lytithwyn

💭
Closing dumb notifications that say I can set my status
View GitHub Profile
@lytithwyn
lytithwyn / dhcp.conf
Created December 12, 2014 14:26
UEFI PXE Configs
# /etc/dnsmasq.d/dhcp.conf
dhcp-range=192.168.1.100,192.168.1.254,12h
dhcp-option=3,192.168.1.1
dhcp-option=15,alltech.local
dhcp-boot=pxelinux.0
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:efi-x86_64,bootx64.efi
except-interface=wan0
dhcp-authoritative
@lytithwyn
lytithwyn / oe_csv_to_tb_csv.awk
Created December 3, 2012 21:36
A awk script that will convert a CSV file exported from Outlook Express into one easily consumable by Thunderbird
BEGIN {
FS= ","
}
/$^/ { }
NF {
if(NR == 1) {
a[1] = "First Name"
a[2] = "Last Name"
} else {
@lytithwyn
lytithwyn / .gitconfig
Created June 28, 2012 22:02
git_indentation_blog_post
[filter "two_four"]
smudge = perl -MPOSIX -pe 's|^( +)|\" \" x floor(length($1)*2)|e'
clean = perl -MPOSIX -pe 's|^( +)|\" \" x floor(length($1)/2)|e'
@lytithwyn
lytithwyn / CheckingForErrors.php
Created April 24, 2012 13:41
Fixtures inside functional tests blog post
<?php
# make sure there were no problems loading the fixtures
self::assertNotContains('Exception', $cliCapturedOutput);
?>
@lytithwyn
lytithwyn / ObjectFromHash.rb
Created January 17, 2012 22:55
Convert a Hash to an object recursively
# modified from http://pullmonkey.com/2008/01/06/convert-a-ruby-hash-into-a-class-object/
class ObjectFromHash
def initialize(hash)
hash.each do |k,v|
# check to see if this value is a hash too
if v.class.name == "Hash"
v = ObjectFromHash.new(v)
end
self.instance_variable_set("@#{k}", v) ## create and initialize an instance variable for this key/value pair
self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")}) ## create the getter that returns the instance variable
@lytithwyn
lytithwyn / grep_unescape_download.sh
Created July 23, 2011 02:41
grep urls out of a source file, unescape them, and download them
pcregrep -o "http%3A%2F%2Fa\d\.sphotos\.ak[^&]+" index | perl -MURI::Escape -ne 'print uri_unescape($_)' | wget -i -
@lytithwyn
lytithwyn / format_code.sed
Created May 3, 2011 22:12
code for PHP Code Formatting with sed blog post
# this line reads the whole file in so we can do multiline substitution
:a;N;$!ba;
# this gets rid of our 5 line breaks between functions
s/\n\n\n\n\n/\n\n/g
# this puts curly braces on the same line with the control structures/function definitions to which they belong
# be aware that if there is a set of lines like this:
#
# if(myTest) //here's some documentation
<?php
$pageOutput = "";
try
{
if(!isset($_GET['page_name']) || empty($_GET['page_name'])) throw(new UserErrorException("This page received an invalid request."));
$database = mysql_db::get();
$pageName = $_GET['page_name'];
@lytithwyn
lytithwyn / rotate_thunderbird_sig.rb
Created February 26, 2011 15:54
A script that will randomize the signature file in my Thunderbird email account
#!/usr/bin/env ruby
require "fileutils"
#this is the file that we will write the chosen sig to
tbirdSigFile = "/home/lytithwyn/.thunderbird/r2hddzc6.default/sigs/lytithwyn@gmail.htm"
Dir.chdir(Dir.home() + "/sigs") do
sigs = Dir.glob("*.htm");
sigFileNumberToUse = rand(sigs.length);
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
Display *dpy = XOpenDisplay(NULL);