Skip to content

Instantly share code, notes, and snippets.

View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
rbarazi / nginx-passenger-ssl.conf
Created Nov 10, 2016 — forked from rkjha/nginx-passenger-ssl.conf
Nginx/Passenger config when using SSL with a Ruby/Rails Application.
View nginx-passenger-ssl.conf
# for redirecting hhtp traffic to https version of the site
server {
listen 80;
return 301 https://$server_name$request_uri;
# for redirecting to non-www version of the site
server {
listen 80;

Keybase proof

I hereby claim:

  • I am rbarazi on github.
  • I am rida ( on keybase.
  • I have a public key whose fingerprint is 7226 ECAA 9246 A00B 169E 4E9B B460 6F17 E71F AD15

To claim this, I am signing this object:

rbarazi /
Created Jun 23, 2016
Continue Converting SVN to GIT repo
head -4 REPO_NAME.dump > REPO_NAME-partial.dump && tail -n +$(grep -n "Revision-number: $(($(svn info file:///REPO_PATH/REPO_NAME | grep Revision | awk -F": " '{print $2}') + 1))" REPO_NAME.dump | awk -F":" '{print $1}') REPO_NAME.dump >> REPO_NAME-partial.dump && svnadmin load /REPO_PATH/REPO_NAME < REPO_NAME-partial.dump
rbarazi / gist:337f470bf957cd16daf9b6b33bebef17
Created Jun 15, 2016 — forked from gkop/gist:1371962
Capture javascript errors in Cucumber+Capybara+Webdriver tests
View gist:337f470bf957cd16daf9b6b33bebef17
# in features/support/env.rb
require 'selenium/webdriver'
# we need a firefox extension to start intercepting javascript errors before the page
# scripts load
Capybara.register_driver :selenium do |app|
profile =
# see
profile.add_extension File.join(Rails.root, "features/support/extensions/JSErrorCollector.xpi") app, :profile => profile
rbarazi / ssl_hack.rb
Created Jun 15, 2016 — forked from Papierkorb/ssl_hack.rb
SSL with Capybara and Selenium
View ssl_hack.rb
# Hack for Capybara to use SSL connections using selenium.
### Usage:
# Require this from rails_helper.rb
### Steps to generate a SSL certificate on a Linux box:
# 0. Starting from 'Rails.root'
# 1. Generate private key. Type in some password.
# $ openssl genrsa -des3 -out private.key 4096
# 2. Generate certificate sign request
# patch for make ruby error
# % rbenv install 1.8.7-p375
# ...
# ossl_pkey_ec.c:815: error: ‘EC_GROUP_new_curve_GF2m’ undeclared (first use in this function)
# ossl_pkey_ec.c:815: error: (Each undeclared identifier is reported only once
# ossl_pkey_ec.c:815: error: for each function it appears in.)
# make[1]: *** [ossl_pkey_ec.o] error 1
# ...
# refs:
rbarazi /
Created Jan 5, 2016 — forked from jed/
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

rbarazi / import_weightbot_csv_to_fitbit.rb
Last active Aug 29, 2015
Import Weightbot CSV to Fitbit
View import_weightbot_csv_to_fitbit.rb
# 1) Backup your wieghtbot data and then download it from:
# 2) Get a consumer_key and a consumer_secret from:
# 3) Use the key/secret from step 2 on to obtain a user_id/token/secret
# 4) install fitgem `gem install fitgem`
# 5) run the following from the console/irb
require 'fitgem'
c =
:consumer_key => "",
:consumer_secret => "",
View cool_ruby_gists
ruby -e '(0..23).cycle{|f|print "\r"+[128336+f].pack("U")+" ";sleep 0.2}'