/page/2

ubuntu-users - Ring Switcher plugin missing in Windows Management in Ubuntu 13.04 Desktop

Ring Switcherを使うためには compiz-pluginsを入れましょう

AWStats - Free log file analyzer for advanced statistics (GNU GPL).

よさげなので導入したい

freadとreadの速度差

tuple(100byte)のデータを1万個用意し、それを読み込む速度を測った。
なお、いつかの調査でgettimeofdayは最大数us程度ずれうるということがわかっている、が、あまり関係なさそう。
結論から言うと、freadでは2000us程度、readでは10000us程度かかっていた。


    struct timeval before, after;
    gettimeofday( &before, NULL );
    /* while( ( tmp = read( fileno( rp ), &tuple[ n ], sizeof( crs_tuple_t ) ) ) > 0 ) { */
    /*     n++; */
    /*     if ( bufsize <= n ) { */
    /*         tuple = ( crs_p_tuple_t ) myrealloc( tuple, sizeof( crs_tuple_t ) * bufsize * 2, "tuple" ); */
    /*         bufsize *= 2; */
    /*     } */
    /* } */
    while( ( tmp = fread( &tuple[ n ], sizeof( crs_tuple_t ), bufsize - n, rp ) ) > 0 ) {
        n += tmp;
        if ( bufsize <= n ) {
            tuple = ( crs_p_tuple_t ) myrealloc( tuple, sizeof( crs_tuple_t ) * bufsize * 2, "tuple" );
            bufsize *= 2;
        }
    }
    gettimeofday( &after, NULL );

iphoneからコメントしたい: 若さとは。大学生とは。

ikejimakengo:

こんにちは。人生22回目の大型連休を迎えております。三年前はバドミントンの大会に行っておりました。一昨年は怪我しておりました。昨年はバイトの関係で東京に残っておりました。今年は水泳の合宿。うぇーい

昔のGWの予定を確認するためmixiの日記を久しぶりに見返した。なんか、わ、若くて読むの恥ずかしかった…顔文字多いよ…

自分も年取ったんだな。


四年生として新歓とかも頑張ってるんですけど、なんか22歳ともなると、18の人と話すの法的に大丈夫?これ別の意味で追加徴収とか起きる?

クソワロタ

キー入力があるまでタスクをwhile(1)みたいに行う方法

stdinかなんかをnonblockingでやるのではなく、別threadでタスクを実行しておいて、master threadでそいつを適当なタイミングで止めてやるという話。
参考: pthreadのキャンセル
pthread_cancelというのがあり、cancel pointをワーカスレッド側に用意( pthread_testcancel)してやればよい。ただ、このサンプルだとsleepがcancel pointになるので問題なかったりもする。

//! gcc -o hoge.bin hoge.c -lpthread 
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <pthread.h>

typedef struct _thread_arg
{
    int test;
} thread_arg_t;

void thread_func( void *tmp )
{
    thread_arg_t *arg = ( thread_arg_t * ) tmp;
    time_t t;
    while ( 1 ) {
        time( &t );
        printf( "%2d: %s", arg->test, ctime( &t ) );
        fflush( stdout );
        sleep( 1 );
        pthread_testcancel( );
    }
}

int main( void ) 
{
    pthread_t    thread;
    thread_arg_t targ = { .test = 1  };

    pthread_create( &thread, NULL, ( void * ) thread_func, ( void * ) &targ );

    getchar();
    pthread_cancel( thread );
    pthread_join( thread, NULL );
    
    printf( "finished\n" );
    return 0;
}

自宅内からサーバを見るための名前解決

dnsmasqを利用して、自宅内からマシンの名前解決が正しく出来るようにした。
dnsmasqで始めるプライベートDNSサーバ
第20回 いろいろなキャッシュ:dnsmasq, cache proxy
あたりが参考になった。
ココに書いてあることの他に、新しいDNSサーバが外に向くよう、/etc/network/interfacesにdns-nameserverにISPのDNSのIPを追加し、iptablesで53番に穴を開けた。

Emacs org-modeで快適タスク管理 入門 - 中川的備忘録

先輩がorg-modeを使ってないEmacsenはなんのために使っているのかわからない!!と言っていたので調べてみた。

ubuntu-users - Ring Switcher plugin missing in Windows Management in Ubuntu 13.04 Desktop

Ring Switcherを使うためには compiz-pluginsを入れましょう

AWStats - Free log file analyzer for advanced statistics (GNU GPL).

よさげなので導入したい

freadとreadの速度差

tuple(100byte)のデータを1万個用意し、それを読み込む速度を測った。
なお、いつかの調査でgettimeofdayは最大数us程度ずれうるということがわかっている、が、あまり関係なさそう。
結論から言うと、freadでは2000us程度、readでは10000us程度かかっていた。


    struct timeval before, after;
    gettimeofday( &before, NULL );
    /* while( ( tmp = read( fileno( rp ), &tuple[ n ], sizeof( crs_tuple_t ) ) ) > 0 ) { */
    /*     n++; */
    /*     if ( bufsize <= n ) { */
    /*         tuple = ( crs_p_tuple_t ) myrealloc( tuple, sizeof( crs_tuple_t ) * bufsize * 2, "tuple" ); */
    /*         bufsize *= 2; */
    /*     } */
    /* } */
    while( ( tmp = fread( &tuple[ n ], sizeof( crs_tuple_t ), bufsize - n, rp ) ) > 0 ) {
        n += tmp;
        if ( bufsize <= n ) {
            tuple = ( crs_p_tuple_t ) myrealloc( tuple, sizeof( crs_tuple_t ) * bufsize * 2, "tuple" );
            bufsize *= 2;
        }
    }
    gettimeofday( &after, NULL );

iphoneからコメントしたい: 若さとは。大学生とは。

ikejimakengo:

こんにちは。人生22回目の大型連休を迎えております。三年前はバドミントンの大会に行っておりました。一昨年は怪我しておりました。昨年はバイトの関係で東京に残っておりました。今年は水泳の合宿。うぇーい

昔のGWの予定を確認するためmixiの日記を久しぶりに見返した。なんか、わ、若くて読むの恥ずかしかった…顔文字多いよ…

自分も年取ったんだな。


四年生として新歓とかも頑張ってるんですけど、なんか22歳ともなると、18の人と話すの法的に大丈夫?これ別の意味で追加徴収とか起きる?

クソワロタ

キー入力があるまでタスクをwhile(1)みたいに行う方法

stdinかなんかをnonblockingでやるのではなく、別threadでタスクを実行しておいて、master threadでそいつを適当なタイミングで止めてやるという話。
参考: pthreadのキャンセル
pthread_cancelというのがあり、cancel pointをワーカスレッド側に用意( pthread_testcancel)してやればよい。ただ、このサンプルだとsleepがcancel pointになるので問題なかったりもする。

//! gcc -o hoge.bin hoge.c -lpthread 
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <pthread.h>

typedef struct _thread_arg
{
    int test;
} thread_arg_t;

void thread_func( void *tmp )
{
    thread_arg_t *arg = ( thread_arg_t * ) tmp;
    time_t t;
    while ( 1 ) {
        time( &t );
        printf( "%2d: %s", arg->test, ctime( &t ) );
        fflush( stdout );
        sleep( 1 );
        pthread_testcancel( );
    }
}

int main( void ) 
{
    pthread_t    thread;
    thread_arg_t targ = { .test = 1  };

    pthread_create( &thread, NULL, ( void * ) thread_func, ( void * ) &targ );

    getchar();
    pthread_cancel( thread );
    pthread_join( thread, NULL );
    
    printf( "finished\n" );
    return 0;
}

自宅内からサーバを見るための名前解決

dnsmasqを利用して、自宅内からマシンの名前解決が正しく出来るようにした。
dnsmasqで始めるプライベートDNSサーバ
第20回 いろいろなキャッシュ:dnsmasq, cache proxy
あたりが参考になった。
ココに書いてあることの他に、新しいDNSサーバが外に向くよう、/etc/network/interfacesにdns-nameserverにISPのDNSのIPを追加し、iptablesで53番に穴を開けた。

Emacs org-modeで快適タスク管理 入門 - 中川的備忘録

先輩がorg-modeを使ってないEmacsenはなんのために使っているのかわからない!!と言っていたので調べてみた。

使いやすい端末アプリ -Guake Terminal- | Ubuntu通信

イケメンだしつかいやすいっぽさげ

GnuPG コマンドライン版の使い方メモ

gpgで鍵を管理してみる

freadとreadの速度差
キー入力があるまでタスクをwhile(1)みたいに行う方法
自宅内からサーバを見るための名前解決

Tumblrについて:

ゆるゆるいっしょうけんめいいきていきたいな。

フォロー: