Skip to content

Instantly share code, notes, and snippets.

@michaelglass
michaelglass / alerts_and_confirms.rb
Last active September 24, 2019 10:15
test alerts & confirms in poltergeist & capybara webkit
module AlertConfirmer
class << self
def reject_confirm_from &block
handle_js_modal 'confirm', false, &block
end
def accept_confirm_from &block
handle_js_modal 'confirm', true, &block
end
@ihassin
ihassin / deploy.rb
Created December 24, 2013 00:11
Capistrano 3 script to deploy the app
set :application, '<APP_NAME>'
set :repo_url, "<git@PATH/REPO.git>"
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :deploy_to, "/home/deploy/rails/<APP_NAME>"
# set :scm, :git
set :format, :pretty
set :log_level, :debug
@mikeclarke
mikeclarke / env.sh
Created November 23, 2013 21:43
Wrapper script for dealing with environment variables set by the `-link container_name:db` argument. The Dockerfile `ENV` directive will set a static environment variable inside the container, but it's not possible to reference dynamic environment variables (at least not very easily) with ENV. This script should be set as the `ENTRYPOINT` in an …
#!/bin/bash
# Docker doesn't have a great way to set runtime environment variables,
# so use this script to prepare the execution environnment for later processes.
export SQLALCHEMY_DATABASE_URI="postgresql://${DB_PORT_5432_TCP_ADDR}:5432/database_name"
# Execute the commands passed to this script
# e.g. "./env.sh venv/bin/nosetests --with-xunit
exec "$@"
@blissdev
blissdev / errors
Created August 25, 2013 08:05
Installing Postgres 9.3rc1 and extensions with Ansible
TASK: [start postgres] ********************************************************
changed: [192.168.33.78] => {"changed": true, "cmd": "/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/logs/pgsql.log start && /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data reload ", "delta": "0:00:00.011510", "end": "2013-08-25 07:59:05.172814", "rc": 0, "start": "2013-08-25 07:59:05.161304", "stderr": "pg_ctl: another server might be running; trying to start server anyway", "stdout": "server starting\nserver signaled"}
TASK: [load pgcrypto] *********************************************************
failed: [192.168.33.78] => {"changed": true, "cmd": "/usr/local/pgsql/bin/psql -d template1 -c \"CREATE EXTENSION pgcrypto;\" ", "delta": "0:00:00.004287", "end": "2013-08-25 07:59:05.523699", "rc": 2, "start": "2013-08-25 07:59:05.519412"}
stderr: psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/t
@linjunpop
linjunpop / deploy-rails-4-app-with-dokku-on-digital-ocean.md
Last active September 11, 2024 10:21
Deploy Rails 4 app with Dokku on DigitalOcean

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash
@bantic
bantic / rails_route_recognizer.rb
Last active September 9, 2022 12:22
Programmatically list all routes (/paths) from within a rails app.
class RouteRecognizer
attr_reader :paths
# To use this inside your app, call:
# `RouteRecognizer.new.initial_path_segments`
# This returns an array, e.g.: ['assets','blog','team','faq','users']
INITIAL_SEGMENT_REGEX = %r{^\/([^\/\(:]+)}
def initialize
@skopp
skopp / diffbot
Last active December 17, 2015 23:09
diffbot dev customizing - this is in HAML, just saved without the extension (Gists don't allow subdirs apparently)
!!!
%html{:lang => "en"}
%head
%meta{:charset => "utf-8"}/
%title Customize Instructions
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/
/ Default styles
%link{:href => "/dev/css/bootstrap.min.css", :rel => "stylesheet"}/
%link{:href => "/dev/css/fonts.css", :rel => "stylesheet"}/
%link{:href => "/dev/css/default.css", :rel => "stylesheet"}/
@sntran
sntran / elixir
Last active December 17, 2015 23:09
Dockerfile for Erlang container for Docker.IORename each of these to `Dockerfile` to build the imagedocker build -t="{imagename}" .docker run -i -t {imagename} /bin/bash
# Elixir on Erlang
#
# VERSION 0.13.2
FROM sntran/kerl
MAINTAINER Son Tran-Nguyen "[email protected]"
RUN apt-get install -y unzip
RUN mkdir -p /opt/erlang/elixir
RUN cd /opt/erlang/elixir && curl -L -O https://github.com/elixir-lang/elixir/releases/download/v0.13.2/Precompiled.zip && unzip Precompiled.zip
@postmodern
postmodern / rails_rce.rb
Last active March 5, 2025 00:46
Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
@gavinandresen
gavinandresen / btcpayments.rst
Last active May 28, 2024 17:41
Bitcoin Payment Messages

SEE BIP 70

See https://en.bitcoin.it/wiki/BIP_0070 for the latest version of this document; I'll keep this document so the process of discussion/revision isn't lost.

Bitcoin Payment Messages

This document proposes protocol buffer-based formats for a simple payment protocol between a customer's bitcoin client software and a merchant.