Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Tested on Ruby 2.5.1
require 'mini_racer'
MiniRacer::Platform.set_flags!
$iso = MiniRacer::Isolate.new
# Some mindless JS to keep the runtime busy for a moment
MY_JS = <<~JS
var foo = [];
#!/bin/bash
MODULES="janus renderraum magickraum imagehaus product-type-repo shop delivery-dates search-service"
for M in $MODULES; do
if [[ ! -d $M ]]; then
echo "Missing checkout for $M"
exit 1
fi
done
@TJC
TJC / Hello.kt
Created August 16, 2018 11:15
Super basic Kotlin example with JSON
// src/main/kotlin/Hello.kt
import com.beust.klaxon.Klaxon
fun main(args: Array<String>) {
println("Hello Kotlin!")
var item = Klaxon().parse<LineItem>(exampleJson())
// parse can return null, so you have to refer to item with the null-safety operator:
println("Nice ${item?.itemId} you've got there")
item = null
@TJC
TJC / import.rb
Created July 3, 2018 07:02
Ruby CSV to LevelDB
#!/usr/bin/env ruby
# Imports purchase-orders CSV into LevelDB
# Took ~11 minutes to run over 20.5 M records
require 'json'
require 'csv'
require 'leveldb-native'
# Docs at:
# https://github.com/vjoel/ruby-leveldb-native
@TJC
TJC / remove_all_s3_versions.py
Created April 20, 2018 06:05
Empty and remove an S3 bucket containing versioned file tombstones
#!/usr/bin/env python
# This took several days to run, but worked. Unlike the lifecycle rules I'd tried to use instead.
import boto3
session = boto3.Session()
s3 = session.resource(service_name='s3')
bucket = s3.Bucket('your-bucket-name')
bucket.object_versions.delete()
bucket.delete()
@TJC
TJC / retry-buildkite.rb
Created February 12, 2018 01:55
Trigger a buildkite rebuild of current branch
#!/usr/bin/env ruby
require 'json'
require 'uri'
require 'net/http'
def get_git_branch
`git rev-parse --abbrev-ref HEAD`.strip
end
def get_git_name
@TJC
TJC / reboot-tplink.go
Created July 18, 2017 06:17
Embarrassingly quick and dirty Go program to reboot a TP-Link TD-8840 ADSL modem.
@TJC
TJC / README
Created January 6, 2017 05:04
Test jets3t library again Minio
Download the files below into some directory.
Edit setup_env.sh to point to a Minio server.
source ./setup_env.sh
sbt run
@TJC
TJC / demo.sh
Created January 5, 2017 01:28
Test Minio resiliency
#!/bin/bash
echo "first file is ok" > first.txt
echo "second file is ok" > second.txt
echo "third file is ok" > third.txt
docker-compose up -d
echo "Waiting for docker compose for 10 seconds"
echo "Note: this demo assumes you've configured mc to have an endpoint called local configured...."
sleep 10
mc mb local/test
mc cp first.txt local/test/
@TJC
TJC / built.sbt
Created November 24, 2016 05:49
Demonstrate slow riak client shutdown
lazy val root = (project in file(".")).
settings(
organization := "au.net.strategicdata",
name := "riak-slow",
version := "0.1",
scalaVersion := "2.11.8"
)
libraryDependencies += "com.basho.riak" % "riak-client" % "2.1.0"