Skip to content

Instantly share code, notes, and snippets.

Avatar

Claudio Cicali claudioc

View GitHub Profile
@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
View mastodon_on_macbookm1.md

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

View BTC historic data up to may 2021
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
View git-create-repo.sh
#!/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)]`
View release.js
#!/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 (?)
View gist:aed152ceebdc8936dd0f4a0009893cdc
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
View secretary_problem.py
#!/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
View drop_shadow.sh
#!/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
View user.screenshot.drop_shadow.plist
<?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>
View fs-api.ts
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
View gist:0e7b1f85eb3449258faf8cb94ea8a2c7
-- Contenuto del tsconfig.json
{
// Enable support for importing CommonJS modules targeting es6 modules
"esModuleInterop": true,
// When using above interop will get missing default export error from type check since
// modules use "export =" instead of "export default", enable this to ignore errors.
"allowSyntheticDefaultImports": true
}