Skip to content

Instantly share code, notes, and snippets.

View sunchess's full-sized avatar
🎧
Focusing

Alexander Dmitriev sunchess

🎧
Focusing
  • Russia, Rostov-on-Don
View GitHub Profile
@jittuu
jittuu / gist:792715
Created January 24, 2011 02:19
Test Omniauth Facebook Callback Controllers in Devise with rspec
require 'spec_helper'
describe Users::OauthCallbacksController, "handle facebook authentication callback" do
describe "#annonymous user" do
context "when facebook email doesn't exist in the system" do
before(:each) do
stub_env_for_omniauth
get :facebook
app.directive('clickOutside', ['$document', function ($document) {
return {
restrict: 'A',
scope: {
clickOutside: '&'
},
link: function (scope, el, attr) {
var handler = function (e) {
if (el !== e.target && !el[0].contains(e.target) && document.body.contains(e.target)) {
scope.$apply(function () {
@dogweather
dogweather / dig_bang.rb
Last active February 18, 2020 11:40
DigBang: Safely unsafe hash traversal
# `Hash#dig!`
#
# Like Ruby 2.3's `Hash#dig`, but raises an exception instead of returning `nil`
# when a key isn't found.
#
# Ruby 2.3 introduces the new Hash#dig method for safe extraction of
# a nested value. See http://ruby-doc.org/core-2.3.0/Hash.html#method-i-dig.
# It is the equivalent of a safely repeated Hash#[].
#
# `#dig!`, on the other hand, is the equivalent of a repeated `Hash#fetch`. It's
@edib
edib / upgrade_pg.sh
Last active October 18, 2022 04:36 — forked from ibussieres/upgrade_pg.sh
Upgrade PostgreSQL 9.3 to 9.6 on Ubuntu 16.04
sudo apt-get install postgresql-9.6 postgresql-server-dev-9.6 postgresql-contrib-9.6 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo systemctl stop postgresql
sudo su - postgres -c '/usr/lib/postgresql/9.6/bin/pg_upgrade -b /usr/lib/postgresql/9.3/bin -B /usr/lib/postgresql/9.6/bin \
-d /var/lib/postgresql/9.3/main/ -D /var/lib/postgresql/9.6/main/ \
-O "-c config_file=/etc/postgresql/9.6/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" --link'
sudo apt-get remove postgresql-9.3 -y