Skip to content

Instantly share code, notes, and snippets.

View jcieslar's full-sized avatar

Jakub Cieślar jcieslar

View GitHub Profile
@jcieslar
jcieslar / Rails cheatsheet.md
Created September 15, 2015 13:50
Rails cheatsheet
gem install bundler # install bundler for bundle command

rails s # run rails server
rails c # run rails console - access to database tables

bundle # install gems dependencies

rake db:setup # run db:create, db:schema:load, db:seed
rake db:create # create database
@jcieslar
jcieslar / Gemfile
Last active August 29, 2015 14:23
Angular i18n locale currency pain and how to setup with rails
gem 'rails-assets-angular-i18n', '~> 1.4.1'
@jcieslar
jcieslar / mailer.rb
Created June 16, 2015 12:00
custom locales only for part of app - I18n.with_locale
def send_email
# I18n.locale => :en
I18n.with_locale(:pl) do
# I18n.locale => :pl
end
# I18n.locale => :en
end
@jcieslar
jcieslar / en.yml
Created June 15, 2015 11:28
translations
en:
dashboard:
earnings:
name: Name
value: Current value
$scope.foo = { a: [1, 2, 3] }
console.log "foo", $scope.foo
# foo Object {a: Array[3]}a: Array[3]0: 22 1: 33 2: 44 length: 3__proto__: Array[0]__proto__: Object
console.log "foo.a", $scope.foo.a
# article_ctrl.js?body=1:23 foo.a [1, 2, 3]
angular.extend($scope.foo, { a: [22, 33, 44] })
################################################
foo = { a: [1, 2, 3] }
console.log "foo", foo
@jcieslar
jcieslar / selectize_spec.rb
Created March 19, 2015 16:33
Capybara and selectize
page.execute_script("$('.selectize-input input').val('ber')")
sleep 0.5
page.execute_script("$('.selectize-input input').keyup()")
sleep 0.5
page.execute_script("$('.full-name').mousedown()")
# https://github.com/brianreavis/selectize.js/blob/master/src/selectize.js
@jcieslar
jcieslar / sonic_pi.md
Last active November 14, 2015 22:43
Sonic Pi setup for Ubuntu 14.04

Ubuntu setup for Sonic Pi

Install dependencies

sudo apt-get -y --force-yes install supercollider ruby1.9.3 libqscintilla2-l10n libqscintilla2-dev qt4-dev-tools cmake libffi-dev qt4-qmake libqt4-dev

Clone repo

git clone [email protected]:samaaron/sonic-pi.git

Server extensions

@jcieslar
jcieslar / capybara_spec.rb
Created March 11, 2015 14:48
Capybara click link with target _blank
click_link 'User'
within_window(page.driver.browser.window_handles.last) do
expect(page).to have_content 'USERNAME'
end
@jcieslar
jcieslar / form.slim
Created February 27, 2015 14:03
Simple form input 'as: integer' brake rails numericality validations
/* wrong */
= f.input :twitter_followers, as: :integer
/* correct */
= f.input :twitter_followers
@jcieslar
jcieslar / geocoder.rb
Created January 16, 2015 11:41
Geocoder free ip info - working provider
# config/initializers/geocoder.rb
Geocoder.configure(
:timeout => 5,
:ip_lookup => :telize
)