Skip to content

Instantly share code, notes, and snippets.

View gregory's full-sized avatar
🎯
Focusing

Grégory Horion gregory

🎯
Focusing
View GitHub Profile
fs = require 'fs'
webpage = require 'webpage'
page = webpage.create()
renderedUrls = 0
totalUrls = 0
# Taken from https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js
# Converted into coffee
waitFor = (testFx, onReady, timeOutMillis) ->
maxtimeOutMillis = (if timeOutMillis then timeOutMillis else 5000) #< Default Max Timout is 3s
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
require 'adhearsion'
require 'adhearsion/initializer/asterisk'
require 'drb'
# http://help.cloudvox.com/faqs/getting-started/setup-for-ruby-adhearsion
desc "Make an outgoing phone call to number provided as 'call' (via Cloudvox)"
task :make_outgoing_call do
if ENV['call']
# Outgoing context from Cloudvox Switchboard, under "Outgoing settings (AMI)."
namespace :db do
require "sequel"
Sequel.extension :migration
DB = Sequel.connect(ENV['DATABASE_URL'])
desc "Prints current schema version"
task :version do
version = if DB.tables.include?(:schema_info)
DB[:schema_info].first[:version]
end || 0
@gregory
gregory / .README.md
Last active August 29, 2015 14:14 — forked from gnarf/..git-pr.md

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from GitHub remotes:

  • git pr 4 - creates local branch pr/4 from the origin remote and checks it out
  • git pr 4 upstream - creates local branch pr/4 from upstream remote and checks it out
@gregory
gregory / scraping.rb
Last active August 29, 2015 14:18 — forked from ngauthier/scraping.rb
#!/usr/bin/env ruby
# From: http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html
require 'capybara'
require 'capybara/poltergeist'
require 'csv'
require 'gdbm'
class NickBot
include Capybara::DSL
@gregory
gregory / Gemfile
Last active August 29, 2015 14:19 — forked from Burgestrand/Gemfile
source :rubygems
gem 'pry'
gem 'capybara'
gem 'capybara-webkit'
gem 'celluloid'
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@gregory
gregory / README.md
Created November 21, 2015 06:52 — forked from oscarrenalias/README.md
Docker service discovery with HAproxy, consul and registrator on Docker Machine and Docker Swarm
@gregory
gregory / gist:0aeaf4a433737f02f050
Created November 21, 2015 08:58
Docker 1.9.0 - Using docker-machine, swarm and overlay networking with etcd
docker-machine create -d virtualbox cluster-store
CLUSTER_STORE_IP=$(docker-machine ip cluster-store)
docker $(docker-machine config cluster-store) run -d \
--restart="always" \
--publish="2379:2379" \
microbox/etcd:2.1.1 \
-name etcd0 \
-advertise-client-urls http://${CLUSTER_STORE_IP}:2379 \
-listen-client-urls http://0.0.0.0:2379 \