Skip to content

Instantly share code, notes, and snippets.

MobileSafari_PID=$(ps x | grep "MobileSafari" | grep -v grep | awk '{ print $1 }')
if [ "$MobileSafari_PID" == "" ]; then
echo "Mobile Safari.app must be running in the Simulator to enable the remote inspector."
else
cat <<EOM | gdb -quiet > /dev/null
attach $MobileSafari_PID
p (void *)[WebView _enableRemoteInspector]
detach
@sousk
sousk / run_test.rake
Created December 13, 2011 10:40
Rake task running headless JavaScript test with QUnit-Tap & PhantomJS
namespace :test do
desc "run headless test"
task :run do
tg = ENV['target'];
runner = 'tmp.sh'
unless tg
puts "an argument required: target=path_to_test.hml"
exit
@sousk
sousk / gist:1280108
Created October 12, 2011 02:44
Visually Hidden
.element-invisible {
position: absolute !important;
height: 1px; width: 1px;
overflow: hidden;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
/* Hide only visually, but have it available for screenreaders: h5bp.com/v */
.visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
@sousk
sousk / png2minb64.sh
Created September 14, 2011 03:58
Compress & base64 encode your PNG file
fs8=`ruby -e "print '$1'.sub(/\.png$/, '-fs8.png')"`
if test -e "$fs8"; then
rm $fs8
echo "rm $fs8\n"
fi
todataURI()
{
openssl base64 -in $fs8 | awk -v ext="png" '{ str1=str1 $0 }END{ print "data:image/"ext";base64,"str1 }' | pbcopy
}
@sousk
sousk / transparent.gif.txt
Created July 6, 2011 11:41
base64 encoded transparent gif for Data URI
data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==
@sousk
sousk / jquery_deferred_chains.js
Created March 17, 2011 10:06
combine multiple chains with jQuery.Deferred
$.when(
sushi_roll(),
dispatch()
).done(function() {
console.log('accepted:', arguments[0], arguments[1]);
});
var n = 0;
function dispatch() {
return $.Deferred(function(dispached) {
#!/usr/bin/env ruby
confbase = 'git-ssh-create'
init_command = 'git --bare init'
server = `git config --global #{confbase}.server`.chomp
if server.empty?
warn "Please set git config server."
warn " git config --global #{confbase}.server '[username@]yourserver.example.com'"
exit 1
@sousk
sousk / prove-runner (TM's command)
Created February 1, 2011 10:47
prove runner, TextMate's code snippet, make your test running on remote.
#!/usr/bin/env ruby
file = ENV['TM_FILEPATH']
if file =~ /\.t$/
local = ENV['LOCAL_PROJECT_ROOT']
remote = ENV['REMOTE_PROJECT_ROOT']
path = file.sub local, remote
else
local = ENV['TEST_LOCAL_DIR']
@sousk
sousk / gist:782303
Created January 17, 2011 00:30
colorize screen log
エンジニアの人って割と白黒のログ眺めてる人が多い気がしますが、僕は何かと色つけたい派ですね。
bash に
ctail(){ tail -f $1 | perl -pe 's/'$2'/\033\[1;35m$&\033\[0m/gi'; }
と書いて
ctail /var/log/system.log "(error|exception|unable)"
とかやってます
@sousk
sousk / gist:765757
Created January 5, 2011 01:01
Android Version Detection
app.is_android2p2 = (navigator.userAgent ||"").search(/Android\s*2.2/) > -1 ? true:false;