Skip to content

Instantly share code, notes, and snippets.

@raarellano
raarellano / bash.rc
Created May 16, 2015 23:19
Comodo SSL concatenation order
cat STAR_yourdomain_ext.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > bundle.cer
@raarellano
raarellano / application_helper.rb
Created May 12, 2015 15:21
Fields inside a fields_for block
def sanitized_object_name(object_name)
object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
end
def sanitized_method_name(method_name)
method_name ||= @method_name.sub(/\?$/,"")
end
def form_tag_id(object_name, method_name)
"#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
@raarellano
raarellano / bash.rc
Last active December 3, 2015 20:18
PostgreSQL Backups
#Backup Database
sudo su - postgres
pg_dump postgres > postgres_db.bak
#Backup Remote System
pg_dump -h remote_host -p remote_port name_of_database > name_of_backup_file
#Restore Datadump
psql empty_database < backup_file
@raarellano
raarellano / form.html.haml
Created March 27, 2015 03:32
Rails form collection select with HTML options
=f.collection_select :category_id, Category.all, :id , :title, {prompt: "Select a Category"}, {class: "form-control"}
@raarellano
raarellano / gist:55b8858e2f743ff60b60
Created March 16, 2015 17:03
Update SSL Certificate - Heroku

Renewing an SSL Certificate

Renew through domain provider

The domain provider should offer a way to renew the certificate. Through DNSimple for example first click on the domain scroll to the SSL Certificates area and click the button to renew SSL Certificate. The domain provider will ask what email to send the validation email to. This are pre determined emails that usually the person who bought the certificate will setup. Choose a persons email (if not yours or the company’s) that you have contact with.

Validate Request

The SSL provider will send the email to the email you previously chose. This email usually takes a few minutes to deliver. If you are not the person it send the email to instruct the person to validate the request.

There will be clear instructions on the email of how to validate the request. Usually the SSL provider will provide a link with a “validation code”. Click the link to validate the request, copy the validation code, and and paste the validation code in the input provid

@raarellano
raarellano / bash
Created February 26, 2015 21:26
Migrate between Heroku Databases
heroku addons:add pgbackups --app production-app
heroku addons:add pgbackups --app staging-app
heroku pgbackups:capture --app production-app
heroku pgbackups --app production-app
heroku pgbackups:restore HEROKU_POSTGRESQL_EXAMPLE_URL `heroku pgbackups:url --app production-app` --app staging-app
@raarellano
raarellano / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@raarellano
raarellano / controller.rb
Created September 8, 2014 20:28
Export to Excel
def participants_export
@model_template = @survey.model_template
@categories = @model_template.categories.wout_overall
@sub_categories = @model_template.sub_categories
#Users + Scores
if params[:start_date] && params[:end_date]
@start_date_searched = params[:start_date].to_s
@start_date = Date.parse(@start_date_searched)
@raarellano
raarellano / batch
Created June 30, 2014 16:10
Pull remote branch
git fetch origin [remote-branch]:[new-local-branch]
@raarellano
raarellano / bash
Created April 1, 2014 16:19
Update all records with callbacks
User.find_each(&:save)