Skip to content

Instantly share code, notes, and snippets.

View aburnett's full-sized avatar
⌨️
Writing the code

Adam Burnett aburnett

⌨️
Writing the code
View GitHub Profile
@aburnett
aburnett / open_facebook_app.js
Last active September 30, 2020 15:51
Open Facebook app on iOS if it exists, falling back to browser otherwise
function preventPopup(timeout) {
clearTimeout(timeout);
timeout = null;
window.removeEventListener("pagehide", preventPopup);
}
function openFacebook(site, platform) {
let fbAppUrl;
switch (platform.type) {
case "ios":
@aburnett
aburnett / gist:b3168c70bf752ea1cc4540cb174ac242
Created May 25, 2018 01:41
terraform aws provider debug
2018/05/24 21:39:41 [INFO] Terraform version: 0.11.7
2018/05/24 21:39:41 [INFO] Go runtime version: go1.10.1
2018/05/24 21:39:41 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.11.7/bin/terraform", "apply", "-no-color"}
2018/05/24 21:39:41 [DEBUG] Attempting to open CLI config file: /Users/adam/.terraformrc
2018/05/24 21:39:41 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/05/24 21:39:41 [INFO] CLI command args: []string{"apply", "-no-color"}
2018/05/24 21:39:41 [INFO] command: empty terraform config, returning nil
2018/05/24 21:39:41 [DEBUG] command: no data state file found for backend config
2018/05/24 21:39:41 [DEBUG] New state was assigned lineage "f92380d6-2738-92fd-0a93-a2c06df30704"
2018/05/24 21:39:41 [INFO] command: backend initialized: <nil>
@aburnett
aburnett / ScheduledEventMetrics.java
Last active August 4, 2019 11:58
Publish AWS Step Function per-activity backlog as Cloudwatch metric
public void metricPendingActivities() {
AWSStepFunctions client = AWSStepFunctionsClientBuilder.defaultClient();
ListStateMachinesRequest lsmr = new ListStateMachinesRequest();
//TODO: paging
ListStateMachinesResult machinesResult = client.listStateMachines(lsmr);
Map<String, Long> counts = machinesResult.getStateMachines()
.stream()
.map(m -> {
@aburnett
aburnett / docker-machine-prompt.sh
Created October 16, 2015 13:40
Cheesy method to show currently active docker machine in PS1
#Usage: PS1='[$(__active_machine "{%s} ")\u@\h $]
EMOJI=🐳
__active_machine() {
FORMAT=$1
if ACTIVE=$(docker-machine active 2>/dev/null); then
STATE=$(docker-machine status $ACTIVE)
if [ "$STATE" = "Running" ]; then
unset STATE
IP=$(docker-machine ip $ACTIVE)
fi
@aburnett
aburnett / docker-init
Created February 13, 2015 14:00
bash function to automatically ensure the boot2docker environment is up and running on OSX
#!/bin/bash
# start boot2docker and shellinit automatically
DOCKER_RUN=`which docker`
docker(){
if ! /Applications/VirtualBox.app/Contents/MacOS/VBoxManage list runningvms | grep boot2docker-vm >/dev/null ; then
boot2docker start
fi
if [ "$DOCKER_HOST" == "" ]; then
$(boot2docker shellinit)