Skip to content

Instantly share code, notes, and snippets.

@dysinger
dysinger / docker-ruby-fpm.sh
Last active August 29, 2015 13:56
Stop using rbenv & rvm on servers. plz. kthnx.
cat > Dockerfile <<\EOF
FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y ruby1.9.3 build-essential \
libc6-dev libffi-dev libgdbm-dev libncurses5-dev \
libreadline-dev libssl-dev libyaml-dev zlib1g-dev
RUN gem install fpm --bindir=/usr/bin --no-rdoc --no-ri
RUN apt-get install -y curl
RUN curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p484.tar.gz|tar oxzC /tmp
WORKDIR /tmp/ruby-1.9.3-p484
@hkorte
hkorte / elasticsearch-missing-geo-value.sh
Created April 2, 2014 15:13
A change in geo_point parsing in Elasticsearch 1.1.0 leads to a different treatment of input documents without a valid geo_point. My application produced JSON documents containing "location:{}", which is not accepted as a missing value anymore. So in case you also see Exceptions like "MapperParsingException[failed to parse]; nested: Elasticsearc…
curl -XDELETE 'http://localhost:9200/testindex?pretty=true'
curl -XPOST 'http://localhost:9200/testindex?pretty=true' -d '
{
"mappings": {
"testdoc": {
"properties": {
"name": {
"type": "string"
},
"location": {
@jzajpt
jzajpt / haml2erb
Created March 11, 2009 07:59
Simple & stupid HAML to ERB convertor...
#!/usr/bin/env ruby
#
# haml2erb
require 'rubygems'
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
@madhums
madhums / omniauth.rb
Created November 15, 2010 10:49
OmniAuth configuration for rails 2.3.x
#config/initializers/omniauth.rb
require 'openid/store/filesystem'
ActionController::Dispatcher.middleware.use OmniAuth::Builder do #if you are using rails 2.3.x
#Rails.application.config.middleware.use OmniAuth::Builder do #comment out the above line and use this if you are using rails 3
provider :twitter, 'key', 'secret'
provider :facebook, 'app_id', 'secret'
provider :linked_in, 'key', 'secret'
provider :open_id, OpenID::Store::Filesystem.new('/tmp')
end
@porras
porras / why_steak.md
Created January 8, 2011 14:48
Why Steak (over Cucumber)

Why Steak (over Cucumber)

From here

  • Plain text have no value if people writing and reading the specs are developers. Code is natural language for developers (specially if that code is Ruby). Having a client who reads the specs is a possible situation and Cucumber is cool there, but in my experience that situation is not the most common one. If in your case there's no value in having your specs in English rather than in Ruby, Cucumber is an additional layer of abstraction in exchange of nothing.

  • There's a myth about clients writing the specs. It sounds like a unicorn to me, but let's take it. Still, I wouldn't want it. Clients are experts in problems, I am expert in solutions. I want the client to describe the problem I have to solve, not to describe the solution.

  • Some people say Cucumber is cool because you write the stories, the client validates them, and then you can start developing. That is not Agile. The on

@hron84
hron84 / haml2erb
Created March 6, 2011 23:42 — forked from jzajpt/haml2erb
haml2erb
#!/usr/bin/ruby
require 'rubygems'
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, opts = {} )
push_text "<%= #{text.strip} %>"
end
@leshill
leshill / gist:870866
Created March 15, 2011 15:17
Cucumber/Capybara JS alert handling
# Add this to more_web_steps.rb
# Selenium docs: http://code.google.com/p/selenium/wiki/RubyBindings#Javascript_Alert/Confirm today!
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text|
alert = page.driver.browser.switch_to.alert
alert.text.should eq(text)
alert.send(action)
end
@sstephenson
sstephenson / config.ru
Created April 8, 2011 04:46
Rackup file for Rails 2.3 apps
require File.dirname(__FILE__) + '/config/environment'
run ActionController::Dispatcher.new