Skip to content

Instantly share code, notes, and snippets.

@kiewic
kiewic / dynamoDbTest.js
Last active January 11, 2021 21:57
How to insert or delete items from a DynamoDB table using Node.js
var AWS = require('aws-sdk');
var region = "us-west-2";
var accessKeyId = process.env.DYNAMODB_ACCESS_KEY_ID;
var secretAccessKey = process.env.DYNAMODB_SECRET_ACCESS_KEY;
var tableName = "your table name";
var dynamoDB = new AWS.DynamoDB({
region: region,
accessKeyId: accessKeyId,
@kiewic
kiewic / xhubsignature.js
Created November 17, 2016 08:39
How to validate a X-Hub-Signature header when using Express.js and body-parser
var express = require('express');
var bodyParser = require('body-parser')
var crypto = require('crypto');
// Calculate the X-Hub-Signature header value.
function getSignature(buf) {
var hmac = crypto.createHmac("sha1", process.env.FB_APP_SECRET);
hmac.update(buf, "utf-8");
return "sha1=" + hmac.digest("hex");
}
@kiewic
kiewic / FakeODataResponseMessage.cs
Created September 17, 2016 00:04
OData: Generate the EDMX $metadata document from an IEdmModel and print it to the console.
using Microsoft.OData.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Web.OData.Builder;
namespace FooApp
{
class FakeODataResponseMessage : IODataResponseMessage
{
@kiewic
kiewic / Do-RecursiveGitPull.ps1
Created July 8, 2016 06:02
Perform git pull in all subdirectories that contain a git repository using PowerShell.
Get-ChildItem -Directory -Force -Recurse *.git | ForEach-Object { cd $_.Parent.FullName; Write-Host $_.Parent.FullName; git pull }