Quick fix for Pathauto module running on PostgreSQL

Submitted by jianingy on Wed, 07/01/2009 - 10:09

Since there is no 'CONCAT' function in PostgreSQL, Pathauto module will report a function undefined error when it is trying to read from/write to database. There is an easy and quick fix for this issue -- just create a CONCAT function using '||' operator.

CREATE FUNCTION CONCAT (text, text) RETURNS text AS 'SELECT $1 || $2' LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT;

Debug Library using LD_DEBUG environment variable

Submitted by jianingy on Mon, 06/22/2009 - 09:54

LD_DEBUG is an environment variable for debugging library problem. The following example shows how to use it.

[jianingy(0)@nby ~/devel/trie]$ LD_DEBUG=help src/trietool 
Valid options for the LD_DEBUG environment variable are:

  libs        display library search paths
  reloc       display relocation processing
  files       display progress for input file
  symbols     display symbol table processing
  bindings    display information about symbol binding
  versions    display version dependencies
  all         all previous options combined

rxvt-unicode tabbed extension patch

Submitted by jianingy on Mon, 04/20/2009 - 10:33

This patch makes tabbed extension support directly tab access by pressing ctrl + n. Also, I applied some color changs which makes the tab bar more comfortable as i thought.

Download Here

diff -rupN orig/tabbed new/tabbed
--- orig/tabbed	2009-04-20 10:23:35.000000000 +0800
+++ new/tabbed	2009-04-20 10:29:38.000000000 +0800
@@ -10,8 +10,8 @@ sub refresh {
 
    my @ofs;
 
-   substr $text, 0, 7, "[NEW] |";
-   @$rend[0 .. 5] = ($self->{rs_tab}) x 6;
+   substr $text, 0, 7, "  NEW  ";
+   @$rend[0 .. 5] = ($self->{rs_tabbar}) x 6;
    push @ofs, [0, 6, sub { $_[0]->new_tab }];
 
    my $ofs = 7;
@@ -26,7 +26,7 @@ sub refresh {
       my $txt = "$act$idx$act";
       my $len = length $txt;
 
-      substr $text, $ofs, $len + 1, "$txt|";
+      substr $text, $ofs, $len + 1, "$txt ";
       @$rend[$ofs .. $ofs + $len - 1] = ($self->{rs_tab}) x $len
          if $tab == $self->{cur};
 
@@ -224,10 +224,10 @@ sub on_init {
    my $tabfg = $self->x_resource ("tab-fg");
    my $tabbg = $self->x_resource ("tab-bg");
 
-   defined $fg    or $fg    = 3;
-   defined $bg    or $bg    = 0;
-   defined $tabfg or $tabfg = 0;
-   defined $tabbg or $tabbg = 1;
+   defined $fg    or $fg    = 0;
+   defined $bg    or $bg    = 7;
+   defined $tabfg or $tabfg = 12;
+   defined $tabbg or $tabbg = 0;
 
    $self->{rs_tabbar} = urxvt::SET_COLOR (urxvt::DEFAULT_RSTYLE, $fg    + 2, $bg    + 2);
    $self->{rs_tab}    = urxvt::SET_COLOR (urxvt::DEFAULT_RSTYLE, $tabfg + 2, $tabbg + 2);
@@ -333,7 +333,12 @@ sub tab_key_press {
          $self->make_current ($self->{tabs}[$idx2]);
 
          return 1;
-      }
+      } elsif ($keysym > 48 && $keysym < 58) {
+         my ($idx) = $keysym - 49;
+         $self->make_current ($self->{tabs}[$idx]) if $self->{tabs}[$idx] != $tab and $idx < @{ $self->{tabs}};
+
+         return 1;
+	  }
    }
 
    ()

An Implementation of J.H Conway's Life Game

Submitted by jianingy on Thu, 04/16/2009 - 22:33

大学时数据结构课的作业。用MASM32实现了J.H.Conway生命游戏. 翻箱倒柜找出这么个东西,还勾起了不少大学时的回忆,哎~~

Source Code

Download:

Screenshot:

Manually Load Shared Library

Submitted by jianingy on Thu, 03/19/2009 - 13:11

Once, set environment variable LD_PRELOAD to a shared library, it can be loaded no matter whether your program will load or not load it.

e.g.

[jianingy(0)@nby ~]$ ldd /opt/bamboo/bin/bamboo 
	linux-gate.so.1 =>  (0x0082a000)
	libdl.so.2 => /lib/libdl.so.2 (0x009c7000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x051fc000)
	libm.so.6 => /lib/libm.so.6 (0x0099c000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x05110000)
	libc.so.6 => /lib/libc.so.6 (0x00110000)
	/lib/ld-linux.so.2 (0x00801000)

Remote sudo without echoing password

Submitted by jianingy on Mon, 03/09/2009 - 10:20

Whenever using scripts or manually execute 'ssh somebox sudo somecmd', you'll find that your password of sudo will be displayed on the screen not hidden. I still remember the sense that I was running by maintenance script and "alert" everyone not look at my screen. Now, this stupid thing has been fixed. After some searching, finally I found that you can use -t option of ssh to force a pseudo-tty allocation, which means that the password of remote sudo won't be echoed ever.

Check out this simple expect script

GCC Structure Alignment

Submitted by jianingy on Sun, 01/04/2009 - 13:19

The alignment manner on 32bits and 64bits system are usually different. On a 32bits box, a struct is aligned by 4 bytes, while on a 64bits box it is 8 bytes.

Therefore, when you need to run you program both on 32bits and 64 bits, it's better to set up the alignment to four manually by using "#pragma pack"

For example,

#pragma pack(push, 4)
    typedef struct {
        int size;
        int last;
    } TailHeader
#pragma pack(pop)

Filco茶轴87键小键盘入手

Submitted by jianingy on Fri, 01/02/2009 - 14:13

采用德国Cherry的茶色开关,日本封装。做工精细,手感相当好,击键时有哒哒的响声。很有十几年前老电脑的感觉。此款编号为: FKBN87M-EB.

正面:
Filco Keyboard (Keys)

Shut The Flashing Wifi Led

Submitted by jianingy on Sat, 12/27/2008 - 00:24

Under many linux distributions, the led for wifi of your notebook will keep flashing while there are transmitting operations.It drives us crazy

To solve this problem, you need just a small script.

#!/bin/sh

if [ "`id -u`" != "`id -u root`" ]; then
    echo "`whoami`: you need root priviledge to run this application. Invkoing sudo ..." 
    exec sudo bash -c "$0 $@"
fi

for trigger in /sys/class/leds/iwl-*X/trigger; do
    echo none > $trigger
    cat $trigger
done

Fedora Core 10 Font Packages with LCD Filter and BCI patch applied

Submitted by jianingy on Fri, 12/26/2008 - 23:21

I found those patches at AUR of archlinux. And applied them to RPMs of FC10.
Including:

Recent comments

Syndicate content