Skip to content

Instantly share code, notes, and snippets.

View imsickofmaps's full-sized avatar

Mike Jones imsickofmaps

View GitHub Profile
@imsickofmaps
imsickofmaps / testimonial.html
Created May 22, 2013 14:14
Place this file in perch/templates/content/ then put a `<?php perch_content('Testimonials') ?>` snippet in the page that you want, refresh page, then choose Testimonial as the type in the admin area.
<h3><perch:content id="company_name" type="text" label="Company Name" html="false" required="true" title="true" /></h3>
<perch:content id="testimonial" type="textarea" label="Testimonial" textile="true" editor="markitup" imagewidth="640" imageheight="480" />
<strong><perch:content id="name" type="text" label="Name" html="false" required="true" /></strong><br>
<strong><perch:content id="job_role" type="text" label="Job Role" html="false" required="true" /></strong>
@imsickofmaps
imsickofmaps / checkEmbedded.js
Created May 24, 2013 17:27
Javascript function that takes an array of ISO string formatted dates related to a users signin activity and determines they have signed in a minimum 1x per week over the past four weeks. Used to determine if they are "Embedded" in cohort terms.
// bad
dates = ["2013-04-02T08:27:01.209Z", "2013-04-26T08:27:01.209Z", "2013-05-16T08:27:01.209Z", "2013-05-23T08:27:01.209Z", "2013-05-24T08:27:01.209Z"];
// good
dates = ["2013-04-25T08:27:01.209Z", "2013-04-31T08:27:01.209Z", "2013-05-06T08:27:01.209Z", "2013-05-13T08:27:01.209Z", "2013-05-20T08:27:01.209Z", "2013-05-24T08:27:01.209Z"];
function checkEmbedded(dates) {
// takes an array of ISO string formatted dates and determines
// they have signed in a minimum 1x per week over the past four weeks
var today = new Date();
@imsickofmaps
imsickofmaps / drop_all_tables.sql
Created May 27, 2013 14:25
DROP TABLES (all) SQL statement for situations where dropping DB is not possible
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'replacenameofdb'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@imsickofmaps
imsickofmaps / checkCohort.js
Created May 27, 2013 17:34
For cohort analysis on logins
function checkEmbedded(dates) {
// takes an array of ISO string formatted dates and determines
// they have signed in a minimum 1x per week over the past four weeks
var today = new Date();
var week = 7*24*60*60*1000;
dates.sort();
dates.reverse();
if (dates.length < 4){
// hasn't visited more than 4 times yet
return false;
[2013-05-28T14:16:39.451147, INFO] Starting sandbox ...
[2013-05-28T14:16:39.451952, INFO] Loading sandboxed code ...
[2013-05-28T14:16:39.517862, INFO] Loaded user +27845091190: {"current_state":"initial_state","answers":{"second_state":"yes","prebirth_6_q_1_a_1":"q_2","first_state":"Yes!","name_set":"Mike","register_prebirth_2":"1","prebirth_6_q_2":"prebirth_6_q_2_a_1","welcome_state":"yes","register_all_hivinfo":"yes","register_all_smsoptin":"yes","third_state":"yes","register_all_thanksandstart":"yes","name_confirm":"yes","initial_state":"pregnant","prebirth_6_q_1":"prebirth_6_q_1_a_1","register_all_1":"pregnant"}}
[2013-05-28T14:16:39.519574, INFO] Content: Help
[2013-05-28T14:16:39.618876, ERROR]
[2013-05-28T14:16:39.625199, ERROR] undefined:112
[2013-05-28T14:16:39.627181, ERROR] response = im.config.output.help;;
[2013-05-28T14:16:39.640407, ERROR] ^
[2013-05-28T14:16:39.641987, ERROR] TypeError: Cannot read property 'help' of undefined
[2013-05-28T14:16:39.643240, ERROR] at undefined:112:52
{
"user_store": "cheep_cheep"
"transport": "sms",
"output": {
"help": "CheepCheep to send SMSes to list. Add to list with '+0821234556'. Remove with '-0821234556'. Send with 'SEND Your Message'. Message limited to 100 letters."
}
}
{
"user_store":"sms_sender",
"sms_tag": ["pool", "addr"]
}
var vumigo = require("vumigo_v01");
var jed = require("jed");
if (typeof api === "undefined") {
// testing hook (supplies api when it is not passed in by the real sandbox)
var api = this.api = new vumigo.dummy_api.DummyApi();
}
var Promise = vumigo.promise.Promise;
var success = vumigo.promise.success;
// Single - Works
p.add_callback(function(result) { return self.send_sms(im, msg, recipients[0])});
// Fails
for (var i=0;i<recipients.length;i++){
p.add_callback(function(result) { return self.send_sms(im, msg, recipients[i])});
}
@imsickofmaps
imsickofmaps / issues_gh.py
Created June 16, 2013 21:10
Github list issues from API
import requests, pprint, json
ORG = "imsickofmaps"
repo = "simplestorymaker"
GH_TOKEN = "token"
r = requests.get('https://api.github.com/repos/%s/%s/issues' % (ORG, repo), headers={'Authorization': 'bearer %s' % GH_TOKEN})
pprint.pprint(json.loads(r.text))