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 / _ScaledSpriteMap.scss
Last active Aug 29, 2015
SCSS Scaled Sprite Map
View _ScaledSpriteMap.scss
@mixin scaled-sprite-background($name, $scale, $spritemap) {
background: $spritemap;
$spritePath: sprite-path($spritemap);
@include background-size(image-width($spritePath) * $scale);
$position: sprite-position($spritemap, $name);
background-position: (nth($position, 1) * $scale) (nth($position, 2) * $scale);
height: image-height(sprite-file($spritemap, $name)) * $scale;
@donatj
donatj / ordmaker.php
Created Sep 25, 2014
Convert String to Escaped Hexadecimal Notation
View ordmaker.php
#! /usr/bin/env php
<?php
$data = $argv[1];
$split = str_split($data);
foreach($split as $ord) {
echo "\\x" . dechex(ord($ord));
}
View join2insert.php
#!/usr/bin/env php
<?php
$string = "";
$opt = getopt('r');
while( $line = fgets(STDIN) ) {
$string .= $line;
}
@donatj
donatj / fast-patch.php
Created Apr 1, 2015
Fast Patch Redux
View fast-patch.php
#!/usr/bin/env php
<?php
if( count($argv) < 3 ) {
echo "Requires at least two arguments\n";
die(1);
}
$dir = realpath($argv[1]);
if( !is_dir($dir) ) {
@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 / 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 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;
}
You can’t perform that action at this time.