Skip to content

Instantly share code, notes, and snippets.

View Surgo's full-sized avatar
🛰️
Generating...

Kosei Kitahara Surgo

🛰️
Generating...
View GitHub Profile
<mt:Order limit="45">
<mt:Entries lastn="15">
<mt:OrderItem>
<$mt:Include module="Entry Summary"$>
<mt:setvarblock name="order_by"><mt:EntryDate utc="1" format="%Y%m%d%H%M%S"></mt:setvarblock>
</mt:OrderItem>
</mt:Entries>
<mt:ActionStreams lastn="30">
<mt:OrderItem>
<p class="service-icon service-<mt:var name="service_type">"><mt:StreamAction></p>
from appengine_django import models
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
class Timeline(polymodel.PolyModel):
"""
Usage::
user = users.get_current_user()
message = 'test'
timeline = Timeline(author = user, message = message)
<?php
class Page {
var $object_list = array(); // ページング処理したいオブジェクト配列
var $num_page = 0; // 総ページ数
var $number = 0; // 現在のページ
var $per_page; // ページ毎のアイテム数
var $count = 0; // 総アイテム数
function Page($object_list, $per_page = 10) {
$this->object_list = $object_list;
"""
A helper for the app engine blobstore API and Django.
Works with the appengine patch:
http://code.google.com/p/app-engine-patch/
Taken and inspired by:
http://appengine-cookbook.appspot.com/recipe/blobstore-get_uploads-helper-function-for-django-request/
Usage:
@Surgo
Surgo / srm494_div2_level1.py
Created January 27, 2011 13:19
SRM494 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM494 - div2 - level one
Mr. White is a very versatile person - absolutely everything is interesting to him.
Perhaps this is why he has many friends. Quite unfortunately, however, none of his
friends are versatile at all. Each of them is interested only in two topics and
refuses to talk about anything else. Therefore, each time Mr. White organizes a party,
it's a big problem for him to decide whom to invite so that the party is interesting
@Surgo
Surgo / srm495_div2_level1.py
Created January 28, 2011 00:05
SRM495 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM495 - div2 - level one
Rabbit Hanako has N boxes of carrots numbered 0 through N-1.
The i-th box contains carrots[i] carrots.
She decides to eat K carrots from these boxes. She will eat the carrots one at a time,
each time choosing a carrot from the box with the greatest number of carrots.
@Surgo
Surgo / srm493_div2_level1.py
Created January 29, 2011 16:43
SRM493 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM493 - div2 - level one
Little Romeo likes cosmic amoebas a lot. Recently he received one as a gift from
his mother. He decided to place his amoeba on a rectangular table. The table is a
grid of square 1x1 cells, and each cell is occupied by either matter or antimatter.
The amoeba is a rectangle of size 1xK. Romeo can place it on the table in any
orientation as long as every cell of the table is either completely covered by part
@Surgo
Surgo / srm492_div2_level1.py
Created January 30, 2011 14:29
SRM492 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM492 - div2 - level one
Gogo owns N wine cellars, numbered 0 through N-1. He possesses a
time machine and will use it to advance time in one of the cellars,
maturing all the wine inside. However, as a side effect, he must
also choose one other cellar and turn back time there, making
the wine inside younger.
@Surgo
Surgo / srm490_div2_level1.py
Created January 31, 2011 01:52
SRM490 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM492 - div2 - level one
Suppose that we're given a moment of time written as HH:MM,
where HH is the hour and MM is the minutes. Let's say that
this moment is lucky if it is formatted AB:AB, AA:BB or AB:BA,
where both occurrences of A stand for the same digit and both
occurrences of B also stand for the same digit. It is allowed
@Surgo
Surgo / srm489_div2_level1.py
Created February 1, 2011 13:16
SRM489 - div2 - level one
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""SRM489 - div2 - level one
Little Teddy and Little Tracy are now learning how to speak words.
Their mother, of course, doesn't want them to speak bad words.
According to her definition, a word W is bad if at least one of
the following conditions hold (see the notes section for definitions):