Skip to content

Instantly share code, notes, and snippets.

View eight's full-sized avatar

Yoshinori Morimoto eight

View GitHub Profile
#!/bin/sh
# my absolute path on bash
echo $(cd $(dirname $0);pwd)
#!/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
#!/usr/bin/env python
"""Python urllib2 proxy usage sample
"""
import urllib2
#今回はプロキシ設定を空にしておく
#proxies = {'http': 'http://www.example.com:3128/'}
proxies = {}
#プロキシハンドラーを作成して
# -*- 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 -*-
"""ISBN(国際標準図書番号)規格改定
http://www.isbn-center.jp/whatsnew/kikaku.html
ISBNコードをいろいろするライブラリ。isbnlib.py
"""
import os,sys
#13桁ISBNの接頭文字
ISBN13_PREFIX = ('978','979')
<?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>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""モジュラス10ウエイト3とISBNのチェックデジット計算。Python版。
"""
def m10w31(code):
"""モジュラス10ウエイト3チェックデジットの計算
"""
s = list(str(code))
s.reverse()
sum = 0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""月末、月初のdatetime.dateオブジェクトを返す。
Oracleのadd_months互換の月加減。
"""
import datetime
from calendar import monthrange
def first_day(date):
"""月初を返す"""
<?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>
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