Skip to content

Instantly share code, notes, and snippets.

@pamelafox-coursera
pamelafox-coursera / hangouts.html
Created July 3, 2013 18:48
Google Hangouts Code (Think Again)
<p>Google+ Hangouts are online rooms where you can have a face-to-face conversation with up to 10 people at once. This is a great way to meet your classmates and to practice thinking and arguing with students all over the world!</p>
<p>
We've provided some possible discussion topics, but you can talk about whatever you want in each of the rooms, so don't hesitate to jump right in and see what everyone's talking about. And don't worry if you're the first person in a room -- other students
will be there soon :-)
</p>
<p>
When you click to join a hangout, you will be asked to create a Google+ Account if you do not already have one. After entering a Hangout room, you will also need to click the JOIN button to participate in the Hangout. Have fun, and please use the
<a
href="https://class.coursera.org/thinkagain-2012-001/forum/list?forum_id=27">Google+ Hangouts Forum</a>to give us your feedback!
</p>
@pamelafox-coursera
pamelafox-coursera / hangouts.html
Last active January 20, 2023 07:26
Google Hangout code
Google+ Hangouts are online rooms where you can have a real-time audio/video conversation with up to 10 classmates at once. You can schedule hangouts in advance for study groups, review sessions and social meetups with classmates. Use this forum to plan
your hangouts with classmates and talk about it afterward: <a href="https://class.coursera.org/behavioralecon-001/forum/list?forum_id=105">Google+ Hangouts Forum</a>. We've scheduled a bunch of these for you (see all the events <a href="https://plus.google.com/u/0/communities/106659009032200000126/events"
target="_blank">here</a>), so feel free to join one of those or go ahead and make your own!
<br>
<br>Scheduled Hangouts will appear on this page. If you use Google Calendar, you can click the Attend button to get a reminder when the hangout is about to begin, but entering a hangout is on a first come first serve basis. You do have to have a Google+ account
to do this (but you can easily create one).
<br>
<br>
<h3>New to Hangouts?</h3>
Check <a href="https://s
@pamelafox-coursera
pamelafox-coursera / AWidgetView.js
Last active December 16, 2015 22:28
jQuery BBQ Backbone Widget
define([
"backbone",
"jquery",
"underscore",
"js/lib/util",
"js/lib/jquery.bbq"
],
function(Backbone, $, _, util, bbq) {
var WIDGET_INFIX = '-state-';
@pamelafox-coursera
pamelafox-coursera / CalendarHelper.class.php
Created April 10, 2013 23:09
Generate iCal files in PHP
<?php
class CalendarEvent {
/**
*
* The event ID
* @var string
*/
private $uid;
@pamelafox-coursera
pamelafox-coursera / youtubefriendlyuploadtitles.js
Created September 19, 2012 04:13
Truncate and Latinize Titles for Youtube
function truncateText(string, nMaxChars) {
if (string.length <= nMaxChars)
return string;
var xMaxFit = nMaxChars - 3;
var xTruncateAt = string.lastIndexOf(' ', xMaxFit);
if (xTruncateAt == -1 || xTruncateAt < nMaxChars / 2)
xTruncateAt = xMaxFit;
return string.substr(0, xTruncateAt) + "...";
@pamelafox-coursera
pamelafox-coursera / util_memcache.py
Created September 14, 2012 21:21
Memcache utility functions
# So we can easily bust cache between huge versions
def get_cache_key(key):
return 'v01022012' + key
def put_in_cache(key, val, time=None):
from google.appengine.api import memcache
try:
key = get_cache_key(key)
@pamelafox-coursera
pamelafox-coursera / merge.py
Created September 12, 2012 14:32
Merge results of Django values() for many to many
import itertools
results = [{'universities': 1L, 'name': u'Course Name', 'categories': 1L, 'id': 2L}, {'universities': 2L, 'name': u'Course Name', 'categories': 1L, 'id': 2L}, {'universities': 1L, 'name': u'Course Name', 'categories': 5L, 'id': 2L}, {'universities': 2L, 'name': u'Course Name', 'categories': 5L, 'id': 2L}, {'universities': 1L, 'name': u'Course Name', 'categories': 6L, 'id': 2L}, {'universities': 2L, 'name': u'Course Name', 'categories': 6L, 'id': 2L}]
"""
When you call values() on a queryset where the Model has a ManyToManyField
and there are multiple related items, it returns a separate dictionary for each
related item. This function merges the dictionaries so that there is only
one dictionary per id at the end, with lists of related items for each.
"""
@pamelafox-coursera
pamelafox-coursera / wd.js
Created August 27, 2012 17:21
wd-async tests for Coursera
// Run with ./node_modules/mocha/bin/mocha app/www/test/web/wd.js --timeout 5000
var assert = require('assert');
var wd = require('wd-sync').wd
var Wd = require('wd-sync').Wd;
browser = wd.remote();
/** test data **/
var testData = {
@pamelafox-coursera
pamelafox-coursera / transloadit2.js
Created August 11, 2012 12:49
Transloadit checkFileTypes
// My HTML specifies accept="" on the input
// I add this additional function to transloadit2.js
Uploader.prototype.checkFileTypes = function() {
var self = this;
var acceptedTypes = self.$files.attr('accept');
if (!acceptedTypes) {
return true;
}