Skip to content

Instantly share code, notes, and snippets.

@Override
public void onResume(){
super.onResume();
IntentFilter completeFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
registerReceiver(completeReceiver, completeFilter);
}
@Override
public void onPause(){
super.onPause();
@chan-lee
chan-lee / get_daily_log_per_user_in_team.py
Created August 22, 2014 07:20
send json from appengine with python to google charts api
from collections import namedtuple
class AdminLogsByTeamHandler(AdminHandler): # get
@admin_required
def get(self, team_id):
team_key = ndb.Key(Team, int(team_id))
Quantity = namedtuple("Quantity", ["date", "account"])
resolution_by_day = {}
logs = Log.query(Log.team == team_key).fetch()
for log in logs:
class RestModel(ndb.Model):
def to_dict(self, **kwargs):
result = super(RestModel, self).to_dict(**kwargs)
result['id'] = self.key.id()
parent_key = self.key.parent()
if parent_key is not None:
result['parent'] = parent_key.id()
return result
@chan-lee
chan-lee / appengine_config.py
Created April 22, 2014 00:42
using namespace 'test' in app engine when it runs by dev server or is called with subdomain 'test.'
# -*- coding: utf-8 -*-
import os
from google.appengine.api import namespace_manager
def namespace_manager_default_namespace_for_request():
if 'test' in os.environ['SERVER_NAME'] or 'Dev' in os.environ['SERVER_SOFTWARE']:
return 'test'
return namespace_manager.google_apps_namespace()
@chan-lee
chan-lee / sample_etag_memcache.py
Last active November 21, 2016 22:17
using etag and memcache with webapp2 in app engine
# -*- coding: utf-8 -*-
import webapp2
from model import *
from google.appengine.api import memcache
import hashlib
import logging
import random
import string
import json