Skip to content

Instantly share code, notes, and snippets.

@jg
jg / example.rb
Created July 21, 2011 13:17
VCR issue attached files
require 'vcr'
require 'mechanize'
VCR.config do |c|
c.cassette_library_dir = 'cassettes'
c.stub_with :webmock
c.default_cassette_options = { :record => :new_episodes }
end
@jg
jg / example.rb
Created August 31, 2011 13:56
VCR issue (2)
require 'vcr'
require 'mechanize'
VCR.config do |c|
c.cassette_library_dir = 'cassettes'
c.stub_with :webmock
c.default_cassette_options = { :record => :new_episodes }
end
@jg
jg / Gemfile
Created August 31, 2011 14:20
VCR issue (3)
source 'http://rubygems.org'
gem "vcr", '~> 1.11.2'
gem 'mechanize', '~> 2.0.1'
@jg
jg / gist:1234449
Created September 22, 2011 09:59 — forked from JosephPecoraro/shell-execution.rb
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@jg
jg / .ctags
Created November 18, 2012 10:41 — forked from anonymous/.ctags
Scala ctags conf, Vim tagbar integration
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,classes/
--regex-Scala=/^[ \t]*object[ \t]*([a-zA-Z0-9_]+)/\1/o,objects/
--regex-Scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/\1/t,traits/
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/r,cclasses/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/a,aclasses/
--regex-Scala=/^[ \t]*def[ \t]*([a-zA-Z0-9_=]+)[ \t]*.*[:=]/\1/m,methods/
--regex-Scala=/[ \t]*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/V,values/
--regex-Scala=/[ \t]*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\1/v,variables/
@jg
jg / gist:4207915
Created December 4, 2012 19:43 — forked from dwins/gist:4207894
def fetch[R : Fetchable](s: SQLCursor): R = implicitly[Fetchable[R]].fetch(s)
trait Fetchable[R] {
def fetch(s: SQLCursor): R
}
implicit object IntIsFetchable extends Fetchable[Int] {
def fetch(s: SQLCursor): Int = s.getInt
}
@jg
jg / typeclass.scala
Created December 8, 2012 09:42
Typeclass Pattern
/** Notes from Seth Tisue 2012 NE Scala Symposium presentation
* Problem: decoupling, generic code that works for many types and is easily extensible
* Serialization example below
*/
case class Person(name: String, age: Int)
case class Restaurant(name: String, branch: Boolean)
/**
* 1. overloading
@jg
jg / gist:4307503
Created December 16, 2012 13:55
Lisp macro wizardry
(defmacro diff(expr var)
; (pprint "diff")
; (pprint expr)
; (pprint var)
;(pprint (first expr))
;(pprint (second expr))
;(pprint (third expr))
(cond
; a' = 0
((numberp expr) 0)
@jg
jg / build.sbt
Created March 10, 2013 08:01 — forked from Swind/build.sbt
// Set the project name to the string 'My Project'
name := "SBTProject"
// The := method used in Name and Version is one of two fundamental methods.
// The other method is <<=
// All other initialization methods are implemented in terms of these.
version := "1.0"
//Add Repository Path
resolvers += "db4o-repo" at "http://source.db4o.com/maven"
abstract class TaskListRestriction
case class TaskList(name: String) extends TaskListRestriction {
override def toString = name
}
case class TaskListFilter extends TaskListRestriction
case object FilterToday extends TaskListFilter {
override def toString = "Today"