Skip to content

Instantly share code, notes, and snippets.

@sadjow
sadjow / paperclip_support.rb
Last active August 29, 2015 14:26
Avoid paperclip to process the images in tests.
# Avoid paperclip to process the images in tests.
module Paperclip
class << self
alias_method :old_run, :run
def run cmd, params = "", expected_outcodes = 0
case cmd
when "identify"
return old_run(cmd, params, expected_outcodes)
@sadjow
sadjow / .bashrc
Created July 13, 2015 17:00
Make tmux works with vim on ubuntu
export TERM="screen-256color"
alias tmux="TERM=screen-256color tmux -2"
# Generates SQL from migrations
#
# Usage:
# rake db:[migrate,rollback]:with_sql
#
# The previous rake task will run migrations and create a file in `db/migrate_sql`
# Depending on migrate or rollback a file will be created with the respective
# sufix.
#
# Drawbacks:
@sadjow
sadjow / makesure.example.coffee
Last active August 29, 2015 14:08
A simple example of makesure using CoffeeScript
validateUser = makesure ->
@permit "name email" # optional
@attrs("name email").isNot('empty').orSay "can't be empty"
userInput =
name: ""
description: "My description"
admin: true
@sadjow
sadjow / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../google-map/google-map-directions.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@sadjow
sadjow / .vimrc
Created August 26, 2014 20:29
Make vim on gnome terminal use 256 colors better
" Add this to the end of vimrc
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
# https://37signals.com/svn/posts/2742-the-road-to-faster-tests
# spec/support/performance/deferred_garbage_collection.rb
class DeferredGarbageCollection
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f
@@last_gc_run = Time.now
def self.start

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@sadjow
sadjow / slugable.rb
Created September 18, 2013 17:14 — forked from brennovich/slugable.rb
# app/models/concerns/slugable.rb
module Slugable
extend ActiveSupport::Concern
included do
validates_format_of :slug, :without => /^\d/
before_save :generate_slug
end
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# you need an updated simple_form gem for this to work, I'm referring to the git repo in my Gemfile
config.input_class = "form-control"
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.use :input