Skip to content

Instantly share code, notes, and snippets.

>>> import random
>>> def heya(li):
... random.shuffle(li)
... while li:
... yield li.pop(), li.pop()
...
>>> li = ['shoma', 'takanory', 'ike', 'tim', 'shimizukawa', 'jbking']
>>> list(heya(li))
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
#! ~/dev/misc/tokyoci/py/bin/python
# coding: utf-8
from akismet import Akismet
KEY = "xxxxxxxxxx"
BLOG_URL = "http://www.cmscom.jp/blog"
def _to_str(s):
assert isinstance(s, basestring)
@terapyon
terapyon / gist:6408878
Created September 2, 2013 03:02
今回(2013summer)のPyhack(合宿)の成果

今回(2013summer)のPyhack(合宿)の成果

  • Ploneカンファレンスの発表の流れを決めた(原さんと)
  • Plone関係作りこみ
    • Ploneのコンパネのレジストリーに保存や編集したときのイベントを捉えて、各種別の動作につなげる(jbkingにアドバイスを受けた)
    • Thread localを使っている時やZEO時に、全てに反映させる為の仕組み(数値を比べたり)を実装(田原さんに教えてもらった)
    • Fuzzy Searchの基礎データの保存をSQliteにする準備や実装。色々とやったがsqlalchemyを使うことにした。(aodagにたくさん聞いた)
@terapyon
terapyon / gist:8454015
Created January 16, 2014 12:16
calendar formating
# -*- coding: utf-8 -*-
from datetime import datetime as dt
from collections import OrderedDict, defaultdict
data1 = [{'id':"1", "start":(2014,01,16,9,0), "end": (2014,01,16,14,0)},
{'id':"2", "start":(2014,01,16,10,0), "end": (2014,01,16,11,0)},
{'id':"3", "start":(2014,01,16,12,0), "end": (2014,01,16,15,0)},
{'id':"4", "start":(2014,01,16,12,0), "end": (2014,01,16,14,0)},
{'id':"5", "start":(2014,01,16,15,0), "end": (2014,01,16,17,0)},
{'id':"6", "start":(2014,01,16,16,0), "end": (2014,01,16,18,0)},
@terapyon
terapyon / sample.v4.vcl
Last active March 13, 2019 13:51
This file is a sample VCL for Varnish 4.0. It will be used a back-end Plone. And support purge.
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.
@terapyon
terapyon / file0.txt
Created July 18, 2014 07:58
AWS S3 + CloudFront で動画ストリーム ref: http://qiita.com/terapyon/items/b77ac981da790662e247
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::c2-video-test/*"
]
}
@terapyon
terapyon / index.html
Created July 19, 2014 04:50
iOS向けにAWS S3 + CloudFrontで動画ストリーム ref: http://qiita.com/terapyon/items/e4925c15c7ee58778f92
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>動画ストリーミングのテスト</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
@terapyon
terapyon / default.vcl
Created December 25, 2014 01:48
Varnish で 複数のバックエンドシステムを使い分ける ref: http://qiita.com/terapyon/items/f532717ca0005c8dc5df
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.