Skip to content

Instantly share code, notes, and snippets.

☕️
Caffeinating

Jesse Donat donatj

☕️
Caffeinating
Block or report user

Report or block donatj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@donatj
donatj / fast-patch.sh
Created Aug 27, 2010
Git Fast Patch Shell Script
View fast-patch.sh
#!/bin/sh
set -o errexit
# make sure we're at the root of git repo
if [ ! -d .git ]; then
echo "Error: must run this script from the root of a git repository"
exit 1
fi
if [ ! -d "$1/.git" ]; then
@donatj
donatj / Apache Log Parser
Created Aug 31, 2010
Useful Regular Expressions
View Apache Log Parser
(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?<timestamp>.*?)\] "GET (?<request>.*?) (?<httpver>HTTP/1\.\d)" (?<response>\d{3}) (?<response_size>\d{1,}) "(?<referer>.*?)" "(?<client>.*?)"
@donatj
donatj / lorem.php
Created Sep 22, 2010
PHP Flavored Lorem Ipsum Generator
View lorem.php
<?php
include('words_example.php'); //Our Datasetm $data
$patSize = 5;
foreach( $data as $word ) {
for( $i = 0; $i <= strlen( $word ) - 2; $i++ ) {
$j = 0;
$str = '';
@donatj
donatj / imagesnap.php
Created Nov 16, 2010
PHP Mac Camera Grab
View imagesnap.php
<?php
header("Content-Type: image/jpg");
passthru('/usr/local/bin/imagesnap -');
@donatj
donatj / hl.cfg
Created Dec 9, 2010
PhpED Dark Highlighting Configuration
View hl.cfg
<?xml version="1.0" encoding="utf-8"?><root version="6000"><sect_php><name_0>Whitespace</name_0><color_0>clNone</color_0><fontcolor_0>clTeal</fontcolor_0><isbold_0>0</isbold_0><isunderline_0>0</isunderline_0><isitalic_0>0</isitalic_0><isstikeout_0>0</isstikeout_0><name_1>String</name_1><color_1>clNone</color_1><fontcolor_1>$003CCE94</fontcolor_1><isbold_1>0</isbold_1><isunderline_1>0</isunderline_1><isitalic_1>0</isitalic_1><isstikeout_1>0</isstikeout_1><name_2>Comment</name_2><color_2>clNone</color_2><fontcolor_2>$00AEAEAE</fontcolor_2><isbold_2>0</isbold_2><isunderline_2>0</isunderline_2><isitalic_2>1</isitalic_2><isstikeout_2>0</isstikeout_2><name_3>Text</name_3><color_3>clNone</color_3><fontcolor_3>clNone</fontcolor_3><isbold_3>0</isbold_3><isunderline_3>0</isunderline_3><isitalic_3>0</isitalic_3><isstikeout_3>0</isstikeout_3><name_4>Reserved words</name_4><color_4>clNone</color_4><fontcolor_4>$004848E1</fontcolor_4><isbold_4>1</isbold_4><isunderline_4>0</isunderline_4><isitalic_4>0</isitalic_4><isstikeou
@donatj
donatj / NaturalSort.sql
Created Jan 18, 2011
Useful MySQL Expressions
View NaturalSort.sql
CONCAT(IF(ASCII(LEFT(products_model,1))>57,LEFT(products_model,1),'0'),IF(ASCII(RIGHT(products_model,1))>57,LPAD(products_model,10,'0'),LPAD(CONCAT(products_model,'-'), 10,'0')))
View selector_string2array
/**
* Method for taking a string formatted as a css selector and breaking it down into id/classes/attributes/in-line styles
* to use in the creatin of an element. I.E. "#id.class.class2[attribute=value]{ border: 1px solid blue; }"
*
* @ignore this is the original regex i wrote, which was awesome, but broke on some edge cases ...
* "!(\#(.+?)(\.|\[|\{)){1,}!" => ' id="$2" $3', //ID
* "!(\.(.*?)(\[|\{)){1,}!" => ' class="$2" $3', //CLASS
* "!\[(.*?)=([^\[]*)\]!" => ' $1="$2" ', //ATTRS
* "!\{(.*)\}!" => ' style="$1" ', //INLINE STYLE
* "!\.([a-zA-Z_]+[\w\-]*)!" => ' $1', //SPECIFIC CLASSES
View reverse_words.php
#!/usr/bin/php -q
<?php
$handle = @fopen("B-large-practice.in", "r");
$count = fgets($handle);
for( $i = 1; $i <= $count; $i++ ) {
echo 'Case #' . $i . ': ' . implode(' ', array_reverse(explode(' ', trim(fgets($handle)))) ) . PHP_EOL;
}
View Application.xaml.vb
Imports System.Windows.Shell
Class Application
Public Sub New()
Dim jl As New JumpList
JumpList.SetJumpList(Application.Current, jl)
Dim SaveAs As New JumpTask
SaveAs.ApplicationPath = System.Reflection.Assembly.GetExecutingAssembly.Location()
@donatj
donatj / penny-arcade-line-height.user.js
Created May 31, 2011
Penny Arcade Line-Height User Script
View penny-arcade-line-height.user.js
// ==UserScript==
// @name Penny Arcade Line-Height Correction
// @author Jesse G. Donat
// @namespace http://donatstudios.com/
// @match http://www.penny-arcade.com/*
// @description Fixes Penny-Arcades stupid unreadable lineheight
// ==/UserScript==
document.getElementsByClassName('body')[0].style.lineHeight='1.6em';
You can’t perform that action at this time.