Wednesday, September 19, 2007
select only 2-level domains.
select url from d_directories_backlinks where directory_id in (select entry_id from d_directories where lang='ja') and length(split_part(replace(get_host(url),'www.',''),'.',3))=0;
Thursday, September 6, 2007
network monitoring tools
http://nethogs.sourceforge.net/
Just found these great tools. the nethogs allows to measure the b/w by process id that is really helpful.
Just found these great tools. the nethogs allows to measure the b/w by process id that is really helpful.
Sunday, July 8, 2007
Tuesday, May 29, 2007
make fonts to be smooth in kubuntu linux
emacs /home/user/.fonts.conf
<?xml version="1.0″ ?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="autohint" mode="assign">
<bool>true</bool>
</edit>
</match>
</fontconfig>
<?xml version="1.0″ ?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="autohint" mode="assign">
<bool>true</bool>
</edit>
</match>
</fontconfig>
Wednesday, May 16, 2007
View user defined function in postgresql
Once you have written your function you may view its definition in pg_proc. EG
select * from pg_proc where proname='myFunction';
Friday, March 23, 2007
restore mysql database table from Microsoft file
load data infile '/var/www/_system_/htdocs/sites.csv' into table sites fields terminated by ';' ENCLOSED by '"' LINES TERMINATED BY '\r\n' STARTING BY '';
Thursday, March 22, 2007
pg_autovacuum usage
this is how i use autovacuum.
pg_autovacuum -v 3 -V 0.001 -a 2 -A 0.01 -U user password -d 3 -s 100
usage: pg_autovacuum
[-D] Daemonize (Detach from tty and run in the background)
[-d] debug (debug level=0,1,2,3; default=0)
[-s] sleep base value (default=300)
[-S] sleep scaling factor (default=2.000000)
[-v] vacuum base threshold (default=1000)
[-V] vacuum scaling factor (default=2.000000)
[-a] analyze base threshold (default=500)
[-A] analyze scaling factor (default=1.000000)
[-L] logfile (default=none)
[-c] vacuum_cost_delay (default=none)
[-C] vacuum_cost_page_hit (default=none)
[-m] vacuum_cost_page_miss (default=none)
[-n] vacuum_cost_page_dirty (default=none)
[-l] vacuum_cost_limit (default=none)
[-U] username (libpq default)
[-P] password (libpq default)
[-H] host (libpq default)
[-p] port (libpq default)
pg_autovacuum -v 3 -V 0.001 -a 2 -A 0.01 -U user password -d 3 -s 100
usage: pg_autovacuum
[-D] Daemonize (Detach from tty and run in the background)
[-d] debug (debug level=0,1,2,3; default=0)
[-s] sleep base value (default=300)
[-S] sleep scaling factor (default=2.000000)
[-v] vacuum base threshold (default=1000)
[-V] vacuum scaling factor (default=2.000000)
[-a] analyze base threshold (default=500)
[-A] analyze scaling factor (default=1.000000)
[-L] logfile (default=none)
[-c] vacuum_cost_delay (default=none)
[-C] vacuum_cost_page_hit (default=none)
[-m] vacuum_cost_page_miss (default=none)
[-n] vacuum_cost_page_dirty (default=none)
[-l] vacuum_cost_limit (default=none)
[-U] username (libpq default)
[-P] password (libpq default)
[-H] host (libpq default)
[-p] port (libpq default)
Saturday, March 17, 2007
http(s) over ssh tunnelling
if machine A stands in DMZ(before the firewall) and B is part of the corporate network (behind the firewall),
on the machine A :
# ssh -gNL 33333:B:443 root@B
for example:
# ssh -gNL 33333:192.168.1.119:443 root@192.168.1.119
-g - Allows remote hosts to connect to local forwarded ports.
this will cause https://A:33333/ to work just like https://B:33333/ but from outside the network.
on the machine A :
# ssh -gNL 33333:B:443 root@B
for example:
# ssh -gNL 33333:192.168.1.119:443 root@192.168.1.119
-g - Allows remote hosts to connect to local forwarded ports.
this will cause https://A:33333/ to work just like https://B:33333/ but from outside the network.
Monday, February 12, 2007
remove accents from strings using postgresql
function remove_accents(&$str)
{
return svq("select convert(TO_ASCII(convert('".pg_escape_string($str)."','UNICODE','LATIN 1'),'LATIN 1'),'LATIN 1','UNICODE');");
}
{
return svq("select convert(TO_ASCII(convert('".pg_escape_string($str)."','UNICODE','LATIN 1'),'LATIN 1'),'LATIN 1','UNICODE');");
}
Thursday, February 8, 2007
lighttpd canonical hosts (non-www to www redirect)
This will redirect http://domin.com to http://www.domain.com/ with 301 code
$HTTP["host"] == "domain.com" {
url.redirect = ( "^/(.*)" => "http://www.domain.com/$1" )
}
$HTTP["host"] == "domain.com" {
url.redirect = ( "^/(.*)" => "http://www.domain.com/$1" )
}
pure ftp with postgres
in the conf file words User, Password, Dir must be enclosed in "" coz its special words
starting:
pure-ftpd-postgresql -l pgsql:/etc/pure-ftpd/db/postgresql.conf -A &
starting:
pure-ftpd-postgresql -l pgsql:/etc/pure-ftpd/db/postgresql.conf -A &
Friday, February 2, 2007
install emacs on debian
aptitude install emacs-common
aptitude install emacs21
search for module to emable php-mode:
apt-cache search emacs | grep php
php-elisp - Emacs support for php files
apt-get install php-elisp
aptitude install emacs21
search for module to emable php-mode:
apt-cache search emacs | grep php
php-elisp - Emacs support for php files
apt-get install php-elisp
W: There are no public key available for the following key IDs
If you just ran apt-get update and you got:
There are no public key available for the following key IDs:
A70DAF536070D3A1
then type:
sudo gpg --recv-key --keyserver wwwkeys.eu.pgp.net A70DAF536070D3A1
sudo gpg --export A70DAF536070D3A1 | apt-key add -
and all will be well.
There are no public key available for the following key IDs:
A70DAF536070D3A1
then type:
sudo gpg --recv-key --keyserver wwwkeys.eu.pgp.net A70DAF536070D3A1
sudo gpg --export A70DAF536070D3A1 | apt-key add -
and all will be well.
Wednesday, January 31, 2007
simple php process monitor
require_once("declare.php");
define("RUNFILEDIR",PREFIX."/runfiles");
function setrunfile()
{
$fp = fopen(RUNFILEDIR."/".getmypid(),"w");
fwrite($fp,time());
fclose($fp);
}
function delrunfile($PID=0)
{
if(!$PID) $PID = getmypid();
unlink(RUNFILEDIR."/$PID");
}
function kill($PID)
{
delrunfile($PID);
exec("kill -KILL $PID");
}
function monitor($maxruntime=999999)
{
foreach(getfiles(RUNFILEDIR) as $f)
if($ts=file_get_contents($f))
{
$etime = time()-$ts;
$PID = preg_replace("#.*\/#","",$f);
info("$PID - $etime");
if($etime>$maxruntime)
kill($PID);
}
}
monitor();
Sunday, January 28, 2007
Temporary failure in name resolution
php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
Error: The system could not resolve domain name to ip address.
Solution:
get nameserver ip addreses from the internet provider
open /etc/resolv.conf and add:
nameserver first ip
nameserver second ip
Error: The system could not resolve domain name to ip address.
Solution:
get nameserver ip addreses from the internet provider
open /etc/resolv.conf and add:
nameserver first ip
nameserver second ip
Subscribe to:
Posts (Atom)