Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Starr-Bochicchio andrewsomething

View GitHub Profile
@andrewsomething
andrewsomething / assign-ip.py
Last active Oct 16, 2020
Assign a DigitalOcean Floating IP to a Droplet
View assign-ip.py
#!/usr/bin/python
import os
import sys
import requests
import json
api_base = 'https://api.digitalocean.com/v2'
@andrewsomething
andrewsomething / testHook.js
Created Sep 28, 2015
My first hook.io microservice
View testHook.js
import pprint
print("Hello, this is a Python script.")
print("Hook['params'] is populated with request parameters")
pprint.pprint(Hook['params'])
View Vagrantfile
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 Aug 22, 2019
This script takes a cloud-config file as input and returns the 'shellified' script that would be produced by cloudinit from the runcmd stanza.
View cloud_init_runcmd.py
#!/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
"""
View gist:5d21e17b9ddb4507ed22
#!/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
View echoHttpRequest.js
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 Feb 26, 2015
Power off and Snapshot a DigitalOcean Droplet
View snapshot.rb
#!/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")
View gist:a82566e13181708f350f
$ 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 Aug 5, 2014
Get an an OAuth2 token using the "implicit" flow in Python and Gtk+ w/ DigitalOcean as the example
View OAuth2-Gtk.py
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):
You can’t perform that action at this time.