Skip to content

Instantly share code, notes, and snippets.

@chrismytton
chrismytton / pygments-demo.html
Created January 11, 2026 07:56
Example of using Python's Pygments library in the browser via Pyodide
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pygments Syntax Highlighter</title>
<script src="https://cdn.jsdelivr.net/pyodide/v0.29.0/full/pyodide.js"></script>
<style>
* {
margin: 0;
@chrismytton
chrismytton / starship.toml
Created December 31, 2025 07:31
Starship disable all language modules
# ~/.config/starship.toml
# This disables all language modules in Starship and just leaves the git integration working.
# See https://starship.rs/config/#default-prompt-format for the default prompt
format = """
$directory\
$git_branch\
$git_commit\
$git_state\
@chrismytton
chrismytton / github_pr_summary.py
Last active October 9, 2025 18:31
Get a list of pull requests created by the authenticated user for a given year
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# ]
# ///
import requests
from datetime import datetime
import os
@chrismytton
chrismytton / init.lua
Created March 5, 2017 12:26
Hammerspoon version of Karabiner's "Control_L to Control_L (+ when you type Control_L only, send escape)"
-- Send escape when ctrl is tapped
local send_escape = false
local ctrl_pressed = false
hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function(event)
local flags = event:getFlags()
if flags["ctrl"] then
ctrl_pressed = true
send_escape = true
else
@chrismytton
chrismytton / yaml2json.sh
Created October 19, 2016 15:32
Shell function to convert YAML to JSON
yaml2json () {
ruby -r yaml -r json -e 'puts YAML.load($stdin.read).to_json'
}
$ ruby benchmark.rb
user system total real
rcsv 1.420000 0.100000 1.520000 ( 1.514617)
csv 11.450000 0.350000 11.800000 ( 11.838005)
@chrismytton
chrismytton / rerun_all_reviews.bash
Created April 5, 2016 17:00
Rerun the review_changes app over all open PRs
heroku run -- \
ruby -r ./app -e \
'ARGV.each { |pr| PullRequestReview.perform_async(pr.to_i) }' \
$(curl -s 'https://api.github.com/repos/everypolitician/everypolitician-data/pulls?per_page=100' | jq '.[] | .number')
id name qualification
3 Edward G. Cross Diploma in Agriculture
3 Edward G. Cross B Sc. Honours in Economics
10 Thamsanqa Mahlangu Advanced Diploma in Purchasing and Supply
10 Thamsanqa Mahlangu Diploma in Stores Management
10 Thamsanqa Mahlangu Journeyman Certificate in Carpentry
19 Fani Munengami Diploma in Marketing, Public Relations and Advertising
22 Tendai Biti Bachelor of Laws (LLB)
25 Fungai J Majome Post Graduate Diploma
25 Fungai J Majome Bachelor of Laws (LLB)

Results from running this on my machine:

$ ruby benchmark.rb 
                           user     system      total        real
ruby_empty_loop        0.010000   0.000000   0.010000 (  0.011223)
for_loop_no_body       1.550000   0.030000   1.580000 (  1.576662)
for_loop_with_body     3.030000   0.020000   3.050000 (  3.058479)
@chrismytton
chrismytton / .gitignore
Last active August 29, 2015 14:13
Image which takes 6 seconds to load
/node_modules/