How To Find Files by Content Under UNIX

grep 'string' *.txt
grep 'main(' *.c
grep '#include<example.h>' *.c
grep 'getChar*' *.c
grep -i 'ultra' *.conf
grep -iR 'ultra' *.conf
grep --color=auto -nH 'DIR' *
    Where

  • -i : Ignore case distinctions in both the PATTERN (match valid, VALID, ValID string) and the input files (math file.c FILE.c FILE.C filename).
  • -R : Read all files under each directory, recursively
  • -n : Prefix each line of output with the 1-based line number within its input file.
  • -H Print the file name for each match. This is the default when there is more than one file to search.
  • –color=auto Highlight autput.
Posted in linux | Tagged , , | Leave a comment

Play 1080P video on slow ubuntu machine with old core 2 duo proc

By default mplayer uses only one thread, so processor and system doesn’t uses on full power.
I have added option threads=2 to use second core.

mplayer -lavdopts threads=2 video-1080p.mkv
Posted in Uncategorized | Leave a comment

Test Server Speed

For testing server speed can be used ab utility

ab -r -n500 -c100 http://127.0.0.1/

Result Report for nginx

Completed 500 requests
Finished 500 requests
 
 
Server Software:        nginx/1.0.8
Server Hostname:        127.0.0.1
Server Port:            80
 
Document Path:          /
Document Length:        20 bytes
 
Concurrency Level:      100
Time taken for tests:   0.026 seconds
Complete requests:      500
Failed requests:        49
   (Connect: 0, Receive: 31, Length: 18, Exceptions: 0)
Write errors:           108
Total transferred:      116790 bytes
HTML transferred:       10200 bytes
Requests per second:    19528.96 [#/sec] (mean)
Time per request:       5.121 [ms] (mean)
Time per request:       0.051 [ms] (mean, across all concurrent requests)
Transfer rate:          4454.66 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    4   0.9      4       5
Processing:     0    1   0.9      0       4
Waiting:        0    0   0.8      0       3
Total:          3    5   0.6      5       6
WARNING: The median and mean for the processing time are not within a normal deviation
        These results are probably not that reliable.
 
Percentage of the requests served within a certain time (ms)
  50%      5
  66%      5
  75%      5
  80%      5
  90%      5
  95%      6
  98%      6
  99%      6
 100%      6 (longest request)

Result Report for Some JSF Application on tomcat

Completed 500 requests
Send request failed!
Finished 500 requests
 
 
Server Software:        Apache-Coyote/1.1
Server Hostname:        192.168.20.1
Server Port:            8080
 
Document Path:          /search/search.jsf
Document Length:        26246 bytes
 
Concurrency Level:      100
Time taken for tests:   5.907 seconds
Complete requests:      500
Failed requests:        188
   (Connect: 0, Receive: 46, Length: 142, Exceptions: 0)
Write errors:           363
Total transferred:      11880250 bytes
HTML transferred:       11802678 bytes
Requests per second:    84.64 [#/sec] (mean)
Time per request:       1181.430 [ms] (mean)
Time per request:       11.814 [ms] (mean, across all concurrent requests)
Transfer rate:          1964.03 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1  924 610.8    830    2591
Processing:     0  241 703.8      0    2590
Waiting:        0  210 630.3      0    2258
Total:         54 1165 669.2    982    2593
 
Percentage of the requests served within a certain time (ms)
  50%    982
  66%   1293
  75%   1584
  80%   1731
  90%   2264
  95%   2267
  98%   2592
  99%   2592
 100%   2593 (longest request)
Posted in Uncategorized | Leave a comment

Found path for command

Found path for command

which nginx
Posted in Uncategorized | Tagged , , | Leave a comment

gentoo unknown filesystem type ‘ext2′

gentoo unknown filesystem type ‘ext2′

tune2fs -O has_journal /dev/sda1

After this mount partition using

mount /dev/sda1 /boot
Posted in Uncategorized | Tagged , | Leave a comment

Installing Gentoo, mount&chroot in case of kernel panic

Problem: Sometimes gentoo kernel wan’t load and we need mount and change root manually.
Here is detailed steps for it:

  • Load via liveCD
  • mount partitions
    swapon /dev/sda2
    mount /dev/sda3 /mnt/gentoo
    mount /dev/sda1 /mnt/gentoo/boot
  • Chroot
    mount -t proc none /mnt/gentoo/proc
    mount --rbind /dev /mnt/gentoo/dev
    chroot /mnt/gentoo /bin/bash
    env-update
    source /etc/profile
    export PS1="(chroot) $PS1"
Posted in gentoo | Tagged , , | Leave a comment

Installing erlang on Mac OS Lion 10.7 via port

Problem:port hangs ups when installing erlang on beam.smp package
Solution:
Execute following code:

sudo port clean erlang
sudo port install apple-gcc42
sudo port install erlang configure.compiler=apple-gcc-4.2 configure.cxx=g++-apple-4.2

Useful Links:
Port Problem Hot List

Posted in osx | Tagged , , | Leave a comment

Be carefull when allocating java heap memmory

Problem: Java Refuses to Start – Could not reserve enough space for object heap
Solution when specifying max ammount of memmery using -Xmx and not setting XMS(minimal ammount) caused system to allocate max ammount on start. So you need specify -Xms arg too

//wrong, there no XMS
-Xmx1024m -XX:MaxPermSize=512m
//correct
-Xms128m -Xmx1024m -XX:MaxPermSize=512m
Posted in programming | Tagged , | Leave a comment

Disable usage report

To disable usage dialog at JBoss Tools, add system property

-Dusage_reporting_enabled=false
Posted in Uncategorized | Tagged , , | Leave a comment

Managing Chat Alerts in Skype

If you don’t want to get an alert when there is some activity in a chat session you can turn off all alerts for this chat session by typing

/alertsoff

in the text box and hitting enter. You can also try the

/alertson sometext

command in the chat window. It’s useful sometimes to set

/alertson yourname

so you’re only alerted to messages in the chat when someone mentions you by name.

Posted in Uncategorized | Tagged , | Leave a comment