Skip to content

Instantly share code, notes, and snippets.

View Rodrigora's full-sized avatar
🏠
Working from home

Rodrigo R Aquino Rodrigora

🏠
Working from home
  • Dublin Ireland
View GitHub Profile
@Rodrigora
Rodrigora / git branch on prompt
Created June 4, 2013 16:11
git branch on prompt
parse_git_branch() {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
// jQuery Masked Input
$('#celular').mask("(99) 9999-9999?9").ready(function(event) {
var target, phone, element;
target = (event.currentTarget) ? event.currentTarget : event.srcElement;
phone = target.value.replace(/\D/g, '');
element = $(target);
element.unmask();
if(phone.length > 10) {
element.mask("(99) 99999-999?9");
} else {
@Rodrigora
Rodrigora / add-support-to-array-to-emberjs-models
Last active August 29, 2015 14:07
add support to array attributes to EmberJS models
DS.ArrayTransform = DS.Transform.extend
deserialize: (serialized)->
if Ember.typeOf(serialized) == "array"
serialized
else
[]
serialize: (deserialized)->
type = Ember.typeOf deserialized
if type is 'array'
@Rodrigora
Rodrigora / minitest_assertions.rb
Created February 11, 2015 21:08
All Minitest Assertions
def assert test, msg = nil
def assert_empty obj, msg = nil
def assert_equal exp, act, msg = nil
def assert_in_delta exp, act, delta = 0.001, msg = nil
def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
def assert_includes collection, obj, msg = nil
def assert_instance_of cls, obj, msg = nil
def assert_kind_of cls, obj, msg = nil
def assert_match matcher, obj, msg = nil
def assert_nil obj, msg = nil
@Rodrigora
Rodrigora / commands
Created March 17, 2015 00:38
find and replace text in files recursively
# find text in files
grep -r "Text To Search" /path/to/search
# replace text in files
find . -name show.html.erb -exec sed -i "s/Text To Search/Text To Replace/g" {} \;
@Rodrigora
Rodrigora / Gemfile
Last active September 9, 2015 17:14
Running ActiveRecord specs
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'bcrypt'
@Rodrigora
Rodrigora / config.fish
Last active September 14, 2015 14:48
Fish Shell config file with git branch and current RVM
set -g -x PATH /usr/local/bin $PATH
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
@Rodrigora
Rodrigora / request_macros.rb
Created September 19, 2015 21:50
Helper for requests specs with authenticity token
module RequestMacros
def login_user(user = nil)
user = create(:user, password: 'password') unless user
# ensure password is valid when `user` is provided
expect(user.valid_password?('password')).to be(true)
# ensure user is confirmed
user.confirm!
@Rodrigora
Rodrigora / replace-in-files.sh
Last active January 5, 2021 13:02
Replace string in files
# finds all files in app folder with .rb extension
# for each file
# capitalizes every "cr" strings preceded by a non-letter and followed by a capital letter
find app -name '*.rb' -exec sed -i '' -- "s/\([^a-zA-Z]\)[Cc][Rr]\([A-Z]\)/\1CR\2/g" {} +
# rename PGIntegrationError -> CRProviderError
find app -name '*.rb' -exec sed -i '' -- "s/PGIntegrationError\CRProviderError/g" {} +
find app spec config lib -name '*.rb' -exec sed -i '' -- "s/pg_integration_error\?\cr_provider_error\?/g" {} +
{
"bold_folder_labels": true,
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Ocean.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 21,
"highlight_line": true,
"ignored_packages":
[
"JavaScript",
"SublimeERB",