Monday, December 16, 2013
handle close event of browser in flash
Tuning the network
/etc/sysctl.conf file, or a new config file such as /etc/sysctl.d/99-tuning.conf and run sysctl -p to have the kernel pick them up. We use a syctl-cookbook to do the hard work.net.ipv4.ip_local_port_range='1024 65000'
net.ipv4.tcp_tw_reuse='1'
net.ipv4.tcp_fin_timeout='15'
net.core.netdev_max_backlog='4096'
net.core.rmem_max='16777216'
net.core.somaxconn='4096'
net.core.wmem_max='16777216'
net.ipv4.tcp_max_syn_backlog='20480'
net.ipv4.tcp_max_tw_buckets='400000'
net.ipv4.tcp_no_metrics_save='1'
net.ipv4.tcp_rmem='4096 87380 16777216'
net.ipv4.tcp_syn_retries='2'
net.ipv4.tcp_synack_retries='2'
net.ipv4.tcp_wmem='4096 65536 16777216'
vm.min_free_kbytes='65536'
net.ipv4.ip_local_port_range
possible SYN flooding on port 80. Sending cookies” it might mean the system can’t find an available port for the pending connection. Increasing the capacity will help alleviate this symptom.net.ipv4.tcp_tw_reuse
net.ipv4.tcp_fin_timeout
How to check connection status
netstat -tan | awk '{print $6}' | sort | uniq -css -s
How to fix the "LANGUAGE = (unset)" perl errors on Debian
First try two commands:
If it does not work try:
If it does not work try:
THE PROBLEM: Perl gives LANGUAGE = unset errors.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file
INTERACTIVELY FIX (debian):
# dpkg-reconfigure locales
(Select your language and hit "OK")
PROGRAMTICALLY FIX (debian):
# sed -i "s/^# en_US/en_US/" /etc/locale.gen
# grep -v "^#" /etc/locale.gen
en_US ISO-8859-1
en_US.ISO-8859-15 ISO-8859-15
en_US.UTF-8 UTF-8
#localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
# /usr/sbin/locale-gen
Generating locales (this might take a while)...
en_US.ISO-8859-1... done
en_US.ISO-8859-15... done
en_US.UTF-8... done
Generation complete.
# update-locale LANG=en_US.UTF-8
===========================================================================
Answering myself:
I've managed to solve the problem by adding
LANGUAGE = en_US.UTF-8 LC_ALL = en_US.UTF-8 LANG = en_US.UTF-8 LC_TYPE=en_US.UTF-8
LC_CTYPE=en_US.UTF-8LC_ALL=en_US.UTF-8LANG=en_US.UTF-8
VC++ Error Link 2019: unresolved external symbol "__declspec(dllimport) public: static char* __edecl ..."
Sunday, December 15, 2013
Unix Nohup: Run a Command or Shell-Script Even after You Logout
This quick tip is for beginners. If you’ve been using nohup for a while, leave us a comment and tell us under what situations you use nohup.
http://linux.101hacks.com/unix/nohup-command/# nohup command-with-options &
Wednesday, May 30, 2007
Processing a BufferedImage
To convert a color image to grayscale, you can use ColorConvertOp as follows:
import java.awt.image.*;
import java.awt.color.*;
ColorConvertOp op = new ColorConvertOp(ColorSpace.getInstance(CS_GRAY), null);
BufferedImage grayImage = op.filter(sourceImage, null);
To invert the colors in an image (producing a photographic negative effect), you might use a RescaleOp as follows:
RescaleOp op = new RescaleOp(-1.0f, 255f, null);
BufferedImage negative = op.filter(sourceImage, null);
To brighten an image, you can use a RescaleOp to linearly increase the intensity of each color value. More realistic brightening effects require a nonlinear transform, however. For example, you can use a LookupOp to handle brightening based on the square-root function, which boosts midrange colors more than colors that are dark or bright:
byte[] data = new byte[256];
for(int i = 0; i < 256; i++)
data[i] = (byte)(Math.sqrt((float)i/255.0) * 255);
ByteLookupTable table = new ByteLookupTable(0, data);
LookupOp op = new LookupOp(table, null);
BufferedImage brighterImage = op.filter(sourceImage, null);
You can blur an image using a ConvolveOp. When processing an image by convolution, a pixel value in the destination image is computed from the corresponding pixel value in the source image and the pixels that surround that pixel. A matrix of numbers known as the kernel is used to specify the contribution of each source pixel to the destination pixel. To perform a simple blurring operation, you might use a kernel like this to specify that the destination pixel is the average of the source pixel and the eight pixels that surround that source pixel:
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
Note that the sum of the values in this kernel is 1.0, which means that the destination image has the same brightness as the source image. To perform a simple blur, use code like this:
Kernel k = new Kernel(3, 3, new float[] { .1111f, .1111f, .1111f,
.1111f, .1111f, .1111f,
.1111f, .1111f, .1111f });
ConvolveOp op = new ConvolveOp(k);
BufferedImage blurry = op.filter(sourceImage, null);