昭和ネオンという会社がやっている古い看板の博物館なわけです。
レトロなものに興味があるのでキニナルのです。
import gdata.calendar.service
def print_event():
#認証部分
username = 'グーグルアカウント'
calendar_service = gdata.calendar.service.CalendarService()
calendar_service.email = username
calendar_service.password = 'グーグルアカウントのパスワード'
#適当にプログラム名を指定すればよい感じ
calendar_service.source = 'Google_Calendar_Event_Get_test'
calendar_service.ProgrammaticLogin()
#デフォルトのカレンダーから取得する
visibility = 'private'
projection = 'full'
query = gdata.calendar.service.CalendarEventQuery(username, visibility, projection)
#検索条件の指定
#検索範囲を指定
query.start_min = '2009-11-01'
query.start_max = '2009-12-02'
#繰り返しイベントを別のイベントとして取得
query.singleevents = 'true'
#イベントの開始日時の昇順でソート
query.orderby='starttime'
query.sortorder='a'
feed = calendar_service.CalendarQuery(query)
for ev in feed.entry:
for e in ev:
print '%s. [%s]-[%s]' % (ev.title.text,e.start_time,e.end_time)
urlpatterns = auth_patterns + patterns('',
('^test/$','django.views.generic.simple.direct_to_template',
{'template': 'test.html'}),
) + urlpatterns
import django.utils.simplejson as json
def parse_json(json_str):
obj = json.loads(json_str)
return obj
#2つの指定座標が収まるズームサイズを求める
#sizeは画像サイズ(正方形地図を利用としています)
# 長方形の場合は、二つの値を受け取ってそれぞれに対して
# zoomを計算して小さい方を選べばよいと思います。
#x1,y1はポイント1の緯度経度
#x2,y2はポイント2の緯度経度
def get_zoom_size(size,x1,y1,x2,y2):
dx = float(x1)-float(x2)
dy = float(y1)-float(y2)
d=math.sqrt(dx*dx+dy*dy)
if d==0:
return 14
zoom = math.log(float(size)/d)/math.log(2)
return int(math.floor(zoom))
# -*- coding: utf-8; -*-
from time import time
from math import floor
from urllib import urlencode
from google.appengine.api import urlfetch
def google_append_color(color,dt):
color_array = color.split(',')
return color_array[int(dt % len(color_array))]
def google_ad(request):
scheme = 'https://' if request.is_secure() else 'http://'
dt = time()
params = {
'ad_type':'text_image',
'channel':'設定したいchannelのコードを設定',
'client':'ca-mb-' + '自分のAdSenseの値を設定',
'dt':repr(floor(dt*time())),
'format':'mobile_single',
'https':request.META.get('HTTPS', ''),
'ip':request.META.get('REMOTE_ADDR', ''),
'markup':'xhtml',
'oe':'utf8',
'output':'xhtml',
'ref':request.META.get('HTTP_REFERER', ''),
'url':scheme + request.META.get('HTTP_HOST', '') + request.META.get('REQUEST_URI', ''),
'useragent':request.META.get('HTTP_USER_AGENT', ''),
'color_border':google_append_color('ここは色をカスタマイズするならば利用',dt),
'color_bg':google_append_color('ここは色をカスタマイズするならば利用',dt),
'color_link':google_append_color('ここは色をカスタマイズするならば利用',dt),
'color_text':google_append_color('ここは色をカスタマイズするならば利用',dt),
'color_url':google_append_color('ここは色をカスタマイズするならば利用',dt),
}
screen_res = request.META.get('HTTP_UA_PIXELS', '')
delimiter = 'x'
if screen_res == '':
screen_res = request.META.get('HTTP_X_UP_DEVCAP_SCREENPIXELS', '')
delimiter = ','
if screen_res == '':
screen_res = request.META.get('HTTP_X_JPHONE_DISPLAY', '')
delimiter = '*'
res_array = screen_res.split(delimiter)
if len(res_array) == 2:
params['u_w'] = res_array[0]
params['u_h'] = res_array[1]
muid = request.META.get('HTTP_X_DCMGUID', '')
if muid != '':
params['muid'] = muid
muid = request.META.get('HTTP_X_UP_SUBNO', '')
if muid != '':
params['muid'] = muid
muid = request.META.get('HTTP_X_JPHONE_UID', '')
if muid != '':
params['muid'] = muid
muid = request.META.get('HTTP_X_EM_UID', '')
if muid != '':
params['muid'] = muid
url = 'http://pagead2.googlesyndication.com/pagead/ads?' + urlencode(params)
result = urlfetch.fetch(url)
if result.status_code != 200:
return None
return result.content
# -*- coding: utf-8; -*-
from urllib import urlencode
from google.appengine.api import urlfetch
def get_geo_form(request,return_uri,w='現在位置で探す'):
params = {
'ua':request.META.get('HTTP_USER_AGENT', ''),
'return_uri':return_uri,
'api_key':'APIを利用するためのAPIキーを指定します。',
'display':w,
}
url = 'http://api.cirius.co.jp/v1/geoform/xhtml?' + urlencode(params)
result = urlfetch.fetch(url)
if result.status_code != 200:
return None
return result.content
# -*- coding: utf-8; -*-
import xml.etree.ElementTree as etree
import urllib
from google.appengine.api import urlfetch
#場所名から緯度経度取得
def geocoding(addr):
url = 'http://maps.google.com/maps/geo?'
url = url + 'key=' + 'グーグルマップAPIのキー'
url = url + '&sensor=false'
url = url + '&output=xml'
url = url + '&q=' + urllib.quote(addr.encode('utf-8'))
result = urlfetch.fetch(url)
if result.status_code != 200:
return None
dom = etree.fromstring(result.content)
namespace ='http://earth.google.com/kml/2.0'
code = dom.findtext('.//{%s}code' % namespace)
if code != "200":
return None
point = dom.findtext('.//{%s}coordinates' % namespace)
if point == None :
return None
tmp = point.split(',')
ret = {}
ret['lon'] = tmp[0]
ret['lat'] = tmp[1]
return ret
# -*- coding: utf-8; -*-
import xml.etree.ElementTree as etree
import urllib
from google.appengine.api import urlfetch
#緯度経度から場所名取得
def regeocoding(lat,lon):
url = 'http://maps.google.com/maps/geo?'
url = url + 'key=' + 'グーグルマップAPIのキー'
url = url + '&hl=ja'
url = url + '&oe=UTF8'
url = url + '&output=xml'
url = url + '&q=' + str(lat) + ',' + str(lon)
result = urlfetch.fetch(url)
if result.status_code != 200:
return None
logging.info(result.content)
dom = etree.fromstring(result.content)
namespace ='http://earth.google.com/kml/2.0'
code = dom.findtext('.//{%s}code' % namespace)
if code != "200":
return None
for placemark in dom.findall('.//{%s}Placemark' % namespace):
ad = placemark.find('.//{urn:oasis:names:tc:ciq:xsdschema:xAL:2.0}AddressDetails')
if ad.get("Accuracy") == "5" or ad.get("Accuracy") == "6":
continue
else :
addr = placemark.findtext('.//{%s}address' % namespace)
break
addr = addr.replace(u'日本', '', 1)
return addr
#画像縦サイズ:ysize
#画像縦サイズ:xsize
#画像中心緯度:clat
#画像中心軽度:clon
#縦横の表示域を算出
lx=float(xsize)/pow(2,float(zoom))
ly=float(ysize)/pow(2,float(zoom))
#小数点以下をいい感じに丸める処理
lattop = round((float(clat)+ly/2)*1000000)/1000000
latbtm = round((float(clat)-ly/2)*1000000)/1000000
lontop = round((float(clon)+ly/2)*1000000)/1000000
lonbtm = round((float(clon)-ly/2)*1000000)/1000000
w = "日本語"
ww = "aaa" + w + "bbb"
w = u"日本語"
ww = "aaa" + w + "bbb"
var aaa = "{{ test }}";
var aaa = "{{ test|escapejs }}";
var aaa = "{{ test|striptags|escapejs }}";
.updnWatermark label
{
position: absolute;
padding: 1em;
padding-left: 0.5em;
white-space: nowrap;
color: #999;
}
<link rel="stylesheet" href="/blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="/blueprint/print.css" type="text/css" media="print">
<!--[if lt IE 8]><link rel="stylesheet" href="/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<div class="container showgrid">
</div>
<div class="container showgrid">
<div class="span-24 last">
<p>一行目は、24個のグリッドを一つの要素で使い切ります。</p>
</div>
<div class="span-8">
<p>2行目は3つの要素を配置します。</p>
</div>
<div class="span-8">
<p>2つ目の要素です。</p>
</div>
<div class="span-8 last">
<p>3つ目の要素です。行の最後なのでlastクラスを指定しています。</p>
</div>
</div>
<div class="container showgrid">
<div class="span-12">
<p>この中を入れ子で指定します。</p>
<div class="span-5 colborder">
<p>ここで親グリッド12のうち5個利用します。colborderを指定したことで、5個のグリッドの後にグリッド一つ分の空白をあけることになります。なので合計6個分のグリッドをココで指定しています。</p>
</div>
<div class="span-6 last">
<p>入れ子でも、入れ子内で行の最後になった場合はlastクラスを指定します。</p>
</div>
</div>
<div class="span-12 last">
<p>行の最後なのでlastを指定しています。</p>
</div>
</div>
<div class="container showgrid">
<div class="span-8 prepend-4 append-5">
<p>グリッド4つ分あけてからグリッド8個分確保します。そしてその後に5個分のグリッドをあけます。つまり17個分ここで指定したことになります。</p>
</div>
<div class="span-7 last">
<p>隣の要素との間に5グリッド分の間が開いています。</p>
</div>
</div>
一行目は、24個のグリッドを一つの要素で使い切ります。 | ||||||||||||||||||||||||||
2行目は3つの要素を配置します。 | 2つ目の要素です。 | 3つ目の要素です。行の最後なのでlastクラスを指定しています。 | ||||||||||||||||||||||||
この中を入れ子で指定します。
| 行の最後なのでlastを指定しています。 | |||||||||||||||||||||||||
グリッド4つ分あけてからグリッド8個分確保します。そしてその後に5個分のグリッドをあけます。つまり17個分ここで指定したことになります。 | 隣の要素との間に5グリッド分の間が開いています。 |
<script type="text/javascript"
src="http://www.google.com/jsapi?key={{gkey}}"></script>
<script type="text/javascript">
google.load("maps", "2.x",{"other_params":"sensor=false"});
var map = null;
function initialize() {
map = new google.maps.Map2(document.getElementById("map"));
map.setUIToDefault();
GEvent.addListener(map, "click", getAddress);
var point;
point = new GLatLng(35.6585873, 139.7454247)
map.setCenter(point, 14);
}
function getAddress(overlay, point) {
if (point != null) {
map.clearOverlays();
map.setCenter(point);
var marker = new GMarker(point);
map.addOverlay(marker);
map.savePosition();
}
}
google.setOnLoadCallback(initialize);
</script>
<body onunload="GUnload()">
<div id="map" style="width: 600px; height: 480px"></div>
</body>
map.savePosition();
map.setCenter(point);
var marker = new GMarker(point);
map.addOverlay(marker);
from ragendja.settings_post import settings
settings.add_app_media('combined-%(LANGUAGE_CODE)s.js',
'jquery/jquery.js',
'jquery/jquery.fixes.js',
'jquery/jquery.ajax-queue.js',
'jquery/jquery.bgiframe.js',
'jquery/jquery.livequery.js',
'jquery/jquery.form.js',
#追加しました
'jquery/jquery.cookie.js',
)
#セット
$.cookie('attr','val',{ expires: 30 });
#ゲット
test = $.cookie('attr');
INSTALLED_APPS = (
# Add jquery support (app is in "common" folder). This automatically
# adds jquery to your COMBINE_MEDIA['combined-%(LANGUAGE_CODE)s.js']
# Note: the order of your INSTALLED_APPS specifies the order in which
# your app-specific media files get combined, so jquery should normally
# come first.
'jquery',
・・・
)
LANGUAGE_CODE = 'ja'
LANGUAGES = (
('ja', 'Japanese'),
('en', 'English'),
)
#ここに書かれているファイルにまとめられるようです。
#ここに纏め上げるjavaスクリプトやcssを書くようです。
COMBINE_MEDIA = {
'combined-%(LANGUAGE_CODE)s.js': (
'.site_data.js',
),
'combined-%(LANGUAGE_DIR)s.css': (
'global/look.css',
),
}
MEDIA_VERSION = 1
INSTALLED_APPS = (
# ...
'mediautils',
# ...
)
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}combined-{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}.css" />
<script type="text/javascript" src="{{ MEDIA_URL }}combined-{{ LANGUAGE_CODE }}.js"></script>
from ragendja.settings_post import settings
settings.add_app_media('combined-%(LANGUAGE_CODE)s.js',
'myapp/code.js',
)
def index(request):
payload = dict()
payload['test'] = 'testtest'
#変更前のコード
# return render_to_response('test_index.html', payload)
#変更後のコード
return render_to_response(request,'test_index.html',payload)
from django.test import TestCase
from lib.common import func
class GmapHelperTestCase(TestCase):
def setUp(self):
pass
def test_func(self):
self.assertEquals('aaa', 'bbb')
- url: /admin/.*
script: common/appenginepatch/main.py
login: admin
from ahaha.models import Ohoho
from django.contrib import admin
admin.site.register(Ohoho)
# -*- coding: utf-8; -*-
from django.conf import settings
import xml.etree.ElementTree as etree
from google.appengine.api import urlfetch
import urllib
def test_gmap():
url = 'http://maps.google.com/maps/geo?'
url = url + 'key=' + settings.MAP_KEY
url = url + '&sensor=false'
url = url + '&output=xml'
url = url + '&q=' + urllib.quote('千代田区丸の内1-9-1')
result = urlfetch.fetch(url)
if result.status_code == 200:
dom = etree.fromstring(result.content)
namespace ='http://earth.google.com/kml/2.0'
retunrn dom.findtext('.//{%s}coordinates' % namespace)
#from pkg_resources import resource_string
from uamobile import detect class UserAgentMobileMiddleware(object): def process_request(self, request): request.device = detect(request.META)
from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response def index(request): payload = dict() payload['docomo'] = request.device.is_docomo() payload['au'] = request.device.is_ezweb() payload['softbank'] = request.device.is_softbank() payload['pc'] = request.device.is_nonmobile() return render_to_response('index.html', payload)
<html> <head> <title>test</title> </head> <body> aaa<br> docomo:{{docomo}}<br> au:{{au}}<br> sofubank:{{softbank}}<br> pc:{{pc}}<br> </body> </html>
urlpatterns = patterns('myapp.views', (r'^$', 'index'), )
Djangoルート |-uamobile |-IPy.py |-common | |-__init__.py | |-middleware.py |-myapp | |-views.py |-templates |-index.html
INSTALLED_APPS = (
'appengine_django',
'poll',
)
from django.conf.urls.defaults import *
urlpatterns = patterns('poll.views',
(r'^$', 'index'),
(r'^create/$', 'create'),
(r'^poll/(?P[^\.^/]+)/$', 'poll_detail'),
(r'^poll/(?P[^\.^/]+)/results/$', 'poll_results'),
)
from django import forms
import models
from google.appengine.ext.db import djangoforms
class PollForm(djangoforms.ModelForm):
class Meta:
model = models.Poll
exclude = ['created_by']
class ChoiceForm(forms.Form):
choice = forms.CharField(max_length = 100)
def __init__(self, poll=None, *args, **kwargs):
self.poll = poll
super(ChoiceForm, self).__init__(*args, **kwargs)
def save(self):
choice = models.Choice(poll = self.poll, choice = self.cleaned_data['choice'])
choice.put()
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
public dynamic class Fukidashi extends Sprite {
public var max_width:uint;
private var max_height:uint;
private var min_width:uint;
private var min_height:uint;
private var start_x:uint;
private var start_y:uint;
private var end_x:uint;
private var end_y:uint;
private var set_pos:Boolean = false;
private var zoom_on:Boolean = false;
public function Fukidashi(fillColor:Number = 0xEDE5D7, max_w:uint = 70, max_h:uint = 35, min_w:uint = 18, min_h:uint = 9) {
max_width = max_w;
max_height = max_h;
min_width = min_w;
min_height = min_h;
var canvas:Sprite = new Sprite();
var fukidashi:Sprite = createFukidashi(canvas, fillColor);
//回転の中心が左下になるように移動する
addChild(fukidashi);
max_width = fukidashi.width;
max_height = fukidashi.height;
buttonMode = true;
set_minisize();
addEventListener(MouseEvent.ROLL_OVER, overHandler);
}
private function set_minisize() : void {
width = min_width;
height = min_height;
}
public function set_position(sx:uint, sy:uint, ex:uint, ey:uint) : void {
start_x = sx;
start_y = sy;
end_x = ex;
end_y = ey;
set_pos = true;
}
public function overHandler(event:Event):void {
if (set_pos) {
zoom_on = true;
Tweener.addTween(this, {x:end_x,y:end_y,width:max_width,height:max_height,time:0.1,transition:"easeOutBack",onComplete:tweenEnd} );
} else {
width = max_width;
height = max_height;
}
}
public function outHandler(event:Event):void {
if (set_pos) {
zoom_on = false;
Tweener.addTween(this, {x:start_x,y:start_y,width:min_width,height:min_height,time:0.2,transition:"easeOutBack",onComplete:tweenEnd} );
} else {
width = min_width;
height = min_height;
}
}
public function tweenEnd() :void {
if (zoom_on) {
removeEventListener(MouseEvent.ROLL_OVER, overHandler);
addEventListener(MouseEvent.ROLL_OUT, outHandler);
} else {
removeEventListener(MouseEvent.ROLL_OUT, outHandler);
addEventListener(MouseEvent.ROLL_OVER, overHandler);
}
}
//フィールドを囲む吹き出しを作る
private function createFukidashi(canvas:Sprite, fillColor:Number) :Sprite {
var fldW:uint = max_width;
var fldH:uint = max_height;
//吹き出しを描く;
var w:uint = Math.ceil(fldW * 1.1);
var h:uint = Math.ceil(fldH * 1.4);
canvas.graphics.lineStyle(1, fillColor);
canvas.graphics.beginFill(fillColor);
canvas.graphics.drawRoundRect(0, 0, w, h,10,10);
canvas.graphics.endFill();
canvas.graphics.beginFill(fillColor);
canvas.graphics.moveTo(w * 0.15, h * 1.3);
canvas.graphics.lineTo(w * 0.35, h);
canvas.graphics.lineTo(w * 0.25, h * 0.5);
canvas.graphics.endFill();
return canvas;
}
}
}
import flash.filters.DropShadowFilter;
・・・
var filter : DropShadowFilter = new DropShadowFilter();
filter.distance = 2;
var box : Sprite = new Sprite();
box.graphics.drawRect(0, 0, 50, 50);
box.filters = [filter];
var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, loadCompleteHandler);
var myImgLoader:Loader = new Loader();
myImgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
var sample_tf : TextField = new TextField();
sample_tf.width = 100;
sample_tf.autoSize = TextFieldAutoSize.LEFT;
sample_tf.selectable = false;
sample_tf.multiline = sample.wordWrap = true;
sample_tf.text = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわ";
var need_dot:Boolean = false;
var max_height = 30;
while ( sample_tf.height > max_height ) {
sample_tf.text = sample_tf.text.slice( 0, sample_tf.text.length -1 );
need_dot = true;
}
if (need_dot) {
sample_tf.text = sample_tf.text.slice( 0, sample_tf.text.length -1 ) + "…";
//削除した文字がたまたま半角文字だと「…」をつけると
//heightをオーバーする可能性があるので念のためもう一度チェックを入れる
if (sample_tf.height > max_height) {
sample_tf.text = sample_tf.text.slice( 0, sample_tf.text.length -2 ) + "…";
}
}