Skip to content

Instantly share code, notes, and snippets.

View d6veteran's full-sized avatar

Will Curran d6veteran

  • Google, D20Mob, SuperKablamo
  • Seattle, WA
View GitHub Profile
[{
"name~=": "Wikipedia",
"type": "/common/topic",
"/common/topic/webpage":
[{"uri":null,
"id" : null,
"topic": null,
"category": null}]
}]
@d6veteran
d6veteran / gist:743713
Created December 16, 2010 17:42
Init and Resize iFrame on Facebook Application Canvas Page
window.fbAsyncInit = function() {
FB.init({appId: '{{ facebook_app_id }}', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('{% if current_user %}auth.logout{% else %}auth.login{% endif %}', function(response) {
window.location.reload();
});
FB.Canvas.setAutoResize();
};
@d6veteran
d6veteran / gist:745671
Created December 17, 2010 20:42
Freebase schema for Type /games/game
{
"code": "/api/status/ok",
"result": [{
"attribution": [
"/user/metaweb"
],
"creator": [
"/user/metaweb"
],
"derivative_games": [
@d6veteran
d6veteran / gist:746044
Created December 18, 2010 02:05
Using mql extended to call out to extended data - in this case a weblink.
[{
"id": "/en/settlers_of_catan",
"/common/topic/weblink": [{
"description": "BoardGameGeek",
"url": null
}]
}]
@d6veteran
d6veteran / gist:749192
Created December 20, 2010 23:09
Getting Spiel Des Jahres Winners
query = [{
"type": "/games/game",
"id": None,
"name": None,
"!/award/award_honor/honored_for": {
"award": {
"id": "/en/spiel_des_jahres"
},
"year": {
"value": None,
@d6veteran
d6veteran / gist:760090
Created December 30, 2010 18:24
Using urllib2 for POSTing
#!/usr/bin/python
####
# 02/2006 Will Holcomb <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
@d6veteran
d6veteran / gist:774644
Created January 11, 2011 16:17
Custom filter for Webapp templates: match item to items in List
from google.appengine.ext.webapp import template
from django import template as django_template
def in_list(value, arg):
"""
Given an item and a list, check if the item is in the list.
Usage:
{% if item|in_list:list %}
in list
{% else %}
@d6veteran
d6veteran / gist:797387
Created January 26, 2011 20:30
Dereference Reference Properties in Batch Get()
def prefetch_refprops(entities, *props):
fields = [(entity, prop) for entity in entities for prop in props]
ref_keys = [prop.get_value_for_datastore(x) for x, prop in fields]
ref_entities = dict((x.key(), x) for x in db.get(set(ref_keys)))
for (entity, prop), ref_key in zip(fields, ref_keys):
prop.__set__(entity, ref_entities[ref_key])
return entities
@d6veteran
d6veteran / gist:801431
Created January 29, 2011 02:18
Freebase Query for BGG IDs using cursor
[{
"cursor": true,
"id": null,
"type": "/games/game",
"mid": null,
"key": {
"namespace": "/user/pak21/boardgamegeek/boardgame",
"value": null,
"optional": false
}
@d6veteran
d6veteran / gist:916056
Created April 12, 2011 18:12
Score Lists
<!-- HIGH SCORES -->
<div class="block">
<div class="score-block">
<div class="block-header">
<h2>High Scores</h2>
</div>
{% if high_scores %}
{% for s in high_scores %}
<div class="tiny-score">
<div class="player">