Skip to content

Instantly share code, notes, and snippets.

names_to_test = [
'blah',
'foo',
'bar',
]
for name in names_to_test:
stripped_name = util.clean_string(name)
pattern = r'^[A-Za-z]+$'
re.match(pattern, stripped_name)
@cmacrander
cmacrander / gist:d0edf7e693e8d460879c
Last active August 29, 2015 14:02
Logic for setting up qualtrics links
class QualtricsLink(NamedModel):
def get_link(self):
keys = QualtricsLink.all().fetch(100, keys_only=True)
try:
link = self._get_link_transactionally(keys.pop())
# repeat if you don't have a link
return link.link_string
@cmacrander
cmacrander / gist:1b5171cde2f2ca6ddf0c
Last active March 15, 2018 15:55
Final page redirection in Qualtrics
/*
MIT License
Copyright (c) 2018 PERTS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@cmacrander
cmacrander / gist:95b244a01ddd4aae8a29
Last active August 29, 2015 14:17
Institutional Survey Redirector Sample
<?php
// Institutional Survey Redirector Sample
// --------------------------------------
//
// The purpose of this script is to demonstrate how institutions should
// handle a student and correctly send them to CTC's systems.
//
// Please be familiar with the documentation.
//
@cmacrander
cmacrander / gist:3c772e27d600d7dfaa48
Last active August 26, 2015 20:17
KeywordArguments for javascript
// See http://ejohn.org/blog/partial-functions-in-javascript/
Function.prototype.partial = function () {
'use strict';
var fn = this, args = Array.prototype.slice.call(arguments), i;
return function () {
var arg = 0;
for (i = 0; i < args.length && arg < arguments.length; i += 1) {
if (args[i] === undefined) {
args[i] = arguments[arg];
arg += 1;
@cmacrander
cmacrander / map.py
Created September 17, 2015 17:00
Dead-end attempt to use map reduce to convert app engine backup files in gcs to json.
from google.appengine.api import datastore # for reading backup files
from google.appengine.api.files import records # for reading backup files
from google.appengine.datastore import entity_pb # for reading backup files
from mapreduce import base_handler
from mapreduce import mapreduce_pipeline
from mapreduce import operation as op
from mapreduce import shuffler
import json
import logging
@cmacrander
cmacrander / platform_hacking.js
Created September 30, 2015 21:12
Javascript console tricks for hacking the Platform
// var allUsers = [];
// var allActivities = [];
var activitiesByClassroom = {};
forEach(allActivities, function (act) {
if (act.activity_ordinal === "1") {
activitiesByClassroom[act.assc_classroom_list[0]] = act;
}
});
@cmacrander
cmacrander / .jshintrc.js
Last active February 3, 2017 23:47
PERTS .jshintrc
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition, for PERTS
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@cmacrander
cmacrander / phrase.py
Created November 3, 2015 23:47
Friendly random phrase generator
import random
foods = [
'onion',
'carrot',
'pear',
'bean',
'corn',
'bread',
'apple',
@cmacrander
cmacrander / query_string_to_object.js
Created November 11, 2015 19:30
queryStringToObject
// Read query string parameters as a javascript object.
//
// Not tested for:
//
// * Mixing bracketed and non-bracketed keys
// * Indexed brackets
// * Nested lists
//
// Some examples (See unit tests below for full details):
//