This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
app_name = 'APP_NAME' | |
opsworks_app_id = 'APPID' | |
config = `heroku config -s --app #{app_name}`.strip | |
json = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
# This is the json output of the old zone, fetched using the AWS CLI. | |
zone = JSON.parse(File.read('DOMAIN.zone.json'))['ResourceRecordSets'] | |
new_zone_id = 'NEW_ZONE_ID' | |
# We don't want to migrate the SOA and NS records from the old zone. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Loading function'); | |
const https = require('https'); | |
const url = require('url'); | |
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration | |
const slack_url = 'https://hooks.slack.com/services/...'; | |
const slack_req_opts = url.parse(slack_url); | |
slack_req_opts.method = 'POST'; | |
slack_req_opts.headers = {'Content-Type': 'application/json'}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The OAuth access token provided by the Google API expires in 60 minutes. After expiration, | |
# you must exchange a refresh token for a new access token. Unfortunately, the the Google API | |
# ruby gem does not include a method for refreshing access tokens. | |
# You can read up on how to refresh an access token here: | |
# https://developers.google.com/accounts/docs/OAuth2WebServer#refresh | |
# This Token model implements that process. It's based off of a Token model that can be created | |
# by running: | |
# rails g model Token token:text refresh_token:string expires_at:datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MKMapView+ZoomLevel.h | |
// | |
// Created by Daniel.Burke on 7/3/14 via Nikita Galayko @ StackOverflow | |
// Copyright (c) 2014 Forrent.com. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#define MERCATOR_RADIUS 85445659.44705395 | |
#define MAX_GOOGLE_LEVELS 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Often times we need to send emails on a delayed basis. We could make this really easy on the client | |
# side by automatically mounting an endpoint with rack middleware, and firing the mailer with the | |
# arguments supplied. | |
# | |
# Under the hood, this would use the same architecture as an abstract job, where a webhook is hit | |
# at the specified time, but by focusing on the email / action mailer use case the client doesn't need | |
# to write any boilerplate code. | |
Tick::EmailJob.create!( | |
:at => appointment.start_time - 1.hour, | |
:message => "Don't forget, your appointment starts in 1 hour!", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH table_scans as ( | |
SELECT relid, | |
tables.idx_scan + tables.seq_scan as all_scans, | |
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes, | |
pg_relation_size(relid) as table_size | |
FROM pg_stat_user_tables as tables | |
), | |
all_writes as ( | |
SELECT sum(writes) as total_writes | |
FROM table_scans |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming an Ubuntu Docker image | |
$ docker run -it <image> /bin/bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"deploy": { | |
"discourse": { | |
"database": { | |
"adapter": "postgresql", | |
"host": "aaa.amazonaws.com", | |
"port": "5432", | |
"database": "bbb", | |
"pool": "5", | |
"username": "ccc", |