Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ghing
ghing / README.md
Last active April 19, 2024 02:16
User script and bookmarklet for copying current page title and URL as a Markdown link

Link copying bookmarklets and user scripts

I often want to copy the link to a page I'm viewing in the browser to the clipboard to paste it in a note or document that I'm editing. These are bookmarklets and user scripts to help with this task.

What's in here?

  • copy_markdown_link_bookmarklet.js: A bookmarklet that copies the the title and URL of the current page to the clipboard as a Markdown-formatted link. This works in Chrome, but not in Firefox, I think because "Writing to the clipboard is available without permission in secure contexts and browser extensions, but only from user-initiated event callbacks. Browser extensions with the "clipboardWrite" permission can write to the clipboard at any time." (See https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API)
  • copy_markdown_link_userscript.js: A user script that copies the the title and URL of the current page to the clipboard as a Markdown-formatted link. I wrote this because Firefox didn't seem to support providing clipboard access
@ghing
ghing / README.md
Created March 23, 2020 18:13
Identifying which PDFs are image vs. text

Identifying which PDFs are images vs. text

Someone who was in my PDF text extraction session at NICAR 2020 asked how to identify image vs. text PDFs when you have thousands of files and they're a mixture of formats with the end goal of only running OCR software on the image PDFs.

This is how I would approach the problem using command-line tools.

Assumptions

  • You’re working on a Mac or Linux machine where you have access to some common command-line utilities such as find and sed
  • This should work under the Windows Subshell for Linux under Windows also
@ghing
ghing / datatable.js
Created July 11, 2021 16:43
Customized version of DataTable class from Simple-Datatables that allows filtering of rows with a function.
/**
* Customized version of DataTable class from Simple-Datatables that allows
* filtering of rows with a function.
*
* See https://github.com/fiduswriter/Simple-DataTables/blob/master/src/datatable.js
*/
import { DataTable } from "simple-datatables";
/**
@ghing
ghing / README.md
Last active January 29, 2021 21:12
`CERTIFICATE_VERIFY_FAILED` in Python, on a Mac, on a computer that uses Cisco Umbrella

CERTIFICATE_VERIFY_FAILED in Python, on a Mac, on a computer that uses Cisco Umbrella

If you've ever tried to initiate an HTTPS request in Python on a Mac, perhaps usign the popular requests library, you've probably run into an exception that looks something like this:

requests.exceptions.SSLError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/03-11-2020.csv (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))

These issues are complicated by the fact that many users have multiple versions of Python installed and that there may be multiple pieces of software handling certificates.

@ghing
ghing / README.md
Last active March 7, 2020 00:03
The Original Pinettes during NICAR 2020

Hi NICAR friends! My friend with whom I'm staying suggested checking out an all-woman brass band called the Original Pinettes who play every Friday.

The band's Wikipedia entry (https://en.wikipedia.org/wiki/The_Original_Pinettes_Brass_Band) says the Pinettes are the only all-woman brass band in New Orleans, started when the members were at a Catholic Girls school, and persisted as a band despite being disrupted by relocation caused by Katrina.

Here's the details:

Friday, March 6, 2020
Bullet's Sports Bar
2441 A P Tureaud Ave.
New Orleans, LA 70119

@ghing
ghing / dropbox_on_ubuntu.md
Created December 6, 2019 15:30
Log of steps I took when installing Ubuntu 18.04 in such a way that I could use Dropbox after they dropped support for many Linux filesystems.

This is an excerpt from an install log notebook I kept when reinstalling my system that includes just the parts relevent to Dropbox.

WTF Dropbox

This whole OS installation was precipitated by the fact that Dropbox dropped support for all Linux filesystems except for plain ext4, so it wasn't working with ecryptfs and LVM and all the default ways Ubuntu sets up the filesystem.

However, Dropbox does work with full-disk encryption and an ext4 filesystem. The technology for full disk encryption under Linux is LUKS.

The key things I need to make sure happen when setting up my partitions and installing the system are:

@ghing
ghing / README.md
Created October 8, 2019 22:33
Installing landsat-util on MacOS with Python 3.7

Installing landsat-util on MacOS with Python 3.7

Last updated October 8, 2019.

Or don't

If you have expereince with Docker, running the Dockerized landsat-util is probably the easiest way to avoid all these dependency issues.

The problem

@ghing
ghing / .bash_completion
Last active July 5, 2019 21:47
Make and Bash completion
# bash completion for GNU make
# This has been modified from the version in
# `/usr/local/etc/bash_completion.d/make` so that file paths are also
# autocompleted.
#
# To use, copy or append this to `~/.bash_completion`
have make || have gmake || have gnumake || have pmake &&
_make()
{
@ghing
ghing / tamper2py.py
Created April 4, 2011 03:50
Simple script to convert a HTTP post data copied from the Tamper Data Firefox extension into Python code that can be used in a script using the mechanize library.
We couldn’t find that file to show.
@ghing
ghing / dailygraphics_markdown_links.js
Created October 10, 2017 17:19
Dailygraphics markdown links bookmarklet