"; */ ?>


22
Mar 07

Convert TABs to spaces using shell scripting

The purpose is simple and clear – to archive a “indentational independence“, when indentation is the same across all platforms, editors and systems.

Here is the simple shell script that takes the file as the command line argument and substitute all TABs with spaces:

#!/bin/sh

#
#   Script converts TABs to spaces in a given file
#

if [ $# -ne 1 ]; then
     echo 1>&2 "This script converts TABs to spaces in a given file
                \\n\\n\\tUsage: $0 "
     exit 127
fi

expand $1 > temp && mv temp $1

The above script shows how that it is all done by virtue of the “expand” command that does just that ;)

And no need to worry about sed‘s s/tab/space/g pattern, because “expand” does exactly what we need ;)


22
Mar 07

Golden AWK tips to analyze a server log

Here are several of 100% working, simple, and yet very powerful TIPs on how AWK can be used to parse/process the server log (apache’s “access.log”) to return the data about website visitors and other useful statistics:

1. Find the number of total unique visitors:

cat access.log | awk '{print $1}' | sort | uniq -c | wc -l

2. Find the number of unique visitors today:

cat access.log | grep `date '+%e/%b/%G'` | awk '{print $1}' | sort | uniq -c | wc -l

3. Find the number of unique visitors this month:

cat access.log | grep `date '+%b/%G'` | awk '{print $1}' | sort | uniq -c | wc -l

4. Find the number of unique visitors on arbitrary date – for example March 22nd of 2007:

cat access.log | grep 22/Mar/2007 | awk '{print $1}' | sort | uniq -c | wc -l

5. (based on #3) Find the number of unique visitors for the month of March:

cat access.log | grep Mar/2007 | awk '{print $1}' | sort | uniq -c | wc -l

6. Show the sorted statistics of “number of visits/requests” “visitor’s IP address”:

cat access.log | awk '{print "requests from " $1}' | sort | uniq -c | sort

    for better understanding here is a snapshot/part of the result:
    …. …. …. …. …. ….
    4217 requests from 68.25.101.134
    4374 requests from 78.14.245.20
    4601 requests from 71.222.80.119
    4829 requests from 92.73.226.209
    4892 requests from 70.45.131.7
    5003 requests from 214.178.52.97
    5294 requests from 129.21.217.229
    7249 requests from 68.32.32.64
    15739 requests from 68.46.26.47
    16105 requests from 61.299.15.129
    29140 requests from 68.208.154.18
    196452 requests from 139.21.68.20
    603581 requests from 102.78.30.12

7. Similarly by adding “grep date”, as in above tips, the same statistics will be produces for “that” date:

cat access.log | grep 26/Mar/2007 | awk '{print "requests from " $1}' | sort | uniq -c | sort


Below is the “very general” about the above: :)
There is a certain point in the life of any website owner when he/she stops in the middle of the street/hall/train/plane puzzled with a question: “hm… how many creatures did actually see my work?”, or even “how many creatures did see my work today?” The answer lies in front of the eyes, we just often do not see it – due to the simple fact that

we are sure we see everything ;)

but it is there… there, in a server log.

There are tons of log analyzer software out there, just go to sourceforge.net and look for one – you’ll see plenty (good example is awstats), but what if something very simple needed, and what if installing all other software is overhead, and most of the cases, another security risk? Then we go to Google, find this blog and keep reading :)

There is a very powerful, yet not well used (known?) language/tool as AWK which is there on almost any Linux/Unix. The purpose is simple:

“AWK is a general purpose programming language that is designed for processing text-based data, either in files or data streams.”


21
Mar 07

Список бесплатных MP3 сайтов

Очень часто просят найти “вот эту песню”, или срочно нужен “вот этот минус” и т.д. Ну чё.. иду на google, yandex и упражняюсь в клавиатурных боях и в искусственном интеллекте поисковых систем… Короче вот чё – вот вам линки вы сами ищите :)

БЕСПЛАТНО и БЕЗ РЕГИСТРАЦИИ

www.zaycev.net       Пока самый популярный
www.muzudar.ru     Mало, зато бесплатно.
www.bun.ru              Вцелом сайт про баннеры, но музыку качать тоже можно.
www.snikers.ru        Дизайн своеобразный, но качать можно.
www.grammy.ru      Просто музыкальный сайт. Из плюсов — умеренное количество рекламы без навязчивых и ослепительно мигающих флэш-баннеров.
www.zachot.ru          Качабелный
www.mp3shek.net   Музыка есть, то при каждом клике выплевывает высплывающий флэш-баннер.
www.realmusic.ru    Как утверждают сами создатели, этот сайт — прежде всего, средство коммуникации между слушателями и композиторами. Здесь можно скачать и заценить музыку начинающих композиторов.
www.filesearch.ru     FTP-поиск музыки, выдает результаты сразу в виде линков на mp3-файлы. Работает так себе, плюс постоянно выкатывает флэш-баннер посередине страницы.
www.oth.net              Принцип действия такой же, как и www.filesearch.ru, но 95% найденых песен не скачиваются. Можно попробовать в крайнем случае.

БЕСПЛАТНО, но ПОСЛЕ РЕГИСТРАЦИИ

www.mp3real.ru         Есть музыка в MP3 и видеоклипы.
www.cdonpc.ru            Дает бесплатно качать MP3 со скоростью 16 kB/s, но только 2 композиции в сутки, и то только из списка обновлений сайта; все остальное – за бабки
www.mp3zzz.ru           “Серый” сайт… ни обратной связи, ни копирайтов, ни условий пользования.
www.rmp.ru                 Скачивать можно после бесплатной регистрации. Можно также выложить на сайт свои mp3-файлы.

и вот исчо чё ;)

http://mp3plus.ru/
http://gh.ffshrine.org/soundtracks.php
http://mp3spider.ru
http://audio.bard-cafe.komkon.org/
(собрание авторской песни)
http://www.rmp.ru (регистрация) http://www.mp3shek.net/top/
http://musicmp3.spb.ru/
http://www.fsmusic.ru/
http://muzoff.ru
http://myzuka.ru
http://mp3ex.net
http://mp3xa.net
http://music-portal.com.ru/

http://music-portal.com.ru/
http://ytopia.net
http://audiofind.ru (глючит)
http://WWW.DELIT.RU (ограничение на кол-во скачанных композиций на один аккаунт в сутки; регистрация)
http://www.rusmuz.ru/
http://www.rsradio.ru/ (транс)
http://3mp3.ru/ru/
http://www.qsound.ru/
http://www.freemp3.dp.ua/
http://mp3ex.net/
http://www.msound.net/ (dance)
http://mp3club4y.narod.ru/(club)
http://hotcharts.ru/
http://www.zvuki.ru/
http://allost.ru/ (саундтреки)
http://www.mediaportal.ru/
http://www.muted.ru/ (hard’n’heavy)

Буду признателен всем кто добавит линки в комментарии или “расскажет” о не рабочем линке сверху – я уберу.

Зарание пасиб тебе!

из источников хочеться поблагодарить allmp3free.ru спасиб!


21
Mar 07

Changing Tabs to Spaces in Eclipse

Let’s say you are developing a high performance code using Eclipse on Windows, than you deploy it to Unix Server, which FTPs some of the code to IBM’s z/OS… Let’s just say you do :)

It is obvious that these different operating systems use different editors and might even use (z/OS – EBCDIC) different character encodings… That is where incorrect formatting/indentation can decrease readability and maintainability tremendously…

Here is one quick tip on how to ensure that indentation stays the same across all the systems/editors:

use spaces instead of tabs

Here is how to change the default Eclipse “tabbing behavior” to the unified “spacing” one. Some people refer to it as changing “Hard TABs to soft TABs”:

1. Open the default workspace in Eclipse (open Eclispse :) ) and go to “Window -> Preferences -> Java -> Code Style -> Formatter”

p

2. Click on “Show” button (if you previously edited this profile the button caption will be “Edit”)

show/edit profile window

and change the “Tab Policy” from “Tabs only” to “Spaces only”

3. Click “Ok”, choose the name for this profile and save it

save profile window

 

You are all set and ready for “indentational independence” ;)

 


21
Mar 07

Meet Yanik or Google Apps in action

Our universe is a big place… Unconsciously, in our imagination, we limit it by our home, which we believe is in a shape of 3D ellipse which makes its round trips around something big and shiny that we call The Sun…

To make a long story short – I have a very close Chinese friend (the fact that he is from China supports an above paragraph’s right to existence ;) ), who recently went above & beyond and bought himself a domain fengonline.com. The story would end here, and would be quite dull indeed, but there is more…

Yanik (that is how I call Mr. Feng), did not go to our domain parents GoDaddy and GoMommy, he was braver than that and bought his domain from “Dr. No Evil” – Mr. Google.

Along with the $10 a year domain, guys from Google offered him a set of Google Apps for free (“Families & groups” edition), which comes with Gmail, Google Talk, Google Calendar, Docs & Spreadsheets, etc..

It is very customizable, as you can see, Yanik, even added a “Search Torrent” and “MapMyWord”, which are external apps.

It is another very cool solution from Google team, and if you did not have a chance to try it, Yanik says it’s definitely worth it ;)

… who knows who watches us from beyond The Sun, whoever that may be, if he/she/it has a modem and can be connected to the www, he/she/it would definitely go to Yanik’s site :) ..and guess what, my UFO guest – now you can search for torrents there too ;)