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:
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.
- Rename the old table: RENAME TABLE store_record TO <new_name>
- Create an empty table: CREATE TABLE <new_name> LIKE store_record
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).
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.
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.
Monday, 22 October 2012
How to use and tweak Emacs Code Browser
Emacs is one of the most featured text editor in Linux/Unix like systems. The users don't need to move over the fingers to achieve almost all operations to edit text files or to code. It would be a quite efficient multi-function text editor if the horrible beginning start time of using it is neglected. Some keyboard companies produce specific customised keyboard such as HHKB for the ease of Emacs' using.
One of the Emacs' feature is to browser a program project with a large number of source files. More windows and tools are provided to navigate through the whole project. However, the installation and settings of ECB (Emacs Code Browser) is very complicated with a lot of works involved in its long manual. Here I record my short settings of a usable ECB. Not all of the features of either Emacs or ECB are exploited according to my settings, because I am also a newbie of Emacs and ECB. All of my efforts contribute on the usable version of working Emacs and ECB.
Setting the ECB to work in Emacs.
Find out the location of the installed ECB. I installed it by using yum tools. In this case, the location is /usr/share/emacs/site-lisp/ecb. Put this path into the list of emacs' load-path. Then require the ecb after that. However, an error message would be shown up saying that something wrong with the stack-trace-on-error. Then toggle on the stack-trace-on-error before load the ecb to the load-path in .emacs, the configuration file of Emacs.
ECB would ask you to insert some other setting to Emacs' configuration file. Just accept it is fine.
How to use the ECB:
1. navigation among different windows:
use the C-c . g (x) command, where (x) can be:
d: directory window
s: source files window
m: class and function names window
h: history window
2. Show any working directory in directory window.
When I open the ECB mode by using M-x ecb-activate, the directory window have nothing displayed. In order to set the working directory in the directory window the following steps are required:
M-x customize-option RET ecb-source-path RET
Choose the INS button in the opening custom buffer in order to insert a directory as a source path.
Choose to save for current session or for future sessions by type a number for specific type saving. Then the working directory should be shown in the directory window.
3. Customise the layout of ECB
There are several predefined layout available to users in ECB. The method used to change to these layouts is to set the option "ecb-layout-name". This is quite similar with the method used to set the working path of current session. The local tool of Emacs: M-x customize-option is employed to accomplish these sort of tasks.
The command M-x ecb-show-layout-help can be used to check the details of a predefined layout through it text-type picture.
One of the Emacs' feature is to browser a program project with a large number of source files. More windows and tools are provided to navigate through the whole project. However, the installation and settings of ECB (Emacs Code Browser) is very complicated with a lot of works involved in its long manual. Here I record my short settings of a usable ECB. Not all of the features of either Emacs or ECB are exploited according to my settings, because I am also a newbie of Emacs and ECB. All of my efforts contribute on the usable version of working Emacs and ECB.
Setting the ECB to work in Emacs.
Find out the location of the installed ECB. I installed it by using yum tools. In this case, the location is /usr/share/emacs/site-lisp/ecb. Put this path into the list of emacs' load-path. Then require the ecb after that. However, an error message would be shown up saying that something wrong with the stack-trace-on-error. Then toggle on the stack-trace-on-error before load the ecb to the load-path in .emacs, the configuration file of Emacs.
ECB would ask you to insert some other setting to Emacs' configuration file. Just accept it is fine.
How to use the ECB:
1. navigation among different windows:
use the C-c . g (x) command, where (x) can be:
d: directory window
s: source files window
m: class and function names window
h: history window
2. Show any working directory in directory window.
When I open the ECB mode by using M-x ecb-activate, the directory window have nothing displayed. In order to set the working directory in the directory window the following steps are required:
M-x customize-option RET ecb-source-path RET
Choose the INS button in the opening custom buffer in order to insert a directory as a source path.
Choose to save for current session or for future sessions by type a number for specific type saving. Then the working directory should be shown in the directory window.
3. Customise the layout of ECB
There are several predefined layout available to users in ECB. The method used to change to these layouts is to set the option "ecb-layout-name". This is quite similar with the method used to set the working path of current session. The local tool of Emacs: M-x customize-option is employed to accomplish these sort of tasks.
The command M-x ecb-show-layout-help can be used to check the details of a predefined layout through it text-type picture.
Sunday, 21 October 2012
Thread-local storage
Thread-local storage (TLS) is a programming method that is used to make static and global variables be local to a thread. The '"errno" is a canonical example of TLS method. Actually, a "errno" should be a static variable used by all functions to determine the error status. However, in each thread of a running process, there should be a separated one in order to prevent the infection from other threads in the same process.
The comparing method to achieve the similar function with the TLS is the thread lock for a static or global variable. However, a carelessness of requiring the lock in any threads in the process would affect other threads.
The comparing method to achieve the similar function with the TLS is the thread lock for a static or global variable. However, a carelessness of requiring the lock in any threads in the process would affect other threads.
Subscribe to:
Posts (Atom)