Skip to content

Instantly share code, notes, and snippets.

View johnjjung's full-sized avatar
✌️

John Jung johnjjung

✌️
View GitHub Profile
@johnjjung
johnjjung / rabbitmq-autoscaler
Created December 8, 2022 21:06
Dynamically scale based on rabbitmq backlog
#!/bin/bash
namespace=""
deployment=""
function getCurrentPods() {
# Retry up to 5 times if kubectl fails
for i in $(seq 5); do
current=$(kubectl -n $namespace describe deploy $deployment | \
grep desired | awk '{print $2}' | head -n1)
@johnjjung
johnjjung / slackspotify.sh
Created September 12, 2019 15:36 — forked from jgamblin/slackspotify.sh
A Script To Set Current Spotify Song As Slack Status
#!/bin/bash
# https://gist.github.com/jgamblin/9701ed50398d138c65ead316b5d11b26
# launchctl start com.user.slack-spotify
# Get it from here : https://api.slack.com/custom-integrations/legacy-tokens
APIKEY=""
trap onexit INT
@johnjjung
johnjjung / DockerCleanupScripts.md
Created December 22, 2018 03:05 — forked from johnpapa/DockerCleanupScripts.md
Docker Cleanup Scripts

Docker - How to cleanup (unused) resources

Cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@johnjjung
johnjjung / cell-locate.cpp
Created January 28, 2017 03:26 — forked from technobly/cell-locate.cpp
Cellular Locate Test Application
/******************************************************************************
Copyright (c) 2015 Particle Industries, Inc. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@johnjjung
johnjjung / gist:9250f24d05d536f13ce6c8d6cdb67947
Last active December 21, 2016 00:45
firebase firebase key in python
def encodeAsFirebaseKey(self, string):
return string.replace(".", '%P') \
.replace("#", '%H') \
.replace("$", '%D') \
.replace("/", '%S') \
.replace("[", '%OB') \
.replace("]", '%CB')
def decodeAsFirebaseKey(self, string):
return string.replace("%P", '.') \
@johnjjung
johnjjung / firebase string to encoder
Created December 20, 2016 21:05
string encoder
function encodeAsFirebaseKey(string) {
return string.replace(/\%/g, '%25')
.replace(/\./g, '%2E')
.replace(/\#/g, '%23')
.replace(/\$/g, '%24')
.replace(/\//g, '%2F')
.replace(/\[/g, '%5B')
.replace(/\]/g, '%5D');
};
@johnjjung
johnjjung / gist:bf62dc18b189c2b9e5f687bb3e06f76b
Last active October 20, 2016 14:09
create random 32 character bash
date +%s | shasum | base64 | head -c 32 ; echo
@johnjjung
johnjjung / index.php - cors
Created August 30, 2016 19:50
Bad way to bypass cors
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
@johnjjung
johnjjung / gist:8685463e4d57bc63cc1345bc261a0089
Created July 18, 2016 13:51
Generate Flask Web App Secret Key
import os
print os.urandom(24).encode('hex')
# coding: utf-8
# Imports
import os
import cPickle
import numpy as np
import theano
import theano.tensor as T