Skip to content

Instantly share code, notes, and snippets.

View johnston's full-sized avatar

Stuart Johnston johnston

View GitHub Profile
@johnston
johnston / data-star-CSRF.js
Created April 12, 2025 19:40
Automatically add a CSRF token to requests with data-star
import { load } from "@starfederation/datastar/bundles/datastar-core"
import * as plugins from "@starfederation/datastar/plugins"
// Function to get CSRF token from meta tag
const getCSRFToken = () => {
const meta = document.querySelector('meta[name="csrf-token"]')
return meta ? meta.getAttribute('content') : null
}
// Helper function to create CSRF-enabled HTTP method handlers
@johnston
johnston / setup.sh
Created April 27, 2020 10:57 — forked from shaneog/setup.sh
GCE install for Buildkite Agent v3 (Beta)
#!/usr/bin/env bash
set -eo pipefail
DATE=$(date +%Y%m%d-%H%M%S)
GROUP_NAME="buildkite-agent"
TEMPLATE_NAME="${GROUP_NAME}-${DATE}"
# Builder Group
gcloud compute instance-templates create "${TEMPLATE_NAME}-builder" \
@johnston
johnston / postgres12_fix.rb
Created December 5, 2019 14:05
Fixes Rails < 4.2 PostgreSQL 12 "panic" issue
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
def set_standard_conforming_strings
old, self.client_min_messages = client_min_messages, 'error'
execute('SET standard_conforming_strings = on', 'SCHEMA') rescue nil
ensure
self.client_min_messages = old
end
end
Verifying my Blockstack ID is secured with the address 17aqRSLX2q8Kwy37qHfhhKHTc4fEwapkWZ https://explorer.blockstack.org/address/17aqRSLX2q8Kwy37qHfhhKHTc4fEwapkWZ

Keybase proof

I hereby claim:

  • I am johnston on github.
  • I am johnstonnorth (https://keybase.io/johnstonnorth) on keybase.
  • I have a public key ASAXTuVydtjzaGgSMSZc-tieEGtg4nHrxwfoctSOfdVrYAo

To claim this, I am signing this object:

sudo apt-get -y update && sudo apt-get -y upgrade
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core python-software-properties software-properties-common libxslt-dev libxml2-dev
# RUBY 1.9.3
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz
tar -xvzf ruby-1.9.3-p374.tar.gz
cd ruby-1.9.3-p374/
./configure
make
sudo make install