Skip to content

Instantly share code, notes, and snippets.

View inem's full-sized avatar
🌰
In progress

Ivan Nemytchenko inem

🌰
In progress
View GitHub Profile
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'active_support'
require 'haml'
require 'thin'
gem 'tmm1-amqp'
require 'mq'
@gus
gus / index.txt
Created November 30, 2009 21:55 — forked from toothrot/index.txt
Ruby/Clojure analogs
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:
require 'rubygems'
require 'haml'
require 'effigy'
require 'effigy/core_ext/hash'
template = Haml::Engine.new(%{%html
%head
%title
%body
%h1
# Basic text search with relevancy for MongoDB.
# See http://blog.tty.nl/2010/02/08/simple-ranked-text-search-for-mongodb/
# Copythingie 2010 - Ward Bekker - ward@tty.nl
#create (or empty) a docs collection
doc_col = MongoMapper.connection.db('example_db').collection('docs')
doc_col.remove({})
#add some sample data
doc_col.insert({ "txt" => "it is what it is"})
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
require 'rubygems'
puts ENV["GEM_HOME"]
require 'mongoid'
require 'mongoid/version'
puts "Using Mongoid: #{Mongoid::VERSION}"
Mongoid.master = Mongo::Connection.new.db("mongoid_playground")
class Animal
@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@kossnocorp
kossnocorp / Gemfile
Created November 23, 2010 15:17
config/application.rb
...
group :development do
...
gem 'rails3-generators'
gem 'haml-rails'
...
end
...
@netzpirat
netzpirat / string_call.coffee
Created November 29, 2010 21:23
String.call and Namespaces in CoffeeScript tested with JasmineBDD
#
# Calls a function that is defined as a String
#
# 'ws.extranett.subdomain_for'.call('argument1', 'argument2')
#
# Will call the function subdomain_for bound on the object extranett
# with arguments 'argument1' and 'argument2'
#
String::call = (args...) ->