Skip to content

Instantly share code, notes, and snippets.

View cyril's full-sized avatar
🌶️
I like spicy pad thai

Cyril Kato cyril

🌶️
I like spicy pad thai
View GitHub Profile
@ibraheem4
ibraheem4 / postgres-brew.md
Last active April 14, 2024 20:30 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 19, 2024 23:35
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@solnic
solnic / fun.rb
Last active December 26, 2015 23:29
Ruby object that has "functions" rather than methods
class Function
attr_reader :name, :fn
class Composed
attr_reader :left, :right
def initialize(left, right)
@left = left
@right = right
end
@josevalim
josevalim / 0_README.md
Created September 13, 2012 21:52
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

@ahawkins
ahawkins / web_object.rb
Created May 11, 2012 14:04
My take on ActiveResource using OpenStruct delegating to a HTTP class.
module RadiumIo
class WebObject < OpenStruct
def initialize(attrs = {}, &block)
super
yield self if block_given?
end
def self.create(attributes = {}, &block)
account = new attributes, &block
account.save
@drnic
drnic / Guardfile
Created April 5, 2012 06:45
An example Guardfile with the works for a Rails app
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
@gabrielstuff
gabrielstuff / reset_db_password.sh
Created November 19, 2011 11:36
This little snippet helps to reset mysql root password
$ ps -ax
$ #Kill all the related mysql process and direct run the next lines#
$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
#direct log after execute bellow command#
$ mysql -u root
mysql > database mysql;
@robcthegeek
robcthegeek / user.rb
Created November 9, 2011 21:32
"Standard" User Model Using Mongoid/BCrypt
require 'bcrypt'
class User
include Mongoid::Document
include Mongoid::Timestamps
include BCrypt
attr_accessor :password, :password_confirmation
attr_protected :password_hash
@dhh
dhh / gist:981520
Created May 19, 2011 19:27
bulk api
# Bulk API design
#
# resources :posts
class PostsController < ActiveController::Base
# GET /posts/1,4,50,90
# post_url([ @post, @post ])
def show_many
@posts = Post.find(params[:ids])
end