Skip to content

Instantly share code, notes, and snippets.

View alexlopes's full-sized avatar
🏠
Working from home

Alex Lopes alexlopes

🏠
Working from home
View GitHub Profile
@alexlopes
alexlopes / github_gpg_config.md
Created March 25, 2020 15:05
Github + GPG + Custom gitconfig

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
@alexlopes
alexlopes / docker_tricks.md
Last active February 11, 2020 03:06
Docker Tricks

Run Docker without Sudo

Add the docker group if it doesn't already exist.

sudo groupadd docker

Add the connected user "${USERNAME}" to the docker group.

sudo gpasswd -a ${USERNAME} docker

Add your user to the docker group.

sudo usermod -aG docker $USER

@alexlopes
alexlopes / freedom.md
Created October 24, 2019 14:31
freedom

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 {} \;
@alexlopes
alexlopes / elk_tricks.md
Created August 14, 2019 21:42
ELK Tricks

Delete Index

curl -u user:pass -X DELETE "localhost:9200/twitter?pretty"
@alexlopes
alexlopes / test_lowercased.py
Created August 8, 2019 19:33
Pyhon Test messages with all chars lowercased
import ast
import logging
import sys
import unittest
from io import BytesIO
class TestFormatterMessagesOutputs(unittest.TestCase):
def setUp(self):
logging.basicConfig( level=logging.INFO)
@alexlopes
alexlopes / sql.md
Created March 14, 2019 17:39
SQL Tricks
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 February 12, 2019 17:10 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/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
@alexlopes
alexlopes / python_tricks.md
Last active December 31, 2018 13:16
Python Tricks

Setup

Installing pip in-line

sudo curl -s  https://bootstrap.pypa.io/get-pip.py  | sudo  python - 'pip<10'

Code Inspect

@alexlopes
alexlopes / my_graph.md
Created December 18, 2018 14:15
my graph
@alexlopes
alexlopes / pygh.py
Created December 5, 2018 13:15
Python and GitHub snippets
if __name__ == '__main__':
pass