create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
| 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 |
##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
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.
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.
| 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 |
| #!/usr/bin/env ruby | |
| # If you get "unknown OID 705: failed to recognize type of '<field>'. It will be treated as String." | |
| # it probably means that type of column could not be identified when retriving records | |
| # Example | |
| User.where("'something' as something") | |
| # Will results in unknown OID. However doing this: |
| After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work. | |
| The error was something like "database files are incompatible with server". | |
| Database files have to be updated before starting the server, here are the steps that had to be followed: | |
| # need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default | |
| brew unlink postgresql | |
| brew install postgresql95 | |
| brew unlink postgresql95 | |
| brew link postgresql |
A summary of the Rails Guides on Routes, plus other tips.
The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views.
Examples
# Redirects /orders/report to orders#report.
get 'orders/report', to: 'orders#report'| require "rubygems" | |
| require "rack" | |
| require "middleman/rack" | |
| require "rack/contrib/try_static" | |
| protected_middleman = Rack::Auth::Basic.new(Middleman.server) do |username, password| | |
| [username, password] == [ENV['HTTP_USERNAME'], ENV['HTTP_PASSWORD']] | |
| # Enable proper HEAD responses | |
| use Rack::Head |
| require 'rubygems' | |
| require 'middleman/rack' | |
| protected_middleman = Rack::Auth::Basic.new(Middleman.server) do |username, password| | |
| [username, password] == ['theuser', 'thepassword'] | |
| end | |
| run protected_middleman |