Skip to content

Instantly share code, notes, and snippets.

@neilellis
neilellis / HelloScript.java
Last active August 29, 2015 14:07
An example of the http://github.com/cazcade/dollar library in action. And yes this is all valid Java!
import com.cazcade.dollar.Script;
import com.cazcade.dollar.SecondScript;
import com.cazcade.dollar.var;
import java.util.Date;
/**
* @author <a href="http://uk.linkedin.com/in/neilellis">Neil Ellis</a>
*/
public class HelloScript extends Script {
@neilellis
neilellis / FirstScript.java
Created October 6, 2014 14:05
Piping in Dollar
package com.cazcade.dollar.pipe;
import com.cazcade.dollar.Script;
import com.cazcade.dollar.var;
import java.util.Date;
/**
* @author <a href="http://uk.linkedin.com/in/neilellis">Neil Ellis</a>
*/
$GET("/v2/webshot/:key", (http) ->
$($("params", http.params()), $("query", http.queryParams()))
.$pipe(new ParamValidator())
.$pipe(new KeyValidator())
.$void(() -> $().$error(
"Sorry your key is not recognized, maybe you need to check http://app.snapito.io/#/account",
var.ErrorType.VALIDATION))
.$pipe((v) -> {
if (v.$match("userStatus", "over_free")) {
http.status(302);
@neilellis
neilellis / JsonUtil.java
Last active August 29, 2015 14:07
Convert Main style string arguments to Json. This includes using --foo bar syntax
/*
* Copyright (c) 2014 Neil Ellis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@neilellis
neilellis / bash_tricks.sh
Created April 16, 2015 15:05
Some useful bash features
#!/usr/bin/env bash
set -eux
#e - error if non zero return value
#u - undefined variables trigger syntax error
#x - debug
#minus sign ADDS the flags
#plus sign REMOVES the flags
@neilellis
neilellis / cached-circle.yml
Last active August 29, 2015 14:19
Basic Circle.yml files for Tutum
machine:
services:
- docker
dependencies:
cache_directories:
- "~/docker"
override:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS tutum.co
@neilellis
neilellis / sanitized-stack.yml
Created May 20, 2015 11:50
Example tutum stack
lb:
image: 'tutum/haproxy:latest'
links:
- brochure
- render
- server
ports:
- '80:80'
restart: always
roles:
@neilellis
neilellis / README.md
Last active December 7, 2019 22:51
An example Blue/Green deployment using Tutum and Cloudflare (for DNS)
@neilellis
neilellis / dns-hack.sh
Last active July 29, 2019 06:09
Fixes links on Alpine Linux
#!/usr/bin/with-contenv sh
if [ ! -f /etc/dnsmasq-resolv.conf ]
then
cp -f /etc/resolv.conf /etc/dnsmasq-resolv.conf
echo "nameserver 127.0.0.1" > /etc/resolv.conf
fi
while ! ps -ef | grep -v grep | grep dnsmasq-resolv.conf
do
sleep 1

Install:

curl https://gist.githubusercontent.com/neilellis/41b1509bdf1636260c9a/raw/509e253297d031733474fd8dc373c93ca5c6b33e/dkr > ~/.dkr
echo ". ~/.dkr" >> ~/.bash_profile