Skip to content

Instantly share code, notes, and snippets.

View atroche's full-sized avatar

Alistair Roche atroche

View GitHub Profile
[user]
name = Alistair Roche
email = roche.a@gmail.com
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
thirty_days_ago = datetime.datetime.now() - datetime.timedelta(days=30)
is_quiet = len(messages.items) < 10 or (messages[9].updated_at
< thirty_days_ago)
def headers(self):
if current_app.config.get("LIVE"):
return {"Bcc": "staging+newsite@streetlife.com"}
return {}
from streetlife.frontend.mail.models import UserMail, Mail
from streetlife.frontend.user.models import User
for um in UserMail.objects():
um.mail_updated_at = um.mail.updated_at = um.mail.messages[-1].posted_at
um.save()
super(Mail, um.mail).save()
def save(self, message):
"""Append new comment to the message, increment comment_count."""
user = current_user._get_current_object()
# Set the comment's pk to -1 so we can find it in the comment list
# (We can't guarantee it will be last when we go to access it)
comment = Comment(body=clean_html_input(self.body.data),
author=user, pk=-1)
message_qs = Message.objects(id=message.id)
@atroche
atroche / gist:1322143
Created October 28, 2011 12:19
Facebook Beautified
if (!window.FB) window.FB = {
_apiKey: null,
_session: null,
_userStatus: "unknown",
_logging: true,
_inCanvas: window.location.search.indexOf("fb_sig_in_iframe=1") > -1 || window.location.search.indexOf("session=") > -1 || window.location.search.indexOf("signed_request=") > -1 || window.name.indexOf("iframe_canvas") > -1 || window.name.indexOf("app_runner") > -1,
_https: window.name.indexOf("_fb_https") > -1,
_domain: {
api: "https://api.facebook.com/",
api_read: "https://api-read.facebook.com/",
@atroche
atroche / README.md
Last active December 10, 2015 10:58 — forked from mbostock/.block

A treemap recursively subdivides area into rectangles; the area of any node in the tree corresponds to its value. This example uses color to encode different packages of the Flare visualization toolkit. Treemap design invented by Ben Shneiderman. Squarified algorithm by Bruls, Huizing and van Wijk. Data courtesy Jeff Heer.

@atroche
atroche / politicians.json
Created January 1, 2013 04:39
Dataset of Australian politicians' follower counts scraped from Twitter
{
"name":"politicians",
"children":[
{
"name":"Liberal",
"children":[
{
"name":"Tony Abbott",
"size":92104
},
"use strict";
var insertAtRightPlace = function(number, array) {
var i;
for(i = 0; i < array.length; i++) {
if (number <= array[i]) {
break;
}
}
<!DOCTYPE html>
<html>
<head>
<title>Nominate Your Town</title>
<script id="town-row-template" type="text/x-handlebars-template">
<td class="rank">
{{ rank }}