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
pch /
Last active Feb 18, 2019
How to install Unison on Mac OS El Capitan & Vagrant

How to install Unison on Mac OS El Capitan & Vagrant - for Docker Sync

You can install Unison on the Mac via homebrew (brew install unison), but it's very likely that it won't work properly, resulting in errors like:

Unison failed: Uncaught exception Failure("input_value: bad bigarray kind")
Fatal error: Lost connection with the server
View gist:1322006

How to use Spotify in any country

If you can put up with ads, you can easily trick Spotify and sign up for an account, even if you're not in one of the supported countries. You'll need:

  • A Facebook account
  • SSH access to a server based in one of the supported countries (US, UK, whatevs).

First, set up an SSH tunnel, as described here:


Keybase proof

I hereby claim:

  • I am pch on github.
  • I am pchm ( on keybase.
  • I have a public key ASDohLNPHrR-IY6_I7lzw1SiENKSNNIKkmT9-BQIpRQoxQo

To claim this, I am signing this object:

pch / assert_queries.rb
Last active Sep 19, 2016
assert_queries - rails 4
View assert_queries.rb
# Assertion for checking the number of queries executed within the &block
def assert_queries(num = 1, &block)
queries = []
callback = lambda { |name, start, finish, id, payload|
queries << payload[:sql] if payload[:sql] =~ /^SELECT|UPDATE|INSERT/
ActiveSupport::Notifications.subscribed(callback, "sql.active_record", &block)
assert_equal num, queries.size, "#{queries.size} instead of #{num} queries were executed.#{queries.size == 0 ? '' : "\nQueries:\n#{queries.join("\n")}"}"
pch /
Last active May 17, 2016
Nukes all trailing whitespace in the current project (rails specific).
find . -not \( -name .git -prune -o -name images -prune -o -name GeoLiteCity.dat -prune \) -type f -print0 | xargs -0 perl -pi -e 's/ +$//'
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>",
pch / git-sync
Last active Dec 18, 2015
Git sync - light version
View git-sync
git_branch() {
echo $(git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'})
git_dirty() {
st=$(git status 2>/dev/null | tail -n 1)
if [[ $st == "" ]]
View wifi_presence
require 'net/http'
out = `arp-scan -lq`
macs =
out.split("\n").map do |line|
if line =~ /([0-9A-F][0-9A-F :]{16})/i
puts $1
$1.split(' ').join(':').upcase
View gist:953698
# 1
:one => 1,
:two => 2
# 2
:one => 1,
:two => 2)
View gist:837658
module Devise
module Controllers
module ScopedViews
# Monkey path for generating proper templates path when dealing with
# namespaced resources and custom views.
def render_with_scope(action, options={})
controller_name = options.delete(:controller) || self.controller_name
if self.class.scoped_views?
You can’t perform that action at this time.