Skip to content

Instantly share code, notes, and snippets.

View holocronweaver's full-sized avatar

Jesse Johnson holocronweaver

  • Seattle, Washington
View GitHub Profile
@holocronweaver
holocronweaver / merge_sort.py
Created March 5, 2025 19:53
Simple, Clear Python Merge Sort
#! /usr/bin/env python3
import unittest
class MergeSort:
'''Partition list in half, then sort each half and merge the halves.
Merging does the actual sorting. It looks at the front of the left and right
halves and picks the smallest value to append to the merged list.
Time: O(n log n), memory: O(n)
@holocronweaver
holocronweaver / straight.el
Created September 1, 2018 20:14
Using straight.el with Prelude: place in your .emacs.d/personal/preload folder
;;; straight --- Use straight.el to manage packages with version control.
;;; Commentary:
;; straight.el allows git to track package versions, ensuring Emacs
;; stability and reversible package upgrades.
;;; Author: holocronweaver
;;; Created: 2018
;;; Code:
(let ((bootstrap-file (concat user-emacs-directory "straight/repos/straight.el/bootstrap.el"))
(bootstrap-version 3))
(unless (file-exists-p bootstrap-file)
@holocronweaver
holocronweaver / Range.hpp
Created September 1, 2017 20:49 — forked from tunabrain/Range.hpp
Python ranges in C++
#ifndef RANGE_HPP_
#define RANGE_HPP_
template<typename T> class RangeIterator;
template<typename T>
class Range
{
T _start, _end, _step;
@holocronweaver
holocronweaver / example.py
Last active August 4, 2017 22:33
Example of capturing Bash output in Python
from subprocess import check_output
def sh(x): return check_output(x, shell=True).decode()
def script(x):
return sh("""
derp () {{
printf "hello %d\\n" {0}
sha256sum example.py
}}
@holocronweaver
holocronweaver / wookieepedia_default_to_legacy.js
Created February 2, 2017 00:44
A Greasemonkey/Tampermonkey script for defaulting Wookieepedia to Legacy instead of Disney Canon.
// ==UserScript==
// @name Wookieepedia Default to Legacy
// @namespace https://holocronweaver.com/
// @version 0.1
// @description Default to Legacy instead of Disney Canon.
// @author holocronweaver
// @match http://starwars.wikia.com/*
// @grant none
// ==/UserScript==
@holocronweaver
holocronweaver / string_switch.cpp
Created January 12, 2017 23:11
In C++, using string hashes in switches is faster than if-else string comparisons on average.
#include <cstdlib>
#include <iostream>
#include <string>
#include <boost/timer/timer.hpp>
#define NUM_CALLS 1000000
template <size_t N, size_t I = 0>
struct hash_calc
#pragma once
// openvr.h
//========= Copyright Valve Corporation ============//
// Dynamically generated file. Do not modify this file directly.
#ifndef _OPENVR_API
#define _OPENVR_API
#include <stdint.h>
#! python3
import shlex
import sys
import re
import io
header = open('openvr.h', newline='\n').read()
annoyingMacroPattern = re.compile(r'#define\s+(\w+).*VR_CLANG_ATTR.*')
@holocronweaver
holocronweaver / OgreActivityJNI.cpp
Last active August 29, 2015 14:26
Slightly modified OgreJNI app for Android meant to show a triangle. Instead shows nothing!
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2012 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@holocronweaver
holocronweaver / log
Last active August 29, 2015 14:25
opam repo add debugging
00:00.146 SYSTEM locking /Users/jesse/.opam/lock
00:00.147 FILENAME cleandir /Users/jesse/.opam/log
00:00.147 SYSTEM rmdir /Users/jesse/.opam/log
00:00.151 SYSTEM mkdir /Users/jesse/.opam/log
00:00.151 STATE LOAD-STATE(global-lock)
00:00.151 FILE(config) Read ~/.opam/config in 0.000s
00:00.160 STATE Loaded /Users/jesse/.opam/state.cache in 0.009s
00:00.161 FILE(aliases) Read ~/.opam/aliases in 0.000s
00:00.171 FILE(repo-config) Read ~/.opam/repo/android/config in 0.000s
00:00.171 FILE(repo-config) Read ~/.opam/repo/default/config in 0.000s