Skip to content

Instantly share code, notes, and snippets.

View ryanfb's full-sized avatar

Ryan Baumann ryanfb

View GitHub Profile
@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)
@allanmac
allanmac / sha256.cu
Last active November 10, 2023 01:26
A CUDA SHA-256 subroutine using macro expansion
// -*- compile-command: "nvcc -m 32 -arch sm_35 -Xptxas=-v,-abi=no -cubin sha256.cu"; -*-
//
// Copyright 2013 Allan MacKinnon <allanmac@alum.mit.edu>
//
// 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
@valpackett
valpackett / Alfred-Pinboard-INSTANT.md
Last active September 7, 2023 21:01
INSTANT Pinboard search from Alfred 2

INSTANT Pinboard search from Alfred 2

I've had a Python script that makes an HTML Bookmarks file for LaunchBar.
Now that I use Alfred 2, I modified it to make XML for Alfred.
This allows me to search my bookmarks with GREP SPEED!

Installation

First, add your token (from pinboard.in/settings/password) to ~/.netrc

@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

@rrrodrigo
rrrodrigo / instagram-download.txt
Created April 10, 2012 11:45
How to download all your Instagram pictures in highest resolution without using any API
Following the news about Facebook buying Instagram I decided to delete my Instagram account before Facebook claims ownership of my pictures.
Since the Instagram-recommended (in their FAQ): http://instaport.me/export doesn't work for me (probably they can't cope with the high demand),
here is a quick and dirty way to download all my Instagram pictures in their highest resolution in a few easy steps.
You will need: Firefox, Firebug, some text editor, wget
1. Go to http://statigr.am/yourlogin using Firefox with Firebug extension active
2. Scroll down as many times as it is needed to have all yor pictures thumbnails displayed (I had some 3 hundred pictures so it was not that much scrolling, YMMV)
3. In the Firebug JS console run this JS code: $(".lienPhotoGrid a img").each(function(index) { console.log($(this).attr('src')) })
4. JS console will contain urls to all the thumbnails images, like this: http://distilleryimage1.s3.amazonaws.com/4ed46cf2801511e1b9f1123138140926_5.jpg
@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:

@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
@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)
@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">
@codingjester
codingjester / oauth_tumblr.py
Created April 3, 2012 23:33
OAuth Tumblr Getting Access Tokens
import urlparse
import oauth2 as oauth
consumer_key = 'consumer_key'
consumer_secret = 'consumer_secret'
request_token_url = 'http://www.tumblr.com/oauth/request_token'
access_token_url = 'http://www.tumblr.com/oauth/access_token'
authorize_url = 'http://www.tumblr.com/oauth/authorize'