Skip to content

Instantly share code, notes, and snippets.

View ShakataGaNai's full-sized avatar
🐍
Can Has Status! Working on the Pythons

Jon Davis ShakataGaNai

🐍
Can Has Status! Working on the Pythons
View GitHub Profile
@ShakataGaNai
ShakataGaNai / gist:5566077
Last active December 17, 2015 06:29
function ddbLogSMS() - Sample for DynamoDB/Twilio. For http://snowulf.com/2013/05/13/wrapping-my-brain-around-dynamodb/
function ddbLogSMS($act,$data){
date_default_timezone_set("UTC");
$now = time();
$upd = array();
$upd['ACTION'] = array("Action" => \Aws\DynamoDb\Enum\AttributeAction::PUT,
"Value" => array(
Type::STRING => $act
)
);
/*
* Handy Reference: http://www.sublimetext.com/docs/file-type-preferences
*/
{
"ignored_packages":
[
"Vintage"
],
"indent_guide_options":
[
[
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["super+shift+r"], "command": "reindent" }
]
var express = require("express");
var app = express();
// http://localhost:9001/users/1
app.get('/users/:id', function(req, res, next){
var id = req.params.id;
if (checkPermission(id)) {
res.send("private");
} else {
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();
/*
* HID RFID Reader Wiegand Interface for Arduino Uno
* Originally by Daniel Smith, 2012.01.30 -- http://www.pagemac.com/projects/rfid/arduino_wiegand
*
* Updated 2016-11-23 by Jon "ShakataGaNai" Davis.
* See https://obviate.io/?p=7470 for more details & instructions
*/
#define MAX_BITS 100 // max number of bits
@ShakataGaNai
ShakataGaNai / dd-agent.yaml
Created June 25, 2017 19:10
Sample Datadog agent for Kubernetes 1.6+ using Taints and Tolerances
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: dd-agent
spec:
template:
metadata:
labels:
app: dd-agent
name: dd-agent
var AWS = require('aws-sdk');
exports.handler = (event, context, callback) => {
var iotdata = new AWS.IotData({endpoint: 'ASDFASDF.iot.us-west-2.amazonaws.com'});
var params = {
topic: 'esp8266_RANDOMID/hellofromamzn',
payload: 'This is from Lambda',
qos: 0
};
@ShakataGaNai
ShakataGaNai / cloudbuild.yaml
Last active October 4, 2018 15:19
A sample cloudbuild.yml - details at https://obviate.io/?p=7913
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/yourorg/mystaticsite:$COMMIT_SHA', '.' ]
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/yourorg/mystaticsite:latest', '.' ]
images:
- 'gcr.io/yourorg/mystaticsite:$COMMIT_SHA'
- 'gcr.io/yourorg/mystaticsite:latest'
tags:
- "cloudbuild"
@ShakataGaNai
ShakataGaNai / lambda-at-edge-headers.js
Last active September 19, 2017 22:06
A quick demonstration of using Lamba@Edge to inject extra HTTP Security/Cache Headers
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
var hr = {
'Strict-Transport-Security': 'max-age=600;',
'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
'Pragma': 'no-cache',
'X-LambdaAtEdge': 'true'