Skip to content

Instantly share code, notes, and snippets.

Avatar

Giovanni Frigo GiovanniFrigo

View GitHub Profile
@GiovanniFrigo
GiovanniFrigo / config\functions\config.json
Last active Jul 20, 2020
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)
View config\functions\config.json
{
"enabled": true,
"provider": "local",
"providerOptions": {
"sizeLimit": 10737418240
}
}
@GiovanniFrigo
GiovanniFrigo / stillalive.rc
Last active Apr 12, 2019 — forked from rawdatalab/stillalive.rc
STILL ALIVE as a Bash script with beep (didn't create, just sharing) - sox version
View stillalive.rc
# 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 / pruning merged remote branches.md
Last active Mar 3, 2020
Pruning merged branches on a git repository
View pruning merged remote branches.md

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 / breakSentenceAtPos.js
Created May 7, 2018
Simple function to break a sentence around a certain position without breaking the words (only at whitespaces)
View breakSentenceAtPos.js
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 / Execute this on shell.sh
Last active Nov 12, 2018
Adding a new user to a Ubuntu/Debian server
View Execute this on shell.sh
# 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 / crontab configuration (`crontab -e`)
Last active Jan 19, 2019
Crontab configuration of my MBP. Let's add some small automation here!
View crontab configuration (`crontab -e`)
# 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 / excel_to_json.py
Last active Mar 30, 2016
Creates json files from each column of a given xlsx file
View excel_to_json.py
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 / .profile
Last active May 15, 2018
My own .profile file
View .profile
####
# 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 / find_jpg_rec.py
Created Nov 17, 2015
Generate html file from images in a directory (recursive)
View find_jpg_rec.py
#!/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 += "/"