Search This Blog

Thursday, December 06, 2007

slime-close-parens-at-point

the default key binding of the function slime-close-parens-at-point is C-c C-q
but it's obsolete from slime-2.0_p20070816-r1,the comments in the source file are as following:

;; SLIME-CLOSE-PARENS-AT-POINT is obsolete:

;; It doesn't work correctly on the REPL, because there
;; BEGINNING-OF-DEFUN-FUNCTION and END-OF-DEFUN-FUNCTION is bound to
;; SLIME-REPL-MODE-BEGINNING-OF-DEFUN (and
;; SLIME-REPL-MODE-END-OF-DEFUN respectively) which compromises the
;; way how they're expect to work (i.e. END-OF-DEFUN does not signal
;; an UNBOUND-PARENTHESES error.)

;; Use SLIME-CLOSE-ALL-PARENS-IN-SEXP instead.


well,bind slime-close-all-parens-in-sexp to C-c C-q,and I can pretend that nothing happened in my world.

Tuesday, October 02, 2007

to thinkpaders,about tp-fancontrol

from a certain version of thinkpad_acpi,fan_control is disabled by default,as Documentation/thinkpad-acpi.txt said:

NOTE NOTE NOTE: fan control operations are disabled by default for
safety reasons. To enable them, the module parameter "fan_control=1"
must be given to thinkpad-acpi.

so the tp-fancontrol daemon won't work any more if the thinkpad_acpi module isn't told that it should enable the fan_control.

let's do that:

#vim /etc/modules.d/thinkpad_acpi

then add the following line:
options thinkpad_acpi fan_control=1

:wq

#update-modules

now tp-fancontrol should work again.

Thursday, September 13, 2007

Yodaesque

what?yes!yodaesque!
Practical Common Lisp,Page 285,it reads:
"Compared to the clauses I’ve described so far, with their prepositions and subclauses, do is a model of Yodaesque simplicity."

and...the footnote:
“No! Try not. Do . . . or do not. There is no try.” —Yoda, The Empire Strikes Back

Orz...

Tuesday, July 24, 2007

emacs-unicode-2 compile error

several days ago,an error was reported (SYNTAX_ENTRY_FOLLOW_PARENT undefined) when emerge emacs-cvs,I tried to make a patch to get it compiled,but failed.however,the problem is resolved taday after cvs update.

Tuesday, July 17, 2007

app-emacs/cedet-1.0_pre4-r1

maybe there is a bug in cedet-1.0_pre4-r1,everytime I open a .c file,emacs will complain that "Autoloading failed to define function semantic-default-c-setup",and it occurs even when I create a semanticdb,so I try to downgrade cedet to 1.0_pre3-r2,no problems any more.

Sunday, June 17, 2007

a gtk+'s bug fixed

the bug wat not fixed until gtk+-2.10.13
with previous gtk+ versions,a save dialog will stretch out and draw back very frequently,as a result,the cpu load will be 100%
now all gtk+ applications get right.

Friday, June 15, 2007

a bug of x60

if the modem is disabled in bios,then the sound card will be disabled,too.
after I disabled the modem,I must run "alsaconf" to drive the sound card every rebooting.

Tuesday, June 12, 2007

paging in linux

ever since 2.6.11,there is a new level named pud(page upper directory) plusing to pgd,pmd,pte,and so something chaged.
what confused me is that,as ULK said:
"For 32-bit architectures with no Physical Address Extension, two paging levels are sufficient. Linux essentially eliminates the Page Upper
Directory and the Page Middle Directory fields by saying that they contain zero bits. However, the positions of the Page Upper Directory
and the Page Middle Directory in the sequence of pointers are kept so that the same code can work on 32-bit and 64-bit architectures. The
kernel keeps a position for the Page Upper Directory and the Page Middle Directory by setting the number of entries in them to 1 and
mapping these two entries into the proper entry of the Page Global Directory."
so I wonder how does the kernel eliminate pud and pmd as well as keep the position of them to make the code work on 32-bit and 64-bit arch?

at first,I thought pgd still leads the paging unit to pud,then pud to pmd,blablabla...
but it is completely wrong,coz the paging unit in x86 knows only 2-level paging when with pae disabled!
so in the hardware paging unit(x86)'s perspective,there are only pgd,pte,nothing else.

but how to understand "the same code can work on 32-bit and 64-bit architechtures"?
well,I think it means the kernel folds pud and pmd away,so any functions or macros operating on pud or pmd will be lead to pgd,thus the code need no change between 32-bit and 64-bit.

anyone any ideas?plz show me:)

Monday, May 21, 2007

example of Bresenham's line algorithm

it depends on gtk+-2.0,using function gdk_draw_point to draw points.I wrote this little program because the stupid Chinese education:they are still writing c programs compiled by turbo c and with a "graphic.h" to draw graphics.



#include <gdk/gdk.h>//in fact,I do not know whether I need this

#include <gtk/gtk.h>



void linebres(int xa, int ya, int xb, int yb,GtkWidget *widget,GdkDrawable *drawable)

{

int dx = abs(xa-xb), dy = abs(ya-yb);

int p;

int twody, twodx;

int x,y,xend,yend;

float k=dy/dx;

int temp;

if(k > 1|| k < -1){

temp = xa;

xa = ya;

ya = temp;

temp = xb;

xb = yb;

yb = temp;

}



p = 2 * dy - dx;

twody = 2 * dy;

twodx = 2 * dx;



if(xa - xb > 0){

x = xb;

y = yb;

xend=xa;

}

else{

x = xa;

y = ya;

xend = xb;

}



gdk_draw_point (drawable,widget->style->black_gc,x,y);



while(x < xend){

x++;

if(p < 0)

p += twody;

else{

y++;

p += (twody-twodx);

}

gdk_draw_point (drawable,widget->style->black_gc,x,y);

}

}





static void on_destroy (GtkWidget * widget, gpointer data)

{

gtk_main_quit ();

}



gint expose_callback(GtkWidget *widget, GdkEventAny *event, gpointer data)

{

GdkDrawable *drawable;

int i;

drawable=widget->window;

linebres (10,5,180,60,widget,drawable);

return 0;

}



int main(int argc, char **argv)

{

gtk_init ( &argc, &argv);



GdkWindowAttr attr;



GtkWidget *window;



GtkWidget *widget = gtk_drawing_area_new ();

gtk_drawing_area_size (GTK_DRAWING_AREA (widget),200,200);



window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_container_add (GTK_CONTAINER (window),widget);



g_signal_connect (G_OBJECT (window), "destroy",G_CALLBACK (on_destroy), NULL);



g_signal_connect (G_OBJECT(widget), "expose_event",GTK_SIGNAL_FUNC(expose_callback), NULL);



gtk_widget_show_all (window);



gtk_main ();



return 0;



}



Wednesday, May 16, 2007

trackpoint in gentoo

trackpoint will work fine in gentoo by the following steps:
1.enable "press to select"

echo -n 1 > /sys/devices/platform/i8042/serio1/press_to_select

2.to enable scrolling,put the following lines into xorg.conf's trackpoint section(it's an "InputDevice" section)

Option "Emulate3Buttons" "on"
Option "Emulate3TimeOut" "50"
Option "EmulateWheel" "on"
Option "EmulateWheelTimeOut" "200"
Option "EmulateWheelButton" "2"
Option "YAxisMapping" "4 5"
Option "XAxisMapping" "6 7"
Option "ZAxisMapping" "4 5"

now restart X,and enjoy the trackpoint.

Thursday, May 10, 2007

installed gentoo 2007.0 amd64

the new livecd of 2007.0(amd64) now bootable,so I installed a 64bit gentoo.
64bit firefox can use 32bit flash plugin now:

#emerge netscape-flash
#emerge nspluginwrapper

everything should be all right now,if not,execute the following command:

$nspluginwrapper -i /usr/lib32/nsbrowser/plugins/libflashplayer.so

Wednesday, May 09, 2007

usb cd writer howto

1.build a kernel supporting usb cd



Device Drivers --->

SCSI device support --->

[M] SCSI CDROM support

[ ] Enable vendor-specific extensions (for SCSI CDROM)

[M] SCSI generic support



2.install packages that do the cd burning



#emerge cdrtools



3.do the burning with cdrecord

say,I want to burn livecd-amd64-installer-2007.0.iso



#cdrecord -speed=4 dev=/dev/sr0 -v livecd-amd64-installer-2007.0.iso



and wait for it until finish burning

Monday, May 07, 2007

use wpa_supplicant

I choose WPA-PSK for my wireless router,so the corresponding configure is like following:

$wpa_passphrase ssid passphrase

where passphrase is the router's PSK pass,and it outputs a string which should be assigned to "psk" in wpa_supplicant.conf,like this:

network={
ssid="ssid"
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
psk=psk
priority=2
}

Saturday, May 05, 2007

browse chinese bbs with urxvt in utf8

for most chinese bbs output gbk encoding,so the urxvt should be told that it is going to treat the stream as gbk,more than that,it should also be told that the input mothod works in a utf8 enviroment,so I start a urxvt to browse bbs like this:

LC_ALL=zh_CN.GBK urxvt -imlocale 'zh_CN.utf8' -fn '10x20,xft:AR PL
New Sung:antialias=false' -e screen

it looks perfect

ENTRY in *.S files

the gdt of a cpu is described like this:

ENTRY(cpu_gdt_table)
.quad 0x0000000000000000
...

while ENTRY is a macro defined in include/linux/linkage.h ike this:

#define ENTRY(name) \
.globl name; \
ALIGN; \
name:

so it means a globally visible label leading a memory of data(gdt)?hmmm

Tuesday, April 24, 2007

at last,ipw3945 gets no hot any more on my x60

It really sucks when my x60's right palm-rest gets too hot in summer because of ipw3945.The record has got up to 54 degree.

At last,I find a way to get it cooler:

#iwpriv eth1 set_power 7

and it will never gets too hot.

Now in my box,the PCI temperature(that's exactly ipw3945) is 44 degree.

Wonderful!





Sunday, April 08, 2007

a problem of openssl 0.9.8e

if your openssl version is 0.9.8e and you are using openssh to connect to an ssh1 host,you will get an error like this:


Disconnecting: Corrupted check bytes on input

to solve the problem,use openssl 0.9.8d or other no-bug version.

Wednesday, April 04, 2007

practical common lisp



I am reading this book these days.

Friday, March 16, 2007

xmms2

As everyone knows,xmms is a great audio player,except it depends on gtk+,so I turned to bmp which depends on gtk+-2.0.But letting bmp to play flac is diffculty,so I choosed bmpx.
At first,bmpx satisfied me,until version 3.
1.compiling bmpx take 99% of my memory!you know,I have 1GB ram,it sucks!
2.shout cast or something is cool,BUT,I did,do,and will never need that!But everytime bmpx tries to access the stupid network address that I cat not connect to from my network in order to get information about shout cast which makes bmpx's starting up take at least 5 minutes!What's more,bmpx does not provide an option to close the sucking function until a recent version.
So,now I give bmpx up and get xmms2,a C/S audio player.I can choose different clients as I wish to communicate with the xmms2 server,it's cool.

Thursday, March 15, 2007

hdaps now works

At last I found an hdaps protect patch for kernel 2.6.20,patch it:


#patch -p1 < /path/to/hdaps_protect-2.6.20.patch

remember to compile hdaps as a module
then install the tp_smapi with hdaps support:

#USE="hdaps" emerge tp_smapi
#modprobe tp_smapi

and install hdapsd:

#emerge hdapsd
#rc-update add hdapsd default battery

after reboot,try it with updatedb,when I shake my laptop,the hard drive stops working,and when I stop,it remains working,cool!
ps:
first,when a boot the laptop with the new patched kernel,something goes wrong:
my ethernet card can not be brought up,due to EEPROM checksum error,
then I insert a cable,remove the e1000 module and probe it again,it works.Then I use a script from lenovo,run it:

#./vidalia-eeprom-mod-script eth0

now problem resolved
:P

Saturday, March 10, 2007

hibernate-ram,special keys,etc,on x60

At last,with a suspend2-sources-2.6.20,I have make the hibernate-ram work,it's great!I use acpid to grab fn+f4 or lid off to get hibernate-ram activate automatically:


x60 shelling # cat /etc/acpi/events/tp_hotkey
event=ibm/hotkey.*
action=/etc/acpi/actions/tp_hotkey.sh "%e"



x60 shelling # cat /etc/acpi/actions/tp_hotkey.sh
#!/bin/bash

#receive our hotkey event
event=$1

#ibm thinkpad x60 hotkeys
nop="ibm/hotkey HKEY 00000080 00000000"
fnf1="ibm/hotkey HKEY 00000080 00001001"
fnf2="ibm/hotkey HKEY 00000080 00001002"
fnf3="ibm/hotkey HKEY 00000080 00001003"
fnf4="ibm/hotkey HKEY 00000080 00001004"
fnf5="ibm/hotkey HKEY 00000080 00001005"
fnf6="ibm/hotkey HKEY 00000080 00001006"
fnf7="ibm/hotkey HKEY 00000080 00001007"
fnf8="ibm/hotkey HKEY 00000080 00001008"
fnf9="ibm/hotkey HKEY 00000080 00001009"
fnf10="ibm/hotkey HKEY 00000080 0000100a"
fnf11="ibm/hotkey HKEY 00000080 0000100b"
fnf12="ibm/hotkey HKEY 00000080 0000100c"
fnbksps="ibm/hotkey HKEY 00000080 0000100d"
#fnhome="ibm/hotkey HKEY 00000080 00001010"
#fnend="ibm/hotkey HKEY 00000080 00005010"
wireless_switch="ibm/hotkey HKEY 00000080 00007000"

case $event in
$nop)
;;
$fnf1)
;;
$fnf2)
/usr/bin/xscreensaver-command -lock
;;
$fnf3)
;;
$fnf4)
sudo /usr/sbin/hibernate-ram
;;
$fnf5)
;;
$fnf6)
;;
$fnf7)
;;
$fnf8)
;;
$fnf9)
;;
$fnf10)
;;
$fnf11)
;;
$fnf12)
;;
#$fnhome)
# echo 'up' > /proc/acpi/ibm/brightness
# ;;
#$fnend)
# echo 'down' > /proc/acpi/ibm/brightness
# ;;
$wireless_switch)
if [ -f /var/run/ipw3945d/ipw3945d.pid ]
then
/etc/init.d/ipw3945d stop
else
/etc/init.d/ipw3945d start
fi
;;
esac



x60 shelling # cat /etc/acpi/events/lm_lid
event=button[ /]lid
action=/etc/acpi/actions/lm_lid.sh %e



x60 shelling # cat /etc/acpi/actions/lm_lid.sh
#!/bin/bash

test -f /usr/sbin/hibernate-ram || exit 0

# lid button pressed/released event handler

#
#/usr/sbin/laptop_mode auto
/usr/sbin/hibernate-ram




The volume controlling keys are actually valid without any configuration,and using a tpb with xosd support,we can see it working;

And the BACK and FORWARD key need xmodmap:

x60 shelling # cat .Xmodmap
! Page left
keycode 234 = F19
! Page right
keycode 233 = F20

Now make a little mod to firefox:

#cd /usr/lib/mozilla-firefox/chrome
#unzip browser.jar

and add the following two lines (the lines with "TP") to content/browser/browser.xul:

<key id="goBackKb" keycode="VK_LEFT" command="Browser:Back" modifiers="alt"/>
<key id="goForwardKb" keycode="VK_RIGHT" command="Browser:Forward" modifiers="alt"/>
<key id="goBackTP" keycode="VK_F19" command="Browser:Back"/>
<key id="goForwardTP" keycode="VK_F20" command="Browser:Forward" />

restart firefox,now BACK makes firefox back and FORWARD makes firefox forward.

Friday, March 09, 2007

my new laptop:lenovo thinkpad x60

with core 2 duo T5500,512m ram,60g hd,it provides me an excellent experience.
however,without an internal cdrom,it's difficult to install an os.I still choose gentoo,but whose livecds can not be booted from a usb drive.so at last,I use a knoppix liveusb to boot the laptop,and installed gentoo 2006.1 for x86(for knoppix is 32bit,I have no choise but install a 32bit os).
anyhow,it's beautiful,and my ethernet card,wireless card,sound card are all driven,hdpas not configured yet.
now I am writing this blog via wireless network,it's great.

Monday, February 05, 2007

just a note,about vcard-based avatars in xmpp

It used to confuse me,but at last I understand.Well,everyone in the roster has a vcard,something recording his personal information.And to get someone's avatar,one of the methods is vcard-based.
Maybe someone's presence stanza is like this:


<presence from='juliet@capulet.com/balcony'>
<x xmlns='vcard-temp:x:update'>
<photo>sha1-hash-of-image</photo>
</x>
</presence>

on receiving it,we can check the sha1sums of all the cached avatars,if there is an avatar's sha1sum matches the "photo" element's content,then just use the avatar,otherwise,we need to retrieve the complete vcard infomation like this:

<iq from='romeo@montague.net/orchard'
to='juliet@capulet.com'
type='get'
id='vc2'>
<vCard xmlns='vcard-temp'/>
</iq>

then we wait for the response:

<iq from='juliet@capulet.com'
to='romeo@montague.net/orchard'
type='result'
id='vc2'>
<vCard xmlns='vcard-temp'>
<BDAY>1476-06-09</BDAY>
<ADR>
<CTRY>Italy</CTRY>
<LOCALITY>Verona</LOCALITY>
<HOME/>
</ADR>
<NICKNAME/>
<N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N>
<EMAIL>jcapulet@shakespeare.lit</EMAIL>
<PHOTO>
<TYPE>image/jpeg</TYPE>
<BINVAL>
Base64-encoded-avatar-file-here!
</BINVAL>
</PHOTO>
</vCard>
</iq>

Ok,decode the base64-encoded-avatar-file in the "BINVAL" and we can get the avatar.

Saturday, February 03, 2007

ebank of spdb

Shanghai Pudong Development Bank's new version of ebank can now be accessed under linux,using firefox,either version 1.5 or 2.0.
It's a milestone for Chinese banks,for there was never a bank escaped from evil MS,until spdb.
Personally,I am excited:I can throw terrible windows over completely,I can get it out of my hard disk.

Tuesday, January 09, 2007

use XML::Simple

suppose I have a .passwds.xml file like this:


<?xml version="1.0"?>
<users>
<user>
<uid>0</uid>
<name>root</name>
<passwd>123456</passwd>
<identity>root</identity>
</user>
<user>
<uid>1</uid>
<name>test</name>
<passwd>123456</passwd>
<identity>root</identity>
</user>
</users>


and I can use the following perl script to parse it and determin whether a user can login


#!/usr/bin/perl
use XML::Simple;

$passwds = ".passwds.xml";

my $xmlobj = new XML::Simple(KeyAttr=>[]);

my $data = $xmlobj->XMLin("$passwds");

my $loggedin = -1;

my $username = "test";

my $password = "123456";

foreach (@{$data->{"user"}}){
if (($_->{"name"} ne $username)){
next;
}
$loggedin = 0;
if ($_->{"passwd"} eq $password){
$loggedin = 1;
}
last;
}
if ($loggedin == -1){
print "username incorrect\n";
die;
}
if ($loggedin == 0){
print "password incorrect";
die;
}
print "successfully login\n";

Thursday, January 04, 2007

strlen&sizeof

strlen is a function calculating the length of a string,i.e.,'\0' excluded,
while sizeof is an operator calculating a variable's size when compiling,i.e.,if affect on a string,'\0' will be included.
just as is shown in this little programme:


#include <stdio.h>
#include <string.h>

#define s "hello"
int main ()
{

printf ("strlen:%d\n",strlen (s));
printf ("sizeof:%d\n",sizeof (s));
return 0;/*thank u,anonymous,haha*/
}

after executed,it outputs:
strlen:5
sizeof:6