2012年2月26日日曜日

ubuntu 11.10 に python 2.5系をインストール

$ wget 'http://python.org/ftp/python/2.5.6/Python-2.5.6.tar.bz2'
$ tar xf Python-2.5.6.tar.bz2
$ cd Python-2.5.6/

$ ./configure --disable-ipv6 --disable-shared --enable-unicode

$ make

running build_ext
/usr/include/sqlite3.h: version 3.7.7
Traceback (most recent call last):
File "./setup.py", line 1545, in
main()
File "./setup.py", line 1540, in main
'Lib/smtpd.py']
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/dist.py", line 974, in run_commands
self.run_command(cmd)
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/dist.py", line 994, in run_command
cmd_obj.run()
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/command/build.py", line 112, in run
self.run_command(cmd_name)
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/dist.py", line 994, in run_command
cmd_obj.run()
File "/usr/local/src/works/Python-2.5.6/Lib/distutils/command/build_ext.py", line 290, in run
self.build_extensions()
File "./setup.py", line 97, in build_extensions
self.detect_modules()
File "./setup.py", line 810, in detect_modules
sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))]
File "/usr/local/src/works/Python-2.5.6/Lib/posixpath.py", line 119, in dirname
return split(p)[0]
File "/usr/local/src/works/Python-2.5.6/Lib/posixpath.py", line 77, in split
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
make: *** [sharedmods] Error 1

コケる c⌒っ゚Д゚)っ

ライブラリパスを指定

$ make distclean
$ LDFLAGS="-L/usr/lib/i386-linux-gnu" ./configure --disable-ipv6 --disable-shared --disable-unicode
$ make
creating build/scripts-2.5
copying and adjusting /usr/local/src/works/Python-2.5.6/Tools/scripts/pydoc -> build/scripts-2.5
copying and adjusting /usr/local/src/works/Python-2.5.6/Tools/scripts/idle -> build/scripts-2.5
copying and adjusting /usr/local/src/works/Python-2.5.6/Lib/smtpd.py -> build/scripts-2.5
changing mode of build/scripts-2.5/pydoc from 664 to 775
changing mode of build/scripts-2.5/idle from 664 to 775
changing mode of build/scripts-2.5/smtpd.py from 664 to 775
$

こんどは成功(`・ω・´)


$ sudo make install
 :
Compiling /usr/local/lib/python2.5/zipfile.py ...
make: *** [libinstall] Error 1

が、しかし・・・ make install 失敗(´・ω・`)

しょうがないのでエラーを無視でaltinstall

$ sudo make -i altinstall

changing mode of /usr/local/bin/smtpd.py to 775
running install_egg_info
Removing /usr/local/lib/python2.5/lib-dynload/Python-2.5.6-py2.5.egg-info
Writing /usr/local/lib/python2.5/lib-dynload/Python-2.5.6-py2.5.egg-info

これでよしとしよう

2012年2月25日土曜日

xfce4 で eclipse 使用時に ctrl+F6 ctrl+F7 あたりが効くようにする

eclipse使ってて、ctrl+F6とか効かない場合
xfce4のショートカットが邪魔してる
いちおう、debian(xubuntu)とかRedHat系含め、xfce4使ってるなら同じはず

$ vim ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

<property name="&lt;Control&gt;F4" type="string" value="workspace_4_key"/>
<property name="&lt;Control&gt;F5" type="string" value="workspace_5_key"/>
<property name="&lt;Control&gt;F6" type="string" value="workspace_6_key"/>
<property name="&lt;Control&gt;F7" type="string" value="workspace_7_key"/>

あたりを、ばっさり削除する。

保存後に、ログインし直しでOK

注意
・ワースペ使ってる場合、ショートカットが無くなる
・設定エディタで、xfce4-keyboard-shortcutsのxfwm4の下を編集すると復活することがある

debian で時間帯を設定する

$ sudo vim /etc/default/rcS
UTC=no

$ sudo dpkg-reconfigure tzdata

2012年1月23日月曜日

Hoge.c

/*
============================================================================
Name : Hoge.c
Author : M♂DS
Version :
Copyright : M♂DS
Description : Hoge in C, Ansi-style
============================================================================
*/

#include
#include

#define BUFFLEN 256

struct _list {
struct _list *prev;
struct _list *next;
char buff[BUFFLEN];
};

typedef struct _list LIST;

LIST * makeList(LIST *current) {
if (current == (LIST *) NULL) {
current = (LIST *) calloc(1, sizeof(LIST));
current->prev = (LIST *) NULL;
} else {
current->next = (LIST *) calloc(1, sizeof(LIST));
current->next->prev = current;
current = current->next;
}
current->next = (LIST *) NULL;
return current;
}

int main(void) {
LIST *q, *p;
int i;

p = q = (LIST *) NULL;
for (i = 0; i < 100; i++) {
p = makeList(p);
if (q == NULL) {
q = p;
}
snprintf(p->buff, BUFFLEN, "hoge %03d", i);
}

for (p = q; p; p = p->next) {
puts(p->buff);
}
return EXIT_SUCCESS;
}

次の案件に備えて11年ぶりくらいに
C言語を使ってみたが
意外と忘れてなくて良かったε-(´∀`*)ホッ

.screenrc

# -*- shell-script -*-

termcap kterm hs@
terminfo kterm hs@
term ansi
vbell off
bind w windowlist -b
hardstatus alwayslastline "%{= gw} %H %{= wk}%-Lw%{= bw}%n%f* %t%{= wk}%+Lw %{= wk}%=%{= gk} %y/%m/%d %c "
defhstatus I^En:^EtI
shell -$SHELL
startup_message off
autodetach on
defscrollback 5000

bind 'd' setenv DISPLAY
bind w windowlist -b
bind ^p paste
bind p paste

bind r eval 'echo "Resize window"' 'command -c resize'
bind -c resize ^] command
bind -c resize j eval 'resize +1' 'command -c resize'
bind -c resize k eval 'resize -1' 'command -c resize'

bindkey -m > eval "stuff ' '" writebuf 'exec sh -c "xsel -i -b < /tmp/screen-exchange; sleep 0.1"'


2009年2月23日月曜日

Ruby/RailsのためのVim導入(その1)

CentOSに付属のvim(vi)は、rubyオプションが有効になっていないので
vim-rubyを導入しても正しく動作しない。
よってvimの最新版をソースから導入する事にした。

作業前に、vimのrubyオプションが無効な事を確認

$ vim --version | grep ruby
+python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
つ´Д`)つ


ソースをダウンロード
$ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
$ wget ftp://ftp.vim.org/pub/vim/extra/vim-7.2-extra.tar.gz
$ wget ftp://ftp.vim.org/pub/vim/extra/vim-7.2-lang.tar.gz
$ tar xvfj vim-7.2.tar.bz2
$ tar xvfz vim-7.2-extra.tar.gz
$ tar xvfz vim-7.2-lang.tar.gz

パッチをダウンロード
※ブラウザで、ftp://ftp.vim.org/pub/vim/patches/7.2/ にアクセスして、最新の番号を確認する
$ mkdir patches
$ cd patches
$ wget ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.001-100.gz
$ curl -O 'ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.[101-124]'
$ cd ../vim72
$ zcat ../patches/7.2.* | patch -p0

configure
※--enable-rubyinterp を付ける

$ ./configure --enable-perlinterp --enable-pythoninterp --enable-tclinterp \
> --enable-rubyinterp --enable-multibyte --enable-xim --enable-fontset \
> --with-features=big --prefix=$HOME 2>&1 | tee config.log

makeして導入
$ make 2>&1 | tee make.log
$ make install
(prefixが、/usr/local とかならsudoを付ける)

確認
$ $HOME/bin/vim --version | grep ruby
+printer -profile +python +quickfix +reltime +rightleft +ruby +scrollbind

・-)

参照(っていうか、そのまんま・・・)
http://www.hazama.nu/t2o2/archives/002696.html

2008年8月2日土曜日

[ruby] rubygems でmysql ライブラリをインストールする

mysql-develが入っているか確認する

$ rpm -qa | grep -i mysql
mysql-5.0.45-7.el5
mysql-devel-5.0.45-7.el5

gemでインストールします(そのままだとエラーが出ますね)

$ sudo /opt/ruby/bin/gem install mysql --no-rdoc --no-ri
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/opt/ruby/bin/ruby extconf.rb install mysql --no-rdoc --no-ri
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/ruby/bin/ruby
--with-mysql-config
--without-mysql-config
(snip)

Gem files will remain installed in /opt/ruby/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/ruby/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

mysqlの設定を、mysql-configから取得するように指定

$ sudo /opt/ruby/bin/gem install mysql --no-rdoc --no-ri -- --with-mysql-config
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed

チェックする(require でmysqlが読み込めればOK)

$ /opt/ruby/bin/irb -rrubygems
irb(main):001:0> require 'mysql'
=> true
irb(main):002:0> exit

成功したっぽい

2008年7月28日月曜日

[unix] スペースを含むファイル名をfindとxargsで使う方法

Mac OS Xみたいに、ディレクトリやファイル名にスペースを含んでいる場合
find と xargsをそのまま実行すると
スペースの前後で別々の引数として処理される(´・ω・`)

・対応方法
スペースを区切り文字にするのではなく0(ゼロ、null)を区切り文字にする。

$ find . -type f -print0 | xargs -0 ls
のように
find には、-print0
xargsには、-0もしくは--null
オプションを指定する。

それでも正しく認識せんぞという場合は効率が悪いけど
xargs -i と "{}" を書くようにしよう・・・
 find -print0 | xargs --null -i ls "{}"

2008年7月24日木曜日

[bash][小ネタ] read でいろいろ

$ read -ep 'USERNAME: ' uname
$ echo $uname


-e で、readlineの機能(スクロールバックやCtrl-rでヒストリ検索など)を利用できる。
-p で、プロンプトを表示できます。

2008年7月16日水曜日

[nkf] nkfのインストール

ソースからnkfを入れる

http://sourceforge.jp/projects/nkf/ からダウンロード
$ wget http://iij.dl.sourceforge.jp/nkf/26243/nkf-2.0.8b.tar.gz


$ tar xvfz nkf-2.0.8b.tar.gz
$ cd nkf-2.0.8


Makefileを修正
$ vi Makefile


修正内容
$ diff -dc Makefile.bak Makefile

*** Makefile.bak 2008-07-16 20:59:16.000000000 +0900
--- Makefile 2008-07-16 21:02:19.000000000 +0900
***************
*** 1,5 ****
! CC = cc
! CFLAGS = -O
# CFLAGS = -O3
SHAR = shar
# SHAR = shar -T
--- 1,5 ----
! CC = gcc
! CFLAGS = -O3 -Wall
# CFLAGS = -O3
SHAR = shar
# SHAR = shar -T

デフォルト出力をutf8にする場合config.hファイルを修正
$ vi config.h


config.h 修正内容
$ diff -dc config.h.bak config.h

*** config.h.bak 2007-07-25 00:13:03.000000000 +0900
--- config.h 2008-07-16 20:58:10.000000000 +0900
***************
*** 59,68 ****
/******************************/
/* デフォルトの出力コード選択 */
/* Select DEFAULT_CODE */
! #define DEFAULT_CODE_JIS
/* #define DEFAULT_CODE_SJIS */
/* #define DEFAULT_CODE_EUC */
! /* #define DEFAULT_CODE_UTF8 */
/******************************/
#else
#define DEFAULT_CODE_SJIS
--- 59,68 ----
/******************************/
/* デフォルトの出力コード選択 */
/* Select DEFAULT_CODE */
! /* #define DEFAULT_CODE_JIS */
/* #define DEFAULT_CODE_SJIS */
/* #define DEFAULT_CODE_EUC */
! #define DEFAULT_CODE_UTF8
/******************************/
#else
#define DEFAULT_CODE_SJIS

make
$ make

インストールは、パスの通っているディレクトリにコピー
$ sudo cp -p nkf /usr/local/bin/

2008年6月21日土曜日

[OpenBSD] pkg_add パッケージの設定

ring serverを使うのが良いですね。
$ vi .bashrc
# PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`uname -m`/
# PKG_PATH=http://ring.k-opti.com/archives/OpenBSD/`uname -r`/packages/`uname -m`/
PKG_PATH=http://www.dnsbalance.ring.gr.jp/archives/OpenBSD/`uname -r`/packages/`uname -m`/
export PKG_PATH