Skip to content

Instantly share code, notes, and snippets.

View harrylove's full-sized avatar

Harry Love harrylove

View GitHub Profile
If you work on or make any of these, I just wanted to say thanks.
I really appreciate what you do. I can't imagine what my life would
be like without them. Of course things could be better but I think
my life is pretty good with these things in my world.
Ruby, Rails, MongoDB, MySQL, PostgreSQL, JavaScript, HTML, CSS,
Firefox, Safari, Chrome, Firebug, YSlow!, Page Speed, iPhone, iOS,
Mac OS X, iTunes, iPod, TextMate, Apache, Nginx, NodeJS, Git, jQuery,
Prototype, Processing, Growl, Quicksilver, Illustrator, Photoshop,
and Fireworks;
class ThingsController < ApplicationController
# curl -c mycookies localhost:3000/things/new
# The "-c" flag will create/overwrite a cookie file named "mycookies"
def new
render :json => { :authenticity_token => form_authenticity_token }
end
# curl -i -b cookies -d "test=hey&authenticity_token=[URLEncoded auth token]" localhost:3000/things
# The "-i" flag returns the response header (optional)
@harrylove
harrylove / resque-pgrep-solaris
Created May 3, 2011 20:42
List all Resque workers and Resque pool manager on Solaris
$ pgrep resque | xargs pargs -a
26760: /opt/local/ree/bin/ruby /opt/local/ree/bin/resque-pool --daemon --environment s
argv[0]: resque-1.15.0: Waiting for mailer
argv[1]:
argv[2]:
argv[3]:
argv[4]:
26975: /opt/local/ree/bin/ruby /opt/local/ree/bin/resque-pool --daemon --environment s
@harrylove
harrylove / resque-web-smf-manifest.xml
Created May 5, 2011 20:46
Solaris SMF manifest file for Resque-web Sinatra app
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="resque-web">
<service name="application/resque-web" type="service" version="1">
<create_default_instance enabled="false" />
<single_instance />
<dependency name="network" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/milestone/network:default" />
</dependency>
<dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
@harrylove
harrylove / gist:1230292
Created September 20, 2011 20:52
Fun with JavaScript closures
console.info('* TRUTH *');
var truth = function() { return true; };
console.info(truth); // function()
console.info(truth()); // true
console.info('* F *');
var origF = function(arg) { return arg; };
var f = origF;
console.info(f); // function()
@harrylove
harrylove / gist:1230566
Created September 20, 2011 22:11
A simple wrapper function in JavaScript - more fun with closures
var truth = function() { return true; };
var relativeTruth = function() { return false; };
var assert = function(func) {
return func() == true;
};
var wrapper = function(func) {
// perform setup work here
wpcf7_add_shortcode( 'text', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'text*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'text', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'text*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'tel', 'wpcf7_text_shortcode_handler', true );
@harrylove
harrylove / gist:3860060
Created October 9, 2012 17:02
Install Ruby Enterprise Edition from source on SmartOS
# Install any dependencies with pkgin
pkgin in gmake ruby18 readline ncurses gcc47 curl apr apr-util apache ap22-xsendfile postgresql91
# Install REE
env CFLAGS="-I/opt/local/include -O2 -fno-tree-dce -fno-optimize-sibling-calls" ./ruby-enterprise/installer
# Test for segfault
gem update --system
@harrylove
harrylove / template.html
Last active April 21, 2018 11:52
Nested template problem, deployed to http://nestedtemplate.meteor.com/
<head>
<title>conditional templates</title>
</head>
<body>
Open the console. Session.set('active') to 'foo' or 'bar'. Then set the foo contents with Session.set('fooContents') to 'foofoo' and 'foobar'. Set bar contents with Session.set('barContents') to 'barfoo' or 'barbar', respectively.
{{> main }}
</body>