Skip to content

Instantly share code, notes, and snippets.

@jcarlosroldan
jcarlosroldan / print-passwords.py
Created March 16, 2025 03:19
Print all Chrome passwords on Mac
# A little reminder that we're just one message prompt away from leaking all our passwords to the unknown.
import os
import sqlite3
import subprocess
import base64
import binascii
import hashlib
os.system('cp ~/Library/"Application Support"/Google/Chrome/Default/"Login Data" /tmp/chrome_login.db')
safe_storage_key = subprocess.check_output("security find-generic-password -ga 'Chrome' -w", shell=True).decode().strip()
key = hashlib.pbkdf2_hmac('sha1', safe_storage_key.encode(), b'saltysalt', 1003)[:16]
@jcarlosroldan
jcarlosroldan / Fruits policy.txt
Last active November 15, 2024 12:49
Policy for the app Fruits
# Play Store Privacy Policy for JCx64
1. Collection of Information
We collect the following types of information:
- User-Provided Information: Username (to personalize gameplay) and contact information (for support and data deletion requests).
- Automatically Collected Information: A unique identifier (generated on first use to facilitate gameplay and track progress) and game scores, such as the time taken to complete challenges.
2. Use of Information
@jcarlosroldan
jcarlosroldan / image-mapper.py
Created November 15, 2023 13:54
The script creates an HTML map showcasing images from a chosen directory.
from folium import Map, Marker, Popup
from os import listdir
from os.path import isfile
from piexif import load
from PIL import Image
from PIL.ExifTags import GPSTAGS, TAGS
from pillow_heif import read_heif
EXTENSIONS = {'jpg', 'jpeg', 'jfif', 'gif', 'png', 'webp', 'heic'}
PATH = 'your/path/here'
@jcarlosroldan
jcarlosroldan / reveal.css
Created April 13, 2023 01:57
Accurate Polaroid reveal effect
/* See in action at https://codepen.io/juancroldan/pen/vYVLYBx */
.polaroid {
background: #eeefea;
box-shadow: 0 0 .5px 1px #5415;
border-radius: 3px;
}
.polaroid img {
width: 230px;
height: 305px;
@jcarlosroldan
jcarlosroldan / filescan.cpp
Created April 13, 2023 01:54
Iteratively explore every file in a system with multiple workers, build a tree and save it as a text file
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <filesystem>
#include <thread>
#include <mutex>
#include <queue>
#include <condition_variable>
@jcarlosroldan
jcarlosroldan / server.py
Created June 21, 2022 09:18
Minimal Flask server for a JSON API
from flask import Flask
from flask.helpers import request
from traceback import format_exc
SERVER = Flask(__name__)
PORT = 5000
# SSL_CONTEXT = '/etc/ssl/certificate.crt', '/etc/ssl/private.key'
SSL_CONTEXT = None
def api(data: dict):
@jcarlosroldan
jcarlosroldan / tabber.py
Created October 27, 2021 19:41
Convert the files in a directory from space-indented to tab indented detecting the indentation level automatically
''' TABBER: Because spaces suck
This script will recursively convert all files in its directory from space indented to tab indented.
It will detect the number of spaces used for indentation and transform them into tabbed files.
Usage:
1. Copy the directory you want to convert and put this file inside. If you're brave enough, skip the
copying part.
2. Review the EXTENSIONS and IGNORE_FILES values.
3. Run it.
@jcarlosroldan
jcarlosroldan / weekday.py
Last active June 15, 2021 10:42
Weekday computation
WEEK_DAYS = 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'
def weekday(day: int, month: int, year: int) -> str: # You'd rather operate with datetimes, but this is funnier.
''' Computes the day of the week using Zeller's Congruence. '''
year_shift = year + year // 4 - year // 100 + year // 400
return WEEK_DAYS[(5 + day + (13 * (month + 1)) // 5 + year_shift) % 7]
@jcarlosroldan
jcarlosroldan / directory-listing.py
Created July 26, 2019 13:19
Minimal directory listing
from flask import Flask, send_file, request
from hashlib import sha256
from os import listdir
from os.path import join, abspath, dirname, isdir
from sys import stderr
app = Flask(__name__)
template = '<!doctype html><head><meta charset="utf-8"><title>%s</title></head><body><h1>%s</h1><ul>%s</ul></body></html>'
base = abspath('.')
salt = 'changeme' # generated with https://www.random.org/passwords/?num=1&len=24&format=html&rnd=new
@jcarlosroldan
jcarlosroldan / download_file.py
Last active October 2, 2018 19:24
Download file to local with a nice progress bar and time estimate.
from datetime import timedelta
from requests import get
from time import time
from sys import stdout
def bytes_to_human(size, decimal_places=2):
for unit in ["", "k", "M", "G", "T", "P", "E", "Z", "Y"]:
if size < 1024: break
size /= 1024
return "%s%sB" % (round(size, decimal_places), unit)