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 / gist:983569
Created May 20, 2011 19:15
Ajax jQuery Authentication Request
$.ajax( {
url : '/model/user.json',
dataType : 'json',
beforeSend : function(xhr) {
var bytes = Crypto.charenc.Binary.stringToBytes(username + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
error : function(xhr, ajaxOptions, thrownError) {
reset();
@pdeschen
pdeschen / gist:983717
Created May 20, 2011 20:19
nginx 403 handling
upstream test {
server localhost:8080;
}
server {
...
error_page 401 =403 /login;
location ~ ^/model/(.*)$ {
auth_basic "Restricted";
auth_basic_user_file conf/htpasswd;
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 1 column, instead of 3. in line 3.
Source : Ville de Montréal
URL : http://donnees.ville.montreal.qc.ca/archives/fiche-donnees/elections-2009-section-vote-par-adresse
AdrComplete1;AdrComplete2;NoArrondissement;Arrondissement;NoDistrict;District;Section;BVA;BVA-Description;BVA-Adresse1;BVA-Adresse2;BVA-Adresse3;BVO;BVO-Description;BVO-Adresse1;BVO-Adresse2;BVO-Adresse3;NoCiv;NoCivAlpha;NoApp;NoAppAlpha;Specifique;Direction;Generique;Particule;CodePostal;Lot;Matricule;VilleProv;NbElecteurs
7180 avenue des Acacias;Anjou Qc H1J 2B4;2;d'Anjou;21;Ouest (Anjou);13;A-021-01;?COLE JACQUES-ROUSSEAU;7455, rue Jarry est;Anjou (Qc) H1J 1G8;Gymnase;S-021-02;?COLE JACQUES-ROUSSEAU;7455, rue Jarry Est;Anjou (Qc) H1J 1G8;Gymnase;7180;;;;Acacias;;avenue;des;H1J2B4;; ;Anjou;2;
7181 avenue des Acacias;Anjou Qc H1J 2B4;2;d'Anjou;21;Ouest (Anjou);13;A-021-01;?COLE JACQUES-ROUSSEAU;7455, rue Jarry est;Anjou (Qc) H1J 1G8;Gymnase;S-021-02;?COLE JACQUES-ROUSSEAU;7455, rue Jarry Est;Anjou (Qc) H1J 1G8;Gymnase;7181;;;;Acacias;;avenue;des;H1J2B4;; ;Anjou;2;
7190 av
@pdeschen
pdeschen / patinoires.js
Created November 19, 2011 04:03
Montreal Open Data Patinoires
var ndg = new montreal.data.arrondissement("Côte-des-Neiges - Notre-Dame-de-Grâce")
var patinoires = new montreal.data.patinoires();
patinoires.filter(ndg, function(patinoire) {
console.log(patinoire.location);
if (patinoire.open)
console.log(patinoire.condition);
});
@pdeschen
pdeschen / webapi.curl
Created November 19, 2011 04:42
Montreal Open Data API
# get all ice rings from Cote-Des-Neiges
-X GET /cdn/patinoires/
# get all ice rings
-X GET /patinoires
# get all open ice rings
-X GET /patinoires/?open=true
# get geolocation of the ice rings in Code-Des-Neiges
-X GET /cdn/patinoires/locations
@pdeschen
pdeschen / sip.conf
Created December 1, 2011 22:23
SIP Provider Configuration
[provider_1]
type=peer
host=192.168.137.56
dtmfmode=inband
canreinvite=no
qualify=1000
disallow=all
allow=ulaw
[provider_2]
@pdeschen
pdeschen / globals-extensions.ael
Created December 1, 2011 22:29
Globals Definitions within Dial Plan
globals {
// configure the limits for each provider
provider_1_limit=1;
provider_2_limit=4;
// no more edit beyond this point
provider_1_count=0;
provider_2_count=0;
};
@pdeschen
pdeschen / multi-providers.ael
Created December 1, 2011 22:57
Multi Providers Dialplan Context
context multi-provider {
_X. => {
if (${GLOBAL(provider_1_limit)} > ${GLOBAL(provider_1_count)}) {
Set(PROVIDER_CONTEXT=provider_1);
}
else if (${GLOBAL(provider_2_limit)} > ${GLOBAL(provider_2_count)}) {
Set(PROVIDER_CONTEXT=provider_2);
}
else {
Congestion();
@pdeschen
pdeschen / asterisk-load.sh
Created December 31, 2011 04:31
Asterisk configuration exec script
#!/bin/bash
if [ -e /etc/asterisk/enabled/$1.conf ] ; then
echo "#include /etc/asterisk/enabled/$1.conf";
fi
if [ -e /etc/asterisk/enabled/$1/ ] ; then
find /etc/asterisk/enabled/$1/ -name '*.conf' -exec echo "#include {}" \;
fi
@pdeschen
pdeschen / Rakefile
Created December 31, 2011 05:18
Asterisk Configuration Rakefile
VERBOSE=true
ASTERISK_LOAD_SCRIPT='/usr/bin/asterisk-load'
ASTERISK_ETC='/etc/asterisk'
AVAILABLE=ASTERISK_ETC + "/available"
ENABLED=ASTERISK_ETC + "/enabled"
DISABLED=ASTERISK_ETC + "/disabled"
directory AVAILABLE