Skip to content

Instantly share code, notes, and snippets.

@apackeer
apackeer / nodejs
Created June 2, 2016 03:12
node.js init.d script for CentOS
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
@apackeer
apackeer / dynamodb_read_backoff.py
Created June 2, 2016 02:34 — forked from shentonfreude/dynamodb_read_backoff.py
Wrap boto3 dynamodb in an exponential backoff to avoid ProisionedThroughputExceededException
#!/usr/bin/env python
# An exponential backoff around Boto3 DynamoDB, whose own backoff eventually
# fails on long multipage scans. We'd like to use this as a wrapper somehow,
# see: https://gist.github.com/numberoverzero/cec21b8ca715401c5662
from time import sleep
import boto3
from boto3.dynamodb.conditions import Attr
@apackeer
apackeer / java-8-ami.md
Created May 21, 2016 00:39 — forked from rtfpessoa/java-8-ami.md
[Guide] Install Sun Java 8 on Amazon EC2 Ami

First verify the version of Java being used is not Sun Java 8 SDK

java -version

Get the Sun Java 8 SDK from Oracle

wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-x64.rpm"

Install Sun Java 8

sudo rpm -i jdk-8u11-linux-x64.rpm

Check if the default java version is set to Sun Java 8 SDK

console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB();
exports.handler = function(event, context) {
console.log("Request received:\n", JSON.stringify(event));
console.log("Context received:\n", JSON.stringify(context));
var tableName = "OurBlogDemo";
var datetime = new Date().getTime().toString();
@apackeer
apackeer / Amazon_SES.py
Created February 10, 2016 23:56 — forked from seedifferently/Amazon_SES.py
Simple example email wrapper for Boto's SES
"""
Example code for sending emails using boto's SES module. Its main purpose is to
show how easy it is to build multipart text/html emails.
Unfortunately, at this time Amazon's SES doesn't seem to allow you to add
attachments to messages, but if it does in the future it would probably look
like the code that I've commented out below the exception.
The SES module of the Boto package isn't quite finalized yet, but I currently
have this code running using Harry Marr's implementation which is available at:
@apackeer
apackeer / git-unsorted-log.go
Last active August 29, 2015 14:27 — forked from timhughes/git-unsorted-log.go
An example of howto user git2go https://github.com/libgit2/git2go which is a libgit2 bindings package for golang
/*
requires libgit2
*/
package main
import (
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | grep -vE "$(docker ps -a --filter='name=-data' -q | tr \"\n\" \|)" | xargs -r docker rm -v
echo "Removing untagged images..."
docker images --no-trunc | grep "<none>" | awk '{print $3}' | xargs -r docker rmi
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@apackeer
apackeer / timestamp.go
Last active August 29, 2015 14:23 — forked from bsphere/timestamp.go
package timestamp
import (
"fmt"
"labix.org/v2/mgo/bson"
"strconv"
"time"
)
type Timestamp time.Time