2008-02-01から1ヶ月間の記事一覧

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 …