Skip to content

Instantly share code, notes, and snippets.

View esmevane's full-sized avatar

Joseph McCormick esmevane

View GitHub Profile
# Orig
def items options = Hash.new
products = true_category.descendant_products.available.visible
if options[:vendor]
products = products.by_vendor options[:vendor]
end
if options[:factor]
@esmevane
esmevane / example.html
Created May 17, 2012 15:06
Click warning example
<html>
<head>
<title>Checkbox Complete Demo</title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
</head>
<body>
<form action="#" class="no-submit">
<h1>Show/hide submit based on whether a checkbox is checked or not</h1>
<p>
<h2>The scenario</h2>
class Example.Views.Table extends Backbone.View
template: JST['example/table']
initialize: ->
_.bindAll @, 'addOne', 'addAll'
@collection.on 'add', @addOne
render: ->
@$el.html @template()
%a.toggle-advanced{ href: '#' }
%span +
%strong Click here for advanced options
@esmevane
esmevane / raskell.rb
Created August 15, 2012 14:15 — forked from andkerosine/raskell.rb
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
require 'rspec'
require_relative '../app/models/model_name'
describe ModelName do
it "passes a sanity test" do
model = ModelName.new
model.new_record?.should be_true
end
end
@esmevane
esmevane / gist:3761639
Created September 21, 2012 14:04
Ruby: Indented, with explicit namespacing
require 'rspec' as "Spec"
require 'nokogiri' as "Nok"
require 'open_uri' as "Open"
class Index
attr_reader :response
def initialize url
@response = Nok::HTML Open url
@esmevane
esmevane / gist:3762279
Created September 21, 2012 15:51
Ruby: Example test with VCR cassette declaration
describe "Test feature" do
context "an external API request continuity" do
use_vcr_cassette
it "tests one behavior related to a url"
it "tests another behavior related to the the same url"
end
end
@esmevane
esmevane / 01_.rspec
Created October 14, 2012 20:49
[Ruby / Rspec] A tiny rspec example
# Actual filename: .rspec
--format doc
--color
@esmevane
esmevane / fizz_buzz.hs
Created November 13, 2012 22:57
[Haskell] Fizz buzz
fb :: [Integer] -> [String]
fb list = [ fizzbuzz element | element <- list ]
where fizzbuzz x = fizz x ++ buzz x
where fizz x = if x `mod` 3 == 0 then "Fizz" else ""
buzz x = if x `mod` 5 == 0 then "Buzz" else ""