Archive for March 23rd, 2006

dl module

Thursday, March 23rd, 2006

dl  的作用在於相容傳統  c  裡的  dlopen
他可以直接把  c  寫的  .so  抓進來用 不過有一些限制

1.  dl  中的函式  參數最多不能超過  10  個
2.  參數的型別只能是  const  str  *  /  int
3.  python  只會傳入三種相對應的值
   字串  :  字串的起始位址,  即  const  str  *
   None  :  NULL
   Integer  : int
4.  傳回值必需要是  long

假設用  c  寫了一個簡單的  summation  funtion

long  sum(int  lb,  int  ub)
{
  int  s  =  0,  i;
  for(  i  =  lb;  i  <=  ub;  i++  )
    s  +=  i;
  return  s;
}

編譯成  util.so 那麼在  python  裡可以這樣引用

import  dl,  sys
lib  =  dl.open(’./util.so’)
if  not  lib:  sys.exit()

try:
  if  lib.sym(’sum’):  s  =  lib.call(’sum’,  1,  5)
  print  ’sum:’,  s
except  NameError:
  print  ”can’t  find  function”

如果沒有資料交換  (或只需要傳回簡單資料) 這是個簡單的方案
例如說把東西丟進  c  裡處理完就存檔 這樣就很方便了 不必動用  py  extension
但通常會動用  c  就是因為需要快速運算並取回結果阿…

也許透過  shm  是個好方法

console ui library

Thursday, March 23rd, 2006

Python  Dialog

  [Link]

Urwid

  [Link]

  Supported  Encodings
  Urwid  supports  the  following  character  encodings:

  *  UTF-8  (narrow  and  wide  characters)
  *  ISO-8859-*
  *  EUC-JP  (JISX  0208  only)
  *  EUC-KR
  *  EUC-CN  (aka  CN-GB)
  *  EUC-TW  (CNS  11643  plain  1  only)
  *  GB2312
  *  GBK
  *  BIG5
  *  UHC

cryptographic algorithms

Thursday, March 23rd, 2006

mxCrypto  -  Wrapping  OpenSSL’s  cryptographic  algorithms

  [Link]

Here  is  a  very  simple  one:

from  mx.Crypto.Ciphers  import  RC4
from  mx.Crypto.Utils  import  str2hex

c  =  RC4(’MyKey123′)
e  =  c.encrypt(’Hello  World!’)
print  ’Less  readable:’,str2hex(e)
c  =  RC4(’MyKey123′)
print  ’More  readable:’,c.decrypt(e)

Python  Cryptography  Toolkit

  [Link]
  [Link]

M2Crypto

  [Link]

ezPyCrypto  -  Encryption  in  Python  made  EASY

  [Link]

blowfish

  [Link]

Stopped Clock (jimmac’s blog)

Thursday, March 23rd, 2006

Stopped  Clock

  [Link]

一些  art  work  收集
blog  區有一些  gimp  的使用文章 也有demo  clips
[Link]

wordpress 實作的兩個測試用 api

Thursday, March 23rd, 2006

剛發現可以查到所有 method, 就玩了一下
沒想到有這兩個東西

demo.sayHello
demo.addTwoNumbers

連上去玩玩看

>>> server.demo.sayHello()
‘Hello!’
>>> ans = server.demo.addTwoNumbers(’1′, ‘3′)
>>> ans
4
>>> ans = server.demo.addTwoNumbers(’6.27′, ‘3′)
>>> ans
9.2699999999999996

看來精確度不太高:p


wordpress 支援的 xmlrpc method
blogger
– blogger.getUsersBlogs
– blogger.getUserInfo
– blogger.getPost
– blogger.getRecentPosts
– blogger.getTemplate
– blogger.setTemplate
– blogger.newPost
– blogger.editPost
– blogger.deletePost
other
– pingback.ping
– pingback.extensions.getPingbacks
– demo.sayHello
– demo.addTwoNumbers
metaWeblog
– metaWeblog.newPost
– metaWeblog.editPost
– metaWeblog.getPost
– metaWeblog.getRecentPosts
– metaWeblog.getCategories
– metaWeblog.newMediaObject
– metaWeblog.deletePost
– metaWeblog.getTemplate
– metaWeblog.setTemplate
– metaWeblog.getUsersBlogs
mt
– mt.getCategoryList
– mt.getRecentPostTitles
– mt.getPostCategories
– mt.setPostCategories
– mt.supportedMethods
– mt.supportedTextFilters
– mt.getTrackbackPings
– mt.publishPost