Skip to content

Instantly share code, notes, and snippets.

@tskogberg
tskogberg / application_mailer.rb
Created July 6, 2017 06:59
Add sendgrid headers
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 April 11, 2017 07:10
Heroku: Fix "SignalException: SIGHUP" errors
#!/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
# 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
" 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>
/* 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
'
" 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),
module Foo
def bar
end
end
class Baz
include Foo
def Kaz
end
# Ways to resolve hostname
Socket::getaddrinfo("2.1.1.2")
Resolv::getname("2.1.1.2")
class String
def hello
puts "hello from String"
end
end
class MyString < String
def hello
puts "hello from MyString"
end