Unicode keyword translation

Do you see garbled text, unicode keywords in your referral web stats reports like below?

เรียน ที่ไหน

Use the below url for the conversion:

Unicode keyword translation

Here is the simple php source code that uses google translate for translation to English:

<?php header("Content-Type: text/html; charset=iso-8859-1"); ?>

<html>
<head>
  <title>Unicode keyword translation</title>
</head>
<body>
  <br />
  Copy/paste unicode keyword:
  <br />
  <br />
  <form action="convert_keywords.php">
    <input size="100" name="input" value="<?= $_GET['input']; ?>" type="text">
    <input value="Go" type="submit">
  </form>
  <br />
  <br />

<?php
  $pieces
=explode("=", $_SERVER['QUERY_STRING']);
 
$query=$pieces[1];
 
$translate_url="http://translate.google.com/?hl=en#auto|en|" . $query;
  if(!empty(
$query)) {
?>


  <iframe src="<?= $translate_url; ?>" width="100%" height="100%">
  Iframe unsupported...
  </iframe>

<?php } ?>

</body>
</html>

Check and tune network speed

I've had to do this on a couple of servers to check on the network speeds and sysctl tuning.

On the receiving end (192.168.10.1) bring up netcat listening to a port:

while true; do nc -l 8001 >/dev/null ; done

Use the below one liner to send over some data via netcat from 192.168.10.2 which prints out the transfer speed.

( dd if=/dev/zero bs=64K count=1000 | nc 192.168.10.2 8001 ) 2>&1 | awk '/MB/{print $8*8 " " tolower($9)}'

Increase the default maximum TCP buffer size and rerun the above test for proper tuning. Make sure to restart netstat listening socket upon sysctl changes.

The following are recommended:

##
# max TCP buffer size: 16MB (16 * 1024 * 1024).
# Could increase to 32MB for GigE.
#
# Increasing the TCP send buffers will increase the performance
# if you have large files to send.
#
net.core.wmem_max = 16777216

# If you have a lot of large file uploads,
# increasing the receive buffers will help.
#
net.core.rmem_max = 16777216

# increase Linux autotuning TCP buffer limits:
# min, default, and max number of bytes to use
# (only change the 3rd value, and make it 16 MB or more)
#
net.ipv4.tcp_rmem = 4096        87380   16777216
net.ipv4.tcp_wmem = 4096        65535   16777216

# Support for the above large TCP send and receive windows.
# Needs to be set to 1 if the Max TCP Window is over 65535 (64K).
#
net.ipv4.tcp_window_scaling = 1

# Increase backlog to avoid dropped packets and increase throughput.
# Check with `netstat -st | grep packets` and check for
# dropped and packet errors.
#
net.core.netdev_max_backlog = 5000

ssh keygen RSA versus DSA

While generating ssh keys, I usually use RSA type since it can be used to generate 2048 bits key, while DSA is restricted to exactly 1024 bits.

ssh-keygen -t rsa -b 2048

smartctl with 3ware RAID controller

The below information is extracted from the smartctl man page.

To look at ATA disks behind 3ware SCSI RAID controllers:

smartctl -a -d 3ware,N /dev/sda
smartctl -a -d 3ware,N /dev/twe0
smartctl -a -d 3ware,N /dev/twa0

Where N is the disk number.

Devices /dev/sda and /dev/twe0 is used with 3ware series 6000, 7000, and 8000 controllers that use the 3x-xxxx driver.

/dev/sda form is deprecated starting with the Linux 2.6 kernel.

/dev/twa0 is used with 3ware 9000 series controllers, which use the 3w-9xxx driver.

You can also check on the series with the below command:

lspci |grep 3ware

Running Ubuntu 11.04 (Natty) unity 3D on virtualbox 4.x

(via www.ubuntugeek.com)

Unity provides a complete, simple, touch-ready environment that integrations your applications and your workflow.Unity is designed for netbooks and related touch-based devices. It includes a new panel and application launcher that makes it fast and easy to access preferred applications, such as the browser, while removing screen elements that are rarely used in mobile and netbook computing.This tutorial will explain how to run unity under virtualbox.

Find files used for htauth

Below will list all of the files that are used for apache authentication in /var/www/html file path:

find /var/www/html -name .htaccess | xargs awk '{sub(/^[ \t]+/,"")};/File/{print $2}' | sort | uniq

Here is the breakdown:

find /var/www/html -name .htaccess

Find all files named ".htaccess" at path "/var/www/html"

xargs awk '{sub(/^[ \t]+/,"")};/File/{print $2}'

The search output gets piped via xargs to awk, deleting leading whitespace (spaces and tabs) from front of each line and output is of only the second field of lines containing the text "File".

sort | uniq

Awk output is further piped through sort and uniq which results in the files being used for apache authentication.

Converting Shared to Exclusive IP for Plesk Domain

First go into "Clients", select the corresponding client IP Addresses and assign the additional IP address.

Then go into "Domains", select the domain that should be converted to exclusive IP and modify the "Web Host Settings" and assign it the new IP.

Tuning and Optimizing RHEL for Oracle 9i and 10g Databases

(via www.puschitz.com)

This article is a step by step guide for tuning and optimizing Red Hat Enterprise Linux on x86 and x86-64 platforms running Oracle 9i (32bit/64bit) and Oracle 10g (32bit/64bit) standalone and RAC databases. This guide covers Red Hat Enterprise Linux Advanced Server 3 and 4 and the older version 2.1. For instructions on installing Oracle 9i and 10g databases, see Oracle on Linux. Other Linux articles can be found at www.puschitz.com...

Java's Runtime.exec and External Applications

(via www.ensta.fr)

Java was developed with an eye toward platform independence, freeing the software developer from the unpleasant and tedious task of cross-platform porting and testing of software. All too often, however, developers are not able to write completely new applications, but have to interface to existing legacy software and operating systems. This poses a problem as Java cannot make use of many utilities and system-dependent features that these programs have relied upon in the past...

VIM with Ruby support on CentOS-5.5

While trying to get command-t VIM plugin installed I noticed that the default vim-7.0.x installed from CentOS Base repository does not come compiled with ruby support and needed to be upgraded to version 7.2.x:

$ vim --version|grep ruby
+python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent

Notice "-ruby" which states that it is without ruby support.

Once the rpmbuild environment is setup, install the source rpm:

# su - rpmbuild
$ cd ~/rpm/SRPMS/
$ wget http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/vim-7.2.411-1.6.el6.src.rpm
$ rpm -Uvh --nomd5 ~/rpm/SRPMS/vim-7.2.411-1.6.el6.src.rpm

Edit the vim.spec file, line 496 and remove perl-devel from the requirement list.

BuildRequires: python-devel ncurses-devel gettext perl-devel

Then build rpm binary:

$ rpmbuild -bb ~/rpm/SPEC/vim.spec

Install the rpms via:

# rpm -Uvh ~/rpm/RPMS/x86_64/vim-{m,c,e}*

Syndicate content
Comment