Skip to content

Instantly share code, notes, and snippets.

@kwatch
kwatch / scrumble_bench.py
Last active March 4, 2016 08:27
benchmark: scrumble_uinit32 vs encrypt
# -*- coding: utf-8 -*-
import sys
from benchmarker import Benchmarker
import main
from rchk.utils.simple_crypto import encrypt, decrypt
from rchk.utils import scrumble_uint32
@kwatch
kwatch / pydiet.sh
Last active May 8, 2016 15:34
pydiet.sh -- remove unnecessary files from Python directory interactively
#!/bin/sh
###
### pydiet.sh -- remove unnecessary files from Python directory interactively
###
### Feature:
### * remove test script files (ex: python2.7/test/*)
### * remove *.pyo files (ex: python2.7/**/*.pyo)
### * remove *.opt-[12].pyc files (Python 3.5 or later)
###
@kwatch
kwatch / 0_reuse_code.js
Created May 15, 2016 01:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kwatch
kwatch / models.py
Created July 5, 2016 00:22
SQLおじさんのサンプルSQLをO/Rマッパーで書いてみた
# -*- coding: utf-8 -*-
"""
SQLAlchemy example code.
Requirements:
* Python3
* PostgreSQL
* SQLAlchemy
@kwatch
kwatch / perceptron.py
Last active July 17, 2016 02:22
(obsolete) (ML) Example1
# -*- coding: utf-8 -*-
import sys
import numpy as np
class Perceptron(object):
"""Perceptron classifier.
Parameters
@kwatch
kwatch / perceptron_example.py
Last active July 17, 2016 02:22
(obsolete) (ML) Example1
# -*- coding: utf-8 -*-
#from ch02_1 import Perceptron
from perceptron import Perceptron, Perceptron2
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
@kwatch
kwatch / perceptron.py
Last active July 17, 2016 04:47
パーセプトロンのサンプルコード
# -*- coding: utf-8 -*-
##
## 参考: 「Python機械学習プログラミング」
##
## 注: 事前にCSVファイルをダウンロードしておくこと
## $ wget https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data
##
@kwatch
kwatch / compile_urlpath.py
Created September 23, 2016 14:56
r'/foo/<id:\d+>.json' を r'^/foo(?P<id>\d+)\.json$' へと変換するサンプルコード
# -*- coding: utf-8 -*-
## license: public domain
import re
URLPATH_PARAM_PATTERN = r'<(\w+)(?::(.*?))?>'
re_escape = lambda s: re.escape(s).replace(r'\/', '/')
@kwatch
kwatch / SkyHigh.nrset
Created December 14, 2016 20:26
~/Library/Kawasemi2/RomajiSettings/SkyHigh.nrset
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ah</key>
<string>ニョ</string>
<key>ai</key>
<string>ヌ</string>
<key>aj</key>
<string>ナ</string>
@kwatch
kwatch / cal.py
Last active December 26, 2016 05:29
calendar
# -*- coding: utf-8 -*-
from datetime import date, timedelta
class Calendar(object):
def __init__(self, year, month):
self.year = year
self.month = month