Skip to content

Instantly share code, notes, and snippets.

View ian-kent's full-sized avatar

Ian Kent ian-kent

View GitHub Profile
@ian-kent
ian-kent / Main.elm
Last active June 19, 2016 21:36
cat timer
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Http
import Task
import Json.Decode as Json
import String exposing (length)
import Time exposing (Time, second)
@ian-kent
ian-kent / workspace.json
Created February 21, 2016 11:01
Docker containers in websysd
{
"Name": "external",
"Tasks": [{
"Name": "kafka",
"Command": "docker run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=`docker-machine ip \\`docker-machine active\\`` --env ADVERTISED_PORT=9092 spotify/kafka",
"Executor": ["/bin/sh", "-c"],
"Service": true
}, {
"Name": "kafka-manager",
"Command": "docker run -p 9000:9000 -e ZK_HOSTS=\"192.168.99.100:2181\" -e APPLICATION_SECRET=letmein sheepkiller/kafka-manager",
@ian-kent
ian-kent / SSHServer.java
Created January 27, 2016 13:37
SCP server with in-memory FileSystem
package com.github.iankent.sshd;
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
import org.apache.sshd.common.file.FileSystemFactory;
import org.apache.sshd.common.scp.ScpTransferEventListener;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.apache.sshd.server.command.ScpCommandFactory;
@ian-kent
ian-kent / annoying.go
Created June 7, 2015 18:35
This annoys me
func (i *inMemory) Get(key string) (interface{}, bool) {
// This doesn't work ("not enough arguments to return")
return i.data[key]
// But this does
v, ok := i.data[key]
return v, ok
}
@ian-kent
ian-kent / config.go
Created February 6, 2015 21:06
My new favourite golang config pattern
package config
import "flag"
var BindAddress string
var SMTPHost string
var SMTPPort int
func Configure() {
flag.StringVar(&BindAddress, "bind", ":9650", "Bind address")
@ian-kent
ian-kent / elasticache.go
Created December 30, 2014 13:40
elasticache.go
package main
import (
"fmt"
"log"
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/elasticache"
)
@ian-kent
ian-kent / elasticache.go
Created December 11, 2014 15:58
ElastiCache goamz example for DescribeReplicationGroup
package main
import (
"fmt"
"log"
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/elasticache"
)
@ian-kent
ian-kent / test.go
Created December 10, 2014 10:51
Gorilla pat placeholder/query param example
package main
import(
"log"
"net/http"
"github.com/gorilla/pat"
)
func main() {
p := pat.New()
@ian-kent
ian-kent / elasticache.go
Created December 9, 2014 15:28
elasticache.go
package main
import (
"fmt"
"log"
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/elasticache"
)
@ian-kent
ian-kent / gist:93e7d33dd413d85876ae
Created November 13, 2014 17:57
crowdmob countscan
diff --git a/dynamodb/scan.go b/dynamodb/scan.go
index 8e08eb9..3c46933 100644
--- a/dynamodb/scan.go
+++ b/dynamodb/scan.go
@@ -109,6 +109,48 @@ func (t *Table) Scan(attributeComparisons []AttributeComparison) ([]map[string]*
return t.FetchResults(q)
}
+func (t *Table) CountScan() (int64, error) {
+ var lastEvaluatedKey *Key