Skip to content

Instantly share code, notes, and snippets.

View GiovanniFrigo's full-sized avatar

Giovanni Frigo GiovanniFrigo

View GitHub Profile
@GiovanniFrigo
GiovanniFrigo / find_jpg_rec.py
Created November 17, 2015 09:53
Generate html file from images in a directory (recursive)
#!/usr/bin/python2.7
from os import listdir, makedirs, path
from shutil import copy
f = open('output.html', 'w')
def process(directory):
if not directory.endswith( '/' ):
directory += "/"
@GiovanniFrigo
GiovanniFrigo / .profile
Last active May 15, 2018 14:26
My own .profile file
####
# Run source ~/.profile to make changes in this file effective
####
# alias ll, if not already present
alias ll='ls -lah'
# I like this colour schema for `ls`
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
@GiovanniFrigo
GiovanniFrigo / excel_to_json.py
Last active March 30, 2016 12:33
Creates json files from each column of a given xlsx file
try:
import openpyxl
except ImportError:
print ("openpyxl must be installed to run the script. [ pip install openpyxl ]")
exit(-1)
from openpyxl import load_workbook
from openpyxl import workbook
import sys
from os import path, makedirs
@GiovanniFrigo
GiovanniFrigo / crontab configuration (`crontab -e`)
Last active January 19, 2019 14:31
Crontab configuration of my MBP. Let's add some small automation here!
# Delete Screen Shots taken more than an hour ago. Keeps my Desktop clean :)
*/15 * * * * find $HOME/Desktop/Screen\ Shot*.png -mtime +1h -exec rm '{}' \; 2>/dev/null
*/15 * * * * find $HOME/Desktop/Screenshot*.png -mtime +1h -exec rm '{}' \; 2>/dev/null
@GiovanniFrigo
GiovanniFrigo / Execute this on shell.sh
Last active November 12, 2018 14:49
Adding a new user to a Ubuntu/Debian server
# Let' add Mario to the server
# Add the user with the interactive shell
adduser mario
# Check the creation of the user home directory
ls -al /home/mario/
# and set the default console to bash
chsh -s `which bash` mario
@GiovanniFrigo
GiovanniFrigo / breakSentenceAtPos.js
Created May 7, 2018 08:55
Simple function to break a sentence around a certain position without breaking the words (only at whitespaces)
function breakSentence(sentence, len) {
const r = new RegExp(`.{1,${len}}[^\\s]*`,'g');
let chunk;
let splitted = [];
while ((chunk = r.exec(sentence)) !== null) {
splitted.push(chunk[0].trim());
}
return splitted;
}
@GiovanniFrigo
GiovanniFrigo / pruning merged remote branches.md
Last active March 3, 2020 10:36
Pruning merged branches on a git repository

Pre: ensure you are on your main branch (usually master or devel) and that everything is up-to-date with your origin

git checkout master
git fetch

To list all the merged branches, use

@GiovanniFrigo
GiovanniFrigo / stillalive.rc
Last active April 12, 2019 13:42 — forked from rawdatalab/stillalive.rc
STILL ALIVE as a Bash script with beep (didn't create, just sharing) - sox version
# Let 'em know that we're Still Alive
# http://pastebin.com/f72f8f72d (no longer valid)
# On macOS, install sox with brew: `brew install sox`
#!/bin/bash
echo -n "This "
play --no-show-progress --null --channels 1 synth 0.200 sine 784
echo -n "was "
play --no-show-progress --null --channels 1 synth 0.200 sine 740
echo -n "a "
@GiovanniFrigo
GiovanniFrigo / config\functions\config.json
Last active July 20, 2020 16:53
Random collection of strapi config files to try to solve the maxFileSize issue (filenames have reverse slash because gists filenames can't have slashes in their name)
{
"enabled": true,
"provider": "local",
"providerOptions": {
"sizeLimit": 10737418240
}
}