Wednesday, December 22, 2021

Why GDBM?

https://helpful.knobs-dials.com/index.php/File_database_notes

 

Simple file database

 

l   Concurrent write access for multiple processes

 

Simple file databases are useful to persist data with little required structure, and for goals that require storing (large amounts of) data on disk with pretty quick hash-based lookups.

Many such databases are based directly or less directly on the old, simple, yet effective dbm, a (family of) database engine(s) that stores key-value mappings (both strings) in a file (sometimes two, splitting out some metadata/index(verify)).

Implementations usually hashing for fast retrieval, allows rebucketing to have the hashing scale well, and fixed-size buckets to allow relatively efficient modification.

 

https://edoras.sdsu.edu/doc/gdbm/

有優缺點的分析。

Thus gdbm is an excellent lightweight alternative to a full relational database. If all you need to do is to store arbitrary data to be looked up with keys, and do it fast, then gdbm is your solution. However, there are a few caveats.

 

gdbm_fetch()

需要注意的地方!要記得釋放記憶體。

When gdbm fetches a datum from a file, it mallocs the buffer for you and returns the datum -- but that means, of course, that you have to free the buffer yourself! Failure to do so, as always, will work fine until you go into production and everybody's watching, at which point your process will crash and burn from the memory leaks.

https://edoras.sdsu.edu/doc/gdbm/example.html 

Tuesday, February 26, 2013

Bring CAN bus up - TI am335

#1. Create a file, rc.local @ etc/init.d
#2. Create a symbolic link, S99rc.local @ etc/rc5.d, which links to rc.local

# Content of rc.local

ip link set can0 type can bitrate 250000 triple-sampling on
ip link set can0 up


Monday, January 7, 2013

Workaround: NTP behind proxy


#!/bin/bash

PATH="https://ntp-a1.nict.go.jp/cgi-bin/time"
echo Get date from "$PATH"

# Shell will execute /usr/bin/curl $PATH,
# then printed by echo
NOW="`/usr/bin/curl $PATH`"
echo $NOW

# Update system date time
/usr/bin/sudo date --set="$NOW"

Wednesday, July 13, 2011

Emacs on Cygwin

Install Cygwin/X
1. Install Cygwin/X, X Windows on Windows , remember to select packages, like, emacs
2. Add below script to C:\cygwin\home\user\.bashrc
export DISPLAY=:0.0

2. Start XWin Server
3. Type command on shell to start Emacs
$ emacs


Install color-theme for emacs
1. Download , file: color-theme-6.6.0.zip
2. Extract color-theme-6.6.0.zip to C:\cygwin\home\user\.emacs.d
3. Create file, C:\cygwin\home\user\.emacs
4. Add below script to file, .emacs

(add-to-list 'load-path "~/.emacs.d/color-theme-6.6.0/")


Change Emacs theme
1. Open Emacs on Cygwin (Turn on X Server and type: emacs)
2. Type: 'M-x load-library'; then type: 'color-theme'
3. Type: 'M-x color-theme-select'


Set user's default theme
Put below scripts to file .emacs
 (require 'color-theme)  (color-theme-initialize)  (color-theme-robin-hood)
Last script 'robin-hood' is the name of theme


Check load-path
'C-h v load-path RET'

Reference

Monday, April 18, 2011

menuconfig

Add an entry to kernel config menu
** make sure library has been installed, "ncurses-devel"

/kernel source$ make clean
/kernel source$ make menuconfig

Friday, April 15, 2011

Change emacs theme

M-x load-library
color-theme
M-x color-theme-select

After you've selected a theme on the list then press ENTER

P.S. Place color-theme folder to ~/.emacs.d