Skip to content

Instantly share code, notes, and snippets.

View lbalceda's full-sized avatar

Luis Balceda lbalceda

  • San Francisco, California
View GitHub Profile
@lbalceda
lbalceda / gist:5384315
Created April 14, 2013 21:35
script to load / start firebug lite in browsers that don't have inspector
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js">
{
startOpened: true,
enableTrace: true
}
</script>
@lbalceda
lbalceda / gist:5406803
Last active December 16, 2015 08:38
modify owners of all tables or sequences in PostgreSQL
#tables
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" YOUR_DB` ; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done
#sequences
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" YOUR_DB` ; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done
@lbalceda
lbalceda / gist:5616034
Created May 20, 2013 22:15
rails 3 dot gitignore
# Developer
.env
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
# Ignore uploads
@lbalceda
lbalceda / gist:5681074
Last active January 27, 2017 19:30
rails 3 vs rails 4 unicorn logger configuration settings
# For Production you would probably want to default the Log Level to 'INFO' instead of 'DEBUG'.
# Rails 3
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(
ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG'
)
@lbalceda
lbalceda / gist:6136282
Last active February 14, 2018 19:20
Fix "unpermitted parameters" devise & rails 4 strong parameters issue
# Fix "unpermitted parameters" devise & rails 4 strong parameters issue
# registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
...
def sign_up_params
params.require(:user).permit(:email, :username, :whatever, :other, :params)
end
end
@lbalceda
lbalceda / gist:6167203
Last active December 20, 2015 17:18
Excel: Ignore " #N/A " output by combining IFERROR with VLOOKUP to map a missing / nonmatching value to 0 . Includes sheet name in VLOOKUP for cross sheet portability. Don't usually work with excel but my cousin asked me for 'excel help' #family
=IFERROR(VLOOKUP(F2,'Week 1 '!$R$1:$S$4,2,FALSE),0)+IFERROR(VLOOKUP(G2,'Week 1 '!$R$1:$S$4,2,FALSE),0)+IFERROR(VLOOKUP(H2,'Week 1 '!$R$1:$S$4,2,FALSE),0)+IFERROR(VLOOKUP(I2,'Week 1 '!$R$1:$S$4,2,FALSE),0)+IFERROR(VLOOKUP(J2,'Week 1 '!$R$1:$S$4,2,FALSE),0)
@lbalceda
lbalceda / gist:6219019
Created August 13, 2013 08:25
RVM: Fix for OpenSSL::SSL::SSLError " SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint "
# Rebuilds all RVM rubies with 'approved' version of open SSL.
# Taken from https://github.com/pivotal/pivotal_workstation/issues/221#issuecomment-14577443
rvm pkg install openssl; rvm reinstall all --with-open-ssl-dir=$rvm_path/usr --force
@lbalceda
lbalceda / gist:7308441
Created November 4, 2013 20:06
psql connection count on heroku
select count(*) from pg_stat_activity where pid <> pg_backend_pid() and usename = current_user;
@lbalceda
lbalceda / devise_trackable_override.rb
Created March 12, 2014 20:54
override Devise to not update trackable fields when switching from admin to a normal user (using switch_user ruby gem)
#include all in an override initializer
module Devise
module Models
module Trackable
alias_method :original_update_tracked_fields!, :update_tracked_fields!
def update_tracked_fields!(request)
original_update_tracked_fields!(request) unless request.env["devise.skip_trackable"]
@lbalceda
lbalceda / tinycarousel-infinite.modified.js
Last active August 29, 2015 14:04
tinycarousel 1.9 + infinite scrolling + .destroy()
/*jshint browser:true laxcomma:true */
/*
* Tiny Carousel 1.9
* http://www.baijs.nl/tinycarousel
*
* Copyright 2010, Maarten Baijs
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/gpl-2.0.php