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"
@ianbattersby
ianbattersby / gist:4641450
Created January 26, 2013 09:46
Ubuntu TeamCity agent setup
#!/bin/bash
# THESE ARE NOTES, NOT TESTED AS SCRIPT!
# We need the following to get and run teamcity agent
sudo apt-get install openjdk-7-jre-headless
sudo apt-get install unzip #For unzipping buildAgent.zip
# For compiling Simple.Web
sudo apt-get install ruby1.9.1
@ianbattersby
ianbattersby / gist:5201036
Created March 19, 2013 23:18
Fizzbuzz in Kotlin
inline fun Int.divides(d: Int) : Boolean { return this % d == 0 }
fun main(args: Array<String>) : Unit {
var i = 0
iterate { i++ } take 100 forEach {
println(
when (true) {
it.divides(15) -> "fizzbuzz"
it.divides(3) -> "fizz"
@ianbattersby
ianbattersby / gist:7475232
Created November 14, 2013 22:14
Alfred: Bind hotkey to iterm2 new window
on alfred_script(q)
if isAppRunning("iTerm") then
tell application "iTerm"
set myterm to (make new terminal)
tell myterm
set mysession to (make new session at the end of sessions)
tell mysession
exec command "/bin/zsh -l"
end tell
end tell
@ianbattersby
ianbattersby / gist:7254920
Last active December 27, 2015 02:49
Current IntelliJ colour scheme (inspired by Soda Dark)

NB: Where no background is specified, THERE ISN'T ONE (no tick)

General

  • Default text: fgF8F8F8 bg383838
  • Caret: F8F8F8

NB: Rest are darcula defaults I think

Language Defaults

@ianbattersby
ianbattersby / GeEndpointTests.cs
Created September 17, 2013 12:53
Example of Simple.Web bootstrapping w/acceptance test. NOTE: The acceptance test assembly does not need to reference anything other than the bootstrapping assembly!
namespace SimpleWebTest.Tests.Acceptance
{
using SimpleWebTest;
using Xunit;
public class GetEndpointTests : IDisposable
{
private const string port = 5000;
@ianbattersby
ianbattersby / Program.cs
Last active December 22, 2015 07:09
Example Simple.web w/Razor
namespace ConsoleApplication26
{
using System;
using System.Collections.Generic;
using Simple.Web;
using Simple.Web.Behaviors;
internal class Program
{