Skip to content

Instantly share code, notes, and snippets.

View nicka's full-sized avatar
Serverlessing

Nick den Engelsman nicka

Serverlessing
View GitHub Profile
// See: https://www.youtube.com/watch?v=HaEPXoXVf2k
const AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
const dynamoDb = new AWS.DynamoDB.DocumentClient({ api_version: '2012-08-10' });
const TABLE = 'single-table-design';
const GSI1 = 'gsi1';
const GSI1PK = `${GSI1}pk`;
const GSI1SK = `${GSI1}sk`;
@nicka
nicka / four-in-a-row.py
Created November 8, 2018 23:37
Four in a row example
import numpy as np
# print(np.__version__)
ROW_COUNT = 6
COLUMN_COUNT = 7
WINNG_PIECE_COUNT = 4
def create_board():
board = np.zeros((ROW_COUNT, COLUMN_COUNT))
return board
@nicka
nicka / AppSync-Example.yaml
Created May 15, 2018 15:34 — forked from adrianhall/AppSync-Example.yaml
An example CloudFormation template for AWS AppSync
---
Description: AWSAppSync DynamoDB Example
Resources:
GraphQLApi:
Type: "AWS::AppSync::GraphQLApi"
Properties:
Name: AWSAppSync DynamoDB Example
AuthenticationType: AWS_IAM
PostDynamoDBTableDataSource:
@nicka
nicka / .travis.yml
Created August 3, 2017 08:04 — forked from BretFisher/.travis.yml
Travis-CI Docker Image Build and Push to AWS ECR
sudo: required #is required to use docker service in travis
language: php #can be any language, just php for example
services:
- docker # required, but travis uses older version of docker :(
install:
- echo "install nothing!" # put your normal pre-testing installs here
@nicka
nicka / mfa.sh
Last active May 26, 2017 03:02
Assumes an AWS IAM role and exports temporary AWS_* credentials.
#!/bin/bash
#### Description: Assumes an AWS IAM role and export temporary AWS_* credentials.
#### Written by: Nick den Engelsman - nick@bandlab.com on 2017-05
####
#### Setup:
#### 1. npm install -g aws-auth-helper
#### 2. save this script as ~/.aws/mfa.sh
#### 3. chmod +x ~/.aws/mfa.sh
####
#### Edit your .bash_rc (or something else):
@nicka
nicka / xml_parser.rb
Last active August 29, 2015 14:17 — forked from kmile/xml_parser.rb
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The
# XML Reader is a good way to move a cursor through a (large) XML document fast,
# but is not as cumbersome as writing a full SAX document handler. Read about
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html
#
# Just pass the reader in this parser and specificy the nodes that you are interested
# in in a block. You can just parse every node or only look inside certain nodes.
#
# A small example:
#
#!/usr/bin/env ruby
# == Simple Daemon
#
# A simple ruby daemon that you copy and change as needed.
#
# === How does it work?
#
# All this program does is fork the current process (creates a copy of
# itself) then exits, the fork (child process) then goes on to run your
# daemon code. In this example we are just running a while loop with a