Skip to content

Instantly share code, notes, and snippets.

@mathematicalcoffee
mathematicalcoffee / chapter.hs
Last active February 23, 2021 07:10
Pandoc extension to insert the metadata of a file as headings of levels 1, 2 and 3. This is so that if you have (say) each chapter of a thesis in its own file with its own title block, you can still compile the lot together to the one final thesis. See the file for more details.
#!/usr/bin/env runhaskell
-- Filter that adds the metadata block as h1, h2, h3 (title, author, date).
--
-- Usage::
-- chmod +x ./chapter.hs
--
-- # (where each chapter is in its own md file and I want to compile them
-- # into one document preserving the title/author/date for each chapter):
--
-- for f in Chapter*.md; do \
@pdbartsch
pdbartsch / OpenRefine Nominatim Geocode
Last active January 14, 2024 12:43
open-refine geocoding using OpenStreetMap's Nominatim service. (previously called google-refine)
Step One - Starting with a single address field
Edit Column > Add Column by Fetching URLs
Nominatim has a limit of 1 geocode per second so make sure to set the throttle delay to greater than 1000 milliseconds
Fetch URL based on column (quotes needed):
"http://nominatim.openstreetmap.org/search?format=json&email=[YOUR_EMAIL_HERE].com&app=google-refine&q=' + escape(value, 'url')"
------------------------------------------------------------------------------------
Step Two - Extract lat/lon from newly created JSON blobs
@gnarf
gnarf / ..git-pr.md
Last active April 12, 2024 22:00
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@hakre
hakre / dl-file.php
Created January 2, 2012 21:41
Wordpress login to download uploaded files
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+