Skip to content

Instantly share code, notes, and snippets.

@hfs
hfs / pcniter.py
Created January 30, 2018 15:52 — forked from mortenpi/pcniter.py
Previous / current / next iterator in Python 3
def previous_current_next(iterable):
"""Make an iterator that yields an (previous, current, next) tuple per element.
Returns None if the value does not make sense (i.e. previous before
first and next after last).
"""
iterable=iter(iterable)
prv = None
try:
cur = next(iterable)
@hfs
hfs / .gitignore
Last active February 14, 2024 09:41 — forked from sit/.gitignore
How to keep Jenkins configurations in a git repository. Put .gitignore in Jenkins’ home directory (/var/lib/jenkins). Initialize a git repository and add a remote to push to. Create a new Jenkins job to run e.g. nightly with the content of backup.sh as shell execution build step.
# Non-config file types
*.log
*.log.*
*.tmp
*.old
*.bak
*.jar
*.jpi
*.jpi.pinned
*.json