Skip to content

Instantly share code, notes, and snippets.

View StevenACoffman's full-sized avatar

Steve Coffman StevenACoffman

View GitHub Profile
@nolim1t
nolim1t / gist:182890
Created September 8, 2009 12:39
Simple Java webserver on port 8080
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.net.URI;
import java.util.concurrent.Executors;
import com.sun.net.httpserver.Headers;
@jsravn
jsravn / ConnectionDrainingFilter.java
Last active December 4, 2017 20:37
ConnectionDrainingFilter.java
/*
Copyright (c) 2017, Sky UK Ltd All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
export CLUSTER_DNS=[...]
export CLUSTER_IP=[...]
ssh -i workshop.pem docker@$CLUSTER_IP
docker container run -d --name jenkins -p 8080:8080 jenkins:alpine
docker container ls # Wait until it is up and running
@mikeblum
mikeblum / package_and_deploy_lambda_function.sh
Created July 3, 2016 04:00
Deploy Python Lambda fucntions to AWS
#!/bin/bash
# expects the lambda function .py file to be in the same directory as this script.
# based off of Amazon's official documentation:
# http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html#with-s3-example-deployment-pkg-python
# get the lambda function
lambda_func_file=$1
lambda_func="${lambda_func_file%.*}"
# exit if no file specified
[[ -z "$1" ]] && { echo "Lambda function is empty" ; exit 1; }
# generate a deployment timestamp
@joshpadilla
joshpadilla / aws-boto-vpc-create.py
Last active January 20, 2018 01:01
Create AWS VPC
#!/usr/bin/env python
import boto.vpc
import time
REGION_NAME = 'us-west-2'
AMI_ID = 'ami-8e27adbe' # Amazon Linux AMI
conn = boto.vpc.connect_to_region(REGION_NAME)
# Create a VPC
@babo
babo / lambda.py
Created December 17, 2015 11:55
Simple AWS lambda job to create an SQS event for each S3 events.
#!/usr/bin/env python
import argparse
import logging
try:
from urllib import splittype
except ImportError:
from urllib.parse import splittype
import boto3
@danehammer
danehammer / main.go
Created September 7, 2017 18:22
Equilibrium indices in go
package equilib
// Indices returns any of the equilibrium indices, -1 if there is not one
func Indices(nums []int) int {
if len(nums) > 10 {
return -2
}
for i := 0; i < len(nums); i++ {
left := sum(nums[0:i])
right := sum(nums[i+1:])
@objectx
objectx / struct_generator.go
Created July 31, 2017 04:59
Q: How to construct a generator whose types are generated via `gopter/gen`
func genStruct() gopter.Gen {
return genStrucType().FlatMap(
func(arg interface{}) gopter.Gen {
// typ := arg.(reflect.Type)
// Q: How to construct a generator?
return nil
},
reflect.TypeOf((interface{})(nil)),
)
}
@alsmola
alsmola / kms_auth.go
Last active April 17, 2018 11:30
Confidant style KMS-based authentication in Go
/*
Copyright 2016 Alex Smolen (https://alexsmolen.com)
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
@kachayev
kachayev / agents_VS_atoms.clj
Last active May 18, 2018 22:34
Clojure synchronous/asynchronous state changes
$ clj
Clojure 1.4.0
user=> ;; atoms - synchronous sharing state changes
user=> (def w (atom 0))
#'user/w
user=> (swap! w inc)
1
user=> @w
1
user=> (swap! w #(* % 100))