Skip to content

Instantly share code, notes, and snippets.

View simonoff's full-sized avatar
💭
KUBER!!!!

Oleksandr Simonov simonoff

💭
KUBER!!!!
View GitHub Profile
@simonoff
simonoff / rspec-syntax-cheat-sheet.rb
Created October 24, 2011 11:08 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@simonoff
simonoff / workers.rake
Created November 30, 2011 15:39 — forked from karmi/workers.rake
Rake taks to launch multiple Resque workers in development/production with simple management included
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
@simonoff
simonoff / 1_README.md
Created December 13, 2011 12:33 — forked from josevalim/1_README.md
FSSM based FileWatcher for Rails

Rails 3.2 ships with a simple FileWatcher that only reloads your app if any of the files changed.

Besides, it also provides a mechanism to hook up your own file watcher mechanism, so we can use tools like FSSM that hooks into Mac OS X fsevents and does the hard work for us. This is an example on how to hook your own mechanism (you need Rails master, soon to be Rails 3.2):

  1. Copy the 2_file_watcher.rb file below to lib/file_watcher.rb

  2. Add the following inside your Application in config/application.rb

@simonoff
simonoff / update_textmate_bundles.sh
Created February 20, 2012 21:44 — forked from dmnkhhn/update_textmate_bundles.sh
Update Textmate bundles
#!/bin/sh
#
# Update Textmate bundles
# Standard OS X Textmate bundle Verzeichnis
TEXTMATE_BUNDLES="$HOME/Library/Application Support/Textmate/Bundles"
# … ins Verzeichnis wechseln
echo "\n*** Wechsle ins Textmate bundle Verzeichnis..."
@simonoff
simonoff / application.coffee
Created March 5, 2012 18:10 — forked from danhigham/application.coffee
CoffeeScript and Handlebars
window.template_manager = new TemplateManager()
configuration = {}
template_manager.load_template "tabs", "/templates/_tabitems.handlebars", ->
markup = template_manager.transform "tabs", configuration
@simonoff
simonoff / gist:2103390
Created March 19, 2012 08:42 — forked from travis/gist:1084767
testing facebook connect with capybara and rspec
require 'mogli'
module FacebookIntegrationHelpers
shared_context "with unconnected facebook user" do
let(:fb_user) { create_test_user(installed: false) }
after { fb_user.destroy }
end
def app_client
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id)
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
@simonoff
simonoff / mock_tire.rb
Created June 12, 2012 11:50 — forked from dvdplm/mock_tire.rb
Mocking helper to stop Tire from submitting searches to Elasticsearch
module Tire
module Disable
module ClassMethods
def mock_es_response_doc
@mock_es_response_doc ||=
'{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 0,"max_score": null,"hits": []}}'
end
def enable! &blk
old_enabled = @tire_enabled || false
@simonoff
simonoff / es.sh
Created June 13, 2012 20:09
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.4.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@simonoff
simonoff / paginated_collection.js
Created June 15, 2012 15:59 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// 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) {