Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alex Lopes alexlopes

🏠
Working from home
View GitHub Profile
View k8s_tricks.md

Get Pods by Owner name

kubectl get pods -o jsonpath='{range .items[?(@.metadata.ownerReferences[0].name == "owner name")]}{.metadata.name}{"\n"}{end}'
@alexlopes
alexlopes / read-access.sql
Created Dec 3, 2020 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
View read-access.sql
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@alexlopes
alexlopes / lowvol_mac.sh
Created Jun 16, 2020
Mac Os Low Volume - Keep Input Volume Mic under 50 %
View lowvol_mac.sh
# thanks to https://apple.stackexchange.com/a/236425/379437
#!/bin/bash
while true ; do
while (( `osascript -e "input volume of (get volume settings)"` > 50 )); do
osascript -e "set volume input volume (input volume of (get volume settings) - 2)";
sleep 0.01;
done;
sleep 1;
done;
@alexlopes
alexlopes / autoupdate_ff.sh
Last active Sep 14, 2020
Autoupdate Firefox -
View autoupdate_ff.sh
#!/bin/sh
echo "Downloading latest version for linux 32bits in pt-BR"
wget -v --content-disposition "https://download.mozilla.org/?product=firefox-latest&os=linux&lang=pt-BR" -O - | tar -xvj
echo "Removing"
rm -Rf /usr/lib/firefox
@alexlopes
alexlopes / github_gpg_config.md
Created Mar 25, 2020
Github + GPG + Custom gitconfig
View github_gpg_config.md

Github + GPG + Custom gitconfig

Add includeIf directive into original .gitconfig

In the end of your original .gitconfig add includeIf with the directory where your .gitconfig-B will be applied:

# ref https://dzone.com/articles/how-to-use-gitconfigs-includeif
# when gitdir matchs, then use .gitconfig-B
View freedom.md

Change permissions

# This will recursively search your directory tree (starting at dir 'dot') and chmod 755 all directories only.
find . -type d -exec chmod 755 {} \;
#Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;
View elk_tricks.md

Delete Index

curl -u user:pass -X DELETE "localhost:9200/twitter?pretty"
@alexlopes
alexlopes / test_lowercased.py
Created Aug 8, 2019
Pyhon Test messages with all chars lowercased
View test_lowercased.py
import ast
import logging
import sys
import unittest
from io import BytesIO
class TestFormatterMessagesOutputs(unittest.TestCase):
def setUp(self):
logging.basicConfig( level=logging.INFO)
View sql.md
select a.*, b.id from 

(
       select * from (
                       select regexp_substr('TC,HBO,FUT','[^,]+',1,level) element, level as lvl
                       from dual             connect by level <= length(regexp_replace('TC,HBO,FUT','[^,]+')) + 1 
                       )   
       PIVOT ( MAX(element) FOR lvl IN (1,2,3)) mypivot 
) a, something.table b   
@alexlopes
alexlopes / slackpost
Created Feb 12, 2019 — forked from dopiaza/slackpost
Post a message to a Slack channel
View slackpost
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1