Skip to content

Instantly share code, notes, and snippets.

View benrothe's full-sized avatar

Ben Rothe benrothe

View GitHub Profile
@benrothe
benrothe / RemoveDuplicates.sh
Created November 6, 2014 15:39
Remove duplicates from the OS X "Open With" contextual menu
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user; killall Finder
@benrothe
benrothe / StraightenQuotes.sh
Created November 2, 2013 17:17
A TextExpander snippet to convert clipboard contents: “Curly” quotes to "straight", em-dashes to double-hyphens and ellipses to three periods.
#!/usr/bin/env php
<?php
$str = `pbpaste`;
$find = array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6");
$replace = array("'", "'", '"', '"', '-', '--', '...');
echo str_replace($find, $replace, $str);
@benrothe
benrothe / SmartenQuotes.sh
Created November 2, 2013 17:15
A TextExpander snippet to convert clipboard contents: "Straight" quotes to “curly”, double-hyphens to em-dashes and three periods to ellipses.
#!/usr/bin/env php
<?php
$str = `pbpaste`;
$str = preg_replace('/(^|[-\xe2\x80\x94\/(\[{"\s])\'/', "$1\xe2\x80\x98", $str);
$str = preg_replace('/\'/', "\xe2\x80\x99", $str);
$str = preg_replace('/(^|[-\xe2\x80\x94\/(\[{\xe2\x80\x98\s])"/', "$1\xe2\x80\x9c", $str);
$str = preg_replace('/"/', "\xe2\x80\x9d", $str);
$str = preg_replace('/--/', "\xe2\x80\x94", $str);
$str = preg_replace('/\.\.\./', "\xe2\x80\xa6", $str);
echo $str;
@benrothe
benrothe / FindAndReplace.sql
Last active October 5, 2015 07:17
Find & replace data in MySQL
UPDATE [table_name] SET [field_name] = REPLACE([field_name], '[string_to_find]', '[string_to_replace]');
@benrothe
benrothe / QLEnableTextSelection.sh
Created March 7, 2012 21:52
Select text in OS X Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder