Skip to content

Instantly share code, notes, and snippets.

Avatar

Ian Battersby ianbattersby

View GitHub Profile
@ianbattersby
ianbattersby / colours.sh
Created Nov 12, 2018
Display full colour range in terminal window
View colours.sh
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 Dec 1, 2015
Example of a more complicated EventStore projection using GitHub API data
View cURLs.sh
# 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 Jan 26, 2013
Ubuntu TeamCity agent setup
View gist:4641450
#!/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 Mar 19, 2013
Fizzbuzz in Kotlin
View gist:5201036
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"
View es-notes.md
@ianbattersby
ianbattersby / gist:7475232
Created Nov 14, 2013
Alfred: Bind hotkey to iterm2 new window
View gist:7475232
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 Dec 27, 2015
Current IntelliJ colour scheme (inspired by Soda Dark)
View gist:7254920

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 Sep 17, 2013
Example of Simple.Web bootstrapping w/acceptance test. NOTE: The acceptance test assembly does not need to reference anything other than the bootstrapping assembly!
View GeEndpointTests.cs
namespace SimpleWebTest.Tests.Acceptance
{
using SimpleWebTest;
using Xunit;
public class GetEndpointTests : IDisposable
{
private const string port = 5000;
@ianbattersby
ianbattersby / Program.cs
Last active Dec 22, 2015
Example Simple.web w/Razor
View Program.cs
namespace ConsoleApplication26
{
using System;
using System.Collections.Generic;
using Simple.Web;
using Simple.Web.Behaviors;
internal class Program
{
View gist:6425097
public static Type[] EnforceReferencesFor = { typeof(Simple.Web.JsonNet.JsonMediaTypeHandler) };