Skip to content

Instantly share code, notes, and snippets.

View andrewsomething's full-sized avatar

Andrew Starr-Bochicchio andrewsomething

View GitHub Profile
@andrewsomething
andrewsomething / BACKUP.md
Last active March 28, 2023 08:30
Backup GitLab to DigitalOcean Spaces

Backup GitLab to DigitalOcean Spaces

GitLab uses Fog to communicate with various object storage services when running backups. Fog works with S3 as well as S3-compatible services like Spaces. The key difference is that you need to explictly set the endpoint for non-S3 services. If you are using the "ominbus" GitLab packages, you would need to add the following to /etc/gitlab/gitlab.rb:

gitlab_rails['backup_upload_connection'] = {
@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):
@andrewsomething
andrewsomething / hacktoberfest-label.py
Last active October 20, 2022 16:16
This script will add the "hacktoberfest" label to any issue that also has one of the following labels applied: 'help wanted', 'first-timers-only', 'up-for-grabs'
#!/usr/bin/env python3
import os
import sys
import requests
import json
LABELS = ['help wanted', 'help-wanted', 'first-timers-only', 'up-for-grabs',
'good first issue']
API_BASE = 'https://api.github.com/'
@andrewsomething
andrewsomething / main.go
Last active August 29, 2022 16:19
Report download statistics for GitHub release assets
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
"strings"
"text/tabwriter"
@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 / handlers.yml
Last active September 15, 2020 18:13
My "first five minutes" on a server
---
- name: Restart sshd
service:
name: ssh
state: restarted
become: yes
@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")
@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
"""
@andrewsomething
andrewsomething / main.tf
Last active December 12, 2018 23:19
Terraform + DigitalOcean Kubernetes = <3
provider "digitalocean" {}
// Create a cluster on DigitalOcean
resource "digitalocean_kubernetes_cluster" "example" {
name = "example"
region = "nyc1"
version = "1.12.3-do.1"
node_pool {
name = "wokers"
diff --git a/digitalocean/config.go b/digitalocean/config.go
index 96f6785..bc38c31 100644
--- a/digitalocean/config.go
+++ b/digitalocean/config.go
@@ -12,33 +12,63 @@ import (
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
+ "github.com/minio/minio-go"
"golang.org/x/oauth2"