« Archives in October, 2009

jQuery – Avoid duplicate element’s IDs

If the input element has an ID and it is duplicate with another element, it’s likely cause an error. In this case, Firefox 3.5 and IE8 on Windows Vista has no problem while same browsers in Windows XP does not work.

Problem

That works in Vista and Mac OSX but not XP. It’s rather weird it’s a problem that depends on the OS and not the browser. Anyway, it’s a mistake and duplicate IDs should always be avoid.

Solution

jQuery form item highlighting

$(document).ready(function(){
  $("input,textarea,select")
    .focus(function() {$(this).addClass("form-item-focus");})
    .blur(function() {$(this).removeClass("form-item-focus");});
});

MOD files import into iMovies for Panasonic SDR-H18

This little trick is for iMovies to import MOD files automatically. Create this folder and copy MOD files to it: D:\MP_ROOT\101PNV01

Centos and BOINC/World Community Grid

There are RPM packages for Fedora but doesn’t seem one for CentOS. There is no updated instructions on running BOINC client via command line.

1) Download and run boinc_6.2.15_i686-pc-linux-gnu.sh
2) Run "./boinccmd –project_attach www.worldcommunitygrid.org " 
(Log into WCG, the key can be found on menu My Profile, near the bottom)
4) Run "./run_client --daemon" to begin the client
5) Check "tail stdoutdae.txt -f" for output

You might need to install these for dependencies:

yum install libXcomposite
yum install libXdamage

Optimizing TCP stack under CentOS/RHEL Linux

This is from one of our pretty old servers

more /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) for
# more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# From: http://forum.ev1servers.net/showthread.php?s=&threadid=19647
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 30
# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1800
# Turn on the tcp_window_scaling
net.ipv4.tcp_window_scaling = 0
# Turn off the tcp_sack
net.ipv4.tcp_sack = 0
# Turn off the tcp_timestamps
net.ipv4.tcp_timestamps = 0
# Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1
# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Don't Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 1
# Make more local ports available
# net.ipv4.ip_local_port_range = 1024 65000
# Increase maximum amount of memory allocated to shm
kernel.shmmax = 1073741824
# Improve file system performance
vm.bdflush = 100 1200 128 512 15 5000 500 1884 2
# This will increase the amount of memory available for socket input/output queues
# net.ipv4.tcp_rmem = 4096 25165824 25165824
# net.core.rmem_max = 25165824
# net.core.rmem_default = 25165824
# net.ipv4.tcp_wmem = 4096 65536 25165824
# net.core.wmem_max = 25165824
# net.core.wmem_default = 65536
# net.core.optmem_max = 25165824