Skip to content

Instantly share code, notes, and snippets.

View application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: "Example.com <support@example.com>"
def process(name, *args)
set_headers_for_sendgrid(name, args)
super
end
private
@tskogberg
tskogberg / rails
Created Apr 11, 2017
Heroku: Fix "SignalException: SIGHUP" errors
View rails
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../../config/application", __FILE__)
require_relative "../config/boot"
# Make a clean exit on Heroku while running a rails console.
# Without this we'll get a "SignalException: SIGHUP" error in honeybadger.
if ENV["DYNO"]
if ["c", "console"].include?(ARGV.first)
Signal.trap("SIGHUP") { exit 0 }
end
View tmux.conf
# personal settings for tmux
#
# changed bindings
# vim movments keys for tmux (hjkl)
set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
View gist:9da180e56f2d16a8f42e
" Open public I18n translation files
nmap <leader>pu :tabe <BAR> :args config/locales/{en,sv,de}.yml <BAR> vertical all<CR>
" Open admin I18n translation files
nmap <leader>ad :tabe <BAR> :args config/locales/admin.{en,sv,de}.yml <BAR> vertical all<CR>
View gist:9556897
/* Make a trigger to count rows in a table */
CREATE TABLE rowcount (
table_name text NOT NULL,
total_rows bigint,
PRIMARY KEY (table_name));
CREATE OR REPLACE FUNCTION count_rows()
RETURNS TRIGGER AS
'
View ruby_walk.md
View promote_to_let.vim
" Promote variable to RSpec let.
" Based on
" https://github.com/myronmarston/vim_files/commit/ed60919f1857359da617491a7d7c14e8d4befae0
"
" Given either of
"
" foo = x
" @foo = x
"
" on the current line or in a given range (e.g. visual range),
View gist:4586376
module Foo
def bar
end
end
class Baz
include Foo
def Kaz
end
View gist:4276499
# Ways to resolve hostname
Socket::getaddrinfo("2.1.1.2")
Resolv::getname("2.1.1.2")
View extend.rb
class String
def hello
puts "hello from String"
end
end
class MyString < String
def hello
puts "hello from MyString"
end