Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bdotdub's full-sized avatar

Benny Wong bdotdub

View GitHub Profile
-- A script to have Paparazzi! <http://www.derailer.org/paparazzi/> take a screentshot
-- and save it.
-- by Benny Wong
-- 2008/10/02
--
-- Shamelessly adapted from <http://bbs.macscripter.net/viewtopic.php?pid=82666>
--
-- Usage:
-- $ osascript screenshotous.scpt URL FILENAME
--
@bdotdub
bdotdub / soundmanager2.js
Created December 9, 2008 20:46
Matching 'swf' at the end of line to avoid detecting it in the base paths
497c497
< if (smURL.match(/.swf/)) {
---
> if (smURL.match(/.swf$/)) {
@@ -95,8 +95,8 @@
this._defaultFlashVersion = 8;
this.filePatterns = {
- flash8: /.mp3/i,
- flash9: /.mp3/i
+ flash8: /\.mp3(\?.*)?$/i,
+ flash9: /\.mp3(\?.*)?$/i
};
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>canPlayUrl Test</title>
<script src="soundmanager2.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
--- a/lib/sinatra.rb
+++ b/lib/sinatra.rb
@@ -1260,7 +1260,8 @@ module Sinatra
request.env['rack.errors'] << msg
request.env['sinatra.error'] = e
- context.status(500)
+ status = e.class.respond_to?(:code) ? e.class.code : 500
+ context.status(status)
raise if options.raise_errors && e.class != NotFound
@bdotdub
bdotdub / sort_and_vectorize.pl
Created January 9, 2009 18:15
Comparison between perl and ruby code. Ruby wins in my book
@tuples = sort { $a->[0] <=> $b->[0] } @tuples;
my $dates = map { $_->[0] } @tuples;
my $values = map { $_->[1] } @tuples;
function click(theFunction) {
// Something happens
theFunction(event);
}
// Example 1
$('a').click(alert('hi'));
// Example 2: this does the same thing as example 1
alert_result = alert('hi');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>test</title>
<!-- JQUERY -->
<script type="text/javascript" charset="utf-8">
@bdotdub
bdotdub / gist:70317
Created February 25, 2009 17:54
Equivalent?
filter(P, [H|T]) ->
case P(H) of
true -> [H|filter(P, T)];
false -> filter(P, T)
end;
filter(P, []) ->
[].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#!/usr/bin/ruby
require 'aws/s3'
class GitRepoArchiver
attr_reader :repo_name, :repo_dir, :bucket
def init(args)
# Change the current working directory