Computer Scientist

Thursday, 1 August 2013

Endnote X7 export to Bibtex

I converted the endnote library to bibtex several years ago. It's totally behind my mind already. Today I want to try the endnote X7 and to see whether something improved in this new version endnote. It is rather good to involve the bibtex template into its export style options. However, I found that there is no citation key for each reference at all. According to the search, the endnote needs the label of a reference as its citation key. But it seems that it doesn't work quite smoothly.  Therefore, I downloaded a Bibtex Export from endnote's style manager on its site and restart the whole endnote. I am not quite sure if the restart works or the new export style works. Finally, I got it work with reference label to be its citation key.

Wednesday, 5 June 2013

Backup a table in MySQL

In my experiment, each experiment running needs a table in the control machine to record the global inserted files in the system. When an experiment finished, a new empty table should be created in order to record the new experiment's inserted files. For later experiment process, the old table should be backed up also. There could be more efficient and reliable way to back up the tables in a MySQL database, but here is my method to accomplish this task with two SQL commands:
  1. Rename the old table: RENAME TABLE store_record TO <new_name>
  2. Create an empty table: CREATE TABLE <new_name> LIKE store_record
 After these two SQL command, the original 'store_record' table becomes 'new_name' table and an empty new 'store_record' table is created.
WARNING: there is no quotation marks for table name!

This is put in the process of cleaning up experiment results. If cleaning up is necessary, then the data in 'store_record' table is useless. And it is free to be replaced by an empty one for next experiment. If the cleaning up is not performed, it means that the data in last experiment is useful in the next experiment, then the remaining of data in 'store_record' is meaningful.

Sunday, 2 June 2013

libssh remove directory using sftp

In libssh, trying to remove an non-empty directory on a remote host will get a SSH_FX_FAILURE error.

Friday, 24 May 2013

SFSlite output stream system and Chord logging

In Chord source code, there are a great number of "warn", "warnx", "warnt", "fatal" and "panic". They are the output stream part of sfslite library and are used to replace the error output mechanics in standard C++ library in a asynchronous way. According to the tutorial of libasync from David and Frank, et al., these stream makes efforts to accumulate and write data to the terminal in chunks with reasonable boundaries.

This mechanic is defined in err.h and err.C in sfslite/async/ directory. There are some derivations for "warn":
    warn:
      - vwarn: invoke the underlying vfmt of strbuf.
      - warnx: the program name and pid are shown in each message.
      - warnt: a time stamp is shown in each message.
      - vwarnx: invoke the underlying vfmt of strbuf with program name
                      and pid shown

    fatal: message start with "fatal", exit program after messaging
    panic: message start with "PANIC", exit and dump core after messaging.

    assert: this is an replacement of C assert using the panic.

Here is what I found from the sfslite source code.

Actually, there is a quite similar mechanic in Chord called modlogger in chord/utils/modlogger.*, which is labelled an employed idea from sfslite. The modlogger is actually a small logging system with logging levels (CRIT, WARNING, INFO, TRACE) and logging target (standard output or a file descriptor).

Saturday, 23 March 2013

C/C++ Programming Tips

Here, some useful tips or unknowns of C/C++ programming are listed for further reference:

1. Stand alone curly brackets in code.
Sometimes a pair of curly brackets can be found in a C/C++ code file. It seems to be useless:

Configurator::only ().dump();

{
    strbuf x = strbuf ("starting: ");
    for (int i = 0; i < argc; i++) {
        x << argv[i] << " ";
    }
    x << "\n";
    info << x;
}

Here, the curly brackets is not necessarily to exist. However, they have their meanings from two different point of views: Scope perspective and Legacy perspective.
In scope perspective, the codes in the pair of curly brackets is in a new sub scope.
In legacy perspective, the legacy C standard needs variable declarations to be in the very front of the code. The curly brackets are able to make a new "beginning".
I am working on a C++ project. So the original coder considered in a scope perspective.