Skip to content

Instantly share code, notes, and snippets.

@roldan
roldan / twitter_threads.py
Created May 24, 2023 01:13
Download twitter threads from an account to csv file
import tweepy
import csv
import time
consumer_key = 'xxxxxx'
consumer_secret = 'xxxxxx'
access_token = 'xxxx-xxxxxxxxxxx'
access_token_secret = 'xxxxxxxxx'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@roldan
roldan / redis-pretty-print.sh
Last active May 24, 2023 01:14
Bash command to pretty print a redis json output
redis-cli --no-auth-warning json.get KEY:EXAMPLE | sed 's/\\//g' | sed 's/"$//g' | sed 's/^"//g' | sed 's/..$//g'
@roldan
roldan / extract_strike_from_symbol.py
Last active May 6, 2022 18:35
Extraer strike de tickers de opciones BYMA
import re
def extract_strike_from_symbol(symbol, underlying_price):
strike = re.findall('[\d\.]+', symbol)[0].strip('.')
if len(strike) > 4 and '.' not in strike:
s1 = float(strike[:4] + '.' + strike[4:])
s2 = float(strike[:3] + '.' + strike[3:])
diff1 = abs((float(underlying_price) / s1 - 1) * 100)
diff2 = abs((float(underlying_price) / s2 - 1) * 100)
strike = s1 if diff1 < diff2 else s2
@roldan
roldan / gist:32014a6d4ddd884e42e7643f4b883d66
Created June 11, 2021 20:55
`docker ps` with custom format to show containers names with their ip addresses and ports
$ docker ps -q | xargs -n 1 docker inspect --format '{{.Name}}\TAB{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}\TAB{{range $p, $conf := .NetworkSettings.Ports}}{{$p}} {{end}}' | sed 's/\///' | column -t -s '\TAB'
postgres11-main 172.18.0.4 5432/tcp
mysql-main 172.18.0.2 3306/tcp 33060/tcp
postgres9.6-main 172.18.0.3 5432/tcp