Skip to content

Instantly share code, notes, and snippets.

@evaldasg
evaldasg / ar_migrator.rb
Created May 23, 2016 11:12
Rails Migrations stuff.
>> ActiveRecord::Migrator.current_version # prints current DB version
>> ActiveRecord::SchemaMigration.create!(version: '20160606111111') # add DB version
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew cask install google-chrome
brew cask install skype
brew install zsh
brew install tmux
brew install wget
brew install vim --override-system-vi
brew install node --with-debug --with-openssl
brew install rbenv ruby-build
@evaldasg
evaldasg / readme.md
Created June 14, 2016 14:27 — forked from maxivak/readme.md
Send email to multiple recipients in Rails with ActionMailer

Send email to multiple recipients

Send multiple emails to different recipients.

Mailer class

# app/mailers/notify_mailer.rb

class NotifyMailer < ApplicationMailer
@evaldasg
evaldasg / .profile
Created June 16, 2016 07:42 — forked from sindresorhus/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@evaldasg
evaldasg / Gemfile
Created July 1, 2016 15:50 — forked from petems/Gemfile
An example http download with Progress Bar output in the command line with Ruby and the native `net/http` library...
source "https://rubygems.org"
gem "progressbar"
from: https://www.johnhawthorn.com/2012/09/vi-escape-delays/
Eliminating delays on ESC in vim and zsh
While having a vim discussion on twitter with @_jaredn, I remembered that having a delay in entering normal mode after pressing ESC (switching to normal mode) really frustrates me. This delay exists because many keys (arrows keys, ALT) rely on it as an escape character. Here’s the setup I’ve used for a while for near instantaneous switch into normal mode.
vim
A simple solution for vim is to :set esckeys. However, this will break any sequences using escape in insert mode.
@evaldasg
evaldasg / 256_colors.rb
Last active July 9, 2016 12:18
Print out to the console terminal's 256 width colors.
#!/usr/bin/env ruby
# This prints to the console 256 colors for foreground & background
%w(38 48).each do |fgbg| # Foreground/Background
(0..256).each do |color|
print "\e[#{fgbg};5;#{color}m" + " #{color}".ljust(8, ' ') + "\e[0m"
print "\n" if (color + 1) % 10 == 0
end
print "\n\n"
end

IO Open Mode

Ruby allows the following open modes:

"r"  Read-only, starts at beginning of file  (default mode).

"r+" Read-write, starts at beginning of file.

"w"  Write-only, truncates existing file
@evaldasg
evaldasg / .railsrc
Created July 20, 2016 05:05 — forked from janlelis/.railsrc
13 Rails-specific hints for your rails 3 console.
# .railsrc for Rails 3, encoding: utf-8
# see http://rbjl.net/49-railsrc-rails-console-snippets
if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else
# # #
def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end
# # #
# loggers
@evaldasg
evaldasg / pg_locations.sh
Created July 27, 2016 05:46
get file locations for postgresql
select name,setting,category,source from pg_settings where category IN( 'Reporting and Logging / Where to Log', 'File Locations' ) order by category,name;