Skip to content

Instantly share code, notes, and snippets.

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

bruvio bruvio

🏠
Working from home
View GitHub Profile

If you edit or create a file in windows and try to use it in Linux, we will have "\r\n" instead of "\n" at the EOL

to remove this error

sed -i 's/\r//g' good_wav.txt

Extract a .tar.gz file to a specific folder

tar -xf archive.tar.gz -C /home/linuxize/files
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
@bruvio
bruvio / athena-example.py
Created May 21, 2021 19:43 — forked from stephenconnolly1/athena-example.py
Example Python script to create athena table from some JSON records and query it
import boto3
import time
import json
import pprint
import sys
# Defaults
query_output = 's3://platform-prd-my-athena-output-bucket/outputs'
pp = pprint.PrettyPrinter(indent=2)
queryparams = {}
@bruvio
bruvio / athena_boto3.py
Created May 21, 2021 19:42 — forked from ilkkapeltola/athena_boto3.py
query Athena using boto3
import boto3
import pandas as pd
import io
import re
import time
params = {
'region': 'eu-central-1',
'database': 'databasename',
'bucket': 'your-bucket-name',
@bruvio
bruvio / dlAttachments.py
Created October 22, 2018 21:48 — forked from mjseeley/dlAttachments.py
Forked to add downloading of files with the same name and different contents. | WARNING: [messy code]
# Download ALL attachments from GMail
# 1. Script needs to be run via console not in an IDE, getpass.getpass() will fail otherwise.
# https://docs.python.org/2/library/getpass.html
# 2. Make sure you have IMAP enabled in your GMail settings.
# https://support.google.com/mail/troubleshooter/1668960?hl=en
# 3. If you are using 2 step verification you may need an APP Password.
# https://support.google.com/accounts/answer/185833
# 4. Reference information for GMail IMAP extension can be found here.
# https://developers.google.com/gmail/imap_extensions
@bruvio
bruvio / gmail.py
Created October 22, 2018 21:48 — forked from jasonrdsouza/gmail.py
Python script to access a gmail account and download particular emails
import email, getpass, imaplib, os
detach_dir = '.' # directory where to save attachments (default: current)
user = raw_input("Enter your GMail username:")
pwd = getpass.getpass("Enter your password: ")
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select("cs2043") # here you a can choose a mail box like INBOX instead
@bruvio
bruvio / dlAttachments.py
Created October 22, 2018 21:47 — forked from baali/dlAttachments.py
Python script to download all gmail attachments.
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'