Skip to content

Instantly share code, notes, and snippets.

Philippe Creux pcreux

Block or report user

Report or block pcreux

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
pcreux / index.sql
Created Jul 5, 2016
Postgresql rank() with LIMIT 1 = 10x speed up?
View index.sql
CREATE INDEX "index_patrons_on_amount_raised_in_cents" ON "patrons" ("amount_raised_in_cents" DESC)
View data-object-with-time-parsing.rb
require 'time'
require 'virtus'
require 'benchmark/ips'
id: "123",
title: "Hello",
content: "Lorem ipsum" * 100,
pcreux / mkspec.rb
Last active Apr 26, 2016
mkspec - Generate spec file (in vim: `:!mkspec %`)
View mkspec.rb
#!/usr/bin/env ruby
DESC = "
Generate spec file
Example: mkspec app/services/user/create.rb will generate spec/services/user/create_spec.rb
pcreux / dependencies.rb
Last active Aug 29, 2015
Generate graph of dependency for scss stylesheets
View dependencies.rb
#!/usr/bin/env ruby
# Generate a graph of dependencies for your stylesheets.
# Requires graphviz
# Run `ruby dependencies.rb | fdp -Tpng > out.png; open out.png`
PATH = "app/assets/stylesheets/"
pcreux / this-week-in-rails-sample
Last active Aug 29, 2015
Output for latest this week in rails
View this-week-in-rails-sample
layout: post
title: "This week in Rails: 4.2.0 Final, autoload explained, deep_munge and more!"
categories: news
author: chancancode
published: true
date: 2015-01-09 14:04:54 -0800
Welcome to _This week in Rails_, your weekly inside scoop of interesting commits, pull requests and more from [Rails](
pcreux / railsmv.rb
Last active Jun 14, 2017
railsmv - Rename rails services, models etc - railsmv app/services/create_user.rb app/services/user/create.rb
View railsmv.rb
#!/usr/bin/env ruby
# Rename rails services, models etc as well as their test or spec files!
# Example: railsmv app/services/create_user.rb app/services/user/create.rb
require 'optparse'
dry_run = false
View size.rb
class Size
include Comparable
def initialize(str)
unless ALL_STRS.include? str
raise ArgumentError, "#{str} is not a valid size"
@str = str
pcreux / pipable.rb
Last active Jun 12, 2018
*nix has pipes, Elixir has pipes, Ruby deserves pipes.
View pipable.rb
# Elixir has pipes `|>`. Let's try to implement those in Ruby.
# I want to write this:
# email.body | RemoveSignature | HighlightMentions | :html_safe
# instead of:
View policy.rb
require 'virtus'
class User
include Virtus.model
attribute :confirmed_at, Time
attribute :subscribed, Boolean, default: false
class Screencast
pcreux / 000_postgresql_fancy_datatypes
Last active Jan 15, 2017
Postgresql fancy datatypes with Rails / ActiveRecord. Run it with `rake`!
View 000_postgresql_fancy_datatypes
# Postgresql fancy datatypes!
* array
* hstore (=~ hash)
* json
* jsonb
Philippe Creux - [@pcreux](
You can’t perform that action at this time.