Skip to content

Instantly share code, notes, and snippets.

View pdeschen's full-sized avatar

Pascal Deschênes pdeschen

  • Montréal, Canada
View GitHub Profile
@pdeschen
pdeschen / apex.sh
Created November 8, 2017 16:31
medium/serverless/apex
#!/bin/bash
apex deploy
apex invoke coa < test/coa-event.json
apex logs
@pdeschen
pdeschen / S3EventHandler.java
Created November 8, 2017 14:31
medium/serverless/S3EventHandler.java
@Override
public Void handleRequest(S3Event event, Context context) {
List<S3EventNotificationRecord> records = event.getRecords();
...
String bucket = record.getS3().getBucket().getName();
String key = decodeKey(record.getS3().getObject().getKey());
...
// fetch recording off S3 bucket
S3Object object = getS3Object(bucket, key);
@pdeschen
pdeschen / map.js
Last active August 29, 2015 14:20
map extension
// http://stackoverflow.com/questions/164979/uk-postcode-regex-comprehensive
(function(){
var maps = function(converter) {
return [ {
type: 'lang',
filter: function(text) {
return text.replace(/\[map (GIR 0AA|[A-PR-UWYZ]([A-HK-Y]([0-9][A-Z]?|[1-9][0-9])|[1-9]([0-9]|[A-HJKPSTUW])?) ?[0-9][ABD-HJLNP-UW-Z]{2})\]/ig, 'map');
}
}];
@pdeschen
pdeschen / jetty.sh
Last active May 6, 2016 16:09
run-jetty-run!
#!/bin/bash
# usage: jetty -Dfoo=bar --path services --port 8080 path/to/war/file.war
# last 5 args are forwarded to jetty while remainder (if any) is forward to jvm
# such as system properties or remote debugging ala
# -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
length=$(($#-5))
jvm_args=${@:1:$length}
jetty_args=${@:$length+1:$(($#))}
@pdeschen
pdeschen / shelter
Last active January 1, 2016 22:49
shelter kick start
#!/bin/bash
VIRTUAL_BOX_VERSION=${1:-4.3}
VAGRANT_VERSION=${2:-1.4.2}
ARCH=`arch`
if [! -e /etc/redhat-release ] ; then
echo "Only RHEL flavour supported."
exit 1;
fi
@pdeschen
pdeschen / rivr-showcase.java
Last active December 18, 2015 14:59
Rivr showcase
if (login() == null) return STATUS_INVALID_USER;
Interactions mainMenu = newInteraction("main-menu")
.dtmfBargeIn(1)
.audio(audioPath("vm-youhave"))
.synthesis("1")
.audio(audioPath("vm-message"))
.noInputTimeout(DEFAULT_TIMEOUT)
.toInteractions();
@pdeschen
pdeschen / data.java
Last active December 18, 2015 14:59
Rivr data structure
String username;
String password;
int tries = 0;
do {
tries++;
username = processDtmfTurn(askLogin);
password = processDtmfTurn(askPassword);
askLogin = incorrect;
} while (!validate(username, password) && tries < 3);
if (tries == 3) {
@pdeschen
pdeschen / control.java
Last active December 18, 2015 14:59
Rivr Flow Control
String menu;
do {
menu = processDtmfTurn(mainMenu);
if ("0".equals(menu)) {
mailboxConfigure();
} else if ("1".equals(menu)) {
messageMenu();
@pdeschen
pdeschen / exception.java
Last active December 18, 2015 14:58
rivr exception handling
VoiceXmlInputTurn inputTurn = DialogueUtils.doTurn(context, turn);
if (VoiceXmlEvent.hasEvent(VoiceXmlEvent.CONNECTION_DISCONNECT_HANGUP, inputTurn.getEvents())) {
throw new HangUp();
}
if (VoiceXmlEvent.hasEvent(VoiceXmlEvent.ERROR, inputTurn.getEvents())) {
@pdeschen
pdeschen / initd
Created May 12, 2013 18:10
CentOS service initd erb template. Ready to use in Opscode Chef or replace template variables with your own hard-coded value. Takes into account priority/nice, sudo user, and /etc/sysconfig/ Support start, stop, restart, console.
#!/bin/sh
#
# <%=@service%> This shell script takes care of starting and stopping
# the <%=@service%> service.
#
# chkconfig: 2345 65 35
# description: <%=@description%>
#
SERVICE=<%=@service%>