Archive for Work stuff

Custom Django filters in Google App Engine

You want to create your own custom Django filters in App Engine without running a whole Django stack? Here's how in a few lines of code.

First create a specific python file to hold your custom filters at the root of your application. In my case I use customfilters.py like this:

import re
from google.appengine.ext import webapp
 
register = webapp.template.create_template_register()
 
def escapeimg(body):
	return re.sub(r'<img (.*)/>', '[IMG]', body)
 
register.filter(escapeimg)

Then in your main application source file, call the following line outside of the main() definition, for example just after your modules loading:

"""Load custom Django template filters"""
webapp.template.register_template_library('customfilters')

You should then be able to use the new filters you registered in customfilters.py straight away in any of your Django templates without any % load foobar % call

Comments

Crossdomain proxy on Google App Engine

Here's a crossdomain proxy to pipe Javascript Ajax calls from you Google App Engine application to the Flickr API, since most browser will not let you call another domain directly.

import cgi
import urllib
from google.appengine.ext import webapp
from google.appengine.api import urlfetch
 
class FlickrController(webapp.RequestHandler):
	"""Proxy for Ajax calls to flickr"""
	def get(self):
		flickrapiendpoint = 'http://api.flickr.com/services/rest/'
		flickrapikey = 'you_flicker_api_key'
 
		params = self.request.GET
		params.add('api_key', flickrapikey)
		params.add('format', 'json')
		apiquery = urllib.urlencode(params)
 
		result = urlfetch.fetch(url=flickrapiendpoint + '?' + apiquery, method=urlfetch.GET)
		self.response.out.write(result.content)
 
def main():
	application = webapp.WSGIApplication(
		[('/flickr/', FlickrController)],
		debug=True)
	wsgiref.handlers.CGIHandler().run(application)
 
if __name__ == "__main__":
	main()

I didn't see examples of such a script anywhere else so I thought I'd post it here for all to see.

Comments

Let’s leave 20 teeth at age 80!

More cool Dental Health info from my Japanese health insurance society. Coming back from Golden Week vacation, I find the following letter on my desk at work:

Information for Dental Checkup and Treatment:

Announcing the "Let's leave 20 teeth at age 80" campaign

Aren't your decayed teeth or pyorrhea getting worse while you are unaware ofr them? Health Insurance society has been sending application forms of dental checkup to the insured persons in numeric order of Insurance Card.

This time your insurance card number is in range of an applicable object: you are entitled to a complete dental checkup including teeth, gum and supporting bone X-rays at 10% of the medical care cost.

This is actually a pretty good deal, apart from the goofy tag-name for the campaign, and I've signed up for a long overdue checkup on the cheap.

Comments

Meeting shenanigans

Just a random conversation during one of my team's daily meetings at work:

Colleague: We have a problem with the *censored* server.
Boss: Where is that server located?
Colleague: It's in the Intellectual Property room, on the 2nd floor of the Reliability building.
Me: Yeah, you know that place? It's right next to the office of Lost Causes.

We always have lots of fun during our daily meetings.

Comments (1)

More tax fun!

January sees its share of administrative tasks for the new year that just started. So I received some new forms from my office's executive assistant and as usual the English information sheet is of great help:

Special Tax Credit
Inform of special tax credit (deduction of housing loan) system like house loan etc. of residence tax. It comes to be able to deduct the amount of a special deduction like the house loan etc. that were not able to be deducted from the income tax is able to deduct from the residence tax in 2008 fiscal year.

Okay... As usual I'm going to stamp the paper with my hanko and give it back praying that I have not signed over my soul to the devil...

Comments

MQL baffles me

My job consists of writing functional specifications and generally managing the architecture of a big R&D information system based on a wonderful jack-of-all-trade application called eMatrix from Dassault.

I often delve deep into the application with the MQL console (for Matrix Query Language) to dig out some insight into the data we manage.

And, more often than not, I find things that makes me cringe:

MQL<45> print bus ECO ZCO3171 - select history.promote;
business object ECO ZCO3171 -
history.promote = time: 10/22/2007 9:56 state: Design Work
history.promote = time: 10/22/2007 17:23 state: Review
history.promote = time: 10/22/2007 18:28 state: Release
history.promote = time: 10/24/2007 21:33 state: Implemented
MQL<46> print bus ECO ZCO3171 - select history.promote[1];
business object ECO ZCO3171 -
history.promote[1] = time: 10/22/2007 17:23 state: Review
MQL<47> print bus ECO ZCO3171 - select history.promote[0];
business object ECO ZCO3171 -
history.promote[0] = time: 10/22/2007 9:56 state: Design Work
history.promote[0] = time: 10/22/2007 17:23 state: Review
history.promote[0] = time: 10/22/2007 18:28 state: Release
history.promote[0] = time: 10/24/2007 21:33 state: Implemented

If someone has any insight on how a query language can be this flawed, I'm all ears.

PS: If you don't understand anything about this post, I'm deeply sorry for boring you with my tech rants...

Comments

Year-end tax adjustment

I was just handed by my service's executive assistant a 2 page "Year-end tax adjustment declaration for 2007" with a little not saying the deadline is in 5 days. The forms are accompanied by an English leaflet full of statements like this one:

Special exemption for spouses
Due to the change of income low (sic.), special exemption for spouses for the spouse qualifying for exemption for spouse is abolished from 2004.

Great info, as long as you can decypher it, and no indications as to what any of the boxes' labels might mean. I'm going to have a fun time this week...

Comments (1)

Cursed business trip

I'm in Detroit Metro airport waiting or my flight back to Tokyo from my 1 week business trip to the US and I hope my troubles are over. Here's a quick list of the problems so far:

  • In NYC on the first night, my friend got strangled by a crazy drunk jock as we were coming out of a Japanese restaurant close to his place. The jock finally let him go and went on to hit another random guy a block away. He wasn't hurt but we had a good scare.
  • When going to Greenwich Village to buy a bag my girlfriend asked me to bring back, I got fell into the Gay Pride parade and got stuck for over an hour trying to wade through the crowd back to Broadway.
  • On the flight from NYC to Dallas, I was randomly selected for a special security check. Random is the word, it's the second time out of 2 US flights I took since 9/11.

SSSS over and over again

  • My flight today from Dallas to Detroit was cancelled and rebooked for tomorrow 6AM. I will have to wake up around 3:30AM to leave at 4AM for the airport.
  • I was randomly selected again 30 minutes ago after checking in for my flight to Tokyo. This time the machine smelling explosives started to beep and the officer called a supervisor to recheck my bag, pat me down and ask me a bunch of questions...

Just a 13 hours flight left to go and I'll be back home in Japan, safe from all this crazy stuff. I can't wait!

Comments (3)

Business trip to the US

Tomorrow I'm leaving for the US we're I'll conduct some training sessions and will discuss implementation of new systems with people from the North American division of my company. Here's the flight plan:

lots of planes

One weekend in NYC to see a friend
2.5 days in Dallas
2.5 days in Detroit
15470 miles
32 hours 35 minutes in a plane

Comments (1)

Recruiting

Today I had my first interview from the recruiting side of the table. My contract will end in less than 6 months so we're looking for someone to replace me in job. Right now I'm working 50% on technical administration and 50% on functional administration. My replacement would take 100% of the technical stuff and if I were to stay after my contract, I'd take 100% of functional responsibilities.

Anyways, this was a really interesting experience. First it's much harder than I thought: trying to steer the conversation with meaningful questions, helping the candidate to get out of tough spots, etc. All the while I noticed lots of errors that I also do when interviewing for a job and seeing it from the other side I learned a lot.

For example, some questions that I used to think are hard to answer and don't look so relevant reveal themselves as being the turning point of the interview:

  • What do you want to do in 3 years?
  • What is your career plan?

Having an answer that makes sense to these questions really marks a lot more points than I thought when I was looking for a job 2 years ago, fresh out of school.

Comments

« Previous entries