Skip to content

Instantly share code, notes, and snippets.

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 / 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

@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 / 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 / lambda-dynamo
Created July 13, 2016 01:12 — forked from markusklems/lambda-dynamo
Short aws lambda sample program that puts an item into dynamodb
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
import React from 'react'
const provideContext = (contextKey, contextType) => (
React.createClass({
childContextTypes: {
[contextKey]: contextType
},
getChildContext() {
const { children, ...props } = this.props
{
"Version": "2012-10-17",
"Statement": [{
"Action": "ec2:*",
"Effect": "Allow",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:Region": [
"us-east-1",
@apackeer
apackeer / server.py
Created September 1, 2016 06:53 — forked from martijnvermaat/server.py
SimpleHTTPServer with history API fallback
#!/usr/bin/env python
"""
Modification of `python -m SimpleHTTPServer` with a fallback to /index.html
on requests for non-existing files.
This is useful when serving a static single page application using the HTML5
history API.
"""
@apackeer
apackeer / CloningEdisons.md
Created September 19, 2016 22:53 — forked from sxing/CloningEdisons.md
Cloning Edisons by making a flashable image from an existing Edison

This’ll make a flashable clone of an existing Intel Edison (with Yocto... Ubilinux here: https://gist.github.com/sxing/300b8a58c9f438fcc581). I've wanted to extract a flashable image from my Edisons for a while; I usually hack straight on my Edison until something works and don't want to porting to the Yocto build process afterwards. To clone Edisons, I've been using rubidium's commands from the Intel forums, but I wanted a method that worked on top of the Phone Flash Tool used for flashing Edison since it'll be easier to distribute images. I've tested this for flashing Edisons from ww36 (1.0), ww05-2015 (2.0), and ww25.5-2015 (2.1) firmwares to an ww25.5-2015 (2.1) based clone image.

NOTE: I've noticed that this doesn't work well with Edisons that are cloned copies that were produced through copying the entire mmcblk0 block as done in the Intel forum thread referenced above. I've built a workaround for that, but it is a bit longer: https://gist.github.c

@apackeer
apackeer / CloningEdisonPart2.md
Created September 20, 2016 05:47 — forked from sxing/CloningEdisonPart2.md
Got problems with CloningEdisons.md? This is the path I take when things don't work out for some reason.

I'm guessing you've had some problems with the other CloningEdisons instructions (https://gist.github.com/sxing/f02a4a1703b16803a7d4) if you're here. Sorry about that...

This is the path I take when things don't work out, usually related to a completely messed up data corruption that was my fault.

  1. Acquire a microSD card and an Edison breakout that has an microSD card slot, like the Arduino Expansion board. Make sure the microSD card is at least 4GBs in size.
  2. Make sure nothing that needs to be copied over is in your /home folder. This won't be copied over in the process.
  3. Follow these instructions to set up the Edison you want to clone to boot from USB: https://communities.intel.com/thread/61048
  4. Boot to the microSD card.
  5. Make a ext4 image that is the same size as your / partition. If you've already made an image, I recommend not recreating a new image and skip this step to save some time. This gets me pretty close in size without being larger: