Skip to content

Instantly share code, notes, and snippets.

View claudioc's full-sized avatar

Claudio Cicali claudioc

View GitHub Profile
@claudioc
claudioc / tr_extract.py
Last active January 7, 2024 10:58
Extract information from TradeRepublic statements PDF
#!/usr/bin/env python3
from pypdf import PdfReader
import re
import pprint
re_label = "Ausführung Handel Direktkauf Kauf"
re_date = r"\d{2}\.\d{2}\.\d{4}"
re_isin = r"[A-Z]{2}[A-Z0-9]{9}[0-9]"
re_amount = r"-?\d{1,3}(?:\.\d{3})*(?:,\d{2})"
@claudioc
claudioc / mastodon_on_macbookm1.md
Last active February 1, 2023 04:38
How to run Mastodon for development on an Apple M1 Pro device

How to run Mastodon on a (early 2022) MacBookPro M1 Pro

Last updated on late November 2022.

First and foremost: do not waste your time with Vagrant (VirtualBox is not ready yet) or docker-compose (which runs a production environment)

My goal here is to run a Mastodon instance on a laptop, but using a virtual machine of some sort, so to not install a lot of dependencies on the real one. I have found out that the best solution is to use a virtual machine running (Ubuntu) Linux and follow the manual installation instructions from the official guide. The official guide assumes that you will be running the dev environment within a Linux box, but I have found that to be able to run Mastodon inside a virtual machine, several small tweaks are necessary, hence this guide.

My hardware configuration: MBP M1 Pro with 16GB

date,ts,rate
2015-01-27, 1422306000, 261.50871632545
2015-01-28, 1422392400, 252.94129752347
2015-01-29, 1422478800, 233.50756537828
2015-01-30, 1422565200, 234.11944239152
2015-01-31, 1422651600, 229.29348122967
2015-02-01, 1422738000, 219.59582099483
2015-02-02, 1422824400, 226.80453426543
2015-02-03, 1422910800, 236.74507558732
2015-02-04, 1422997200, 225.77968577082
@claudioc
claudioc / git-create-repo.sh
Last active February 20, 2021 17:13
A script to create and set a github repo up
#!/usr/bin/env bash
#
# Creates a new github repository with all our nice defaults,
# using a template repository
#
# Installation:
# - cd ~/bin
# - ln -s <this file>
# Running
# `git create-repo [name of the new repo (optional)]`
#!/usr/bin/env node
// This is a script "recipe" for releasing
// It has been inspired by yeoman generator-release
// The reason for this to exist is that I didn't want to include an external dependency (yeoman) for a 'task',
// when all the tasks of the project are managed by gulp
//
// What this recipe does:
// - Runs sanity check to see if we can release
// - are we in the `releaseEvents` branch?
// - is the working directory git-clean?
@claudioc
claudioc / gist:aed152ceebdc8936dd0f4a0009893cdc
Created January 7, 2021 18:56
Fastest way to create an EC2 machine with Amazon provided SSL certificates (?)
Since you can only use ACM provided certificates from (A/N/E)LB or CloudFormation, I think this
could be the easiest way (using ALB).
- (EC2) Create a security group that only accepts HTTPS
- (EC2) Create a security group that only accepts HTTP connection from the security group above
- (EC2) Create the EC2 instance and bind it to the the security group above
- (EC2) Create a Target Group and use the above EC2 as the target inside it
- (ACM) Create the SSL certificate in ACM (hint: you can create it directly from Route53)
- (EC2) Create an Application Load Balancer in the same EC2's AZs using the above target group and the SSL certificate
- (Route53) Edit your DNS zone to add the LB A record (use its Alias and autocomplete)
@claudioc
claudioc / secretary_problem.py
Created August 30, 2020 16:51
The secretary problem
#!/usr/bin/env python
import random
from math import e
n_runs = 1000
n_scores = 1000
score_max = 1000000
def main():
@claudioc
claudioc / drop_shadow.sh
Created May 29, 2020 17:05
Script which finds the newest screenshot image and adds a shadow to it
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
echo "Needs the filename as the first argument"
exit -1
fi
type /usr/local/bin/convert >/dev/null 2>&1 || { echo >&2 "The convert command must be available."; exit 1; }
input_filename="${1}"
@claudioc
claudioc / user.screenshot.drop_shadow.plist
Last active May 29, 2020 17:01
Plist file to execute a custom script when a directory changes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>usr.screenshot.drop_shadow</string>
<key>ProgramArguments</key>
<array>
<string>/Users/claudioc/bin/drop_shadow.sh</string>
<string>--last-screenshot</string>
import * as fs from 'fs'
import * as path from 'path'
import { promisify } from 'util'
// About returning promises inside an async ts method
// https://github.com/Microsoft/TypeScript/issues/5254
type ScanDirOptions = {
match?: RegExp
exclude?: RegExp