Skip to content

Instantly share code, notes, and snippets.

View reedobrien's full-sized avatar

Reed O'Brien reedobrien

View GitHub Profile
@reedobrien
reedobrien / upload_docs_to_cloudsearch.py
Created July 28, 2015 21:08
Upload docs to AWS CloudSearch with boto3
import json
import boto3
settings = {
"aws.cloudsearch.doc":
"<doc-ep>",
"aws.cloudsearch.search":
"<search-ep>"
}
from avail.aws.cloudsearch import get_cloudsearch_endpoint_from_settings
doc = get_cloudsearch_endpoint_from_settings("doc", settings)
@reedobrien
reedobrien / bucket-notify.py
Last active April 5, 2017 15:43
Add notification for an S3 bucket to an SQS queue with AWS and boto3
import json
import boto3
region = "us-east-1"
settings = {
"bucket_name": "proj-notify-test123",
"queue_name": "proj-notify-test123",
"region": region,
"account_number": ACCOUNT_NUMBER
@reedobrien
reedobrien / create_dynamo_indexes.py
Created June 15, 2015 15:13
Create indexes on DynamoDB table with boto3
import boto3
from boto3.dynamodb.types import STRING
table = boto3.resource("dynamodb", region_name="us-east-1").Table("availdev-JobStateDB-1UIJ881212TPX")
## Attrs for GSI
attrdef = [
{"AttributeName": "state", "AttributeType": STRING},
{"AttributeName": "userId", "AttributeType": STRING},
{"AttributeName": "assetId", "AttributeType": STRING}
@reedobrien
reedobrien / proxypass.go
Created May 2, 2015 17:55
A basic auth protected proxy server
package main
import (
"encoding/base64"
"flag"
"io"
"log"
"net/http"
"strings"
)
package main
import (
"fmt"
"time"
)
func main() {
ticker := time.Tick(time.Second)
for i := 1; i <= 10; i++ {
@reedobrien
reedobrien / guessext.py
Created April 23, 2015 04:53
semi random or bad results
import mimetypes
for i in range(10):
print(mimetypes.guess_extension("image/tiff"))
print(mimetypes.guess_extension("image/jpeg"))
for i in range(10):
mimetypes.init()
print(mimetypes.guess_extension("image/jpeg"))
# This is a copy of the clang-format vim-integration script, refactored to work
# with yapf.
# Questions and/or suggestions? I'm @pignacio in github.
# This script is hosted at http://gist.github.com/pignacio/f93218bbafa2aa94610c
# I'm not sure if this works properly in windows/mac. Only tested in linux.
#
# This file is a minimal yapf vim-integration. To install:
# - Change 'binary' if yapf is not on the path (see below).
# - Add to your .vimrc:
#
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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
// distributed under the License is distributed on an "AS IS" BASIS,
@reedobrien
reedobrien / dawg.py
Last active August 29, 2015 14:10 — forked from smhanov/dawg.py
#!/usr/bin/python3
# By Steve Hanov, 2011. Released to the public domain.
# Updated 2014 to use DAWG as a mapping.
import sys
import time
DICTIONARY = "/usr/share/dict/words"
QUERY = sys.argv[1:]
# This class represents a node in the directed acyclic word graph (DAWG). It
@reedobrien
reedobrien / kvheap.go
Created September 7, 2014 16:11
Key Value Heap
package main
import (
"container/heap"
"fmt"
)
type KVPair struct {
Key string
Value interface{}