Skip to content

Instantly share code, notes, and snippets.

View ianbattersby's full-sized avatar
🐘
@ianbattersby@hachyderm.io

Ian Battersby ianbattersby

🐘
@ianbattersby@hachyderm.io
View GitHub Profile
@ianbattersby
ianbattersby / hash.lua
Created December 5, 2022 14:48
Lua has check on ARM64
local M = {}
local B = bit or bit32 or require("catppuccin.lib.native_bit")
local hash_str = function(str) -- MurmurOAAT_32, https://stackoverflow.com/questions/7666509/hash-function-for-string
local hash = 0x12345678
local tbl = { string.byte(str, 1, #str) }
for i = 1, #tbl do
hash = B.bxor(hash, tbl[i])
hash = hash * 0x5bd1e995
hash = B.bxor(hash, B.rshift(hash, 15))
@ianbattersby
ianbattersby / colours.sh
Created November 12, 2018 18:41
Display full colour range in terminal window
awk 'BEGIN{
s="/\\/\\/\\/\\/\\"; s=s s s s s s s s s s s s s s s s s s s s s s s;
for (colnum = 0; colnum<256; colnum++) {
r = 255-(colnum*255/255);
g = (colnum*510/255);
b = (colnum*255/255);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum+1,1);
@ianbattersby
ianbattersby / cURLs.sh
Created December 1, 2015 21:51
Example of a more complicated EventStore projection using GitHub API data
# Push an IssuesEvent into ES (with known issue number)
curl -i -L -d @example-issues-event.json http://127.0.0.1:2113/streams/github-IssuesEvent -H "Content-Type:application/json" -H "ES-EventType:IssuesEvent" -u "admin:changeit"
# Push a PushEvent into ES (has a commit description with required match)
curl -i -L -d @example-push-event.json http://127.0.0.1:2113/streams/github-PushEvent -H "Content-Type:application/json" -H "ES-EventType:PushEvent" -u "admin:changeit"
# Push a DeploymentEvent into ES (has a description with required match)
curl -i -L -d @example-DeploymentEvent-desc.json http://127.0.0.1:2113/streams/github-DeploymentEvent -H "Content-Type:application/json" -H "ES-EventType:DeploymentEvent" -u "admin:changeit"
{
"$userStreamAcl" : {
"$r" : "$all",
"$w" : "$all",
"$d" : "$all",
"$mr" : "$all",
"$mw" : "$all"
},
"$systemStreamAcl" : {
"$r" : "$admins",
@ianbattersby
ianbattersby / pump.js
Created November 25, 2015 11:00
Pumps GitHubApi events into EventStore (demo)
var githubApi = require("node-github");
var http = require("http");
var timeUntilNextEvents = 10000;
var last_created_at = new Date();
var overlapped = false;
var uuid = (function() {
var self = {};
var lut = []; for (var i=0; i<256; i++) { lut[i] = (i<16?'0':'')+(i).toString(16); }
self.generate = function() {
@ianbattersby
ianbattersby / pump-unauth.js
Created November 25, 2015 10:59
Pumps GitHubApi events into EventStore - unauthenticated (demo)
var http = require('http');
var https = require('https');
var timeUntilNextEvents = 10000;
var last_created_at = new Date();
var overlapped = false;
var uuid = (function() {
var self = {};
var lut = []; for (var i=0; i<256; i++) { lut[i] = (i<16?'0':'')+(i).toString(16); }
self.generate = function() {
#!/bin/sh
# This script will setup Evm (Emacs Version Manager) and Cask on
# Travis to use for Emacs Lisp testing.
#
# In .travis.yml, add this:
#
# - curl -fsSkL https://gist.github.com/ianbattersby/c3399aa8cd9e2a6f8afa/raw > travis.sh && source ./travis.sh
#
# Emacs 24.3 is installed in the above script because Cask requires
[15200,07,15:26:50.939] Read Request Body Failed.
Value cannot be null.
Parameter name: token

Keybase proof

I hereby claim:

  • I am ianbattersby on github.
  • I am ianbattersby (https://keybase.io/ianbattersby) on keybase.
  • I have a public key whose fingerprint is E33D 9F6B 8CAF FB9B 419E 7586 EE2D 6FBB 294F 3BE7

To claim this, I am signing this object: