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 / bot.php
Created April 14, 2012 01:08
Simple IRC Bot
#!/usr/bin/php -q
<?php
include('pinch.php');
$pinch = new Pinch('irc.----.com', 'Manbot', '#channel', 'password');
$pinch->on('/:test ([a-z0-9 ]+)/i', function($msg, $obj){
$obj->msg( $msg[1], '#capdig' );
});
@donatj
donatj / mybot.rb
Created March 30, 2012 14:01
Simple IRC iTunes bot
require 'cinch'
bot = Cinch::Bot.new do
configure do |c|
c.server = ""
c.channels = ["#"]
c.password = ""
c.nick = ""
end
@donatj
donatj / matlock.php
Created February 23, 2012 20:46
Slow Query Log Parser
#!/usr/bin/php
<?php
$file = false;
$defaults = array(
'maxQueryTime' => pow(2,32),
'minQueryTime' => 0,
'maxLockTime' => pow(2,32),
'minLockTime' => 0,
'maxRowsSent' => pow(2,32),
'minRowsSent' => 0,
@donatj
donatj / ascii.php
Created November 9, 2011 22:00
Damn Simple PHP Ascii Art Generator
#!/usr/bin/php -q
<?php
if(isset($argv[1]) && strlen($argv[1])) {
$file = $argv[1];
}else{
echo 'Please Specify a File';
exit(1);
}
@donatj
donatj / ColorCLI.php
Created October 26, 2011 03:34
Simple CLI color class
<?php
class ColorCLI {
static $foreground_colors = array(
'bold' => '1', 'dim' => '2',
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
'cyan' => '0;36', 'light_cyan' => '1;36',
@donatj
donatj / Photobooth_rebuild.sh.php
Last active October 17, 2023 05:34
Photo Booth Rebuild Shell Script - see http://donatstudios.com/Lion-Photobooth-Repair for usage.
#!/usr/bin/env php -q
<?php
/**
* Photo Booth Plist Rebuilder / Repair
* @author Jesse G. Donat <donatj@gmail.com> http://donatstudios.com
* @license http://opensource.org/licenses/mit-license.php
*/
# Update this path with your username
$libraryPath = getenv('HOME') . '/Pictures/Photo Booth Library/';
@donatj
donatj / penny-arcade-line-height.user.js
Created May 31, 2011 16:24
Penny Arcade Line-Height User Script
// ==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';
@donatj
donatj / Application.xaml.vb
Created April 7, 2011 03:55
JumpList Example
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 / reverse_words.php
Created April 7, 2011 02:19
Code Jam Example
#!/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;
}
/**
* 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