Skip to content

Instantly share code, notes, and snippets.

@CodeAbstract
CodeAbstract / custom_operators.rb
Last active December 14, 2015 14:08
Defining operators as if they were ordinary methods using the append (<<) and spaceship operator (<=>) operator
Sample code: Append Operator(<<)
class Inbox
attr_reader :unread_count
def initialize
@messages = []
@unread_count = 0
end
@CodeAbstract
CodeAbstract / gist:3721057
Created September 14, 2012 09:44
Error Statrting MySQL on Mac OSx 10.6.8
Problem:
Starting MySQL
- ERROR! The server quit without updating PID file (/usr/local/var/mysql/User.local.pid).
***mysqld tries to find its tables in /usr/local/var/mysql
Solution:
***change directories accordingly***
@CodeAbstract
CodeAbstract / edit.html.erb
Created July 26, 2012 07:51
Rails 3 + Devise: Change password manually
<%= form_for :user, :url => password_path do |f| %>
<p><%= f.label :current_password, "Current password" %><br />
<%= f.password_field :current_password %></p>
<p><%= f.label :password, "New password" %><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></p>
@CodeAbstract
CodeAbstract / deploy.rb
Created July 25, 2012 11:18 — forked from bkutil/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')