2008-01-01から1年間の記事一覧

SCP on paramiko

import paramiko class SCPClient(paramiko.SSHClient): def read_response(self, stdout): c = ord(stdout.read(1)) if c == 0: return if c == -1: raise paramiko.SSHException("Remote scp terminated unexpectedly") if c != 1 and c != 2: raise param…

"string" and "String" and java.lang.String

js> var s = "abc"; abc js> s = new String(s); abc js> s == new String("abc"); false js> typeof s object js> s instanceof String true js> s = s.toString(); abc js> typeof s string js> s == "abc"; true js> s = new java.lang.String("abc"); ab…

Multiplatform easy-embeddable VM

I read http://lucille.atso-net.jp/blog/?p=496 and found the LLVM for the first time. These days I'm thinking about runtime optimization of PL language in the RDBMS. Although the SQL and 2-dimensional table structure is highly sophisticated…

how to enforce draggable() object to fixed position

I'm using the jquery library these days. It is quite good designed, I believe. But sometimes you would feel it lacks what you'd like to do, especially it is in the very localized problem. I recommend you to read the original code in such c…

Improved way to use transitional values in user function

Once before, I said Use of global variable in user function - umitanuki::quartet Be careful to use global variable and avoid it as long as possible! I found a way to keep transitional value during user function calls. The hint was in fmgr.…

Creating DLL written by C including C++ header

It's my own memorandom. Sometimes you must build dll or so called by c binary. Everything is OK as long as you are playing with c. But once you face to use external c++ library, be bit careful.I struggled for hours and found that a fact: #…

OreScript published

OreScript時代の幕開け - yukobaのブログ In the article above, a proposal of new paradigm in client side scripting. Yesterday an application was published as an experimental one.http://jtb.co.jp/kihin/see html source. Hope this will be a goo…

Bit operations

C

When m is power of 2, multiplication with arbitrary integer n is described as: /* * n * m */ #define bit_mul(n, m) ( (n) << ((m) >> 1) ) devide /* * n / m ( floor ) */ #define bit_div(n, m) ( (n) & ~(m - 1) ) and modulo is just subtract fr…

a bit improvement of array_to_text

PostgreSQL has a function array_to_string(anyarray, text), which is the same of delimiter.join(array) in Python. But I found it is so slow relatively than the implementation of Perl and Python.postgresql-8.2.5/src/backend/utils/adt/varlena…

log2

In Python, there isn't a function equivalent to log2(3). You say import math def log2(n): math.log(n) / math.log(2) to get x in n = 2**x. I didn't know but it's quite common. I must study mathematic more.But I guess it is slow because it c…

How to declare byte chunk whose size is fixed

C

typedef char Key[8]; typedef char *Value; So that struct KeyValue{ Key key; Value value; } // the struct has 12 bytes. /* typedef char *Key; typedef char *Value; struct KeyValue{ Key key; Value value; } */ // only 8 bytes. Is it logical?

Use of global variable in user function

From PostgreSQL: Use of global and static variables in shared libraries The existing C code that I've inherited makes heavy use of static and global variables. I immediately assumed that for thread safety I'd need to roll any of these vari…

PostgreSQL8.3 released

http://www.postgresql.org/about/news.918 PostgreSQL: Documentation: 8.3: Release 8.3This is so excited. Version 8.3 has an unprecedented number of new features. We've created additional pages to catalog them: And there is event some kind o…

Copy URL & Title and create Link

javascript:clipboardData.setData("Text",'<a href="'+location+'" target="_blank">'+document.title+'</a>');undefined;

Template engine by Python (continued)

Almost a week passed sinceTemplate engine by python - umitanuki::quartet Later, I introduce my idea. Ok, the main concept of my idea is "a template system that is written by indent-oriented language should be explicitly indented". What is …

Heated-up Matz's blog

Matz quoted http://mindblind.net/2008/01/24/attacking-php/ in his blog. Against his opinion, many people say like "PHP is a poor language", "PHP is not so bad", "PHPers are bad" or "PHPers are not so stupid". The blog was heated up.Matzに…

iterator of file object and tell()

There was a need to record each file pointer between ascii file lines. I just found the python documentation http://docs.python.org/lib/bltin-file-objects.html and thought you use file.tell() ary = [] lptr = 0 rptr = 0 f = open("file.txt")…

Template engine by python

Python is a powerful language. Through many languages I have written, it is one of the most comfortables. But template engine is an annoying problem in Python. I believe the reason for that is based on its indent system.For example, JSP ca…

English dialy / blog on Hatena ??

If I continue to write in English, The search engines think it is a Japanese site or an English site? Ha, just checked now. Hatena Server says "charset=euc-jp".

attributes on "script" nodes on IE and Firefox

I was writing such code: var nodes = (document.documentElement || document).getElementsByTagName("script"); for(var i=0; i