Skip to content

Instantly share code, notes, and snippets.

View dipietrantonio's full-sized avatar
🏠
Working from home

Cristian Di Pietrantonio dipietrantonio

🏠
Working from home
View GitHub Profile
#!/bin/bash
# Copyright: Pawsey Supercomputing Research Centre
# Author: Cristian Di Pietrantonio
# NOTE!! Must be run on a compute node with at least one GPU for it to detect the architecture.
AMBER_SRC_DIR=$MYSCRATCH/amber_src
BUILD_DIR=$MYSCRATCH/amber_build_automated
INSTALL_DIR=$MYSCRATCH/amber_install_automated
amber_tools_src=$AMBER_SRC_DIR/AmberTools22jlmrcc.tar.bz2
amber_src=$AMBER_SRC_DIR/Amber22.tar.bz2
@dipietrantonio
dipietrantonio / cf.py
Last active November 23, 2022 08:19
cf.py - recursively count the files within a directory tree, displaying directories with the highest file count.
#!/usr/bin/env python3
import os
import os.path
from contextlib import suppress
import argparse
def visit(path, state):
if os.path.isdir(path):
#!/usr/bin/env python3
import os
import subprocess
def process_ldd_out(output):
libs = []
for line in output.splitlines():
line = line.strip()
if line == '' or line == 'statically linked': continue
from functools import reduce
def __convert_time(timeString):
if timeString.endswith("ms"):
return float(timeString[:-2])
elif timeString.endswith("us"):
return float(timeString[:-2])/1e3
elif timeString.endswith("ns"):
return float(timeString[:-2])/1e6
#include <stdlib.h>
//
// bin2hex
// Returns the hexadecimal representation of a bytes sequence.
// Parameters
// - bin: array of bytes
// - size: number of bytes in bin.
// Returns
// A string containing the hex representation of bin.
//
@dipietrantonio
dipietrantonio / timer.py
Created September 9, 2019 19:47
Using a Python context manager as timer.
import time
class Timer:
def __enter__(self):
self.__start = time.time()
def __exit__(self, exType, exValue, exTraceback):
self.__elapsed = time.time() - self.__start
@dipietrantonio
dipietrantonio / N26GiacenzaMedia.py
Last active June 22, 2019 14:46
Calcola la giacenza media del conto corrente N26 a partire dal file contenente le transazioni.
"""
Giacenza media N26
------------------
Script Python che calcola la giacenza media a partire dalla
lista di transazioni che è possibile scaricare dal sito web.
Licenza:
--------
Copyright 2019 Cristian Di Pietrantonio
Permission is hereby granted, free of charge, to any person obtaining
@dipietrantonio
dipietrantonio / doodle.py
Last active March 14, 2019 23:25
Parse a doodle poll from plain html page.
"""
Author: Cristian Di Pietrantonio
Doodle scheduler
"""
import json
import requests
import datetime
@dipietrantonio
dipietrantonio / texToKindle.sh
Created January 15, 2017 11:01
Convert a tex file to an ebook for Kindle
#!/bin/bash
# This script converts a tex source to azw3 format using htlatex and ebook-convert (from calibre)
# to set the resolution of math images edit this file
# sudo gedit /usr/share/texmf/tex4ht/tex4ht.env
# in the section <dvipng> modify the DPI parameter (-D) of the two commands (I use 100)
# do the operation in a temporary directory. htlatex produces a lot of files (and we can't set an output dir)
currdir=`pwd`
@dipietrantonio
dipietrantonio / installJModelica.sh
Last active July 12, 2016 09:40
Install JModelica on Linux
#!/bin/bash
###################################################################################################
#
# Author: Cristian Di Pietrantonio (https://github.com/Halolegend94)
#
# Description: Install easly the last version of JModelica.
# ATTENTION: set manually the requested variables in "manual setting" section before launching this
# Script.
#
###################################################################################################