Skip to content

Instantly share code, notes, and snippets.

View sihil's full-sized avatar

Simon Hildrew sihil

View GitHub Profile
@sihil
sihil / favicon-cake.scala
Created May 8, 2012 09:19
FavIcon Cake - maps from a png to another png with a smaller palette (and counts how many pixels there are of each colour)
/*
This scala script takes in a small png file and converts it to a grayscale image with a smaller
palette size; counting the number of each pixels in the original and resulting image.
*/
import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO
import scala.collection.JavaConversions._
import scala.math.floor
@sihil
sihil / testSalat.scala
Created November 19, 2012 16:55
Type hinting when necessary doesn't seem to work for traits...
import com.novus.salat._
import com.novus.salat.global.ctx
import com.mongodb.casbah.commons.MongoDBObject
trait TestTrait
case class Test(value: TestTrait)
case class ValueType(number: Int) extends TestTrait
object TestGraters {
val testGrater = grater[Test]
@sihil
sihil / gist:8810314
Created February 4, 2014 19:15
Fastly MTRs
fra1235
-------
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. 10.121.75.1 0.0% 392 0.6 4.7 0.6 217.0 20.5
2. 10.120.3.153 0.0% 392 0.5 0.4 0.3 16.1 0.9
3. 10.120.1.73 0.0% 392 0.9 1.2 0.9 25.7 1.3
4. 10.120.1.33 0.0% 392 1.3 1.6 1.3 3.5 0.1
5. 10.120.1.29 0.0% 392 2.5 2.2 1.7 31.0 2.3
6. 10.215.9.67 0.0% 392 2.2 2.2 1.9 32.4 1.6
git diff test.eyaml
index ccf3533..74ceaa3 100644
--- a/test.eyaml
+++ b/test.eyaml
@@ -1,5 +1,5 @@
---
plain-property: You can see me
encrypted-property: ENC[PKCS7,MIIBiQYJKoZIhvcNAQcDoIIBejCCAXYCAQAxggEhMIIBHQIBADAFMAACAQAwDQYJKoZIhvcNAQEBBQAEggEAxqeLyrOtMJy392yNwpNUKPIJ441SRVAMNi84wEGZVc9TIsRkWmMJGxpe+jy9edqnl552pbmD+B5ecfYQ5dehDVeos2CzFrMoCAV+qqvYml1nkbiBdPreZeUVZCLQLOw9I03z+iSEokGUy0x9702zjjK1mafqHWC/ClzdZh1UGxd+1hyGrw/dDOVsZqdLT1bWT+MT5BiyVlmeHFDMy7XFuJkgER73t1WOC0sOrWwua37yKneDA/J5sFYrRypVD+QKLoFMtgxYYBldcenn+whBEJkMNrVTJzGkzo9HPaZ/dJFvBVGPDo6MxRqMFf2Tx/3Mq7bq6Ckoa6PNQiEz4BS88TBMBgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBAvO3CeT6tosqRc8VuufOo3gCB5JxY9ihIbnUJJl0Iuw0qeS6UsqKJ7HSst6+qRH90t5w==]
-another-encrypted-property: ENC[PKCS7,MIIBiQYJKoZIhvcNAQcDoIIBejCCAXYCAQAxggEhMIIBHQIBADAFMAACAQAwDQYJKoZIhvcNAQEBBQAEggEAK7otMYeHetnvkQVXQkjedR/2bXSA6KlDlI7rFBsrXpwsj5A8UBo8N3t5MgKx6kMPQN6T3ILNBA/1k7HFhRAsd5biJ2g1Y4NO8iS7Jedm+zlZ6MQPK0NNtU3+hNHYUfv63jmqKMb9GWswTPaS6fTiWz/+mLl1chWBuK9BW9b6xW6ObOxmK4kYf9xOo7w+OrJy02j4zLNV
ENC[PKCS7,Y22exl+OvjDe+drmik2XEeD3VQtl1uZJXFFF2NnrMXDWx0csyqLB/2NOWefv
NBTZfOlPvMlAesyr4bUY4I5XeVbVk38XKxeriH69EFAD4CahIZlC8lkE/uDh
jJGQfh052eonkungHIcuGKY/5sEbbZl/qufjAtp/ufor15VBJtsXt17tXP4y
l5ZP119Fwq8xiREGOL0lVvFYJz2hZc1ppPCNG5lwuLnTekXN/OazNYpf4CMd
/HjZFXwcXRtTlzewJLc+/gox2IfByQRhsI/AgogRfYQKocZgFb/DOZoXR7wm
IZGeunzwhqfmEtGiqpvJJQ5wVRdzJVpTnANBA5qxeA==]
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Publish or be damned.",
"Parameters": {
"SubscriberPrincipals": {
"Type": "CommaDelimitedList",
"Description": "Account IDs to allow subscription from."
},
"Stage": {
"Type": "String",
@sihil
sihil / iam-upload.sh
Last active September 18, 2015 10:08
Bash script for uploading certificates to IAM
#!/bin/bash
# Upload a certificate and chain to AWS
set -e
DOMAIN=$1
if [ -n "$2" ]; then
PROFILE_PARAM="--profile $2"
fi
if [ -z "${DOMAIN}" ]; then
@sihil
sihil / prism.json
Last active February 24, 2016 18:05
{
"data" : {
"images" : [ {
"arn" : "arn:aws:ec2:eu-west-1::image/ami-XXXXXXXX",
"name" : "ubuntu-vivid-java8_408_2016/02/17_12-18-34",
"imageId" : "ami-XXXXXXXX",
"region" : "eu-west-1",
"description" : "AMI for ubuntu-vivid-java8 built by TeamCity: tools-machine-images#408",
"tags" : {
"Name" : "ubuntu-vivid-java8_408_2016/02/17_12-18-34",
@sihil
sihil / .gitignore
Created April 15, 2016 11:43
Global Git Ignore
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
@sihil
sihil / plambda.yaml
Created October 5, 2016 21:33
Snippet of some CloudFormation resources for Plambda
API:
Type: AWS::ApiGateway::RestApi
Properties:
Name:
Fn::Join:
- " "
- - Restorer Plambda
- Ref: Stage
Description: Experimental Restorer Play app in Lambda