most of these require logout/restart to take effect
# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# Set a shorter Delay until key repeat| sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime |
| # This file should be placed on the directory of ~/blog/config | |
| upstream unicorn { | |
| server unix:/tmp/unicorn.todo.socket fail_timeout=0; | |
| } | |
| server { | |
| listen 80 default; | |
| #server_name example.com; | |
| root /home/username/blog/public; |
| # Usage: | |
| # In your (Application)Controller: | |
| # include Concerns::ForceNonSSL | |
| # force_non_ssl | |
| # | |
| # You can use the same options as with force_ssl. | |
| # See: http://api.rubyonrails.org/classes/ActionController/ForceSSL/ClassMethods.html#method-i-force_ssl | |
| # | |
| # Code based on: https://github.com/rails/rails/blob/ab08519b1aed46dbd4b3e13932bbaddfe42d8315/actionpack/lib/action_controller/metal/force_ssl.rb | |
| # |
| # Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })} | |
| RSpec::Matchers.define :accept_nested_attributes_for do |association| | |
| match do |model| | |
| @model = model | |
| @nested_att_present = model.respond_to?("#{association}_attributes=".to_sym) | |
| if @nested_att_present && @reject | |
| model.send("#{association}_attributes=".to_sym,[@reject]) | |
| @reject_success = model.send("#{association}").empty? | |
| end | |
| model.send("#{association}").clear |
| -- SPLIT_STR MySQL Function | |
| -- from http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/ | |
| CREATE FUNCTION SPLIT_STR( | |
| x VARCHAR(255), | |
| delim VARCHAR(12), | |
| pos INT | |
| ) | |
| RETURNS VARCHAR(255) | |
| RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos), |
##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
| <?php | |
| App::import('Inflector'); | |
| class SluggableBehavior extends ModelBehavior | |
| { | |
| private $_settings = array(); | |
| function setup(&$model, $settings = array()) | |
| { |