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 / gist:77799ca0d96f5d475f1e
Created December 22, 2014 17:20
Elm: Wrong HTML element disappears in state transition
<!DOCTYPE HTML>
<html><head><meta charset="UTF-8"><title>Compiled Elm</title><style>html,head,body { padding:0; margin:0; }
body { font-family: 'Lucida Grande','Trebuchet MS','Bitstream Vera Sans',Verdana,Helvetica,sans-serif; }
a {
color: #1184CE;
text-decoration: none;
}
a:hover {
text-decoration: underline;
color: rgb(234,21,122);
@jameshfisher
jameshfisher / splunk_enterprise_download_urls.md
Last active August 29, 2015 14:04
Splunk Enterprise download URLs
NOT THIS: http://www.splunk.com/page/download_track?file=6.1.2/splunk/linux/splunk-6.1.2-213098-linux-2.6-x86_64.rpm
THIS:     http://download.splunk.com/products/splunk/releases/6.1.2/splunk/linux/splunk-6.1.2-213098-linux-2.6-x86_64.rpm

i.e. take the file argument and prefix it with http://download.splunk.com/products/splunk/releases/

Works for:

  • 6.1.2/splunk/linux/splunk-6.1.2-213098-linux-2.6-x86_64.rpm
  • 6.1.2/universalforwarder/linux/splunkforwarder-6.1.2-213098-linux-2.6-x86_64.rpm
  • ...
@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 / ORM_constraints.md
Last active January 4, 2016 12:59
ORM correctness constraints

ORM correctness constraints

At an old workplace, we used the Hibernate ORM to map a class hierarchy to our relational database. Hibernate represents a class hierarchy in the following way. Let's say we have the tables:

abstract class A
class B extends A
class C extends A
@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 / Javaland.md
Last active January 2, 2016 07:29
Javaland

An introduction to Javaland

Javaland is notorious for its acronyms, inconsistent and redundant naming, bundling of multiple things into new definitions, circular definitions, and so on.

This file aims to reduce this incomprehensible mess into a set of succinct definitions. This should read like a dictionary, where all definitions only refer to prior definitions.

The JVM

Java bytecode refers to two things:

@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

@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 / NinetyNine.hs
Last active December 11, 2015 01:48
initial
module NinetyNine where
import Data.List (foldl')
-- Problem 1: Find the last element of a list.
myLast :: [a] -> a
myLast [] = error "myLast []"
myLast (x:xs) = foldl' (flip const) x xs
-- Problem 2: Find the last but one element of a list.
@jameshfisher
jameshfisher / rust_0.2_compile_segfault.bash
Created July 2, 2012 23:06
Segfault compiling Rust 0.2
james@bast:~$ cd /tmp/
james@bast:/tmp$ tar -xvf rust-0.2.tar.gz
rust-0.2/
rust-0.2/Makefile.in
rust-0.2/mk/
rust-0.2/mk/snap.mk
rust-0.2/mk/llvm.mk
rust-0.2/mk/docs.mk
rust-0.2/mk/platform.mk
rust-0.2/mk/install.mk