This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Gem::Specification.new do |s| | |
| s.name = 'bang' | |
| s.version = '0.1.0' | |
| s.platform = Gem::Platform::RUBY | |
| s.author = 'Jeff Kreeftmeijer' | |
| s.email = '[email protected]' | |
| s.summary = 'Bang!' | |
| s.description = 'Bangs existing model methods' | |
| s.files = ['bang.rb'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // includes bindings for fetching/fetched | |
| var PaginatedCollection = Backbone.Collection.extend({ | |
| initialize: function() { | |
| _.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage'); | |
| typeof(options) != 'undefined' || (options = {}); | |
| this.page = 1; | |
| typeof(this.perPage) != 'undefined' || (this.perPage = 10); | |
| }, | |
| fetch: function(options) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def screen_shot_and_save_page | |
| require 'capybara/util/save_and_open_page' | |
| path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}" | |
| Capybara.save_page body, "#{path}.html" | |
| page.driver.render Rails.root.join "#{Capybara.save_and_open_page_path}" "#{path}.png" | |
| end | |
| begin | |
| After do |scenario| | |
| screen_shot_and_save_page if scenario.failed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Do you ever define #method_missing and forget #respond_to? I sure | |
| # do. It would be nice if we could do them both at the same time. | |
| module MatchMethodMacros | |
| def match_method(matcher, &method_body) | |
| mod = Module.new do | |
| define_method(:method_missing) do |method_name, *args| | |
| if matcher === method_name.to_s | |
| instance_exec(method_name, *args, &method_body) | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mongoose = require('mongoose') | |
| , Schema = mongoose.Schema | |
| , db = mongoose.connect('localhost', 'testing_streaming').connection | |
| , Stream = require('stream').Stream | |
| , express = require('express') | |
| /** | |
| * Dummy schema. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* sample aggregate command queries */ | |
| // make sure we're using the right db; this is the same as "use mydb;" in shell | |
| db = db.getSisterDB("aggdb"); | |
| // just passing through fields | |
| var p1 = db.runCommand( | |
| { aggregate : "article", pipeline : [ | |
| { $project : { | |
| tags : 1, | |
| pageViews : 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # define module behavior | |
| class Module | |
| keywords = ['extended', 'included', 'initialize'] | |
| @extend = (obj) -> | |
| for key, value of obj when key not in keywords | |
| @[key] = value | |
| obj.extended?.apply(@) | |
| this | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'formula' | |
| class Vim < Formula | |
| homepage 'http://www.vim.org/' | |
| url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2' | |
| head 'https://vim.googlecode.com/hg/' | |
| sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d' | |
| version '7.3.294' | |
| def features; %w(tiny small normal big huge) end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| moduleKeywords = ['included', 'extended', 'prototype'] | |
| class Class | |
| # Rename an instance method | |
| # | |
| # ``` coffeescript | |
| # class User | |
| # @alias "methods", "instance_methods" | |
| # | |
| # ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
| describe 'Modal' do | |
| should 'display login errors' do | |
| visit root_path | |
| click_link 'My HomeMarks' | |
| within '#login_area' do | |
| fill_in 'email', with: '[email protected]' | |
| fill_in 'password', with: 'test' |