Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
bogdanRada / Quickly dump ActiveRecord to CSV (Ruby 1.rb
Created December 14, 2012 16:02
Quickly dump ActiveRecord to CSV (Ruby 1.9)
def dump_model(klass)
File.open("#{klass.to_s.underscore.pluralize}.csv", 'w+') do |f|
columns = klass.columns.collect(&:name)
output = CSV.generate do |csv|
csv << columns.map { |column| klass.human_attribute_name(column) }
klass.all.each do |item|
csv << columns.collect { |column| item.send(column) }
end
end
f.puts output

RSpec Around All

Provides around(:all) hooks for RSpec.

Usage

In your Gemfile:

gem 'rspec_around_all', git: 'git://gist.github.com/2005175.git'

About Git Flow

Git Flow is an extension to Git that provides extra functionality and simple commands that force you into a structured and proper branching model. Git Flow is not required and in fact all commands ran by Git Flow can be done using standard Git commands. Git Flow just makes everything easier. Git Flow only needs to be installed on the developer's machine (or wherever development happens) and not on any production server.

Installing on Windows

Git Flow can be installed alongside TortoiseGit without issue, but there are some steps needed.

  1. Download/Install msysGit
  2. Download this file: bin.zip
@bogdanRada
bogdanRada / RubyMine_and_rvm_gemset_detection.sh
Last active December 6, 2022 04:31
RubyMine and rvm gemset detection
#!/usr/bin/env bash
#Put this in .bashrc file
# i am using in the project's folder a file named .config-rvm which contains on each line the branches that
# we want for to have different gemsets.
#The branches that are not in the fle will usee the project's gemset.
# If you don't need this functionality you will not need to create the file .
#Please be careful that the branch name is escaped and only small letters and numbers are allowed.
#So if you have a branch like

Create an .htaccess file in the webroot:

AuthUserFile /app/www/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user

Create a .htpasswd file:

htpasswd -c /app/www/.htpasswd [username]

## Get FFMpeg working on heroku by building binaries using vulcan
gem install vulcan
vulcan create foo
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
require "timeout"
module WaitSteps
extend RSpec::Matchers::DSL
matcher :become_true do
match do |block|
begin
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = block.call
module Retriable
# This will catch any exception and retry twice (three tries total):
# with_retries { ... }
#
# This will catch any exception and retry four times (five tries total):
# with_retries(:limit => 5) { ... }
#
# This will catch a specific exception and retry once (two tries total):
# with_retries(Some::Error, :limit => 2) { ... }
#
<script>
// Charles Lawrence - Feb 16, 2012. Free to use and modify. Please attribute back to @geuis if you find this useful
// Twitter Bootstrap Typeahead doesn't support remote data querying. This is an expected feature in the future. In the meantime, others have submitted patches to the core bootstrap component that allow it.
// The following will allow remote autocompletes *without* modifying any officially released core code.
// If others find ways to improve this, please share.
var autocomplete = $('#searchinput').typeahead()
.on('keyup', function(ev){
ev.stopPropagation();
def test_autocomplete(field, options = {})
fill_in field, :with => options[:with]
page.execute_script("$('##{field}').trigger('focus');")
page.execute_script ("$('##{field}').trigger('keydown');")
selector = "span.tt-dropdown-menu div.tt-suggestion:contains('#{options[:select]}')"
page.should have_selector selector
page.execute_script("$(\"#{selector}\").mouseenter().click()")
page.should have_field(field, :with => options[:select])