Skip to content

Instantly share code, notes, and snippets.

View eight's full-sized avatar

Yoshinori Morimoto eight

View GitHub Profile
function m10w31(code: string): integer;
/**
Delphi版 モジュラス10ウエィト3のチェックデジット計算。
*/
var
i,w,sum: integer;
begin
w := 3;
sum := 0;
for i := length(code) downto 1 do
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""モジュラス10ウエイト3とISBNのチェックデジット計算。Python版。
"""
def m10w31(code):
"""モジュラス10ウエイト3チェックデジットの計算
"""
s = list(str(code))
s.reverse()
sum = 0
@eight
eight / gist:227575
Last active January 13, 2016 08:55
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""yurpc2.py
XML-RPCで郵便番号から住所を取得するPythonスクリプト
"""
import sys
import string
try:
from xmlrpc.client import ServerProxy
except ImportError:
<?php
//XML-RPC IXR_Library.inc.php 使用サンプル
if (isset($_GET['show_source'])) {
highlight_file('sample2.php');
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php
//XML-RPC yubin.class.php 使用サンプル
if (isset($_GET['show_source'])) {
highlight_file('sample.php');
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php
// 全国郵便番号一覧 - 郵便専門ネット http://yubin.senmon.net/
// PHP XML-RPCクライアントクラス yubin.class.php
// 使い方は一番下のテストを。
//
// 2002.11.05 受け渡す郵便番号の型がintになっていたのをstringに修正。
// 2002.11.06 見つからない場合にはfaultCode()が返るようになったのでそれに合わせて変更。
// 2002.11.08 セルフテストのスペルミスを訂正。
// 2002.11.09 仕様変更に対応。初期化関数の冗長な記述を削除。
// 2002.11.11 Addressというクラス名は一般的するぎるのでYubinXMLRPC_Addressに変更。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""ISBN(国際標準図書番号)規格改定
http://www.isbn-center.jp/whatsnew/kikaku.html
ISBNコードをいろいろするライブラリ。isbnlib.py
"""
import os,sys
#13桁ISBNの接頭文字
ISBN13_PREFIX = ('978','979')
#!/usr/bin/env python
# -*- coding: utf-8-*-
# python-ldapを使ってActiveDirectoryで認証してみる
# http://python-ldap.sourceforge.net/
def ADAuth(username,password,host,port=389):
"""ActiveDirectoryのドメイコントローラにユーザ名とパスワードでbindしてみる。
bindできれば認証OK。認証NGなら例外が起きる。
"""
import ldap
# -*- coding: utf-8 -*-
"""MoinMoin custom user authentication sample
"""
from MoinMoin import user
#User Database
_USER_MAP = {'user1,pass1':('user1@example.com',u'user1'),'user2,pass2':('user2@example.com','user2')}
def login(request, **kw):
username = kw.get('name')
password = kw.get('password')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""月末、月初のdatetime.dateオブジェクトを返す。
Oracleのadd_months互換の月加減。
"""
import datetime
from calendar import monthrange
def first_day(date):
"""月初を返す"""