Skip to content

Instantly share code, notes, and snippets.

View imsickofmaps's full-sized avatar

Mike Jones imsickofmaps

View GitHub Profile
beforeEach(function () {
tester = new vumigo.test_utils.ImTester(app.api, {
custom_setup: function (api) {
api.config_store.config = JSON.stringify({
user_store: "oneorg_ussd_dev",
metric_store: "oneorg_ussd_dev",
default_lang: "en_za"
});
fixtures.forEach(function (f) {
@imsickofmaps
imsickofmaps / imsickofmaps.zsh-theme
Created March 10, 2014 11:32
~/.oh-my-zsh/themes/imsickofmaps.zsh-theme
#PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
echo '○'
@imsickofmaps
imsickofmaps / .zshrc
Created March 10, 2014 11:34
~/.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="imsickofmaps"
# Example aliases
function SilentEndState(name, text, next, handlers) {
// State that mimicks the USSD behaviour when a USSD session ends
// it fast forwards to the start of the InteractionMachine.
// We need to do this because SMS/Twitter doesn't have the Session capabities
// that provide us this functionality when using USSD.
var self = this;
handlers = handlers || {};
if(handlers.on_enter === undefined) {
handlers.on_enter = function() {
self.input_event('', function() {});
self.get_contact = function(im){
var p = im.api_request('contacts.get_or_create', {
delivery_class: 'twitter',
addr: im.user_addr
});
return p;
};
def test_filter_pipeline_chaining(self):
fp = FilterPipeline([
DirectionalFilter('inbound').chain(
MSISDNFilter('from_addr', '+27817030792')),
TimestampFilter('2013-09-10 00:00:00', '2013-09-10 23:59:59')
])
stdin = StringIO(self.SAMPLE)
stdout = StringIO()
fp.process(stdin=stdin, stdout=stdout)
self.assertEqual(stdout.getvalue(), self.HEADER + self.INBOUND)
less gdt/tests/messages-export-good.csv | python -m gdt.vumigomessage -m +27817030792 -d outbound -s "2013-09-09 19:37" -e "2013-09-09 19:41"
(ve) ± jspot extract doagricussd.js -k _
Error: on line 259 of file 'doagricussd.js' im is not defined
at run (/usr/local/lib/node_modules/jspot/lib/extract.js:88:15)
at /usr/local/lib/node_modules/jspot/lib/extract.js:12:16
at Array.map (native)
at extract (/usr/local/lib/node_modules/jspot/lib/extract.js:11:30)
at /usr/local/lib/node_modules/jspot/lib/cli.js:80:32
at Array.reduce (native)
at Object.commands.extract (/usr/local/lib/node_modules/jspot/lib/cli.js:77:32)
diff --git a/go-js/lib/doagricussd.js b/go-js/lib/doagricussd.js
index 3d7fcce..a6d4bdd 100644
--- a/go-js/lib/doagricussd.js
+++ b/go-js/lib/doagricussd.js
@@ -258,8 +258,8 @@ function DoAgricUSSD() {
p.add_callback(function (result) {
return self.send_sms(im, _.gettext(
"Thank you for adding your voice and supporting smallholder " +
- "farmers across Africa. Download our free ringtone here: " +
- im.config.download_ringback));
function validateSAID(idnum) {
idnum = idnum.toString().replace(" ", "");
r = /^\d{10}[0-1]\d{2}$/;
if (!r.test(idnum)) return false;
n = idnum;
p1 = parseInt(n[0]) + parseInt(n[2]) + parseInt(n[4]) + parseInt(n[6]) + parseInt(n[8]) + parseInt(n[10]);
p2 = (parseInt(n[1] + n[3] + n[5] + n[7] + n[9] + n[11]) * 2).toString();
p3 = 0;
for (i = 0; i < p2.length; i++) {
p3 += parseInt(p2[i]);