Skip to content

Instantly share code, notes, and snippets.

View irace's full-sized avatar

Bryan Irace irace

View GitHub Profile
@irace
irace / gist:1041837
Created June 23, 2011 03:11
Simple bookmarklet template with jQuery
// Stripped down jQuerify for modern browsers: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
(function() {
var f = function() {
jQuery.noConflict()(function($) {
// Bookmarklet code goes here
});
};
if (typeof jQuery != 'undefined') {
@irace
irace / gist:1105846
Created July 26, 2011 02:54
Chaining numerous invocations of the same anonymous JavaScript function
// Please let me know if one approach is better than the other
(function(arg) {
alert(arg);
return arguments.callee;
}('foo')('bar')('baz'));
(function f(arg) {
alert(arg);
@irace
irace / gist:1112932
Created July 29, 2011 01:09
Wake up when Thom Yorke tickets go on sale (didn't work)
#!/bin/bash
numberOfShows=`curl --silent http://thomyorketickets.waste.uk.com/Store/DisplayItems.html | grep -c "time to be confirmed"`
while true; do
if [ "$numberOfShows" -ne "5" ]; then
while true; do
`say check for tickets`
sleep 5
done
@irace
irace / gist:1112944
Created July 29, 2011 01:18
Invoke JavaScript from Java, using Mozilla Rhino
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.tools.shell.Global;
import org.mozilla.javascript.tools.shell.Main;
public class ScriptTest {
public static void main(String[] args) {
final Context cx = ContextFactory.getGlobal().enterContext();
cx.setOptimizationLevel(-1);
@irace
irace / gist:1441404
Created December 7, 2011 04:02
Mail link to this page
document.location.href = 'mailto:?subject=' + document.title + '&body=' + document.location.href;
@irace
irace / image-animations-jquery.js
Created January 5, 2012 00:42
JavaScript image animations
$.each([
{ images: ['foo.jpg', 'foo2.jpg'], interval: 200 },
{ images: ['bar.jpg', 'bar2.jpg'], interval: 300 }
], function(index, animation) {
$('<img/>')
.attr('src', animation.images[0])
.load(function () {
var $img = $(this), count = 0;
$img.unbind();
@irace
irace / gist:1687047
Created January 27, 2012 04:51
Rudimentary object-to-string implementation
function stringify(value) {
if (typeof value === 'string') {
return '"' + value.replace('"', '\"') + '"';
} else if (!value || typeof value !== 'object') {
return value;
}
if (Object.prototype.toString.call(value) === '[object Array]') {
var entries = [];
@irace
irace / gist:3094279
Created July 11, 2012 22:48
RVM cheat sheet
rvm use system
rm use 1.9.2
gem install tumblr_client
gem query --local
tumblr
@irace
irace / gist:3163951
Created July 23, 2012 14:37
Objective-C block syntax
typedef void (^BlockType)(id);
void (^blockName)(void) = ^{
// Code
};
@property (nonatomic, copy) void (^blockName)(void);
- (id)initWithBlock:(void(^)(void))blockName;
@irace
irace / gist:3250478
Created August 3, 2012 19:04
Aggregate and sort Flurry exception CSV files
if [ -f "errors.txt" ]; then `rm errors.txt`; fi; for file in *.csv; do `tail -n +2 "$file" |
cut -d , -f 3 >> /tmp/errors`; done; sort /tmp/errors > errors.txt; rm /tmp/errors; less errors.txt