Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
<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>
@DinoChiesa
DinoChiesa / RawSerializer.cs
Created March 8, 2013 21:48
Raw Serializer in C#
internal class RawSerializer<T>
{
public T RawDeserialize( byte[] rawData )
{
return RawDeserialize( rawData , 0 );
}
public T RawDeserialize( byte[] rawData , int position )
{
@DinoChiesa
DinoChiesa / edit-in-place.js
Created July 11, 2013 00:49
An edit-in-place directive for AngularJS. It requires no jQuery or other JS framework.
angular
// edit-in-place attribute
.directive( 'editInPlace', function() {
return {
restrict: 'A',
scope: { value: '=editInPlace', onSaveFn: '&onSave', onCancelFn: '&onCancel' },
template: '<span ng-click="handleClick()" ng-bind="value"></span><input ng-model="modelCopy" style="width:100%;"></input>',
link: function ( $scope, element /* , attrs */ ) {
// Let's get a reference to the input element, as we'll want to reference it.
@DinoChiesa
DinoChiesa / stringExtensions.js
Created July 26, 2013 13:57
string extensions for use with the sql-1.asp example I posted previously.
// stringExtensions.js
//
// a few extensions on the string object.
//
// Fri, 10 Feb 2012 16:48
//
(function(globalScope) {
if (typeof String.prototype.trim != 'function') {
@DinoChiesa
DinoChiesa / contentNego.js
Created July 26, 2013 14:08
content negotiation in JS for ASP-classic
// contentNego.js
//
// Simple content negotiation logic for ASP-classic modules.
//
// This module exposes one public function - figureDesiredContentType().
// It checks the HTTP_ACCEPT server variable (whose value is set to the
// value of the Accept request header), and sets a content-type
// mime-string accordingly.
//
// When there are multiple mime-types in the Accept header, or when the
@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);
...
$ 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