Skip to content

Instantly share code, notes, and snippets.

View pirafrank's full-sized avatar
🎯
Focusing

Francesco Pira pirafrank

🎯
Focusing
View GitHub Profile
@pirafrank
pirafrank / firewalld_rules.sh
Last active October 10, 2018 12:32
basic firewalld rules
# basic firewalld rules and commands
# check if running
# systemctl status firewalld
# firewall-cmd --state
# list ports
# firewall-cmd --list-all
# firewall-cmd --list-all --zone=public
# firewall-cmd --list-all --zone=public --permanent
@pirafrank
pirafrank / iptables_rules.sh
Last active April 20, 2020 14:19
basic iptables rules
# iptables basic rules to use (in order)
# set default policy to drop
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
# enable ssh on port 22
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
@pirafrank
pirafrank / docker_jessie.sh
Last active May 28, 2018 16:02
Install Docker on Debian Jessie (Debian 8.x)
#!/bin/bash
# install latest docker-ce release on debian jessie (debian 8.x) or newer
# you need to run this script as root
apt-get update
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
@pirafrank
pirafrank / notes.sh
Created December 13, 2017 18:49
A dummy way to take notes in bash
#!/bin/bash
# @Description: A simple notetaking solution in your CLI
# @Author: Francesco Pira (dev[at]fpira[dot]com)
#
# Usage:
# 1) set an alias like this in your .zshrc or .bashrc:
# alias notes='bash /where/your-script-is/notes.sh'
# 2) notes (ls|new|del|sync|syncinit) [note title]"
#
@pirafrank
pirafrank / instagram_download.py
Last active October 27, 2020 08:28
Use Pythonista to download an image from Instagram. Usage via the share extension or run it straight from your home screen (in this case it will get the url from the iOS clipboard). Save this file in the 'This Phone' path in Pythonista, then download this shortcut: https://www.icloud.com/shortcuts/d45759eb469b445b943049bf8488e995
#!python2
# this script is for Pythonista 2 and 3
# author: Francesco Pira (fpira.com)
import sys
import requests
from bs4 import BeautifulSoup
import re
import clipboard
@pirafrank
pirafrank / install_couchdb_jessie.sh
Created March 4, 2017 16:39 — forked from MatthieuLemoine/install_couchdb_jessie.sh
Install CouchDB from source on Debian Jessie
#!/bin/bash
# Inspired by http://verbally.flimzy.com/install-couchdb-1-6-1-debian-8-2-jessie/
# Erlang
echo -e "deb http://packages.erlang-solutions.com/debian jessie contrib" | sudo tee /etc/apt/sources.list.d/erlang-solutions.list
wget -qO - http://packages.erlang-solutions.com/debian/erlang_solutions.asc | sudo apt-key add -
# Update packages
sudo apt-get update
@pirafrank
pirafrank / imagecompress.sh
Last active February 17, 2018 15:52
compress images to 85% quality (great quality/size ratio) using image_magick. Great to add DSLR pics to iCloud Photo Sync or similar services and save space.
#!/bin/bash
WORKDIR="${1%/}"
cd "$WORKDIR"
if [[ ! ./ -ef $WORKDIR ]]; then
echo "Error: cannot open given dir ($WORKDIR). Exiting..."
exit 1
fi

Last updated: 2015-08-11

Searching for Files

Find images in a directory that don't have a DateTimeOriginal

exiftool -filename -filemodifydate -createdate -r -if '(not $datetimeoriginal) and $filetype eq "JPEG"' .

###Output photos that don't have datetimeoriginal to a CSV### Note this can take a long time if you have a lot of jpgs

@pirafrank
pirafrank / .lftp.mockup.rc
Created December 10, 2016 12:05 — forked from gaubert/.lftp.mockup.rc
~/.lftp.rc parameters detailed
########## SETTINGS
# On startup, lftp executes ~/.lftprc and ~/.lftp/rc. You can place aliases and 'set' commands
# there. Some people prefer to see full protocol debug, use 'debug' to turn the debug on.
# Certain commands and settings take a time interval parameter. It has the format Nx[Nx...], where N is time amount
# (floating point) and x is time unit: d - days, h - hours, m - minutes, s - seconds. Default unit is second. E.g.
# 5h30m or 5.5h. Also the interval can be 'infinity', 'inf', 'never', 'forever' - it means infinite interval. E.g.
# 'sleep forever' or 'set dns:cache-expire never'.
@pirafrank
pirafrank / youtube-uploader-cli.sh
Created November 14, 2016 12:33
Quick script to automate video upload from CLI to YouTube. Replace 'francesco' with your own username.
#!/bin/bash
# Quick script to automate video upload from CLI to YouTube.
# More info and requirements at https://github.com/tokland/youtube-upload
# BEFORE starting: replace 'francesco' with your own username to make it work!
if [[ $# != 3 ]]; then
echo "Error: wrong number of arguments. It should be 3, you put $#."
echo "Usage: ./youtube-uploader-cli.sh [video title] [video path] [public | unlisted | private]"
exit -1