Skip to content

Instantly share code, notes, and snippets.

@chrismytton
chrismytton / github-pr-fetcher.py
Created January 16, 2025 20:55
Get a list of pull requests created by me in 2024
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# ]
# ///
import requests
from datetime import datetime
import os
@chrismytton
chrismytton / response.json
Created December 4, 2024 00:11
GPT-4o audio response
This file has been truncated, but you can view the full file.
{
"id": "chatcmpl-AaXFue5qc9tdw9jJeitCnKxTfOA2S",
"object": "chat.completion",
"created": 1733271006,
"model": "gpt-4o-audio-preview-2024-10-01",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
@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/
@chrismytton
chrismytton / generateblog.rb
Last active August 29, 2015 14:07
Super simple static site system
#!/usr/bin/env ruby
require 'date'
require 'kramdown'
require 'erb'
abort "Usage: #$0 <posts_path>" if ARGV.empty?
Post = Struct.new(:path) do
def title
Date.strptime(File.basename(path, '.md'), '%Y-%m-%d').strftime('%d %B %Y')