Shammer's Philosophy

My private adversaria

2010-10-01から1ヶ月間の記事一覧

Core ファイルの出力先を指定する

DEBUG HACKS からの引用。/etc/sysctl.conf に kernel.core_pattern を設定することで可能。 以下のようにする。 # cat /etc/sysctl.conf kernel.core_pattern = /var/core/%t-%e-%p-%c.core kernel.core_uses_pid = 0 # sysctl -p

ClozureCLでマルチバイト文字のバイト数を判定する

以下のようなプログラムを使用してバイト数を判定していたが、これだけではやっぱり不十分だったようだ。 (defun string-byte-size (s) (let ((count 0)) (when (stringp s) (let ((strings-list (coerce s 'list))) (dolist (i strings-list) (if (typep (c…

数値判定関数-Ver20101021

C

文字列が数値かどうか判定する - Shammerismで書いてみたが、動作しないケースがあったので書き直し。 #include <stdio.h> #include <string.h> #include <ctype.h> /* * If v is number, return 1. * If v is NOT number, return 0. */ int checknumber(char *v){ int len = strlen(v); </ctype.h></string.h></stdio.h>…

UDP Echo Client

C

サーバーを書いてみたので、次はクライアント。 #include <arpa/inet.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> void die_with_error(char *errorMessage) { perror(errorMessage); exit(1); } int main(int argc, char* args…</unistd.h></sys/socket.h></sys/types.h></string.h></stdlib.h></stdio.h></netinet/in.h></arpa/inet.h>

UDP Echo Server

C

C 言語で書いてみた。というか、TCP/IPソケットプログラミングC言語編の内容をほとんどコピーしているに近いのだが。 #include <arpa/inet.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> void die_with_error(char *errorMessage) { perror(errorMessage); exit(</unistd.h></string.h></stdlib.h></stdio.h></netinet/in.h></arpa/inet.h>…

ShellScript条件分岐ーif文-20101010

ShellScript条件分岐ーif文-20100921 - Shammerismのアップデート版。ファイルの比較を追加。 #!/bin/bash echo "IF example!"; if [ $# -ne 1 ];then echo "Usage: $0 [123]"; exit 1; fi # # Compare numbers # if [ $1 -eq 1 ];then echo "You are number…

URLからプロトコルを取り出す

C

HTTP Client 作成の一環で、引数に渡された文字列をURLと想定し、そこからプロトコル部分を抜き出すという処理を書いてみた。Cには、期待する形で使用できるsubstringがなかったのでそれを自作し、その自作したsubstringを使用する形で書いてみた。 #include <stdio.h></stdio.h>…

Thunderbirdのメール書式

仕事の都合で、会社ではWindowsPC、メールソフトにThunderbirdを使っている。 よく、ブラウザで表示させた文字をコピペで貼り付けるのだが、メールの書式がHTML形式になっており、文字の色とか下線とかも一緒にコピーされていて、いちいちそれを修正するのが…