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 / 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');
}
}];
...
if (mBaseUrl.getProtocol().equals("https"))
{
UsernamePasswordCredentials credentials =
new UsernamePasswordCredentials(mAuthenticationUsername,
mAuthenticationPassword);
mHttpClient.getState().setCredentials(AuthScope.ANY, credentials);
def sequencer =
{ sequence, closure ->
if (dtmfSequencerEnabled)
{
for (dtmf in sequence)
{
switch (dtmf)
{
case "*":say("${baseAudioUrl}/dtmf/star.wav");;
case "#":say("${baseAudioUrl}/dtmf/pound.wav");
sequencer ("C20")
{
event = prompt(text, [
repeat:3,
timeout:7,
choices:listOptions( contacts ),
onEvent:
{ handlingEvent->
handlingEvent.onTimeout( {
sequencer ("C21")
say( "Hello, and thank you for calling." )
event = prompt(text, [
repeat:3,
timeout:7,
choices:listOptions( contacts ),
onEvent:
{ handlingEvent->
handlingEvent.onTimeout( {
say( "I'm sorry, I didn't hear anything." )
}
)
sequencer ("C10")
{ say( "Hello, and thank you for calling." ) }
@pdeschen
pdeschen / TropoSmsNotification.java
Created October 28, 2010 22:07
Sends a SMS message to provided number using Apache HttpClient
// Uses a very very simple tropo script configured for your application
// See http://github.com/pdeschen/nubot-labs/raw/master/tropo/src/Sms.groovy
HttpClient mHttpClient = new HttpClient();
String mBaseUrl = "http://api.tropo.com/1.0/sessions";
GetMethod method = new GetMethod();
// here we have to throttle. We can't have more then x sms/minutes.
@pdeschen
pdeschen / update-dns.sh
Created December 10, 2010 19:46
dynamic geoscaling dns update
IP_ADDRESS=`curl http://labs.rassemblr.com/go/ip`
USERNAME=<yourusername>
PASSWORD=<yourpassword>
HOST=<yourAhost>
curl -u $USERNAME:$PASSWORD /
"http://api.geoscaling.com/dns2/dynamic/?host=$HOST&content=$IP_ADDRESS"
@pdeschen
pdeschen / ip.rb
Created December 10, 2010 19:37
http client ip output
#!/usr/bin/ruby
require "cgi"
cgi = CGI.new("html3")
cgi.out() do
ENV['REMOTE_ADDR']
end