Skip to content

Instantly share code, notes, and snippets.

View dg01d's full-sized avatar
🏠
Working from home

daniel goldsmith dg01d

🏠
Working from home
View GitHub Profile
@dg01d
dg01d / FSF Amended By-Laws.text
Created March 23, 2021 20:37
Because the Free Software Foundations By-Laws are provided in a scanned copy of a printed text file...
BY-LAWS
OF
FREE SOFTWARE FOUNDATION, INC.
ARTICLE I
NAME, PURPOSES, LOCATION, CORPORATE SEAL, AND FISCAL YEAR
Section 1 - Name and Purposes. The name and purposes of the corporation
@dg01d
dg01d / nginx.conf
Created May 20, 2018 11:52
Anonymised Nginx Logs
map $remote_addr $anon_remote_addr {
"~^(?<ip_a>\d+\.\d+)\.\d+\.\d+" "$ip_a";
}
log_format anonymised '$anon_remote_addr.0.0 - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
{{ $mention_ids := index $.Site.Data.wm_io.index .URL }}
{{ $mentions := apply $mention_ids "index" $.Site.Data.wm_io.mentions "." }}
{{ $mentions := sort $mentions "wm-received" }}
{{ range $mentions }}
<ul>
{{- if or ("repost-of") ("like-of") }}
<li>Liked by {{ .author.name | markdownify }}</li>
{{- end}}
</ul>
{{ end }}
PHP Warning: require(/srv/watchtower/vendor/composer/../../lib/config.php): failed to open stream: No such file or directory in /srv/watchtower/vendor/composer/autoload_real.php on line 66
PHP Fatal error: require(): Failed opening required '/srv/watchtower/vendor/composer/../../lib/config.php' (include_path='.:/usr/share/php') in /srv/watchtower/vendor/composer/autoload_real.php on line 66
@dg01d
dg01d / README.md
Created February 24, 2018 13:15
Micropub using emacs

Credits

This is just an amendment for hjertnes' script

Notes

  • The setting mb-domain should be set to the full path of the micropub endpoint.
  • I could not get this to work using form-encoded post format. If your endpoint does not support json-encoded posts, this will likely not work.
/**
* Returns a value from an array and deletes
* the key=>value pair like python's s.pop['i']
*
* @param array $arr The array to be searched
* @param $key The search term
* @return The $value mapped to $key or null
*/
@dg01d
dg01d / yaml2json.php
Last active December 6, 2017 20:51
Quick'n'dirty script to convert a folder of YAML-frontmatter files to JSON-frontmatter
<?php
require('vendor/autoload.php');
use Symfony\Component\Yaml\Parser;
$yaml = new Parser();
// Path for the content you want to convert
$files = glob('./micro/*.md');
<script id="webmention-hosted">
(function () {
var sn = document.createElement("script"), s = document.getElementsByTagName("script")[0], url;
url = document.querySelectorAll ? document.querySelectorAll("link[rel~=canonical]") : false;
url = url && url[0] ? url[0].href : false;
sn.type = "text/javascript"; sn.async = true;
sn.src = "//webmention.herokuapp.com/api/embed?url=" + encodeURIComponent(url || window.location) + "&version=cutting-edge";
s.parentNode.insertBefore(sn, s);
}());
</script>
<?php
function array_replace_keys(array $array, array $keys, $filter=false)
{
$newArray = array();
foreach($array as $key => $value) {
if (isset($keys[$key])) {
$newArray[$keys[$key]] = $value;
} elseif (!$filter) {
$newArray[$key] = $value;
@dg01d
dg01d / pelican2yaml.sh
Created January 25, 2017 19:25
A *hillariously* kludgey script to convert my pelican markdown files to hugo-parseable YAML format
#!/bin/bash
# Save standard output and standard error
exec 3>&1 4>&2
# Redirect standard output to a log file
exec 1>/tmp/stdout.log
# Redirect standard error to a log file
exec 2>/tmp/stderr.log
mkdir mod/