Skip to content

Instantly share code, notes, and snippets.

View JohnSmall's full-sized avatar

John Small JohnSmall

View GitHub Profile
@JohnSmall
JohnSmall / digital-ocean-rails.sh
Last active February 19, 2017 14:58
Handy script to prepare a bare Digital Ocean droplet for Rails deployed via Capistrano
#! /bin/bash
# this is a useful little script to setup a rails user, with postgresql, and nginx version of Phusion Passenger on a Digital Ocean droplet
# Once run it's ready to recieve a Capistrano deployment.
# The best way to run it is ssh root@my_do_host 'bash -s' < digital-ocean-rails.sh
set -e -x # die on the first error and send stdout to /var/log/syslog
#create a password and save it
PWD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1)
mkdir -p passwords
echo "rails,$PWD" >> passwords/users.txt
#create a user called rails and allow them to sudo without a password
@JohnSmall
JohnSmall / bitcoin-pay.rb
Created July 28, 2018 15:36 — forked from Sjors/bitcoin-pay.rb
This script demonstrates how a bitcoin transaction is created and signed. Just pass in your own address and private key and it will prepare a transaction for you. You can then copy & paste that transaction into a webservice like Blockchain to send it. I wrote this mostly to understand better how it works. I sometimes had to "cheat" and look at t…
#!/usr/bin/env ruby
require 'open-uri'
require 'JSON'
require 'digest/sha2'
require 'pry'
require 'bigdecimal'
require 'bitcoin' # Because I need to cheat every now and then
# Usage:
# gem install pry json ffi ruby-bitcoin