Skip to content

Instantly share code, notes, and snippets.

View lbalceda's full-sized avatar

Luis Balceda lbalceda

  • San Francisco, California
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lbalceda on github.
  • I am lbalceda (https://keybase.io/lbalceda) on keybase.
  • I have a public key ASDC_w0Xa9R-qzG42tK_ltGNKGUzfa5uRUStSQ6TO8mrtAo

To claim this, I am signing this object:

@lbalceda
lbalceda / gist:782e5fcd2beec296975d
Created December 9, 2015 23:09
dump sql table as insert statements
pg_dump --table=TABLE_NAME_HERE --data-only --column-inserts DATABASE_NAME_HERE > output.sql
@lbalceda
lbalceda / gist:e0e8e13da4011e696adf
Last active September 22, 2015 18:36
git delete merged branches
git branch --merged | grep -v '\*\|master\|develop\|alpha' | xargs -n 1 git branch -d
@lbalceda
lbalceda / gist:9d137f236cf044d8456a
Created August 19, 2014 04:24
jquery select matching text
$.expr[':'].textEquals = function(a, i, m) {
var match = $(a).text().match("^" + m[3] + "$")
return match && match.length > 0;
}
//usage:
$("a:textEquals('Click Me!')");
@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
@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 / 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 / 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: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: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