07102009 music drum'n'bass
渋い!
07102009 music drum'n'bass
06102009 music
自分のitunes掘ってたらみつけた。
特にMAWのremixが好きだけど全部よいですな。
06102009 Linux
interval timerを使うと定期的にシグナルを送れる。
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <signal.h>
int main()
{
void countdown(int);
signal(SIGALRM, countdown);
if ( set_ticker(50) == -1)
perror("set_ticker");
else
while( 1 )
pause();
return 0;
}
void countdown(int signum)
{
static int num = 10;
printf("%d ..", num--);
fflush(stdout);
if ( num < 0 ){
printf("DONE!\n");
exit(0);
}
}
int set_ticker( int n_msecs )
{
struct itimerval new_timeset;
long n_sec, n_usecs;
n_sec = n_msecs / 1000;
n_usecs = ( n_msecs % 1000 ) * 1000L;
new_timeset.it_interval.tv_sec = n_sec;
new_timeset.it_interval.tv_usec = n_usecs;
new_timeset.it_value.tv_sec = n_sec;
new_timeset.it_value.tv_usec = n_usecs;
return setitimer(ITIMER_REAL, &new_timeset, NULL);
}
sleepは秒単位だけどusleep使えばmicrosecondで一時停止できる
05102009 Linux
端末に関して、カノニカルモードとかノンブロッキングとか。あとシグナル処理。
端末を非カノニカル(cr)モードにするには
ノンブロッキングモードにするには
04102009 Linux
端末ドライバのプログラミング。
writeなんてコマンドがあるのか。
ioctlシステムコールにはほとんど触れてない。
昨日は食中りのような、げんなりするような鈍痛でやる気があまり出なかったので本でも読んだ。
フローの幸福からストックの幸福へ。
幸福のペンタゴンモデル
半農半Xという生き方は読んだ。あと、ブータンのGNHの話は伊藤洋一のビジネストレンドの第206回「GNHという考え方」が面白かった。
04102009 家庭菜園
メモ
04102009 Linux
pwdコマンドはinodeを親ディレクトリに辿っていく。ルートディレクトリは. と..が同じinodeを指す。
macbookでls -ia。
$ ls -ia /
2 ./ 31452 Users/
2 ../ 22730 Volumes/
ので.と..のinodeをチェックしながら再帰的に辿るという実装。
void printpathto( ino_t this_inode )
{
ino_t my_inode;
char its_name[BUFSIZ];
if ( get_inode( ".." ) != this_inode )
{
chdir( ".." );
inum_to_name(this_inode, its_name, BUFSIZ);
my_inode = get_inode( "." );
printpathto( my_inode );
printf("/%s",its_name );
}
}
03102009 Linux
lsを書く。
ファイルタイプとパーミッションを調べるのにマスキングを使う。
sys/stat.hのファイルタイプのとこ
/* File type */
#define S_IFMT 0170000 /* [XSI] type of file mask */
#define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */
#define S_IFCHR 0020000 /* [XSI] character special */
#define S_IFDIR 0040000 /* [XSI] directory */
#define S_IFBLK 0060000 /* [XSI] block special */
#define S_IFREG 0100000 /* [XSI] regular */
#define S_IFLNK 0120000 /* [XSI] symbolic link */
#define S_IFSOCK 0140000 /* [XSI] socket */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define S_IFWHT 0160000 /* whiteout */
#define S_IFXATTR 0200000 /* extended attribute */
#endif
man ls
b Block special file.
c Character special file.
d Directory.
l Symbolic link.
s Socket link.
p FIFO.
- Regular file.
03102009 Linux
システムコールを使ってcpコマンドを書く。
そのあと、バッファするバージョンのwhoコマンドを書く。