Skip to content

Instantly share code, notes, and snippets.

@blakefallow
blakefallow / copy_indexes.js
Created June 18, 2024 18:45
copy mongodb indexes
const sourceDbName = "db1";
const targetDbName = "db2";
const sourceDb = db.getSiblingDB(sourceDbName);
const targetDb = db.getSiblingDB(targetDbName);
const collections = sourceDb.getCollectionNames();
collections.forEach(function(collectionName) {
const indexes = sourceDb[collectionName].getIndexes();
kubectl get po --all-namespaces -o json --field-selector="status.phase!=Running" | jq '.items[] | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c
@blakefallow
blakefallow / role-deis-router.yaml
Created October 17, 2018 20:39
role-deis-router.yaml
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: deis
name: deployments-secrets
rules:
- apiGroups: ["extensions", "apps", ""]
resources: ["deployments", "secrets"]
verbs: ["get", "list"]
@blakefallow
blakefallow / clusterrole-deis-router.yaml
Created October 17, 2018 20:38
clusterrole-deis-router.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: deis
name: list-services
rules:
- apiGroups: [""]
resources: ["services", "endpoints", "pods"]
verbs: ["get", "list"]
kubectl get po -a --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete po \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c
@blakefallow
blakefallow / gist:8870d7dddff9b54924a224d4f75ec959
Created January 18, 2018 19:12
Find long running queries
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120)
FROM information_schema.processlist
WHERE command <> 'Sleep'
AND info NOT LIKE '%PROCESSLIST%'
ORDER BY time DESC LIMIT 50;
```json
{
"body": {
"key": {
"eldest_kid": "0120a9bbf79487f5e63072e8979cad3f91a9e7eb1dcec7ec1fea9d21c17c9472ff040a",
"fingerprint": "e41a633d40b4cda56dc0696f15bea5b330610e0b",
"host": "keybase.io",
"key_id": "15bea5b330610e0b",
"kid": "01016eab16f55167ee58a2f6faa48e606c4cf67a6f0941e21dd79c70df1dcc28cd330a",
"uid": "acfa70f4b862ea840e7c985931e70319",
@blakefallow
blakefallow / copydir.sh
Created November 9, 2017 13:07
copy directory structure, no files
find -type d -links 2 -exec mkdir -p "/path/to/backup/{}" \;
@blakefallow
blakefallow / Installs NR Infrastructure daemon (debian)
Created September 26, 2017 20:41
Install New Relic Infrastructure
#/bin/bash
echo "license_key: YOUR_LICENSE_KEY" | sudo tee -a /etc/newrelic-infra.yml && \
curl https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | sudo apt-key add - \
&& sudo apt-get update && sudo apt-get install newrelic-infra -y
@blakefallow
blakefallow / gist:31bb08eb8f31801ddf5a6b4771fd44f5
Created September 16, 2017 18:55
Parse magentic CC data from USB reader
var pattern=new RegExp("^\%B(\d+)\^(\w+)\/(\w+)\^\d+\?;\d+=(\d\d)(\d\d)\d+$");
var match = pattern.exec(card_data);
card_number = match[1];
first_name = match[3];
last_name = match[2];
exp_date = match[5] + "/" + match[4];