Skip to content

Instantly share code, notes, and snippets.

View joaompinto's full-sized avatar

João Pinto joaompinto

View GitHub Profile
#!/usr/bin/python3
# Apply multiplier to duration string ('hh:mm')
# python3 multiply_duration.py 08:30 0.9 # 90% of a day
# python3 multiply_duration.py 08:30 5 # 5 days
import sys
def multiplty_duration(duration, multiplier):

Keybase proof

I hereby claim:

  • I am joaompinto on github.
  • I am joaompinto (https://keybase.io/joaompinto) on keybase.
  • I have a public key whose fingerprint is 44C9 EAAC D815 D09B 6121 C069 D146 43C2 83C8 DDD5

To claim this, I am signing this object:

#!/usr/bin/python3
from os import statvfs
from pprint import pprint
with open('/proc/mounts') as mounts_file:
mount_data = mounts_file.read().splitlines()
pprint(mount_data)
mount_points = map(lambda x: x.split()[1], mount_data)
for mount_path in mount_points:
@joaompinto
joaompinto / basebuild.sh
Last active June 15, 2019 09:18
basebuild.sh
#!/bin/sh
udocker pull debian:stable-slim # ≃ 22MB
CID=$(udocker create --name=build debian:stable-slim) # ≃ 62MB
udocker run $CID << _EOF_
apt-get update
apt-get upgrade
apt-get install -y gcc g++ bison bzip2 gawk make patch perl python3 texinfo # ≃ 351MB
@joaompinto
joaompinto / accesslog2influxdb.yaml
Created April 12, 2019 14:45
accesslog2influxdb.yaml
start:
- read from file list: www.openpipe.org/access*
- iterate: # Produce invididual elements
# Process any filed obtained from the file list
- read from file:
path: $_$
mime_type: "text/plain"
@joaompinto
joaompinto / login.sh
Created February 18, 2016 17:07
Connect to system with expect
#!/usr/bin/expect -f
set target [lindex $argv 0];
set timeout 60
# Request the login password
stty -echo
send_user -- "Password for $target: "
expect_user -re "(.*)\n"
TXT ="""
server.1 = something
server.2 = else
alone = testing
"""
def props2dict(config_data):
lines = config_data.splitlines()
lines = [l for l in lines if '=' in l] # Ignore non formatted lines
@joaompinto
joaompinto / gist:141fa88b7912b0b32296
Created March 16, 2015 17:40
How to create a portable MSYS archive
Surviving on Windows with MSYS
If you are experienced Linux/Unix user you will get a bad time working on Windows, to my rescue comes MSYS which contains most of common utilities like tail, grep and friends. It does not require installation so it can be easily used from Windows servers.
Download the installer (mingw-get-*-bin.zip/ ) from:
http://sourceforge.net/projects/mingw/files/Installer/mingw-get/
Extract mingw-get-*-bin.zip to C:\mingw_install
From the command line:
cd C:\mingw_install\bin
mingw-get.exe install msys-mintty msys-grep msys-base msys-openssh
@joaompinto
joaompinto / etc_profile.d_history_logging.sh
Last active August 29, 2015 13:56
etc_profile.d_history_logging.sh
#!/bin/sh
# avoid duplicates..
export HISTCONTROL=ignoredups:erasedups
# append history entries..
shopt -s histappend
# After each command, save and reload history
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
readonly PROMPT_COMMAND
@joaompinto
joaompinto / etc_cron.daily_nmon
Last active August 29, 2015 13:56
Files used to setup nmon as a service
#!/bin/sh
LOGDIR=/var/log/nmon
/etc/init.d/nmon stop
find $LOGDIR -name "*.nmon" -mtime -mmin +10 -exec gzip {} \;
find $LOGDIR -name "*.nmon.gz" -mtime +90 -exec rm {} \;
/etc/init.d/nmon start