Skip to content

Instantly share code, notes, and snippets.

var urls = {};
// Use browser debug tools to determine the column ID of the column which contains the tweets you want to archive
var columnID = 'e.g. c1668738656730s59';
var col = document.querySelector('.chirp-container[data-column=' + columnID + ']')
// Each time you run this line, new content will be loaded into the column by scrolling, and the new tweet information added
// to urls. Repeat the “up, enter, wait for new content” cycle until either you are satisfied or tweetdeck refuses to load
// more content. If you get HTTP 429 errors, wait a little and continue! Only once you get a 410 or just nothing at all when
// running the line have you reached the end.
col.parentElement.scrollBy(0, col.scrollHeight); document.querySelectorAll('[data-column=' + columnID + '] .tweet-timestamp a').forEach(function (el) {urls[el.href] = true;})
@barnabywalters
barnabywalters / .gitignore
Last active July 12, 2022 16:37
An attempt at making a Composer-compatible repository in a gist
.DS_Store
composer.phar
/vendor/
file: 2021-06-timberlake.csv
# context_query is used to provide context for links to lists of observations when there’s no inat project providing that context.
# If you do have a project with date and place bounds, leave out context_query and use
# project: your-project-id
# instead.
context_query: 'd1=2021-06-11&d2=2021-06-13&place_id=118103'
locale: en
root_header_level: 2
places:
# Places MUST be in smallest to biggest order, id: global MUST be last in list.
@barnabywalters
barnabywalters / album.html
Created May 18, 2021 09:36
mf2 Album Markup
<div class="h-entry">
<h1 class="p-name">Album Name</h1>
<time class="dt-published">2021-02-12</time>
<img class="u-photo" src="cover.png" alt="" />
<p class="p-summary">Summary of what the ablum is</p>
<div class="e-content">
@barnabywalters
barnabywalters / uniquely_observed_species.py
Last active May 14, 2021 10:06
Find which species in an iNaturalist export only have observations from a single observer.
# coding: utf-8
import argparse
import pandas as pd
"""
Find which species in an iNaturalist export only have observations from a single observer.
Get an export from here: https://www.inaturalist.org/observations/export with a query such
as quality_grade=research&identifications=any&rank=species&projects[]=92926 and at least the
<?php
// where $app is a silex/pimple container — this could easily be rewritten as an ordinary function though
// example usage: list($location, $err) = $app['nominatim.reverse']([-1.125, 3.526])
function nameForLocation(array $location, $fallback='Unknown Location') {
if (isset($location['name'])) return $location['name'];
if (isset($location['street-address']) and isset($location['region']))
return "{$location['street-address']}, {$location['region']}";
@barnabywalters
barnabywalters / FifoQueue.php
Last active December 30, 2015 17:49
Taproot post-storage code as of 2013-12-08. Working live on waterpigs.co.uk, probably a little too rusty/specific for convenient use elsewhere but maybe of interest. storage.php is basic functional library — currently it depends on symfony/yaml for post serialisation but that can be replaced with any function capable of serializing an array stru…
<?php
namespace Taproot;
use SplQueue;
class FifoQueue extends SplQueue {
protected $capacity;
public function __construct($capacity) { $this->capacity = $capacity; }
<?php
/**
* Given a string and a baseurl, finds all hashtags matching
* `#[\-_a-zA-Z0-9]+` and wraps them in an `a` element with `rel=tag` set
* and a `href` of baseurl + '/' + tagname without the #.
*/
function autolinkHashtags($text, $baseUrl) {
$baseUrl = rtrim($baseUrl, '/');
@barnabywalters
barnabywalters / template.php
Created November 21, 2013 20:57
Dumbest PHP template rendering function ever
<?php
function renderTemplate($template, array $__templateData = array()) {
$render = function ($__path, $render=null) use ($__templateData) {
ob_start();
extract($__templateData);
unset($__templateData);
include __DIR__ . '/../templates/' . $__path . '.php';
return ob_get_clean();
};
@barnabywalters
barnabywalters / barnabywalters.json
Created November 7, 2013 16:27
HTML from https://twitter.com/barnabywalters, parsed using indieweb/php-mf2-shim as of 2012-11-07
{
"rels": {
"shortcut": [
"https:\/\/abs.twimg.com\/favicons\/favicon.ico"
],
"icon": [
"https:\/\/abs.twimg.com\/favicons\/favicon.ico"
],
"canonical": [
"https:\/\/twitter.com\/BarnabyWalters"