Skip to content

Instantly share code, notes, and snippets.

View xluffy's full-sized avatar
😶
&>/dev/null

xluffy xluffy

😶
&>/dev/null
View GitHub Profile
@xluffy
xluffy / gcemetadata.py
Created February 29, 2024 06:18
Query and display GCE metadata, clone from ec2metadata.py
#!/usr/bin/python3
#
# Query and display GCE metadata, clone from ec2metadata.py
#
from urllib import request as urllib_request
metadata_url = "http://metadata.google.internal/computeMetadata/v1/instance/"
{"providers":{"amazon":{"urlPattern":"^https?:\\/\\/(?:[a-z0-9-]+\\.)*?amazon(?:\\.[a-z]{2,}){1,}","rules":["p[fd]_rd_[a-z]*","qid","srs?","__mk_[a-z]{1,3}_[a-z]{1,3}","spIA","ms3_c","[a-z%0-9]*ie","refRID","colii?d","[^a-z%0-9]adId","qualifier","_encoding","smid","field-lbr_brands_browse-bin","ref_?","th","sprefix","crid","keywords","cv_ct_[a-z]+","linkCode","creativeASIN","ascsubtag","aaxitk","hsa_cr_id","sb-ci-[a-z]+","rnid","dchild","camp","creative","s"],"rawRules":["\\/ref=[^/?]*"],"referralMarketing":["tag"],"exceptions":["^https?:\\/\\/(?:[a-z0-9-]+\\.)*?amazon(?:\\.[a-z]{2,}){1,}\\/gp\\/.*?(?:redirector.html|cart\\/ajax-update.html|video\\/api\\/)","^https?:\\/\\/(?:[a-z0-9-]+\\.)*?amazon(?:\\.[a-z]{2,}){1,}\\/(?:hz\\/reviews-render\\/ajax\\/|message-us\\?|s\\?)"]},"amazon search":{"urlPattern":"^https?:\\/\\/(?:[a-z0-9-]+\\.)*?amazon(?:\\.[a-z]{2,}){1,}\\/s\\?","rules":["p[fd]_rd_[a-z]*","qid","srs?","__mk_[a-z]{1,3}_[a-z]{1,3}","spIA","ms3_c","[a-z%0-9]*ie","refRID","colii?d","[^a-z%0-9]adId","qual
@xluffy
xluffy / backup_mysql.sh
Created November 16, 2018 06:51
backup_mysql.sh
#!/bin/bash
#
# Author: @xluffy
# Purpose: Backup MySQL to local (or remote)
#
# example ~/.my.cnf
#
#[client]
#user = root
@xluffy
xluffy / postgres_queries_and_commands.sql
Created May 18, 2018 08:20 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@xluffy
xluffy / postgres_queries_and_commands.sql
Created May 18, 2018 08:20 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@xluffy
xluffy / gist:9e93412f58fb42fbcf902d150aeed848
Created May 12, 2017 04:03 — forked from afair/gist:3803895
PostgreSQL and Pgpool Architecture

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

#!/bin/bash
#
# Purpose: Install common package
# Author: @xluffy
#
# VAR
declare -a pkgs=(aptitude apt-transport-https apt-utils autoconf automake bash-completion bison
build-essential curl dialog dnsutils gcc git git-core htop iotop iputils-ping keychain
libacl1-dev libevent-dev libffi-dev libgdbm-dev liblzo2-dev libncurses5-dev libreadline6-dev
@xluffy
xluffy / docker_new_command
Created February 20, 2017 02:28
docker_new_command
docker build -- NEW --> docker image build
docker history -- NEW --> docker image history
docker images -- NEW --> docker image ls
docker import -- NEW --> docker image import
docker load -- NEW --> docker image load
docker pull -- NEW --> docker image pull
docker push -- NEW --> docker image push
docker rmi -- NEW --> docker image rm
docker save -- NEW --> docker image save
docker tag -- NEW --> docker image tag
@xluffy
xluffy / A Proper Server Naming Scheme.md
Created August 25, 2016 02:50
A Proper Server Naming Scheme

Specify Environment

  • dev – Development
  • tst – Testing
  • stg – Staging
  • prd – Production

Specify Purpose and Serial Number

  • app – Application Server (non-web)
My name is Linus, and I am your God. - Linus Torvalds
Nobody actually creates perfect code the first time around, except me. But there's only one of me. — Linus Torvalds
Software is like sex: it's better when it's free. - Linus Torvalds
Nvidia, fuck you! - Linus Torvalds
Talk is cheap. Show me the code. - Linus Torvalds
Rules of Optimization: Rule 1: Don't do it. Rule 2 (for experts only): Don't do it yet. — Michael A. Jacksno
If debugging is the process of removing software bugs, then programming must be the process of putting them in. — Edsger Dijkstra
Perl – The only language that looks the same before and after RSA encryption. — Keith Bostic
On the seventh day, God said, "Ship it! We'll release patches later. — Josh Flachsbart
It's not a bug, it's a feature! - Unknown