Skip to content

Instantly share code, notes, and snippets.

Piotr Chmolowski pch

Block or report user

Report or block pch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View reshaping_the_command_approach.rb
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
View grouper_interactor_example.rb
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
confirm_grouper_via_emails(@grouper)
enqueue_bar_assignment(@grouper)
redirect_to home_path
else
@pch
pch / trimws.sh
Last active May 17, 2016
Nukes all trailing whitespace in the current project (rails specific).
View trimws.sh
find . -not \( -name .git -prune -o -name images -prune -o -name GeoLiteCity.dat -prune \) -type f -print0 | xargs -0 perl -pi -e 's/ +$//'
View gist:1975644
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@nov
nov / token_request_sample.rb
Created Mar 23, 2011
Rack::OAuth2::Client Sample - Token Request
View token_request_sample.rb
require 'rubygems'
require 'rack/oauth2'
client = Rack::OAuth2::Client.new(
:identifier => YOUR_CLIENT_ID,
:secret => YOUR_CLIENT_SECRET,
:redirect_uri => YOUR_REDIRECT_URI, # only required for grant_type = :code
:host => 'rack-oauth2-sample.heroku.com'
)
@nov
nov / authorization_request_sample.rb
Created Mar 9, 2011
Rack::OAuth2::Client Sample - Authorization Request
View authorization_request_sample.rb
require 'rubygems'
require 'rack/oauth2'
client = Rack::OAuth2::Client.new(
:identifier => YOUR_CLIENT_ID,
:secret => YOUR_CLIENT_SECRET,
:redirect_uri => YOUR_REDIRECT_URI, # only required for grant_type = :code
:host => 'rack-oauth2-sample.heroku.com'
)
@pch
pch / watermark.rb
Created Jan 18, 2011
Paperclip Watermark processor
View watermark.rb
class User
has_attached_file :photo,
:processors => [:watermark],
:styles => {
:medium => {
:geometry => "300x300>",
:watermark_path => "#{Rails.root}/public/images/watermark.png"
},
:thumb => "100x100>",
}
You can’t perform that action at this time.