Skip to content

Instantly share code, notes, and snippets.

View astrochun's full-sized avatar
😃
Hello, GitHub!

Chun Ly astrochun

😃
Hello, GitHub!
View GitHub Profile
@wrunk
wrunk / jinja2_file_less.py
Last active April 14, 2025 10:17
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@glombard
glombard / reference-markdown-metadata-from-jinja-template.py
Last active March 28, 2025 20:52
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active November 4, 2025 12:43
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@michaelsteffen
michaelsteffen / clean_gpx.py
Created December 3, 2014 00:21
Simple script to clean GPX output from a Garmin cycling computer.
# Must be run with lxml installed to process larger data sets.
# By default looks for ./RawGPX.gpx as the input file and outputs to ./CleanedGPX.gpx. But of course one could change that easily...
import gpxpy
import gpxpy.gpx
import re
def get_furthest_point_above_speed(track, start_segment_no, start_point_no, speed, shortest_length=500):
"""
Starting from a given point on a track, finds the longest subsection of the track
@hackerdem
hackerdem / check_link.py
Last active January 5, 2023 18:22
A simple python script to check broken links of a wesite
@noelboss
noelboss / git-deployment.md
Last active August 12, 2025 18:16
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@kingspp
kingspp / logging.py
Created April 22, 2017 07:14
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@Olliebrown
Olliebrown / configMacPortsMongo.md
Last active April 7, 2025 21:21
Configuring MongoDB installed from MacPorts

This is based on https://github.com/codeforamerica/ohana-api/wiki/Installing-MongoDB-with-MacPorts-on-OS-X

the macports version of MongoDB does not come pre-configured and will not run after installing until you change some settings. The instructions linked above describe a way to fix this but they ignore the fact that many of the directories are already created and owned by the user "_mongo". It also runs the daemon as root rather than _mongo. Below is a modified approach that uses the _mongo user and avoids creating unnecessary directories.

Install and Configure MongoDB

  1. Install mongodb with sudo port install mongodb (you probably want to start with a sudo port selfupdate)
  2. Create configuration directory with sudo mkdir /opt/local/etc/mongodb/
  3. Create configuration file with sudo pico /opt/local/etc/mongodb/mongod.conf
@althonos
althonos / setup.cfg
Last active August 12, 2025 17:32
A `setup.cfg` template for my Python projects
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = file: {name}/_version.txt
author = Martin Larralde
author_email = [email protected]
url = https://github.com/althonos/{name}
description = {description}
long_description = file: README.md
@aviadlevy
aviadlevy / .gitlab-ci.yml
Created April 11, 2019 06:54
.gitlab-ci.yml with versioning and changelog
image: docker:latest
services:
- docker:dind
stages:
- build
- integration
- dev-release
- prod-release