Skip to content

Instantly share code, notes, and snippets.

@AlexVKO
AlexVKO / config_generators.rb
Created December 6, 2015 20:16
rails config generators
config.generators do |g|
g.test_framework :rspec, fixture: true
g.fixture_replacement :factory_girl, dir: 'spec/factories'
g.view_specs false
g.helper_specs false
g.stylesheets = false
g.javascripts = false
g.helper = false
end
@AlexVKO
AlexVKO / Gemfile ok
Created December 6, 2015 19:42
sublime text test
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAgAElEQVR4Xky9a9DuaVbWd/2Pz+E97vPu3t09PYeeA8OMIIIjMXE0qBWrEmOSSmE8QEXj2ZRSIqnKB/PRT6aST5qyKhXLikQQGBCIiqCgQEAQgekZmO6Z7p7u3Xvvd7/7PT6H/zn1u9b97Jmu6Zru3e/7PP//fa97rWtd61rrzr5/00/FMKksC9WjNEyTsmHUeuq1l9caykz5OGnKM2VZpmwaNY6T+nFUnueassz/Td2oIs/VZ5OqItegSVKmfhqUZ5nGcVQ5ZRomvmOU8lxFlklFJn40lzT0k/+5zUZ1Xa+iLLVfFWqmTMU4aTvIz9Blk9SP/mf/Ov86DKpnlZ9tGCYNozTyH4pCfT+p4Af7Qc3Qazav1PC8WcEj+ud5lm6YlBWZ2rZTNuXKy8yfrSkXj5rlmcaB75s08b38/ChlRa4snzRN8bvlvFS3HTTlhUZJIy/FGgyD8rzUOIxe0zHn8QqN/SReve86r6n/jDVP38N7Dr3U9b2qqtZm6FUq93qOfv9MwzBqU06aZbn/OePdJOXT5M/K2aNRasdJZZ5rHPjOUZpGdYNUz0o1Ta9qKtVNo2q/cKZNNmqb516bkpcZpLEfvNcsQte2mpWVsqpQ344qM6nNJ2Vtr6KuvJ99H2s2Frn/P2dvMqnEpn50NU5DMSnvRtVFoUmZhmzQfMw1ZJP6MlMxhREOGTbF4kmN2LTCBsAC95qUt9I4K1Sy6NgYL1fmKoZRnfcg80K0bESGycWD8JAYgPe6n7wAzTSoKkvVY6ahSEa2DaNXxYaMGvMsjHsYVZQ5a4ldq+tGbxgv2IwcDGyPQ1QoL/hnnrbQNMSB82KyKLxe6TVW3/bKJwxB/h0/K0ZR5N6IsZTGdopDOY4a+CEMi3fg+dhoxfP1g7S1IYyqqtyfM7aDpqpQp1gfDJ6FGHko1jvPNLBoGP04aj4vtVlPNnSWjnccR3
@AlexVKO
AlexVKO / tmux.conf
Created November 26, 2015 22:36
Tmux conf
# set Ctrl-a as the default prefix key combination
# and unbind C-b to free it up
set -g prefix C-k
unbind C-b
#set-window-option -g mode-mouse on
# set window and pane index to 1 (0 by default)
set-option -g base-index 1
setw -g pane-base-index 1
@AlexVKO
AlexVKO / comment.rb
Created November 24, 2015 00:05
Post with commentable comments
class Comment < ActiveRecord::Base
belongs_to :commentable, polymorphic: true
has_many :comments, as: :commentable
end
@AlexVKO
AlexVKO / passwords_controller.rb
Created November 3, 2015 05:15
Allow devise to reset password signed in
class PasswordsController < Devise::PasswordsController
# here we need to skip the automatic authentication based on current session for the following two actions
# edit: shows the reset password form. need to skip, otherwise it will go directly to root
# update: updates the password, need to skip otherwise it won't even reset if already logged in
skip_before_filter :require_no_authentication, :only => [:edit, :update]
# we need to override the update, too.
# After a password is reset, all outstanding sessions are gone.
# When already logged in, sign_in is a no op, so the session will expire, too.
# The solution is to logout and then re-login which will make the session right.
@AlexVKO
AlexVKO / palestra-tdc2014-florianopolis
Created October 16, 2015 23:01 — forked from brunogh/palestra-tdc2014-florianopolis
Palestras TDC 2014 - Florianópolis
Palestras TDC 2014 - Florianópolis
Watir
Lucas Prim
http://www.slideshare.net/lucasprim/apresentacao-watir
RSpec Best Friends
Mauro George
http://pt.slideshare.net/maurogeorge/rspec-best-friends-34875731
[
//
// TABS (REGULAR)
//
// Tab set
{
"class": "tabset_control",
"layer0.texture": "",
@AlexVKO
AlexVKO / add_unaccent_to_postgres
Created September 19, 2015 19:48
Adding extensions to Postgresql database with Rails
The default Postgresql installation on Mac OS X using homebrew includes a single extension - plpgsql (PL/pgSQL procedural language) but there are a number of them available in the lib directory (/usr/local/Cellar/postgresql/9.2.1/lib on my machine)
To install an extension into the database, the easiest way I found was to open a database console using the 'rails db' command and then create it directly. I have seen mention of doing this in a Rails migration but this did not work for me.
Note that an extension is installed in a specific database, rather than being added to all databases.
The command to list the installed extensions is '\dx'
$ rails db
psql (9.2.1)
@AlexVKO
AlexVKO / gemfile.rb
Last active October 1, 2015 21:36
my most used Gems for Rails API
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'active_model_serializers' # Serialize json response
gem 'delayed_job_active_record' # Asynchronous priority queue system
gem 'figaro' # For setting environment variables
gem 'kaminari' # for pagination
gem 'newrelic_rpm' # Monitor
gem 'pg' # Posgrees Database