Skip to content

Instantly share code, notes, and snippets.

View donatj's full-sized avatar
Getting back to business

Jesse Donat donatj

Getting back to business
View GitHub Profile
@donatj
donatj / argsr
Last active December 11, 2015 12:18
Argument Expander A stupid simple way to see the result of a glob before running it on something else
#!/usr/bin/env php
<?php
print_r($argv);
@donatj
donatj / move_old_downloads.rb
Created January 22, 2013 23:24
Move Old Downloads - A simple script to move downloads to a sub-directory
#!/usr/bin/env ruby
path = File.expand_path('~/Downloads/');
older_path = File.join(path, 'Older')
days = 20
seconds_offset = ( days*24*60*60)
the_break = Time.now - seconds_offset
Dir.foreach(path) do |fname|
@donatj
donatj / stupid.sh
Last active December 15, 2015 07:38
Stupid Bash Script
for (( ; ; ))
do
yes '-' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
yes '/' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
yes '|' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
yes '\' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
@donatj
donatj / 256color.php
Created April 4, 2013 20:17
Nearest Terminal Color Calculator
<?php
$CLUT = array(
'00' => array( 0, 0, 0 ), '01' => array( 128, 0, 0 ),
'02' => array( 0, 128, 0 ), '03' => array( 128, 128, 0 ),
'04' => array( 0, 0, 128 ), '05' => array( 128, 0, 128 ),
'06' => array( 0, 128, 128 ), '07' => array( 192, 192, 192 ),
'08' => array( 128, 128, 128 ), '09' => array( 255, 0, 0 ),
'10' => array( 0, 255, 0 ), '11' => array( 255, 255, 0 ),
'12' => array( 0, 0, 255 ), '13' => array( 255, 0, 255 ),
@donatj
donatj / jdonat.zsh-theme
Created May 8, 2013 19:30
My oh-my-zsh theme
# local color_array=(cyan white yellow magenta black blue red default grey green)
# hostname | md5 -qr | cut -c1
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%?↵%{$reset_color%})"
local time_code="%{%(?.$reset_color.$fg[red])%}%*%{$reset_color%}"
PROMPT='%{%(?.$fg[$NCOLOR].$fg[red])%}%n%{$fg[green]%}@%m%{$reset_color%} %(?..%{$fg[red]%})%~ \
$(git_prompt_info)\
%{$fg[red]%}%(!.#.»)%{$reset_color%} '
@donatj
donatj / sql_percent.php
Created May 29, 2013 19:41
Add percent markers to a SQL file for importing. Currently limited to 2 gigs in size.
#!/usr/bin/env php
<?php
$file = @$argv[1];
if( !is_file($file) ) {
die('Please provide a SQL file' . PHP_EOL);
}
$file_size = filesize($file);
@donatj
donatj / a_gearnan.log
Last active December 18, 2015 18:29
Gearman Compile Issue
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gearmand configure 1.1.7, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/gearman/1.1.7 --with-mysql
## --------- ##
## Platform. ##
@donatj
donatj / index.php
Last active December 22, 2015 18:19
Turn the Penny Arcade DLC page into a *real* podcast.
<?php
date_default_timezone_set('America/Chicago');
$subject = file_get_contents("http://penny-arcade.com/dlc");
preg_match_all('%<li[ >].*?<h4>(?P<title>.*?)</h4>.*?class="paDLCLink"[^>]href="(?P<file>.*?)".*?</li%si', $subject, $result, PREG_SET_ORDER);
header('Content-Type: application/rss+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
@donatj
donatj / getinfo.sh
Created September 20, 2013 16:52
Displays the OS X Finder "Get Info" dialog.
#!/bin/sh
# Requires a POSIX-ish shell.
#
# Originally From: http://hayne.net/MacDev/Bash/show_getinfo
#
# show_getinfo
# This script opens the Finder's "Get Info" window
# for the file or folder specified as a command-line argument.
@donatj
donatj / _ScaledSpriteMap.scss
Last active August 29, 2015 14:02
SCSS Scaled Sprite Map
@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;