Skip to content

Instantly share code, notes, and snippets.

module Rack
class GoogleAnalytics
TRACKING_CODE = <<-EOCODE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("{{ID}}");
#!/bin/sh
# Author: Carl Youngblood, 2010
# Based on http://www.novell.com/coolsolutions/feature/15380.html
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
#start this first
require 'rinda/ring'
require 'rinda/tuplespace'
DRb.start_service
# Create a TupleSpace to hold named services, and start running
Rinda::RingServer.new Rinda::TupleSpace.new
# Wait until the user explicitly kills the server.
# http://gist.github.com/636681
# http://tinyurl.com/learn-ruby-processing
require 'rinda/ring'
DRb.start_service
ring_server = Rinda::RingFinger.primary
o = ring_server.read([:name,:processing,nil,nil])[2]
o.stroke 255, 0, 0 #Red outline

Stuff in Ruby that is/isn't supported, or is different

Block Comments

###=begin / =end

Rib Rdb writes: "The new parser doesn't support this". Use single line comments instead.

/* --- */ format is also supported.

/*
with selected true as a param.
Element.select.
option("1", "one").
option("2", "two", true).
option("3", "three").to_s
produces:
require 'rubygems'
require 'kingdom-assignment'
if CSV.const_defined? :Reader
# require 'fastercsv'
INSTALLED_CSV = FasterCSV
else
INSTALLED_CSV = CSV
end
6: Cannot find instance method set(int, int) on java.util.List
Mirah::InternalCompilerError: Cannot find instance method set(int, int) on java.util.List
infer at ~/hacking/fresh_mirah/lib/mirah/typer/simple.rb:280
infer at ~/hacking/fresh_mirah/lib/mirah/ast/structure.rb:34
each at org/jruby/RubyArray.java:1603
infer at ~/hacking/fresh_mirah/lib/mirah/ast/structure.rb:33
infer at ~/hacking/fresh_mirah/lib/mirah/typer/simple.rb:275
infer at ~/hacking/fresh_mirah/lib/mirah/ast/flow.rb:125
collect at org/jruby/RubyArray.java:2336
@baroquebobcat
baroquebobcat / output.txt
Created October 30, 2011 19:43 — forked from igrigorik/output.txt
test.mirah
~/hacking/fresh_mirah]$ bundle exec mirahc -V test.mirah
Parsing...
test.mirah
Inferring types...
* [Mirah::Typer] New type defined: 'Test' < ''
* [Mirah::Typer] Learned local type under #<Mirah::AST::StaticScope:0x39e2ee3f> : test = Type(boolean)
* [AST] [RequiredArgument] RequiredArgument(test) resolved!
...
@baroquebobcat
baroquebobcat / Hash.from_xml_using_Nokogiri.rb
Created January 12, 2012 22:56 — forked from dimus/Hash.from_xml using Nokogiri
Adding Hash.from_xml method using Nokogiri
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
#
# - fixes handling of <text> elements
# - prepends namespaces on keys where used including both elements & attributes
# - uses strings instead of symbols to prevent consumption of the symbol table
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Nokogiri::XML::Node
def namespaced_name