To get a unique list of all Python packages your application depends on:
grep -irhP '^import ' interp_stn_to_grid | sort | uniq
where interp_stn_to_grid
is the top-level directory containing all the Python scripts in your application.
To get a unique list of all Python packages your application depends on:
grep -irhP '^import ' interp_stn_to_grid | sort | uniq
where interp_stn_to_grid
is the top-level directory containing all the Python scripts in your application.
This is a simple example that creates a NetCDF file for 1 degree global 2m temperature. There is no time coordinate.
For this portion of code:
ds = xr.DataArray(data, ...)
data
is a NumPy array, assumed to have a shape of num_lats x num_lons
#!/usr/bin/env python | |
import ldap | |
from getpass import getpass | |
# Set constants | |
HOST = '<HOST>' # eg. ldaps://my-ldap-server.com | |
BASE_DN = '<BASE_DN>' # eg. 'dc=example,dc=com' | |
# Set LDAP options |
To run this, just create a virtualenv and install cpc.geofiles:
$ pip install cpc.geofiles
#!/bin/sh | |
ROOT_DIR=/path/to/data | |
START_DATE='19950101' | |
END_DATE='20161231' | |
cd $ROOT_DIR | |
# Loop over all dates within the given date range | |
curr_date=$START_DATE |
#!/bin/sh | |
find . -type f -iname "*.avi" -print0 | while IFS= read -r -d $'\0' infile ; do | |
outfile="${infile%.*}.m4v" | |
echo "Converting ${infile} to ${outfile}..." | |
HandbrakeCLI -Z 'AppleTV 3' -q 25 -i "$infile" -o "$outfile" | |
done |
from PIL import Image | |
im = Image.open(img_file) | |
im.convert('P', palette=Image.ADAPTIVE, colors=256).save(img_file) |
find . -type f -iname "*.txt" -print0 | while IFS= read -r -d $'\0' line; do | |
echo "$line" | |
ls -l "$line" | |
done |
Create a file z.pth
in your virtual env's site-packages
dir (eg. ~/.conda/envs/<env-name>/lib/python3.5/site-packages
) containing this line:
import pkg_resources; pkg_resources.fixup_namespace_packages('')
#!/bin/sh | |
#--------------------------------------------------------------------------------------------------- | |
# Usage | |
# | |
usage() { | |
printf "$(basename "$0") -s <TIME_BETWEEN_TRIES> -t <TIME_TO_TRY> <COMMAND>\n" | |
printf " where:\n" | |
printf " -s TIME_BETWEEN_TRIES time (minutes) between each try\n" | |
printf " -t TIME_TO_TRY total time (minutes) to try the command before giving up\n" |