Monday, March 7, 2011

PENGUIN BOMB

Sunday, February 6, 2011

“Less is More” is Bullshit

“Less is More” is Bullshit by Ian Crawford
“Less is More” implies that more is better. It’s not. Less is less. Less is just right. Less is better.
from 37signals blog.

That's very true.

Monday, January 31, 2011

LLVM

Since I went to a workshop held several weeks ago, I got interested in LLVM. LLVM stands for Low Level Virtual Machine which is a compiler infrastructure (a good tool to use when you write your compiler). There are lots of project going on using LLVM, unladen swallow is a famous one of them. Now I'm reading LLVM tutorial and I found it's not only good for understanding LLVM, but it's very helpful to understand compiler itself, i.e. lexer, parser, and code generation, with lots of practical tips. It's not difficult at all if you have a basic knowledge of C++.

The following info are some tips to run the sample program (toy.cpp) on fedora.

1) Installation


yum install llvm
yum install clang
yum install llvm-doc
yum install clang-doc
yum install llvm-devel


2) Add -rdynamic option when you compile chapter 5 example program.

g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy -rdynamic

Accoding to the gcc man page,

Pass the flag -export-dynamic to the ELF linker, on targets that
support it. This instructs the linker to add all symbols, not only
used ones, to the dynamic symbol table. This option is needed for
some uses of "dlopen" or to allow obtaining backtraces from within
a program.


Without this, you'll see an error message when you use "putchard"

LLVM ERROR: Program used external function 'putchard' which could not be resolved!


3) To Make the chapter 5 example program work exactly like the document, comment out the following line.
Adding this will do some more optimization.

OurFPM.add(createCFGSimplificationPass());


4) If you are puzzled by the following part of chapter5's If/Then/Else section,

// Codegen of 'Then' can change the current block, update ThenBB for the PHI.
ThenBB = Builder.GetInsertBlock();

try executing the following code and see what it generates.

extern foo();
extern bar();
extern kou();
extern tam();
def baz(x) if x then if foo() then kou() else tam() else bar();

and be aware that if/then/else/merge always ends its execution at merge(ifcont) block.

Sunday, January 30, 2011

PyCon mini JP

Yesterday we held PyCon mini JP.




















Ice break

















I think it was a big success. We had a wide variety of sessions and attendances seemed to enjoy them a lot. It was the first time for me to participate in holding a conference. I don't think I could work like others who regularly do it but I enjoyed it a lot and had a good experience. It was interesting that the way people who likes holding conferences think are quite different from other developers, they think about communities much more seriously for example.

Sunday, January 23, 2011

One more video

Find .mov and .ogv from a directory and its sub directories, convert them to .avi files and store them to another directory. 1080p available.

Thursday, January 13, 2011

Zamami pre-alpha

This is a software I've been making.
Watch them on full screen mode with 720p to see how the tool works in detail.

Basic usage


Batch execute and built-in debugger


sqlite


Detect missing files in an image sequence


job dispatch


fancy template


I made a twitter client on it for a complecated node-network example but twitter has turned off Basic auth last year and it doesn't work now. I'll upload it when I've made it working.

Saturday, December 4, 2010

Tips to obfuscate your code.

I often realize people make their code hard to maintain. It's a very good idea to raise your value in the company since nobody else can maintain it. Let's learn from their code. Often you can even get more efficient code since you don't need to write extra lines to make your code nicer. It doesn't cover basic skills like using magic numbers, not making a method name readable, give an object more than one name, delete all comments, etc (Do all of them!). Ideas are listed in order of importance.

(1) Store the same value in more than one places.

If you store the same parameter in more than one places, you need to synchronize them. When a maintainer write a code that changes the value, he will have a change to miss the fact and change only one of them. Every code that uses the other variable which wasn't changed will behave mistakenly. Hopefully the program will be in an inconsistent state.

(2) Store lots of data in an object and every method depends on them

If lots of methods are dependent on the state of the object, the user of the class will need to set all of them properly before using the method and he will be confused. A nice side effect is that it makes the program hard to debug and test cause the behavior of a method can have lots of right and wrong cases. Try packing lots of unnecessary parameters, make the state of objects complicated, and make it hard to maintain.

(3) Reference an object from lots of other objects.

People who look at it will be puzzled, "Is the object I can get from A is the same as what I can get through B?". This strategy is good with (1) above. Unnecessary references are good!

Dec. 24:
Just tried to tell what will happen if you do them. Don't do them of course :)