Skip to content

Instantly share code, notes, and snippets.

View brun0xff's full-sized avatar

brunoathaíde brun0xff

  • Software Engineer
  • Lisbon
View GitHub Profile
@brun0xff
brun0xff / code-tag.txt
Created June 22, 2018 14:53
TODO: FIXME, HACK, and REVIEW
# Use TODO to note missing features or functionality that should be added at a later date.
# Use FIXME to note broken code that needs to be fixed.
# Use OPTIMIZE to note slow or inefficient code that may cause performance problems.
# Use HACK to note code smells where questionable coding practices were used and should be refactored away.
# Use REVIEW to note anything that should be looked at to confirm it is working as intended.

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
{
"gcp": {
"topic_1": {
"copy-a-file-from-gcp-vm-to-local-machine": "scp -i ~/.ssh/my-ssh-key [LOCAL_FILE_PATH] [USERNAME]@[IP_ADDRESS]:~",
"copy-a-file-from-local-machine-to-gcp-vm": "scp -i ~/.ssh/my-ssh-key [USERNAME]@[IP_ADDRESS]:[REMOTE_FILE_PATH] [LOCAL_FILE_PATH]",
"link_ref": "https://cloud.google.com/compute/docs/instances/transfer-files#transferbrowser"
},
"topic_2": {
"connecting-to-instances-on-gcp": "gcloud compute ssh --project [PROJECT_ID] --zone [ZONE] [INSTANCE_NAME]",
"link_ref": "https://cloud.google.com/compute/docs/instances/connecting-to-instance"
-- An audit history is important on most tables. Provide an audit trigger that logs to
-- a dedicated audit table for the major relations.
--
-- This file should be generic and not depend on application roles or structures,
-- as it's being listed here:
--
-- https://wiki.postgresql.org/wiki/Audit_trigger_91plus
--
-- This trigger was originally based on
-- http://wiki.postgresql.org/wiki/Audit_trigger
{
"command": {
"run": "git reset --hard origin/<branch>",
"description": "Sure you are on the branch where the commit is"
}
}
@brun0xff
brun0xff / abb.c
Created March 18, 2019 22:33
árvore binária de busca e algumas funções básicas
#include <stdio.h>
#include <stdlib.h>
typedef struct tipoNo {
int valor;
char op;
struct tipoNo *esq;
struct tipoNo *dir;
} tipoNo;

Funções de procura

/<expressão> => começa a procura pelo início do arquivo do termo "expressão"
?<expressão> => começa a procura pelo final do arquivo do termo "expressão"
n => procura a próxima palavra
N => inverte o sentido da procura 

Movimentação e inserção de texto

:3,9d => apaga as linhas de 3 a 9

1 - Ao adicionar um documento (dicionário) no Elasticsearch utilizando o método:

for ok, result in streaming_bulk(self.client, self.start_data_streaming(),
                                 index=self.index_name, doc_type=self.doc_type,
                                 chunk_size=self._CHUNK_SIZE):
    action, result = result.popitem()
    doc_id = '/%s/doc/%s' % (self.index_name, result['_id'])

Por exemplo:

@brun0xff
brun0xff / read-data-from-storage-to-bq.py
Last active July 8, 2018 00:28
read data from google storage bucket to google cloud datalab --python3.x and jupyter-notebook
# How to read data from Google storage cloud to Google cloud datalab
import google.datalab.storage as storage
import pandas as pd
from io import BytesIO
mybucket = storage.Bucket('BUCKET_NAME')
data_csv = mybucket.object('data.csv')
uri = data_csv.uri

Uma boa prática é ao capturar exceções, mencionar sempre que possível as exceções específicas, em vez de usar apenas except Exception. Exemplo:

try:
    import platform_specific_module
except ImportError:
    platform_specific_module = None