Skip to content

Instantly share code, notes, and snippets.

@z3dm4n
z3dm4n / systemd-run-as-atd-replacement.md
Last active November 2, 2023 13:47
Using systemd-run as atd replacement to run jobs at scheduled times
$ sudo systemd --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

$ sudo systemd-run --property=WorkingDirectory=/foo/bar --property=TimeoutSec=5min --on-active="10min" command args
Running timer as unit: run-1.timer
Will run service as unit: run-1.service

$ sudo systemctl list-timers
@fabriziopandini
fabriziopandini / chartjs-ipython.py
Created March 26, 2016 15:13
Using ChartJs from IPython
import json
from IPython.display import display, Javascript
def chartjs(chartType, data, options={}, width="700px", height="400px"):
""" Custom iphython extension allowing chartjs visualizations
Usage:
chartjs(chartType, data, options, width=1000, height=400)
Args:
@graydon
graydon / country-bounding-boxes.py
Created April 23, 2014 00:03
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
@jgomezdans
jgomezdans / modis_map.py
Created May 8, 2012 15:26
Plotting MODIS data with Matplotlib's Basemap
from osgeo import gdal
from osgeo import osr
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
def reproject_dataset ( dataset, \
pixel_spacing=0.463/100., \
wkt_from="+proj=sinu +R=6371007.181 +nadgrids=@null +wktext", epsg_to=4326 ):