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: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()
@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 / auto_attr_init.py
Created October 3, 2013 11:48
http://melborne.github.io/2013/09/27/auto-attr-set-in-ruby/ をPythonでやるとこれでいいのかなっていう。passなりreturnなり書かないとダメなのがダサいしそもそもPython的にはこういうのはキモいよねっていう。
#-*- coding:utf-8 -*-
from functools import wraps
import inspect
def auto_attr_init(f):
@wraps(f)
def _auto_attr_init(*args, **kwargs):
arg_values = args[1:] + inspect.getargspec(f).defaults
for pair in zip(f.__code__.co_varnames[1:], arg_values):
@kk6
kk6 / .stylelintrc
Created October 26, 2015 14:57
http://mdo.github.io/code-guide/ を参考にしてみた
{
"rules": {
"block-closing-brace-newline-before": [2, "always"],
"block-opening-brace-space-before": [2, "always"],
"color-hex-case": [2, "lower"],
"color-hex-length": [2, "short"],
"color-no-invalid-hex": 2,
"declaration-colon-space-after": [2, "always"],
"declaration-colon-space-before": [2, "never"],
"declaration-no-important": 2,
@kk6
kk6 / gist:521556a824ea43af54a4
Created March 11, 2016 08:40
twitterのプロフィールページで実行すると投稿画像グリッド表示してくれるやつ
javascript:var arr=document.location.href.split('/');var name=arr[arr.length-1];var url='https://twitter.com/search?f=images&vertical=default&q=from%3A'+name+'&src=typd';document.location.href=url;
@kk6
kk6 / sort_media_tweet.py
Last active December 8, 2016 18:48
メディアツイートをいいねやRT順に並べて表示
# -*- coding: utf-8 -*-
"""
メディアツイートをいいねやRT順に並べて表示
必要なファイルとか:
- twitterのConsumer Key, Consumer Secret
- 全ツイート履歴のCSV (twitter公式の「設定 > ユーザー情報」の一番下にある「全ツイート履歴」より)
インストールが必要なパッケージ:
- arrow
@kk6
kk6 / update_venv.py
Last active March 28, 2017 15:27
Pythonのバージョン上げた後にvirtualenv更新するやつ(Python3.5以上で動作)
import os
import subprocess
IGNORE = ['i', 'dont','wanna','update', 'these']
VENVS_DIR = os.path.join(os.path.expanduser('~'), '.virtualenvs')
def get_venvs():
p = subprocess.run("source $(which virtualenvwrapper.sh) && lsvirtualenv -b",
shell=True, stdout=subprocess.PIPE)
@kk6
kk6 / twitter_nav.css
Created January 27, 2017 06:32
twitterのタブを並び替えるユーザースタイルシート
.nav {
display: flex;
}
.home {
order: 1;
}
.moments {
order: 3;
}
.notifications {
@kk6
kk6 / mstdn.py
Last active July 31, 2017 23:28
Pythonでmastodon APIを叩くやつ
# -*- coding: utf-8 -*-
from urllib.parse import urlunsplit
import requests
from oauthlib.oauth2 import LegacyApplicationClient
from requests_oauthlib import OAuth2Session
def register_app(client_name, host, redirect_uris='urn:ietf:wg:oauth:2.0:oob',
scopes='read write follow'):
@kk6
kk6 / config.py
Created November 1, 2018 06:54
ptpythonの設定(~/.ptpython/config.py)
# Source: https://github.com/jonathanslenders/ptpython/blob/master/examples/ptpython_config/config.py
# Pygments CSS Themes: http://jwarby.github.io/jekyll-pygments-themes/languages/python.html
def configure(repl):
repl.vi_mode = True
repl.confirm_exit = False
repl.highlight_matching_parenthesis = True
repl.color_depth = "DEPTH_24_BIT"
repl.use_code_colorscheme("native")