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 keybase.md

Keybase proof

I hereby claim:

  • I am pch on github.
  • I am pchm (https://keybase.io/pchm) on keybase.
  • I have a public key ASDohLNPHrR-IY6_I7lzw1SiENKSNNIKkmT9-BQIpRQoxQo

To claim this, I am signing this object:

@pch
pch / mac-vagrant-unison.md
Last active Feb 18, 2019
How to install Unison on Mac OS El Capitan & Vagrant
View mac-vagrant-unison.md

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 Gemfile
# rspec
group :test do
gem 'rspec-rails'
gem 'launchy'
gem 'capybara'
gem 'webrat'
gem 'database_cleaner'
gem 'email_spec'
gem 'factory_girl_rails'
end
@pch
pch / discipline
Created Feb 13, 2014
Tricking myself into writing.
View discipline
#!/usr/bin/env ruby
#
# I use the following script to trick myself into writing every day.
#
# All it does is create a directory for the current month (YYYY/MM),
# create an empty markdown file for today and annoy the hell out of
# me until I put something in that file.
#
# I run the script with GeekTool every 30 minutes:
# http://projects.tynsoe.org/en/geektool/
@pch
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)
ensure
assert_equal num, queries.size, "#{queries.size} instead of #{num} queries were executed.#{queries.size == 0 ? '' : "\nQueries:\n#{queries.join("\n")}"}"
@pch
pch / git-sync
Last active Dec 18, 2015
Git sync - light version
View git-sync
#!/bin/sh
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 == "" ]]
then
@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 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
end
end.compact.join(',')
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: http://paulstamatiou.com/how-to-surf-securely-with-ssh-tunnel

View gist:953698
# 1
Foo.bar(
:one => 1,
:two => 2
)
# 2
Foo.bar(
:one => 1,
:two => 2)
You can’t perform that action at this time.