Skip to content

Instantly share code, notes, and snippets.

View ryanfb's full-sized avatar

Ryan Baumann ryanfb

View GitHub Profile
@osnr
osnr / search-twitter-around-screenotate.md
Created February 9, 2021 03:40
Search your tweets around the time you took a screenshot.

If you have a Screenotate screenshot HTML file open in your browser, clicking this bookmarklet will search your old tweets from around the time you took the screenshot, so you can find your original tweet of it (if it exists).

Make a new bookmark with the below as URL, replacing from:rsnous with from:YourTwitterUsername:

javascript:void%20function(){const%20a=new%20Date(document.body.innerHTML.match(/%3Cdd%3E(\d\d\d\d\-\d\d\-\d\d)/)[1]),b=new%20Date(a.getTime());b.setDate(b.getDate()-1);const%20c=new%20Date(a.getTime());c.setDate(c.getDate()+1);const%20d=`from:rsnous%20since:${b.toISOString().slice(0,10)}%20until:${c.toISOString().slice(0,10)}`;window.location.href=`https://twitter.com/search%3Fq=${encodeURIComponent(d)}`}();

Or construct the bookmarklet URL yourself -- here's the source code:

@PonteIneptique
PonteIneptique / hocr_to_kraken_transcribe.xsl
Last active March 21, 2020 11:25
XSL for transforming (need Saxon-EE > 9.8) HOCR from tesseract to transcribing file for Kraken (à la ketos prefill)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:saxon="http://saxon.sf.net/"
xmlns:my="foo.bar"
exclude-result-prefixes="xs my saxon uuid"
xpath-default-namespace="http://www.w3.org/1999/xhtml"
version="2.0"
xmlns:uuid="java:java.util.UUID">
@JPLeBreton
JPLeBreton / wadls.py
Last active March 7, 2021 23:53
wadls - list all map files within a WAD/PK3/ZIP
#!/usr/bin/python
import os, sys, zipfile, tempfile
# wadls (pronounced "waddles", thx joshthenesnerd) - list all maps in a wad/zip/pk3
# requires omgifol module, set path to it here or in env variable
OMG_PATH = os.environ.get('OMG_PATH', None) or '/home/jpl/projects/wadsmoosh'
sys.path.append(OMG_PATH)
import omg
@lovasoa
lovasoa / dichotomic-bash.sh
Last active December 6, 2023 23:57
Generic dichotomic search as a shell script
#!/usr/bin/env bash
# Dichotomic search in bash
# This is a bash-specific function that uses bash features.
# This is not guaranteed to work in other shells.
#
# Usage:
# source dichotomic-bash.sh
# result=$(dichotomic_search min max command)
#
# Returns the largest i for which `command i` succeeds (exits with a null exit code)
@bruce30262
bruce30262 / ARMDebianUbuntu.md
Last active June 12, 2023 11:43 — forked from Liryna/ARMDebianUbuntu.md
Emulating ARM on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

If there's no qemu-arm-static in the package list, install qemu-user-static instead

# Endpoint http://vocab.getty.edu/sparql
select ?t ?name (count(*) as ?c) {
?x gvp:placeType ?t. ?t gvp:prefLabelGVP/xl:literalForm ?name
} group by ?t ?name
# 0. Inspired by https://twitter.com/paregorios/status/568513448130187264
# 1. This includes place types AND cultures/styles (eg "religious center" and "Maya")
# 2. Exploring the AAT hierarchy above these types could also be interesting
# 3. We also provide TGN counts as per Mar 2015
# 4. The query is a bit expensive (1.2M places, 2.7M type instances), so be nice and use the attached TSV
diff --git classify/trainingsampleset.cpp classify/trainingsampleset.cpp
index afbf3f4..6121395 100644
--- classify/trainingsampleset.cpp
+++ classify/trainingsampleset.cpp
@@ -693,6 +693,8 @@ void TrainingSampleSet::ComputeCanonicalSamples(const IntFeatureMap& map,
fcinfo.canonical_sample = fcinfo.samples[0];
fcinfo.canonical_dist = 0.0f;
for (int i = 0; i < fcinfo.samples.size(); ++i) {
+ #pragma omp parallel
+ {
anonymous
anonymous / bad-usenet-post-extractor.rb
Created September 3, 2014 03:48
Takes a directory full of disordered, misnamed, obfuscated multi-volume RAR files and extracts them. For those Usenet full TV season backlog posts that get picked up by Sick Beard and have millions of .0 .1 .2 files you can't extract and throw "There are no videofiles in folder" in the post-processor. See e.g. http://sickbeard.com/forums/viewtop…
#!/usr/bin/env ruby
require 'pty'
require 'expect'
$rar_divider = "-------------------------------------------------------------------------------\n"
def check_rar_contents(file)
$stderr.puts "Checking RAR contents for: #{file}"
rar_contents = `unrar l -v "#{file}" 2>&1`.split($rar_divider)
@mcewand
mcewand / PennInHand_grabber.py
Last active August 29, 2015 14:02
Quick script to help students in the Rare Book School M-95 course.
#!/bin/python
# 1. Save this file to your local machine where you want to save the files
# 2. Change 'manuscript' to the one you want
# 3. Change 'lastItem' to the last numbered item of the text section of the manuscript
# 4. Add a directory 'jpgs' that the images will be stored in
# 5. Run "python PennInHand_grabber.py"
import sys
import urllib
@acdha
acdha / ocr-file.py
Created March 17, 2014 22:49
Fragment of code used to process images with Tesseract OCR
def ocr_file(filename, languages, output_base, temp_dir):
log.info("Launching tesseract on %s", filename)
output = subprocess.check_output(['tesseract', filename, output_base,
'-l', '+'.join(languages), TESSERACT_CONFIG],
cwd=temp_dir,
stderr=subprocess.STDOUT)
with OCR_STORAGE.open('%s/%s/%s.log' % (item_id, group, index), 'w') as log_f:
log_f.write(output)