Skip to content

Instantly share code, notes, and snippets.

View kk6's full-sized avatar
🐾
Playing with my cat.

kk6 kk6

🐾
Playing with my cat.
View GitHub Profile
@kk6
kk6 / gist:5805780
Created June 18, 2013 14:26
tinkererの検索が動いてる環境
$ pip freeze
Jinja2==2.7
MarkupSafe==0.18
Pygments==1.6
Sphinx==1.2b1
Tinkerer==1.2
argparse==1.2.1
distribute==0.6.31
docutils==0.10
wsgiref==0.1.2
@kk6
kk6 / gist:5459262
Created April 25, 2013 12:14
mercurial 2.6-rc にバージョン上げたら Rietveld にアップロードしようとすると「Got error status from ['hg', 'diff', '--color', 'never', '--git', '-r', '14910:14965']:」などと出るようになった。そこで「hg diff --color never」してみたらこんなtracebackが。
** Unknown exception encountered with possibly-broken third-party extension hgshelve
** which supports versions unknown of Mercurial.
** Please disable hgshelve and try your action again.
** If that fixes the bug please report it to the extension author.
** Python 2.7.3 (default, Aug 1 2012, 05:16:07) [GCC 4.6.3]
** Mercurial Distributed SCM (version 2.6-rc)
** Extensions loaded: color, eol, convert, extdiff, hgshelve, histedit, info, mq, pager, progress, purge, rebase, record, schemes, transplant, hgflow
Traceback (most recent call last):
File "/usr/local/bin/hg", line 38, in <module>
mercurial.dispatch.run()
#-*- coding:utf-8 -*-
import csv
import requests
from pyquery import PyQuery as pq
def _scrape_links(url, search_query):
response = requests.get(url, params=search_query)
@kk6
kk6 / gist:3795397
Created September 27, 2012 17:56
trigger, bind の簡単な例
(function($) {
// element の true/false に対して control の true/false が追従します
$.fn.toggle_chkboxes = function(control) {
var element = this;
control = $(control);
// element がクリックされたら change.chkboxes イベントを発火させる
element.click(function() {
@kk6
kk6 / warning_unknowns.py
Created September 16, 2012 06:22
コミット時に管理対象外ファイルがあったことを通知するmercrialのhook
#!/usr/bin/env python
import sys
def warning(ui, repo, hooktype, node=None, source=None, **kwargs):
ctx = repo[None]
unknown_files = repo.status(ctx.parents()[0], ctx, unknown=True)[4]
if unknown_files:
for filename in unknown_files:
@kk6
kk6 / session_required_decorator.py
Created September 13, 2012 13:02
Django's session required decorator
#-*- coding:utf-8 -*-
from functools import wraps
from django.contrib import messages
from django.shortcuts import redirect
def session_required(session_key, fail_redirect_to):
def _session_required(view_func):
@wraps(view_func)
@kk6
kk6 / gist:3662923
Created September 7, 2012 03:51
celeryのPeriodic Taskを動的に登録する
>>> from celery.beat import ScheduleEntry
>>> from celery.task import periodic_task
>>> from celery.schedules import crontab
>>> from some_module import some_function
>>> entry = ScheduleEntry(periodic_task(mkdir_every_minute, run_every=crontab()))
>>> entry
<Entry: <function _create_task_cls at 0xb0156f4> None(*(), **{}) {None}>

Mercurialメモ

@kk6
kk6 / face.py
Created January 11, 2012 16:46
#-*- coding:utf-8 -*-
# アルファベットから顔文字生成
# Python3専用です
import unicodedata
def to_face(ls):
for c in ls:
@kk6
kk6 / read_ff_cookies.py
Created October 23, 2011 17:29
http://goo.gl/aw41c を見てなんとなく書いてみるなど。
#-*- coding:utf-8 -*-
# Python 3.2 でのみ動作確認済み
# Python 2.7 で実行するとDatabaseError になりました。
import sqlite3
# 適宜cookies.sqliteファイルまでのpathを編集
COOKIES = r"cookies.sqlite"