Skip to content

Instantly share code, notes, and snippets.

View Pictor13's full-sized avatar
🤹‍♂️
Juggling with curiosity

Igor Pellegrini Pictor13

🤹‍♂️
Juggling with curiosity
  • BerlinOnline Stadtportal GmbH & Co. KG
  • Berlin
View GitHub Profile
@Pictor13
Pictor13 / phpenv-install.md
Last active October 6, 2022 13:55 — forked from sergeyklay/phpenv-install.md
Multiple PHP versions using phpenv and php-build

Multiple PHP versions using phpenv and php-build

Install dependecies

Debian/Ubuntu users

sudo apt install \
  autoconf \
  bison \
@Pictor13
Pictor13 / TimeMachine_double_backup_README.md
Created September 15, 2022 02:19
TimeMachine: 2 backup copies, on the cloud (OneDrive) and on external hard-drive.

To trick OneDrive in backing up TimeMachine's backup, we use a SparseBundle filesystem (explorable) image/file, as it supports differential upload. The partition of the SSD (that contains the backup as a file) is symlinked inside the OneDrive folder (using fstab) so its content (the sparsebundle) gets synced AND is actually stored on the SSD partition (without taking space on the machine).

Create a TimeMachine.sparsebundle first, using Disk Utility:

  • set filesystem to Journaled HFS+ - Mac OS Extended (Journaled) (NOT Case-Sensitive)
  • choose "sparse bundle" as image-format
  • use a GUID partition map
  • give name "TimeMachineMac10" (is the mounting name, it will be used below from tmutil-setdestination!)
@Pictor13
Pictor13 / UsefulExtensions.kt
Last active January 5, 2022 20:13
Kotlin - Extension functions
// Int <--> Boolean
fun Boolean.toInt() = if (this) 1 else 0
fun Int.toBoolean() = if (this == 0) 0 else 1
// Int <--> Binary bit
fun Int.toBit() = this.mod(2).toBoolean().toInt()
fun Int.toBinaryString() = this.toString(2)
fun Int.toPaddedBinaryString() = this.toString(2).padStart(Int.SIZE_BITS, '0')
fun Int.toXaryString(baseX: Int) = this.toString(baseX)
@Pictor13
Pictor13 / fowler.md
Created November 11, 2021 13:49 — forked from danilobatistaqueiroz/fowler.md
Notes from Martin Fowler's "Refactoring"

Refactoring, Fowler

http://martinfowler.com/books/refactoring.html

Five or six years ago I was working on an essay about refactoring CSS. I didn't do that, but I did find these notes while working on something new. Hope they're useful! —Dean

p7 "When you find you have to add a feature to a program, and the program's code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature."

p7

@Pictor13
Pictor13 / php-docker-ext
Created October 28, 2021 01:47 — forked from hoandang/php-docker-ext
Complete list of php docker ext
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
@Pictor13
Pictor13 / Tampermonkey.FuckOffYoutube
Last active December 3, 2020 19:30
Youtube: press "Y" to watch /embed video version. Remove distractions, cookies/privacy requests (you can µBlock all now), useless comments, dopamine-dealers video-suggestions, and all that useless stuff that tracks you.
// ==UserScript==
// @name Youtube Fucookies
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Fuck off Youtube attempts to get your cookies. Press "Y" for going to /embed page and just watch the damn thing.
// @author Igor Pellegrini
// @include /^https?\:\/\/.*youtube\..*\/.*\?.*v=[^&]+.*$/
// @grant GM_log
// ==/UserScript==
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes (needs to be ran as root):
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@Pictor13
Pictor13 / remove-google-ads-from-serp.js
Last active May 9, 2024 16:09
Tampermonkey userscript to remove the annoying first fake results (they are ADs), form Google SERP
// ==UserScript==
// @name remove-google-ads
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove ADs fake-search-results on Google SRP
// @author Igor Pellegrini
// @include /^https?\:\/\/.*.google\..*\/search.*$/
// @grant GM_log
// ==/UserScript==
@Pictor13
Pictor13 / git-tag++
Last active September 12, 2018 18:20
Bash script to increment and add a new git-tag (according to 'semver') [e.g.: "git tag++ -p"]
#!/bin/bash
# Increment a version string using Semantic Versioning (SemVer) terminology, and adds it to git-tags
# - Customised from: https://github.com/fmahnke/shell-semver/blob/master/increment_version.sh)
# INSTALL: put the script in a PATH directory. 'git' will recognize automatically the new command.
# USAGE: "git tag++ -p"
# "git tag++ -Mp"
# BEWARE: "git describe" returns the last-tag JUST for the current tree!
# if amend a commit the SHA will change and the eventual tag will still point to the old unchanged commit
@Pictor13
Pictor13 / AgaviWebRouting.md
Last active July 18, 2018 13:53
Notes about AgaviRouting
  • input parameters are the input in the querystring. extraParams dunno yet. usedParams are the params provided to url generation method.
  • agavi doesn't filter the just valid parameters; if you add &foo=bar it will end in the result of gen(nullRoute)
    • (any parameter to just pass the validated parameters?)
  • AgaviWEBrouting encodes with rawurlencode by default (to test it try to create an AgaviRoutingValue with routing->createValue. One of the params should be to explicitly choose encoding or not.
  • fillGenNullParameters() returns getMatchedParameters(), that are the $url_params passed to routing->gen(route, url_params) E.g. {"firstchar":"a","baseSearch":"ricerca","baseVenue":"luoghi","basePath":"\/it\/biglietti"}