Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
@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);
...
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
roles:
- admin
- developer
- guest
password:
<ResponseCache name="Response-Cache-1">
<CacheKey>
<Prefix/>
<KeyFragment ref="request.uri" type="string"/>
</CacheKey>
<Scope>Exclusive</Scope>
<ExpirySettings>
<TimeoutInSec ref="">60</TimeoutInSec>
</ExpirySettings>
</ResponseCache>
<StatisticsCollector name="Statistics-Collector-1">
<Statistics>
<Statistic name="devjam_{your initials}_cityname"
ref="city_name"
type="STRING">NO_CITY</Statistic>
</Statistics>
</StatisticsCollector>
<ExtractVariables name="Extract-Variables-1">
<Source clearPayload="false">response</Source>
<JSONPayload>
<Variable name="city_name">
<JSONPath>$.name</JSONPath>
</Variable>
</JSONPayload>
</ExtractVariables>
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
@DinoChiesa
DinoChiesa / local.screenshot.fixup.plist
Last active August 29, 2015 14:24
plist for a watcher that renames screenshots
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.screenshot.fixup</string>
<key>Program</key>
<string>/Users/YOURSELF/dev/bash/fixupScreenshotName.sh</string>
<key>RunAtLoad</key>
<false/>
@DinoChiesa
DinoChiesa / fixupScreenshotName.sh
Created July 8, 2015 16:04
Rename screenshots on Mac OSX to something sane
#!/bin/bash
# -*- mode:shell-script; coding:utf-8; -*-
#
# fixupScreenshotName.sh
#
# The MIT License (MIT)
#
# Copyright (c) 2014 by Dino Chiesa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
/*
* ugCollectionForEachPaging
*
* Iterates through all items in a collection within
* Apigee Edge BaaS. Uses the Usergrid client object from the usergrid
* module. Notice - this logic calls {has,get}NextPage().
*
* @param ugClient - the authenticated client object
* @param options - the options for a collection. Pass type and qs.
* @param f - function called with each UG entity. Accepts a single argument.
/*
* ugCollectionForEach
*
* Iterates through all items IN A SINGLE PAGE of a collection within
* Apigee Edge BaaS. Uses the Usergrid client object from the usergrid
* module. Notice - this logic does not call {has,get}NextPage().
*
* @param ugClient - the authenticated client object
* @param options - the options for a collection. Pass type and qs.
* @param f - function called with each UG entity. Accepts a single argument.