Skip to content

Instantly share code, notes, and snippets.


Patrick Oscity padde

View GitHub Profile
View test.json
"hello": "world"
View ilike.sql
SELECT * FROM posts WHERE body ILIKE '%zweitag%'
View tsvector.sql
SELECT to_tsvector('I like to go swimming');
'go':4 'like':2 'swim':5
padde / tsvector_german_broken.sql
Created Jan 8, 2015
to_tsvector (german with english analysis)
View tsvector_german_broken.sql
SELECT to_tsvector('Ich würde gerne schwimmen gehen');
'gehen':5 'gern':3 'ich':1 'schwimmen':4 'würde':2
padde / tsvector_german.sql
Created Jan 8, 2015
to_tsvector (german)
View tsvector_german.sql
SELECT to_tsvector('german', 'Ich würde gerne schwimmen gehen');
'geh':5 'gern':3 'schwimm':4
padde / post.rb
Created Jan 8, 2015
Post model with pg_search
View post.rb
class Post < ActiveRecord::Base
include PgSearch
pg_search_scope :search,
against: :body,
using: {tsearch: {dictionary: 'german'}}
padde / partial_application.rb
Last active Aug 29, 2015
Proc#with – Partial Application
View partial_application.rb
require 'forwardable'
class Proc
def with(*arguments, &block)
proc do |*remaining_arguments|
call(*remaining_arguments, *arguments, &block)
padde / devise.rb
Last active Aug 29, 2015
Rails + Devise + RSpec = ❤️
View devise.rb
# spec/support/devise.rb
module DeviseFeatureHelpers
def sign_in(user = nil, scope = :user)
user ||= build_stubbed :user
login_as user, scope: scope
RSpec.configure do |config|
padde / regex_interpolation.exs
Last active Aug 29, 2015
Elixir Regex Interpolation – do not use in production
View regex_interpolation.exs
defmodule Regex.InterpolationError do
defexception [:message]
defmodule Regex.Interpolation do
def wrap(regex = %Regex{opts: modifiers}) do
|> do_wrap(modifiers)
padde /
Created Jul 19, 2015
Keybase proof

Keybase proof

I hereby claim:

  • I am padde on github.
  • I am padde ( on keybase.
  • I have a public key whose fingerprint is 7B8E 3327 8E52 E3E1 8392 92AE CCBB 382F 5F9D 1786

To claim this, I am signing this object: