Skip to content

Instantly share code, notes, and snippets.

View Joseworks's full-sized avatar

Jose C Fernandez Joseworks

View GitHub Profile
@Joseworks
Joseworks / pg_stat_statements
Created May 11, 2017 20:45 — forked from troyk/pg_stat_statements
enable postgres pg_stat_statements
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020
2) add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
136 pg_stat_statements.max = 1000
137 pg_stat_statements.track = all
3) restart postgres
4) check it out in psql
@Joseworks
Joseworks / render_and_redirect.markdown
Created June 15, 2017 16:25 — forked from jcasimir/render_and_redirect.markdown
Render and Redirect in Rails 3

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action

@Joseworks
Joseworks / securing_rails_updates.md
Created August 1, 2017 16:24 — forked from peternixey/securing_rails_updates.md
How Homakov hacked GitHub and how to protect your application by Peter Nixey

##How Homakov hacked GitHub and the line of code that could have prevented it


Please note: THIS ARTICLE IS NOT WRITTEN BY THE GITHUB TEAM or in any way associated with them. It's simply hosted as a Gist because the markdown formatting is excellent and far clearer than anything I could manage on my personal Tumblr at peternixey.com.

If you'd like to follow me on twitter my handle is @peternixey


@Joseworks
Joseworks / rendering_helper.rb
Created August 10, 2017 15:11 — forked from tylerhunt/rendering_helper.rb
Override Rails' #render helper to fix an issue with rendering partials based on an object within a namespace.
module RenderingHelper
# Override Rails' #render helper to fix an issue with it not honoring objects
# with #to_partial_path definitions that return absolute paths, which is
# problematic when rendering partials within a namespaced controller.
def render(options={}, locals={}, &block)
return super unless options.respond_to?(:to_partial_path)
object = options
path = object.to_partial_path
@Joseworks
Joseworks / multiple_ssh_setting.md
Created October 17, 2017 02:13 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@Joseworks
Joseworks / user.rb
Created November 10, 2017 04:51 — forked from harlow/user.rb
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@Joseworks
Joseworks / OSX UTC Time Zone
Created November 14, 2017 17:23 — forked from nick-desteffen/OSX UTC Time Zone
Set Time zone in OSX to UTC
sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime
@Joseworks
Joseworks / 1.rb
Created December 29, 2017 17:20 — forked from stevegraham/1.rb
Symbol#to_proc
%w(john paul ringo george).map { |p| p.capitalize }
# => ["John", "Paul", "Ringo", "George"]
class Child extends React.Component {
render () {
return (<div>I'm the child</div>);
}
}
class ShowHide extends React.Component {
constructor () {
super ();
this.state = {
@Joseworks
Joseworks / ruby array #subtract
Created January 27, 2018 18:36 — forked from karatedog/ruby array #subtract
Ruby Array's subtract method which subtracts the values of the elements not the elements themselves
# Ruby Array's "-" (minus) method removes elements from the receiver which exist in the parameter Array
[5, 6, 1] - [2, 3, 5]
# => [6, 1]
# this #subtract method will subtract the value of the parameter Array from the value of the receiver Array, defined by the actual index.
# type mismatch, Nil, and different Array length are not handled
class Array