Skip to content

Instantly share code, notes, and snippets.

@Olgagr
Olgagr / get_content_of_email.rb
Created August 22, 2013 13:13
Get content of the mail
UserMailer.job_apply_reject(job_apply).deliver
expect(ActionMailer::Base.deliveries.last.encoded).to include 'Company Lorem ipsum'
@Olgagr
Olgagr / redirect_with_params
Created September 6, 2013 07:52
Redirect to eg. edit action with additional parameters
redirect_to action: :edit, id: @company.id, params: {tab: 'locations' }
@Olgagr
Olgagr / companies_controller_spec.rb
Created September 6, 2013 08:45
send nested attributes in controller tests
recruiters_attributes: {'1234567' => attributes_for(:recruiter)})
@Olgagr
Olgagr / bash_profile
Created November 2, 2013 07:01
Terminal: Create mate command to open Textmate
export EDITOR="mate -w"
@Olgagr
Olgagr / new_gist_file_0
Created December 7, 2013 12:58
Terminal: Set Sublime editor to open from terminal
Make symlink:
ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
And then open and edit .bash_profile:
export EDITOR='sublime -w'
@Olgagr
Olgagr / gist:4192bae863b9b6497e6f
Created September 28, 2014 06:08
Sinatra router implementation - not working
# This implementation causes error:
# ArgumentError: wrong number of arguments (0 for 1..3)
# config.ru:10:in `instance_eval'
# config.ru:10:in `initialize'
# config.ru:26:in `new'
# config.ru:26:in `block in inner_app'
# /Users/ograbek/.rvm/gems/ruby-2.1.2@owning_rails/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
# /Users/ograbek/.rvm/gems/ruby-2.1.2@owning_rails/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
module Heroku
module Rake
class Task
attr_accessor :name
def initialize(name)
@name = name
end
def self.[](name)
Heroku::Rake::Task.new(name)
@Olgagr
Olgagr / gulp_aws_deploy.js
Created October 28, 2014 11:38
Gupl aws deployment script
function deploy(env) {
var bucketSuffix = env === 'staging' ? '-staging' : '';
var publisher = $.awspublish.create({
key: 'xxxx',
secret: 'xxx',
bucket: 'picaly.co' + bucketSuffix,
region: 'eu-west-1'
});
return gulp.src('./dist/**/*')
@Olgagr
Olgagr / gulpfile.js
Last active July 5, 2017 10:39
watchify
var customOpts = {
entries: [config.jsES6MainFile],
debug: true,
transform: ['babelify']
};
var opts = _.assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));
gulp.task('scripts', bundle);
b.on('update', bundle);
@Olgagr
Olgagr / react_authorization.js
Created November 7, 2015 13:37
react authorization
requireAuth: function(nextState, replaceState) {
if (!AuthStore.isAuthenticated()) {
replaceState({ nextPathname: nextState.location.pathname }, '/');
}
},
render: function() {
return (
<Layout>
<Router history={history}>