Skip to content

Instantly share code, notes, and snippets.

@stevef
stevef / gist:944280
Created April 27, 2011 13:51
redirect to app store if registered protocol is not available
var iDeviceRedirect = function( url, appPath )
{
if ( url )
{
window.mobileDetected = true;
// for iDevice, we do redirect on document load.
// After redirect, if our script is still running,
// that means that the redirect failed. We then
// show a dialog box asking to download the app
window.onload = function()
@stevef
stevef / gist:946833
Created April 28, 2011 17:38
irb output using sanitize gem
{11-04-28 15:35}[jruby-1.5.6]fortress:~/Sandbox/ruby sf% cat clean_bad_html.rb
require 'rubygems'
require 'sanitize'
white_list_elements = %w[
a b i em strong dfn code q samp kbd var cite abbr
acronym sub sup dl ul ol li blockquote p h1 h2 h3
h4 h5 h6 pre table tr th td img br
]
@stevef
stevef / gist:948592
Created April 29, 2011 16:36
Bad HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
 <TITLE> New Document </TITLE>
 <META NAME="Generator" CONTENT="EditPlus">
 <META NAME="Author" CONTENT="">
 <META NAME="Keywords" CONTENT="">
 <META NAME="Description" CONTENT="">
 <script src="linked_js.js" type="text/javascript"/>
<STYLE TYPE="text/css">
@stevef
stevef / gist:948596
Created April 29, 2011 16:39
Good HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
 <TITLE> New Document </TITLE>
 <META NAME="Generator" CONTENT="EditPlus">
 <META NAME="Author" CONTENT="">
 <META NAME="Keywords" CONTENT="">
 <META NAME="Description" CONTENT="">
 <script src="linked_js.js" type="text/javascript"></script>
<STYLE TYPE="text/css">
@stevef
stevef / gist:1112913
Created July 29, 2011 00:49
Devise breaks to_json, so we must use my_json
def my_json(options={})
obj = {}
obj = to_json(options.merge!(obj))
obj = JSON.parse obj
obj['user']['id'] = id
obj.to_json
end
@stevef
stevef / gist:1447695
Created December 8, 2011 17:20
Tomcat6 failed startup
deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
@stevef
stevef / gist:1463441
Created December 11, 2011 23:19
JRuby backtrace
org.jruby.exceptions.RaiseException.<init>(RaiseException.java:101)
org.jruby.Ruby.newRaiseException(Ruby.java:3348)
org.jruby.Ruby.newEncodingCompatibilityError(Ruby.java:3323)
org.jruby.RubyString.cat(RubyString.java:1285)
org.jruby.RubyString.cat19(RubyString.java:1221)
org.jruby.RubyHash$5.visit(RubyHash.java:727)
org.jruby.RubyHash.visitAll(RubyHash.java:594)
org.jruby.RubyHash.inspectHash(RubyHash.java:721)
org.jruby.RubyHash.inspect(RubyHash.java:745)
org.jruby.RubyHash$i$0$0$inspect.call(RubyHash$i$0$0$inspect.gen:65535)
"message"=>"One complimentary Hostess Dessert Plate (trio of mini desserts, house-made cupcake, twinkie, cheesecake lollipop) with purchase of entree"
jar-jruby-dist:
[echo] jarjaring for dist
[jarjar] Building jar: /Users/sf/Dropbox/Sandbox/jruby/lib/jruby.jar
_osgify-jar_:
[copy] Copying 1 file to /Users/sf/Dropbox/Sandbox/jruby/build
[bndwrap] jruby 8174 0
[move] Moving 1 file to /Users/sf/Dropbox/Sandbox/jruby/lib
generate-ri-cache:
config.java_libs.delete_if {|f| f =~ /jruby-jars[^\/]+\.jar/}
config.java_libs.delete_if {|f| f =~ /jruby-openssl[^\/]+\.jar/}
config.java_libs.delete_if {|f| f =~ /jruby-rack[^\/]+\.jar/}
config.java_libs += FileList["lib/jars/*.jar"]