Skip to content

Instantly share code, notes, and snippets.

@felipou
felipou / bench_zdiff.py
Last active December 2, 2020 23:49
Simple benchmark for zdiff/zunion/zinter
import random
import re
import string
import pickle
import redis
ZADD_BATCH_SIZE = 2000
r = redis.Redis(port=6380)
# Existing tests
test "BRPOPLPUSH with zero timeout should block indefinitely" {
set rd [redis_deferring_client]
r del blist target
r rpush target bar
$rd brpoplpush blist target 0
wait_for_condition 100 10 {
[s blocked_clients] == 1
@felipou
felipou / tobase64mime.py
Created February 29, 2020 15:02
Convert image from URL to base64 and also prints the mime type
# Requires python-magic, which requires the native libmagic lib
# I installed both on macOS with:
# - pip3 install python-magic
# - port install libmagic
#
# To run:
# python3 tobase64mime.py http://imagedomain.com/file.jpeg
import sys
@felipou
felipou / decrypt_dbeaver.py
Last active March 18, 2024 18:46
DBeaver password decryption script - for newer versions of DBeaver
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
# requires pycryptodome lib (pip install pycryptodome)
import sys
import base64
import os
import json
from Crypto.Cipher import AES
@felipou
felipou / decrypt_dbeaver.py
Last active January 24, 2024 14:11
DBeaver password decryption script
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
import sys
import base64
print(sys.argv[1])
PASSWORD_ENCRYPTION_KEY = b"sdf@!#$verf^wv%6Fwe%$$#FFGwfsdefwfe135s$^H)dg"
@felipou
felipou / datetime_format_string.cpp
Created April 10, 2018 15:15
C/C++ Datetime Format String Performance Tests
/*
Just compile with g++ datetime_format_string.cpp -std=c++11
Tested on GCC 5.4.0 on Ubuntu 16.04
*/
#include <iostream>
#include <chrono>
#include <sys/time.h>
#include <stdio.h>
@felipou
felipou / retry.sh
Last active January 19, 2024 10:24
Retry command
#!/bin/bash
#
# Created by Felipe Machado - 2016/02/14
#
# A retry command for bash
# Retries the given command up to MAX_RETRIES, with an interval of SLEEP_TIME
# between each retry. Just put it on your bash_profile and be happy :)
# Usage:
# retry [-s SLEEP_TIME] [-m MAX_RETRIES] COMMAND_WITH_ARGUMENTS
#
@felipou
felipou / gist:6423969
Created September 3, 2013 13:33
Jump utility auto-completion for Mac OS X
# jeroen janssens' jump utility
# http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
# tab completion for bash on Mac OS X
# I just modified the find command to pipe to the 'basename' command,
# because find on BSD doesn't support the 'printf' option
# I didn't test it on Linux, but it should probably work
_completemarks() {
@felipou
felipou / bloggergist.html
Created October 2, 2012 15:34
Gist on Blogger dynamic views
<!-- You should replace GistID with the id of the gist you want! -->
<div class="gistLoad" data-id="GistID" id="gist-GistID">Loading ....</div>
<!-- This script does the magic! -->
<script src="https://raw.github.com/moski/gist-Blogger/master/public/gistLoader.js" type="text/javascript"></script>
@felipou
felipou / humblebundle_checksums.txt
Created September 27, 2012 19:40
Humble Bundle 6 Files checksums
5e247a6d223a41922b89cb7c0eb21dc6 BIT.TRIPRUNNER_WebSetup.exe
3e7d1b38e4c0c758b18c5ae545703eb4 BIT.TRIPRUNNER.dmg
1b7ede1f3ecc6b329908075272ae6296 gaijin_games_bit.trip_runner_official_soundtrack_mp3.zip
0f19fc4796005b56cd18c08a0c1f729b gaijin_games_bit.trip_runner_official_soundtrack_flac.zip
377db5f7217dd968c4b065f4f6bf0148 bit.trip.runner-linux-1.0-4_i386-1348702546.deb
cfd56600fee27ad127bdd0289afd65a0 bit.trip.runner-linux-1.0-4_amd64-1348702546.deb
900019b5994e1b8b2e08fcf07d9c1c08 bit.trip.runner-linux-1.0-4_i386-1348702546.tar.gz
026712ac29972467f0b167a3eeaa3933 bit.trip.runner_1.0-4_amd64-1348702546.tar.gz
9158eccc1ce94c9f34ccc8fe6c49f8dd dustforce-win-1347945918.zip
89bede45bbdb1ecca6cc6b8d22ff2e2b dustforce-mac-1347945918.zip