This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7つの言語 7つの世界 のセルフスタディで書いたコード。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import from_connpass | |
>>> content = from_connpass.getContent("http://connpass.com/event/213/") | |
>>> users = from_connpass.getidlist(content) | |
OUT: get id: tmae | |
OUT: get id: noguchi616 | |
OUT: get id: th0x0472 | |
# 長いので省略 | |
OUT: get id: utsuidai | |
OUT: get id: n0ts | |
OUT: get id: matetsu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding: utf-8 | |
import os | |
import subprocess | |
import sys | |
PRE_PUSH_SCRIPT = 'pre-push' | |
POST_PUSH_SCRIPT = 'post-push' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: def deco(arg): | |
...: def wrapper(func): | |
...: def _wrapper(): | |
...: return func(arg) | |
...: return _wrapper | |
...: return wrapper | |
...: | |
In [2]: @deco("ham") | |
...: def spam(egg): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
payload = {'stuff': 'hirokiky', 'action': 'dec'} | |
url = 'http://karmaid.org/api/karma' | |
while True: | |
requests.post(url, params=payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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' } |
OlderNewer