Skip to content

Instantly share code, notes, and snippets.

View equivalent's full-sized avatar
:octocat:
I'm IDDQD + IDKFA for Ruby on Rails

Tomas Valent equivalent

:octocat:
I'm IDDQD + IDKFA for Ruby on Rails
View GitHub Profile
@equivalent
equivalent / bootstrap_breadcrumbs_builder.rb
Last active August 29, 2015 13:58 — forked from riyad/bootstrap_breadcrumbs_builder.rb
breadcrumbs_on_rails for Bootstrap 3 override
# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
#
# Originally from https://gist.github.com/riyad/1933884/ modified for Bootstrap 3 and "Go to hell with separator, use Css Dumbass"
# policy
#
# You can use it with the :builder option on render_breadcrumbs:
# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder" %>
#
#
=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')
@equivalent
equivalent / 1_rebinding_module_method.rb
Last active August 29, 2015 14:26
Rebind module method example
# run me with ruby >= 2.0
module A
def x(arg)
"hi #{arg}"
end
end
module B
def x(arg)
@equivalent
equivalent / factories_inside_rails_console.rb
Created November 10, 2011 18:44
use factories inside rails console
require 'factory_girl'
require 'faker' #if needed
Dir[Rails.root.to_s + '/spec/factories/**/*.rb'].each {|file| require file }
@equivalent
equivalent / run_rails_app_tests.sh
Created November 11, 2011 12:20
This is a bash script that runs bundler, drop test database, recreates it, run migrations and runs specs and tests
#!/bin/sh
WORK_DIR=/Users/tomi/rails_apps/myapp/;
RETURN_DIR=/Users/tomi/my_bash_scripts/; #optional
if [ -r $WORK_DIR ]; then
cd $WORK_DIR
@equivalent
equivalent / haml
Created May 15, 2012 12:02 — forked from erich/haml
= form_for [@user, @task], :html => { :class => 'form-inline' } do |f|
-if @task.errors.any?
#error_explanation
%h2= "#{pluralize(@task.errors.count, "error")} prohibited this task from being saved:"
%ul
@equivalent
equivalent / simple_form.rb
Created June 21, 2012 14:16
Simple Form with Bootstrap....initiliazer
# place this file in config/initializers/simple_form.rb
#
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
config.wrappers :default, :class => :input,
@equivalent
equivalent / Gemfile
Created July 9, 2012 21:32
Script to rename files in folders (Sketchup animation render)
source 'https://rubygems.org'
gem 'bundler'
gem 'rb-readline'
@equivalent
equivalent / speedtest
Created July 16, 2012 12:09
ljust speed test
# just speed test for http://stackoverflow.com/questions/11502629/how-to-do-number-to-string-suffix/11502715#11502715
1.9.3p194 :019 > def shot
1.9.3p194 :020?> a=Time.now
1.9.3p194 :021?> 1000000.times do
1.9.3p194 :022 > "5".ljust(3, "0")
1.9.3p194 :023?> end
1.9.3p194 :024?> b =Time.now
@equivalent
equivalent / app-views-my_gem-foo.html.haml
Created July 30, 2012 15:26
simple_form input extensions in own gems
-#app/views/my_gem/foo.html.haml
= f.input :address_country_id_eq, :as => :country_search, label: 'Country'