Skip to content

Instantly share code, notes, and snippets.

View rfong's full-sized avatar

rfong rfong

View GitHub Profile
@rfong
rfong / compile_tags.py
Created May 17, 2021 22:51
Automatic tag-page generator for all post tags on a Jekyll site. See https://rfong.github.io/rflog/2020/02/28/jekyll-tags/
# Filename: __plugins/compile_tags.py
'''
This script generates tag pages for all your post tags for a
Jekyll site. It is invoked from a plugin after post_write.
Run it from the project root if testing.
Convention expected here for tag names is r/[-\w\d]+/
'''
import glob
@rfong
rfong / RAFFLE.md
Last active May 17, 2021 04:36
Run a simple multi-prize raffle, intaking cross-platform submissions from attendees, with the help of some manual data entry

Cross-platform event raffle

Context

Run a simple online giveaway raffle, where raffle tickets are awarded for completing challenges across a variety of different platforms:

  • Facebook tagged submissions
  • Instagram tagged submissions
  • Private uploads
  • Manual tracking (e.g. volunteer shifts, performers, teachers, other staff)

Other points:

@rfong
rfong / POSTGRESQL.md
Last active December 1, 2021 18:26
useful sql things

Dependencies

brew install postgresql

First time setting up local Postgres

Here's a nice readable tutorial on creating local Postgres users and DBs.

Create a user myuser with permissions to administrate a database mydatabase:

@rfong
rfong / flask_error_handlers.py
Last active May 7, 2021 02:50
miscellaneous useful Flask things
"""
Flask application response handlers.
Reference: https://opensource.com/article/17/3/python-flask-exceptions
"""
from flask import Blueprint, jsonify
errors = Blueprint('errors', __name__)
@rfong
rfong / USEFUL_PYTHON_THINGS.md
Last active January 9, 2020 23:58
assortment of useful general python things

Generic Python stuff I find myself rewriting frequently.

No framework-specific functionality here. Any framework-specific dealings will be separated out into their own gists.

@rfong
rfong / LISP_AST.md
Last active May 7, 2021 02:52
Lisp AST parser for recurse center interview

Lisp AST parser

I picked this one because I haven't used Lisp before, and I haven't written an AST since school and remember rather enjoying them. (I did write it in a language I know, though.)

Usage

Go up a directory to run, because python module imports are the devil.

@rfong
rfong / README_mini_zine_layout.md
Last active May 7, 2023 09:26
Use LaTeX to generate print layout for a mini-zine with double-sided pages, folded from a single sheet of paper

what is this

This is a pair of scripts to collate a small-page-size PDF into a final print layout for standard size paper, which can then be printed and assembled into a booklet.

The python script autogenerates intermediate LaTeX layout files to collate the print layout. The bash script runs the generator, and recompiles and schleps around the output files.

use case / why is that necessary

This year I've been getting into making mini-zines, which are folded from normal size sheets of printer paper. (See the attached image for a visual demonstration.)

@rfong
rfong / celestial_navigation_gmt.py
Created January 20, 2019 18:56
Poor Richard's Almanac
# -*- coding: utf-8 -*-
# calculate GMT offset given:
# - lunar center's arc distance from sun center, measured locally at noon
# - lunar center's arc distance from sun center, measured at Greenwich at noon
# - lunar center's arc distance from sun center, measured at Greenwich at 3PM
def angle_to_float(deg, min, sec):
return deg + min/60.0 + sec/3600.0
def gmt_from_lunar(angle_local_tup, angle_greenwich_tup, angle_greenwich_3pm_tup):
@rfong
rfong / osx_hot_tips.md
Created October 9, 2018 21:24
rfong's hot tips for OSX immigrants

useful trivia

  • Cmd-space is a quick search bar that helps you find things (applications, filesystem search, etc)
  • brew is the package manager CLI
  • you can remap keys in Settings > Keyboard if you find them annoying

config

  • Configure the Dock (bottom of the page) in settings to not be annoying