Skip to content

Instantly share code, notes, and snippets.

View sintaxi's full-sized avatar
🔥
GSD

Brock Whitten sintaxi

🔥
GSD
View GitHub Profile
class String
def title_case!
self.split.map{ |w| w.capitalize }.join(' ')
end
end
class Hash
def title_case_keys!
self.each_pair do |k,v|
module StateMachine
def self.included(klass)
klass.extend ClassMethods
end
def self.wrap_method(klass, name)
original_method = "original_#{name}"
before_method = "before_#{name}"
@sintaxi
sintaxi / gist:32194
Created December 5, 2008 01:32
undefined
set :application, "phonegap"
set :deploy_to, "/var/www/phonegap.com"
set :tmp, "#{application}_update"
set :app_root, "/"
set :user, "root"
set :use_sudo, true
role :web, "phonegap.com"
require 'rubygems'
require "hpricot"
PHONEGAP_WEB_PATH = "iphone/www"
namespace :iphone do
task :default => [:import] do
end
desc 'reverts file back to original form'
#######################
# Merb.run_later issues
#######################
Here is what I am running.
- Slicehost account
- Ubuntu 8.04
- jruby 1.1.5 (ruby 1.8.6 patchlevel 114) (2008-11-03 rev 7996) [amd64-java]
- glassfish V3 (0.9.1)
@sintaxi
sintaxi / index.html
Created February 5, 2009 20:03
xhr request to flickr using XUI
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Page Title</title>
<script type="text/javascript" charset="utf-8">
//paste XUI here
getImage = function(){
x$("#imagebox").xhr("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?",
{callback:function(){
#
# #####################################
# Who is the killer?
# #####################################
#
# Handel has been killed and Beethoven is on the case. He has
# interviewed the four suspects and their statements are shown below.
# Each suspect has said two sentences. One sentence of each suspect is a
# lie and one sentence is the truth. Help Beethoven figure out who the
# killer is.
<link id="css" href="stylesheets/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8">
(function(){
var ua = navigator.userAgent;
if(ua.match("iPhone") || ua.match("Android")){
document.getElementById("css").href = "stylesheets/mobile.css";
var meta = document.createElement("META");
meta.setAttribute('content','width=320; initial-scale=1.0; maximum-scale=2.0;');
body{
margin:0;
font-family:Helvetica, Arial;
font-size:84%;
}
a{
color:#24F;
font-weight:bold;
}
class Hits < Application
# this is a nested resource with only a create method
# we use render_then_call (merb only) just to pass back
# a 200 status before doing the calculation
# this action is hit with a XHR POST that looks like...
# http://example.com/shot/4587/hit
#
def create
only_provides :js