Skip to content

Instantly share code, notes, and snippets.

View bjensen's full-sized avatar

Brian Jensen bjensen

View GitHub Profile
@bjensen
bjensen / how-to-copy-aws-rds-to-local.md
Last active March 10, 2021 12:08 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.

https://computingforgeeks.com/install-postgresql-12-on-ubuntu/

sudo apt update
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt -y install postgresql-client-12
@bjensen
bjensen / user.rb
Created August 3, 2013 18:25 — forked from moeffju/user.rb
class User < ActiveRecord::Base
alias :devise_valid_password? :valid_password?
def valid_password?(password)
begin
devise_valid_password?(password)
rescue BCrypt::Errors::InvalidHash
return false unless Digest::SHA1.hexdigest(password) == encrypted_password
logger.info "User #{email} is using the old password hashing method, updating attribute."
self.password = password
@bjensen
bjensen / 0-readme.md
Created December 11, 2012 12:57 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@bjensen
bjensen / gist:4114045
Created November 19, 2012 21:22 — forked from rud/gist:4045605
class ToggleLogging
def self.setup
Signal.trap('USR1') do
toggle
end
end
def self.toggle
level_before = Rails.logger.level == Logger::DEBUG
Rails.logger.level = debug_before ? Logger::INFO : Logger::DEBUG
@bjensen
bjensen / gist:3049038
Created July 4, 2012 19:14 — forked from timothyekl/gist:1217887
Cross-platform: recompile LaTeX documents using Ruby, Guard
# Tested with Ruby 1.9
# Needs gem "guard" (https://github.com/guard/guard)
# Needs gem "guard-shell" (https://github.com/guard/guard-shell)
# Uses process "growlnotify" (http://growl.info/extras.php)
# Uses process "pdflatex" from standard TeXLive distribution
guard 'shell' do
watch(%r{(.+)\.tex}) do |m|
`growlnotify -m #{m[0]} Recompiling`
`pdflatex -interaction=batchmode #{m[0]} >/dev/null`
@bjensen
bjensen / bootstrap_breadcrumbs_builder.rb
Created April 16, 2012 17:51
How to make breadcrumbs_on_rails render a Bootstrap compatible breadcrumb navigation
# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
#
# BootstrapBreadcrumbsBuilder accepts a limited set of options:
# * separator: what should be displayed as a separator between elements
#
# You can use it with the :builder option on render_breadcrumbs:
# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
#
# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
@bjensen
bjensen / hack.sh
Created March 31, 2012 11:09 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
#Keeps a list of registered names associated with classes at a "base" class
#Example:
#
# class Base
# extend Registerable
# end
#
# class Foo < Base
# register :foo
# end
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/