Skip to content

Instantly share code, notes, and snippets.

View jbosboom's full-sized avatar

Jeffrey Bosboom jbosboom

  • 03:00 (UTC -07:00)
View GitHub Profile
@jbosboom
jbosboom / approx-rename.py
Created August 30, 2020 21:46
Approximate file renaming script
#!/usr/bin/env python2
import sys, os, shutil, argparse, string, readline
from fuzzywuzzy import process
parser = argparse.ArgumentParser()
parser.add_argument('directory', type=str)
parser.add_argument('namelist', type=argparse.FileType(mode='r'))
# TODO: option to include extension in renaming?
args = parser.parse_args()
@jbosboom
jbosboom / papergen.py
Created August 30, 2020 21:45
Generates landscape ruled paper
#!/usr/bin/env python2
margin = 0.375
lineheight = (8.5 - 2*margin)/25
linewidth = 11 - 2*margin
midgutter = 11.0/2
ypts = [(margin, midgutter-(margin/2)), (midgutter+(margin/2), 11.0 - margin)]
color = '#A4DDED'
thickness = 1.0/64
@jbosboom
jbosboom / gtest-to-doctest.py
Created August 30, 2020 21:44
Convert gtest macros to doctest macros
#!/usr/bin/env python2
import sys, os, re
conversions = [
('<gtest/gtest.h>', '<doctest.h>'),
(r'TEST\(([a-zA-Z0-9]+), ([a-zA-Z0-9]+)\)', r'TEST_CASE("\1_\2")')
]
severity_map = {'ASSERT': 'REQUIRE', 'EXPECT': 'CHECK'}
@jbosboom
jbosboom / RemoveUnusedPrivateCtors.java
Created May 10, 2015 02:05
Removes unused private constructors from .class files
/*
* Copyright (c) 2015 Jeffrey Bosboom
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@jbosboom
jbosboom / ConstantPoolSortingClassWriter.java
Last active June 14, 2019 04:49
ASM constant pool sorter
/***
* Copyright (c) 2015 Jeffrey Bosboom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
package com.jeffreybosboom.stringbuilderbench;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
@State(Scope.Thread)
public class StringBuilderBench {
//promote to non-final fields to inhibit constant folding (see JMHSample_10_ConstantFold.java)
private String really = "really ", long_string = "long string.", re = "re", al = "al", ly = "ly ";