Skip to content

Instantly share code, notes, and snippets.

PileMdについて

使ってるのはMac版

avatar.png imageテスト

雑感

  • 動作軽い
  • カラースキームが見やすくてよい
@inoshiro
inoshiro / local_settings.py
Created October 26, 2014 05:44
commit 2d9344a82ca71ac90f579a8397e634e951d8145e で検証
import os
SITE_ROOT = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[0:-2])
DONT_HIT_DB = True
SLUMBER_API_HOST = "http://localhost"
TEMPLATE_DIRS = (
'%s/readthedocs/templates/' % SITE_ROOT,
'%s/readthedocs/doc_builder/templates/' % SITE_ROOT,
)
@inoshiro
inoshiro / dev_machine_task.yml
Last active August 29, 2015 14:05
PyCharmのプロジェクトをこんな感じで作りたい
- name : 'setup pycharm project'
pycharm_project : project_dir={{item.project_dir}} venv={{item.venv}} additional_dir={{item.additional_dir}}
with_items:
- { project_dir='~/projects/openstack_havana_nova' venv='~/.virtualenv/openstack_havana_nova' additional_dir='~/repos/openstack_havana/nova' }
- { project_dir='~/projects/openstack_havana_neutron' venv='~/.virtualenv/openstack_havana_neutron' additional_dir='~/repos/openstack_havana/neutron' }
@inoshiro
inoshiro / dec_hirokiky.py
Created April 1, 2014 02:28
hirokiky-- script
import requests
payload = {'stuff': 'hirokiky', 'action': 'dec'}
url = 'http://karmaid.org/api/karma'
while True:
requests.post(url, params=payload)
@inoshiro
inoshiro / deco.py
Last active December 18, 2015 11:59
In [1]: def deco(arg):
...: def wrapper(func):
...: def _wrapper():
...: return func(arg)
...: return _wrapper
...: return wrapper
...:
In [2]: @deco("ham")
...: def spam(egg):
>>> from django import forms
>>> class CommentForm(forms.Form):
... name = forms.CharField(initial='class')
...
>>> f = CommentForm()
>>> print(f)
<tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" value="class" id="id_name" /></td></tr>
>>> f.fields['name'].initial
'class'
@inoshiro
inoshiro / admin.py
Last active January 17, 2017 12:08
Djangoのadminのカスタマイズ例(search/sort/pagination)
from django.contrib import admin
from .models import Memo
class MemoAdmin(admin.ModelAdmin):
list_per_page = 5
list_display = ['username', 'title']
search_fields = ['user__username']
def queryset(self, request):
qs = super(MemoAdmin, self).queryset(request)
@inoshiro
inoshiro / djanto-factory_boy.py
Created February 22, 2013 09:01
factory_boyどうやって使うのかいまいち分からない
from django.test import TestCase
from . import models
import factory
class PollFactory(factory.Factory):
FACTORY_FOR = models.Poll
question = "What's up?"
pub_date = '2013-02-22'
@inoshiro
inoshiro / git-push.py
Created February 9, 2013 08:01
git pushにhookを提供する。リポジトリの .git/hooks に pre-push か post-push が実行ファイルとして置いてあれば実行する
#!/usr/bin/env python
#coding: utf-8
import os
import subprocess
import sys
PRE_PUSH_SCRIPT = 'pre-push'
POST_PUSH_SCRIPT = 'post-push'
@inoshiro
inoshiro / detect_face.py
Created June 24, 2012 10:30
OpenCVのチュートリアルをPythonでやってみた http://gihyo.jp/dev/feature/01/opencv
import cv
imgfile = '../data/members.jpeg'
im = cv.LoadImage(imgfile, 1)
cascade = cv.Load('../data/haarcascade_frontalface_default.xml')
faces = cv.HaarDetectObjects(im, cascade, cv.CreateMemStorage())
for f in faces:
cv.Rectangle(im,
(f[0][0], f[0][1]),
(f[0][0]+f[0][2], f[0][1]+f[0][3]),
cv.CV_RGB(255, 0, 0),