Skip to content

Instantly share code, notes, and snippets.

View pjpetersik's full-sized avatar
🍇

Paul Petersik pjpetersik

🍇
View GitHub Profile
@jeffbyrnes
jeffbyrnes / installcdo.sh
Last active February 24, 2025 12:40 — forked from mainvoid007/installcdo.sh
install cdo with eccodes, hdf5, netcdf4
#!/bin/bash
# This installs CDO with ecCodes, netCDF and HDF5 support. Uses standard locations, with binaries landing in /usr/local/bin
# Forked from https://gist.github.com/mainvoid007/e5f1c82f50eb0459a55dfc4a0953a08e
# Updated to latest versions
# The only “breaking” change for JasPer is the maintainer switched from make to cmake for its build
cdo_path=/opt/cdo-install
apt-get update && apt-get install -y wget build-essential checkinstall unzip m4 curl libcurl4-gnutls-dev
@anttilipp
anttilipp / daylength.py
Created January 6, 2017 18:39
Python function to compute the length of the day given day of the year and latitude.
import numpy as np
def daylength(dayOfYear, lat):
"""Computes the length of the day (the time between sunrise and
sunset) given the day of the year and latitude of the location.
Function uses the Brock model for the computations.
For more information see, for example,
Forsythe et al., "A model comparison for daylength as a
function of latitude and day of year", Ecological Modelling,
1995.
@jhgaylor
jhgaylor / through_relationships.py
Last active May 18, 2025 18:06
Example of using a through model in Django and filtering by a value on the custom through model.
class A(models.Model):
things = models.ManyToManyField("B", through=ThroughModel)
class B(models.Model):
text = models.TextField()
class ThroughModel(models.Model):
a = models.ForeignKey(A)
b = models.ForeignKey(B)
extra = models.BooleanField()
@igniteflow
igniteflow / git_python_current_branch.py
Created February 7, 2012 17:33
GitPython get current active branch
"""
Gets the name of the active Git branch as a string.
Depends on GitPython
pip install GitPython
"""
from git import Repo
repo = Repo('/path/to/your/repo')
branch = repo.active_branch