Skip to content

Instantly share code, notes, and snippets.

View andrewsomething's full-sized avatar

Andrew Starr-Bochicchio andrewsomething

View GitHub Profile
@andrewsomething
andrewsomething / assign-ip.py
Last active May 18, 2021 10:38
Assign a DigitalOcean Floating IP to a Droplet
#!/usr/bin/python
import os
import sys
import requests
import json
api_base = 'https://api.digitalocean.com/v2'
@andrewsomething
andrewsomething / testHook.js
Created September 28, 2015 20:40
My first hook.io microservice
import pprint
print("Hello, this is a Python script.")
print("Hook['params'] is populated with request parameters")
pprint.pprint(Hook['params'])
Vagrant.configure('2') do |config|
config.ssh.private_key_path = 'sshkey/id_rsa'
config.vm.box ='ubuntu/trusty64'
config.vm.network "forwarded_port", guest: 80, host: 8080
provider_is_do = (!ARGV.nil? && ARGV.join('').include?('provider=digital_ocean'))
config.vm.provision 'shell', inline: <<-SHELL
sudo apt-get update
@andrewsomething
andrewsomething / cloud_init_runcmd.py
Last active August 22, 2019 18:36
This script takes a cloud-config file as input and returns the 'shellified' script that would be produced by cloudinit from the runcmd stanza.
#!/usr/bin/python
"""
This script take a cloud-config file as input and returns the 'shellified'
script that would be produced by cloudinit from the runcmd stanza.
https://github.com/number5/cloud-init/blob/74e61ab27addbfcceac4eba254f739ef9964b0ed/cloudinit/config/cc_runcmd.py
https://github.com/number5/cloud-init/blob/74e61ab27addbfcceac4eba254f739ef9964b0ed/cloudinit/util.py#L1708
"""
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: unicorn initscript
# Description: unicorn
### END INIT INFO
@andrewsomething
andrewsomething / echoHttpRequest.js
Last active August 29, 2015 14:21 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
@andrewsomething
andrewsomething / snapshot.rb
Created February 26, 2015 21:08
Power off and Snapshot a DigitalOcean Droplet
#!/usr/bin/env ruby
require 'droplet_kit'
require 'json'
token = ENV['DO_TOKEN']
client = DropletKit::Client.new(access_token: token)
droplet_id = ARGV[0]
snapshot_name = ARGV[1] || Time.now.strftime("%b. %d, %Y - %H:%M:%S %Z")
$ git push deploy
++ id -un
+ [[ dokku != \d\o\k\k\u ]]
+ [[ -n git-receive-pack 'nodejs' ]]
+ export -n SSH_ORIGINAL_COMMAND
+ /usr/local/bin/dokku git-receive-pack ''\''nodejs'\'''
++ id -un
+ [[ dokku != \d\o\k\k\u ]]
+ [[ -n '' ]]
+ case "$1" in
@andrewsomething
andrewsomething / OAuth2-Gtk.py
Created August 5, 2014 03:29
Get an an OAuth2 token using the "implicit" flow in Python and Gtk+ w/ DigitalOcean as the example
from gi.repository import Gtk
from gi.repository import WebKit
import urlparse
BASE_URL = 'https://cloud.digitalocean.com/v1/oauth/'
CLIENT_ID = 'specialsnowflake'
CALLBACK_URL = 'http://andrewsomething.com'
class AuthWin(Gtk.Window):