Apr 13, 2008

Cherry blossoms

This is a photo in a small park near my home.
We can enjoy these flowers for only about 2 weeks, so everybody goes out for a party under the cherry tree on weekends.

Many small tools and something to gather them

Services and tools should be simple and small to use it easily and speedy.
But it will be difficult to manage too many tools.
So, we will need something to gather these tools in one place.

SNS Service for learning English

To improve my English language level, I started using "iKnow", a SNS service for learning English with friends.

iKnow (Japanese site)

For the moment, there are 8 courses called "Channel", and you can choose a Channel according to your purpose, such as "Basic", "For Business", "For studying abroad".
In each Channel, you can learn popular words and phrases, using easy-to-use flash tools.

The most interesting function for me, is the one called "Dictation".
This is a function to train translation from Japanese to English, using popular phrases. I think it would help me writing more beautiful and correct sentences in this blog.

Supper of one day

Introducing some Japanese food may interest you.
So, I will like to introduce some of my lunch and suppers in my blog.

The photo in the right is a set of Sashimi.
Tuna(maguro), yellowtail(hamachi), shrimp, sea urchin(uni), cuttlefish(ika) is included in the set.
This set is for about 3 or 4 people. It is a kind of appetizer.

Apr 12, 2008

Using Django besides Web Applications

I read an article about using Django in command-linse scripts.

It is about using the Django model APIs and settings in ex-web python scripts.
By using this method, we can use the same API in batch scripts with heavy proccesses, like parsing huge XML files, and converting movie file types.

SQLObjects was the only choicse for me before reading this article, so I am happy to know about this method.

Using the new Django Paginator with page links

I have made a Customized Page class for the new Django Paginator.
It shows page links with "prev", "next" buttons.


utils.py

import string
from django.core.paginator import Page, InvalidPage

class BetterPage(Page):
def __init__(self, page, link_template):
self.link_template = link_template
Page.__init__(self, page.object_list, page.number, page.paginator)

def previous_link(self):
if self.has_previous():
tpl = string.Template(self.link_template)
return tpl.safe_substitute({"page": self.number - 1})
else:
return None

def next_link(self):
if self.has_next():
tpl = string.Template(self.link_template)
return tpl.safe_substitute({"page": self.number + 1})
else:
return None

def make_page_links(self, start, end):
tpl = string.Template(self.link_template)
return [(p+1, tpl.safe_substitute({"page": p + 1}), (p+1 == self.number)) for p in range(start, end)]

def page_links(self):
return self.make_page_links(0, self.paginator.num_pages)

def windowed_page_links(self, window_size=5):
links = []
if self.paginator.num_pages <= window_size: links = [self.page_links()] elif self.number - window_size/2 <= 3: links = [self.make_page_links(0, window_size), self.make_page_links(self.paginator.num_pages-2, self.paginator.num_pages)] elif self.number + window_size/2 > self.paginator.num_pages - 2:
links = [self.make_page_links(0, 2), self.make_page_links(self.paginator.num_pages-window_size, self.paginator.num_pages)]
else:
links = [self.make_page_links(0, 2),
self.make_page_links(self.number-window_size/2-1, self.number+window_size/2-1),
self.make_page_links(self.paginator.num_pages-2, self.paginator.num_pages)]
return links

Starting an English blog

From today, I decided to write a English blog for English study.
My sentences might be strange for a while, but I won't stop and
will just hope it gets better as I continue studying and writing.


I am a programmer working in Osaka, Japan.
I mainly use Python, Actionscript and Java.


So I think almost all of my articles will be about programming.