Skip to content

Instantly share code, notes, and snippets.

View crizCraig's full-sized avatar
🛰️
Journeying through levels of abstraction trying to land

Craig Quiter crizCraig

🛰️
Journeying through levels of abstraction trying to land
View GitHub Profile
var devsite = devsite || {};
devsite.devsite = devsite.devsite || {};
$(document).ready(function() {
$("a.sign-in-link").bind("mousedown click", devsite.devsite.login);
$("a.sign-out-link").bind("mousedown click", devsite.devsite.logout);
devsite.devsite.loggedIn(function(d, b) {
b ? devsite.devsite.showError("Error while signing in: " + b) : $("#sign-in-io").hasClass("trig") && devsite.reloadWindow()
})
});
window.IO_2012 = function() {
def deletedbandmemcache():
"""Delete all entities in namespace."""
from google.appengine.api import namespace_manager
######################################
""" ####### IMPORTANT ########## """
TESTSPACE = 'test'
namespace_manager.set_namespace(TESTSPACE)
""" ##### DO NOT DELETE ######## """
######################################
synonyms = {'scotty': 'dog', 'puppy': 'dog', 'dog': 'dog'}
counts = [(2, 'dog'), (2, 'puppy'), (2, 'scotty')]
syn_counts = []
for count in counts:
syn_counts.append((count[0], synonyms[count[1]]))
print syn_counts
sum_counts = {}
@crizCraig
crizCraig / gist:2661613
Created May 11, 2012 18:40
Mobile webkit events
// DOM methods & attributes for Document
DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
DEFINE_ATTRIBUTE_EVENT_LISTENER(contextmenu);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dblclick);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragenter);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragover);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragleave);
@crizCraig
crizCraig / gist:2816250
Last active February 10, 2020 06:48
Deleting all entities in a namespace on Google App Engine with Python.
DEV = os.environ['SERVER_SOFTWARE'].startswith('Dev')
APP_ID = os.environ['APPLICATION_ID']
def deleteDBandMemcache():
if not DEV and APP_ID.find('test') == -1:
# We're not in Kansas anymore. i.e. This is PRODUCTION.
# To test in the cloud, the app id must contain 'test'.
logging.error('trying to run tests on production server = no beuno')
return
@crizCraig
crizCraig / gist:2816295
Created May 27, 2012 22:52
Download images from Google Image search using Python
import json
import os
import time
import requests
from PIL import Image
from StringIO import StringIO
from requests.exceptions import ConnectionError
def go(query, path):
"""Download full size images from Google image search.
@crizCraig
crizCraig / basemodel.py
Created July 14, 2012 21:51
GAE Sharded counter
class BaseShardedCountModel(BaseModel):
# services
# - in-memory counts
# - getting counter name from entity
# - check for transition
def counter(self, name):
from lib.shardedcounter import Counter
return Counter(str(name + '_' + str(self.key().id())))
def getshardedcount(self, name):
# Load the system properties
system=[method://java.lang.System.getProperties()]
# Define the environment and language based on the system properties,
# with sensible defaults.
# (these likely came in as -D options on the command line)
lang=${system->lang|english}
env=${system->env|dev}
# Include language based properties
@crizCraig
crizCraig / HOME-.inputrc
Created April 3, 2014 16:59
Auto search history with up/down in terminal
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
{"kind": "Listing", "data": {"modhash": "0h2ailm0sf73b753219e8695a84f661c5fb5ef47350859c969", "children": [{"kind": "t3", "data": {"domain": "carlcheo.com", "banned_by": null, "media_embed": {}, "subreddit": "programming", "selftext_html": null, "selftext": "", "likes": null, "user_reports": [], "secure_media": null, "link_flair_text": null, "id": "30sz09", "gilded": 0, "archived": false, "clicked": false, "report_reasons": null, "author": "vaguepotato", "num_comments": 127, "score": 698, "approved_by": null, "over_18": false, "hidden": false, "thumbnail": "", "subreddit_id": "t5_2fwo", "edited": false, "link_flair_css_class": null, "author_flair_css_class": null, "downs": 0, "secure_media_embed": {}, "saved": false, "stickied": false, "is_self": false, "permalink": "/r/programming/comments/30sz09/24_years_ago_linus_torvalds_said_linux_is_just_a/", "name": "t3_30sz09", "created": 1427751242.0, "url": "http://carlcheo.com/fascinating-posts-from-tech-founders-who-changed-the-world", "author_flair_text": null, "