Skip to content

Instantly share code, notes, and snippets.

View KrustyHack's full-sized avatar
💭
┬─┬ ノ( ゜-゜ノ)

Nicolas Hug KrustyHack

💭
┬─┬ ノ( ゜-゜ノ)
View GitHub Profile
@KrustyHack
KrustyHack / gist:e9e7aca1d57d79c663caf7984874d4db
Created January 21, 2022 15:33
Jenkins dump credentials to plaintext
import com.cloudbees.plugins.credentials.CredentialsProvider
import com.cloudbees.plugins.credentials.Credentials
import com.cloudbees.plugins.credentials.domains.Domain
import jenkins.model.Jenkins
def indent = { String text, int indentationCount ->
def replacement = "\t" * indentationCount
text.replaceAll("(?m)^", replacement)
}
Jenkins.get().allItems().collectMany{ CredentialsProvider.lookupStores(it).toList()}.unique().forEach { store ->
@KrustyHack
KrustyHack / README.md
Created January 21, 2022 15:33
Removing sensitive data from a repository

Run the following command, replacing PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA with the path to the file you want to remove, not just its filename. These arguments will:

  • Force Git to process, but not check out, the entire history of every branch and tag
  • Remove the specified file, as well as any empty commits generated as a result
  • Overwrite your existing tags
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' --prune-empty --tag-name-filter cat -- --all
@KrustyHack
KrustyHack / gist:887720a6908290bf4f800b3c40797532
Created January 21, 2022 15:32
Docker images used in Kubernetes cluster
kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s '[[:space:]]' '\n' | grep -v gcr.io | sort | uniq -c
@KrustyHack
KrustyHack / gist:b454c79abea884f06c45fda80691dce6
Created January 21, 2022 15:31
Docker image check GCR cache
# Verify whether ubuntu is in our cache
gcloud container images list --repository=mirror.gcr.io/library | grep ubuntu
# List all tagged versions of ubuntu currently in the cache
gcloud container images list-tags mirror.gcr.io/library/ubuntu
@KrustyHack
KrustyHack / README.md
Created January 21, 2022 15:30
ArgoCD disaster recovery

Disaster Recovery

You can use argocd-util to import and export all Argo CD data.

Make sure you have ~/.kube/config pointing to your Argo CD cluster.

Figure out what version of Argo CD you're running:

argocd version | grep server
@KrustyHack
KrustyHack / range.sh
Created January 21, 2022 15:29
Google Cloud Platform IP addresses range
#!/bin/bash
# https://cloud.google.com/compute/docs/faq#find_ip_range
# nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8
myarray=()
for LINE in `dig txt _cloud-netblocks.googleusercontent.com +short | tr " " "\n" | grep include | cut -f 2 -d :`
do
myarray+=($LINE)
for LINE2 in `dig txt $LINE +short | tr " " "\n" | grep include | cut -f 2 -d :`
@KrustyHack
KrustyHack / search.sh
Last active January 5, 2022 09:13
Find GCP bucket accross projects
gcloud projects list --format="value(PROJECT_ID)" | xargs -n1 -t -I% gsutil ls -p % -b gs://*private*
# Credits : https://github.com/fjomier
@KrustyHack
KrustyHack / README.md
Last active January 4, 2022 15:12
Ichibot Commands

Ichibot useful commands (FTX)

If using AlphaBot, prefix all commands with x.

Switch to all instrument :

instrument *
replace buyusd amount: buy amount/askprice
replace sellusd amount: sell amount/bidprice
replace p: position list
@KrustyHack
KrustyHack / databases-sizes.sh
Last active July 2, 2021 12:55
Cloud SQL MySQL - 5 biggest databases
SELECT TABLE_SCHEMA AS `Database`, TABLE_NAME AS `Table`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)` FROM information_schema.TABLES ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC LIMIT 5;