Skip to content

Instantly share code, notes, and snippets.

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

Jim Fisher jameshfisher

🏠
Working from home
View GitHub Profile
@jameshfisher
jameshfisher / How to make a private Gist public.md
Created January 5, 2014 16:31
How to make a private Gist public

Github provides no facility to do this via the UI. This is sad, because it would be extremely useful in order to draft something before publishing it. It would also be trivial for them to implement. Never mind; here's how to do it manually:

  1. Get the "Clone this Gist" text from the left-hand side of the private Gist, e.g. https://gist.github.com/b9cc265982870c091a1e.git, and extract the ID b9cc265982870c091a1e.
  2. Go to https://gist.github.com/ and create a dummy new public Gist.
  3. Get the "Clone this Gist" text from the left-hand side, e.g. https://gist.github.com/8270253.git, and extract the ID 8270253.
  4. git clone git@gist.github.com:b9cc265982870c091a1e tmp-dir && cd tmp-dir && git push -f git@gist.github.com:8270253.git
@jameshfisher
jameshfisher / PHP_semantics.md
Last active April 18, 2023 14:53
Semantics for PHP

PHP semantics

Motivation

PHP is usually included in the top five or six most popular programming languages, as measured by various metrics implemented by e.g. [Tiobe][], [LangPop][], [PYPL][], [lang-index][]. Alongside it sit C, Java, Obj-C, C++, C#, Javascript, and Python. All of these have a formal semantics or at least a rigorous specification.

@jameshfisher
jameshfisher / rename.sh
Created April 3, 2023 16:53
Shell function to rename file with filename editor
rename() {
[ "$#" -ne 1 ] && echo "Usage: rename <file_path>" && return 1
local temp_file=$(mktemp)
echo "$1" > "$temp_file"
"${EDITOR:-vi}" "$temp_file"
local new_path=$(cat "$temp_file")
mv "$1" "$new_path"
echo "$new_path"
rm "$temp_file"
}
@jameshfisher
jameshfisher / restore-file-from-package.sh
Created April 12, 2014 17:44
Restore a file from the package that provides it.
#!/bin/bash
# Usage:
#
# sudo ./restore-file-from-package.sh <filepath>
#
# Restore a file from the package that provides it.
#
# Source: http://askubuntu.com/a/67028/30482
@jameshfisher
jameshfisher / digital_ocean_spaces.js
Created November 15, 2021 11:18
Using Digital Ocean Spaces with S3 client in NodeJS
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
const s3AccessKeyId = "Y64W56U7IE85W46JH"; // Generate key at https://cloud.digitalocean.com/account/api/tokens
const s3SecretAccessKey = "y546wu7ie5u435y/7uei564sy5u6w57";
const s3Bucket = "foo"; // Assumes your Space is https://cloud.digitalocean.com/spaces/foo
const s3Region = "nyc3"; // Get this from "Endpoint" at https://cloud.digitalocean.com/spaces/foo/settings
const s3Endpoint = "https://nyc3.digitaloceanspaces.com"; // From "Endpoint" at https://cloud.digitalocean.com/spaces/foo/settings, prepend 'https://'
const s3Client = new S3Client({
$ curl -v https://unpkg.com/slate-react@0.66.7/dist/slate-react.js
* Trying 2606:4700::6810:7eaf...
* TCP_NODELAY set
* Connected to unpkg.com (2606:4700::6810:7eaf) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
@jameshfisher
jameshfisher / plot_tensorflow_graph.py
Created March 8, 2021 15:19
Plot a TensorFlow graph with graphviz/dot
import tensorflow as tf
try:
# pydot-ng is a fork of pydot that is better maintained.
import pydot_ng as pydot
except ImportError:
# pydotplus is an improved version of pydot
try:
import pydotplus as pydot
except ImportError:
@jameshfisher
jameshfisher / floyd.md
Created June 15, 2020 08:34
"The George Floyd Ritual" conspiracy theory piece

From https://www.godlikeproductions.com/forum1/message4424714/pg1, so you don't have to create an account. Discussed on Twitter.

The George Floyd Ritual Part 2

Criminal acts of brutality, violence, and bloodshed occur every day. Let's ignore those tragedies, and keep the spotlight on George Floyd, who the Media compares to Malcolm X and MLK.

In a previous post, linked below, I showed how George Floyd’s death was a ritual. Now we need to go down another rabbit hole, to examine the Masonic element to his death.

The ritual lasted 8 minutes and 46 seconds do you know why? Before I reveal the hidden meaning, I have to lay the groundwork. Numerically, the digits add up to 18, which is 6+6+6. Others might look for a Bible code, like John 8:46 or something of that nature. I’ll let you think about it.

@jameshfisher
jameshfisher / stravaBug.js
Created October 13, 2018 17:37
Demonstration that Strava Route Builder can't find routes at the prime meridian
// Open https://www.strava.com/routes/new, then copy/paste this code in the debug console.
// It should print results like this, showing that it can't find routes at the prime meridian:
//
// lng: -1.0, errCount: 0
// lng: -0.9, errCount: 0
// lng: -0.8, errCount: 1
// lng: -0.7, errCount: 0
// lng: -0.6, errCount: 0
// lng: -0.5, errCount: 0
// lng: -0.4, errCount: 0
@jameshfisher
jameshfisher / halting_problem_javascript.md
Last active September 7, 2017 01:04
A proof that the Halting problem is undecidable, using JavaScript and examples

Having read a few proofs that the halting problem is undecidable, I found that they were quite inaccessible, or that they glossed over important details. To counter this, I've attempted to re-hash the proof using a familiar language, JavaScript, with numerous examples along the way.

This famous proof tells us that there is no general method to determine whether a program will finish running. To illustrate this, we can consider programs as JavaScript function calls, and ask whether it is possible to write a JavaScript function which will tell us