Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
var express = require('express'), // 4.x
bodyParser = require('body-parser'), // express 4.x requires this
yql = require('yql'),
urlparse = require('url');
// Set up Express environment and enable it to read and write JSON bodies
var app = express();
app.use(bodyParser.json()); // for parsing application/json
// Generic Send Error Function
<ExtractVariables name="Extract-Variables-1">
<Source clearPayload="false">response</Source>
<JSONPayload>
<Variable name="city_name">
<JSONPath>$.name</JSONPath>
</Variable>
</JSONPayload>
</ExtractVariables>
<StatisticsCollector name="Statistics-Collector-1">
<Statistics>
<Statistic name="devjam_{your initials}_cityname"
ref="city_name"
type="STRING">NO_CITY</Statistic>
</Statistics>
</StatisticsCollector>
<ResponseCache name="Response-Cache-1">
<CacheKey>
<Prefix/>
<KeyFragment ref="request.uri" type="string"/>
</CacheKey>
<Scope>Exclusive</Scope>
<ExpirySettings>
<TimeoutInSec ref="">60</TimeoutInSec>
</ExpirySettings>
</ResponseCache>
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
roles:
- admin
- developer
- guest
password:
@DinoChiesa
DinoChiesa / gist:505be4116258c007cbc8
Created December 21, 2015 07:04
Compute SHA-256 in Java
import java.security.MessageDigest;
import org.apache.commons.codec.binary.Base64;
...
MessageDigest md = MessageDigest.getInstance("SHA256");
byte[] hashBytes = md.digest(stringToHash.getBytes("UTF-8"));
String hashB64 = Base64.encodeBase64String(hashBytes);
...
@DinoChiesa
DinoChiesa / httpsig-in-postman-pre-request-script.js
Created January 26, 2016 23:18
pre-request script for Postman, to perform HttpSignature calculation. Also SHA-256 message digest.
function computeHttpSignature(config, headerHash) {
var template = 'keyId="${keyId}",algorithm="${algorithm}",headers="${headers}",signature="${signature}"',
sig = template;
// compute sig here
var signingBase = '';
config.headers.forEach(function(h){
if (signingBase !== '') { signingBase += '\n'; }
signingBase += h.toLowerCase() + ": " + headerHash[h];
});
$ which openssl
/usr/bin/openssl
$ openssl version
OpenSSL 0.9.8zg 14 July 2015
$ /usr/local/Cellar/openssl/1.0.2e_1/bin/openssl version
OpenSSL 1.0.2e 3 Dec 2015
$ brew update
$ brew install openssl
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"