o : Bulunduğun satırın altına yeni bir satır açar ve yazmaya bu yeni satırdan devam edebilirsin.
w : İleriye doğru kelime kelime ilerler
b : Kelime kelime geriye gider.
cw : İmlecin üzerinde olduğu kelimeyi değiştirmeye yarar.
9G : İmleç 9. satıra gider.
H : İmleç sayfanın en tepesine gider (Birinci satıra değil görünen sayfanın ilk satırına)
L : İmleç sayfanın en altıne gider
~ : İmlecin üzerinde olduğu karakteri büyük harf ise küçük harfe, küçük harf ise büyük harfe çevirir. (case dememek için çektiğimiz sıkıntıya bak ya. Kısaca karakterin case'ini değiştirir)
. : son çalıştırılan komutu çalıştırılır.
c$ :İmlecin bulunduğu yerden satır sonuna kadar siler. Editor INSERT modunda kalır. Yazmaya devam edebiliriz.
mt : Imlecin bulunduğu satırı "t" etiketi ile işaretler 't ile imleç işaretli satıra uçar.
vi editörü ile ilgili daha detaylı türkçe bilgi için belgeler.org adresine bakabilirsiniz.
Monday, January 21, 2008
Birkaç vi kısayolu
Friday, January 18, 2008
Başkaldıran dosya sistemlerini fuser ile hizaya getirin
Önce bu fuser da nedir diyenler için kısa bir açıklama:
"Tamam da ne işime yarayacak dosyayı hangi process'in kullandığını öğrenmek" diyenler için de fuser kullanımı ile ilgili bir örnek verelim. Yeni yazdığınız bir CD'yi CD sürücünüze takıp mount ettiniz. CD içindeki dokumanlarla işiniz bittikten sonra CD'yi çıkartmaya çalıştığınızda aşağıdaki gibi bir mesajla karşılaşabilirsiniz:

Ya da komut satırında umount komutu ile CD'yi unmount etmek isteğinizde aşağıdaki gibi "device is busy" mesajı ile karşılaşabilirsiniz.

İşte fuser tam burada yardıma koşuyor. CD'yi meşgul eden process'in PID'sini bulmak için aşağıdaki işlemler yapılır.

Bizim örneğimizde aranan process 7614 numaralı evince dir.(Gnome Document Viewer) Bu process'i kapattıktan sonra CD yi problemsiz unmount edebiliriz.
Dosya sistemindeki bir dosyayı ya da bir soketi hangi
process'in kullandığını gösteren komut.
"Tamam da ne işime yarayacak dosyayı hangi process'in kullandığını öğrenmek" diyenler için de fuser kullanımı ile ilgili bir örnek verelim. Yeni yazdığınız bir CD'yi CD sürücünüze takıp mount ettiniz. CD içindeki dokumanlarla işiniz bittikten sonra CD'yi çıkartmaya çalıştığınızda aşağıdaki gibi bir mesajla karşılaşabilirsiniz:
Ya da komut satırında umount komutu ile CD'yi unmount etmek isteğinizde aşağıdaki gibi "device is busy" mesajı ile karşılaşabilirsiniz.
İşte fuser tam burada yardıma koşuyor. CD'yi meşgul eden process'in PID'sini bulmak için aşağıdaki işlemler yapılır.
Bizim örneğimizde aranan process 7614 numaralı evince dir.(Gnome Document Viewer) Bu process'i kapattıktan sonra CD yi problemsiz unmount edebiliriz.
Kullandığım firefox eklentileri
- del.icio.us buttons.
İnternette surf yaparken beğendiğim sayfaları del.icio.us profilime eklemek için kullanıyorum. http://del.icio.us/ilkinulas - AdBlockPlus
Olmazsa olmaz bir plugin. - Tab Mix Plus
Firefox'un tab özelliğine ilave özellikler ekliyor. Yanlışlıkla kapattığınız bir tab'ı yeniden açmak gibi. - Web Developer Plugin
Özellikleri saymakla bitmez. Web'de geliştirme yapıyorsanız çok işinize yaracak bir plugin. En beğendiğim özellikleri:
cookie arayüzü ve sayfa içindeki bütün HTML elemanlarını açıp kapayabilme özelliği. - Firebug
Özellikle Ajax ile geliştirme yapanlar için çok kullanışlı bir plugin. Firefox'un asenkron yaptığı HTTP request'leri firebug console'dan takip edebilirsiniz. - UnPlug
Bu plugin'i Youtube videolarını bilgisayarınıza indirmek için kullanabilirsiniz. - YSlow
Firebug plugin'ine ek olarak kullanılan bu plugin'i Yahoo geliştirmiş. We sayfasını yahoo'nun belirlediği kriterlere göre sınıyor. Bir nevi performans testi uyguluyor. - Greasemonkey
Bu plugin kısaca, sayfa yüklendikten sonra sayfada post-processing yaparak sayfanın yeniden yapılandırılmasını sağlar. Sadece greasemonkey plugin'ini kurmak yetmez. Greasemonkey sitesinden "user script" denen betikleri kurmanız gerekmektedir.
Sunday, January 13, 2008
A Tutorial on XML Namespaces
XML namespaces are used to avoid element name conflicts. A namespace is a set of names in which all names are unique. An XML namespace can be tought as a Java package name. To distinguish two classes of the same name we put the classes in two different packages. For example; you may choose to put a class that is used to connect to a relational database system in com.foo.sql package (com.foo.sql.Connection) and a class that manages TCP/IP socket connections in com.foo.net package (com.foo.net.Connection).
An XML namespace is used in the same way. Namespaces make it easier to come up with unique names. Without namespaces all XML element names must be unique all over the world. I'll try to explain this with an example.
Xml representation of a java class.
<class>
<name>com.foo.bar.Customer</name>
<method>getName</method>
<method>setName</method>
<superclass>com.foo.bar.Person</superclass>
</class>
Xml representation of a college class.
<class>
<code>MATH101E</code>
<name>Mathematics 1</name>
<language>English</language>
<credits>4</credits>
<class>
If these two "class" XML elements are used in the same XML document there will a name conflict. These name conflicts can be resolved by using namespaces.
<j:class xmlns:j="http://java.sun.com/class">
<j:name>com.foo.bar.Customer</j:name>
<j:method>getName</j:method>
<j:method>setName</j:method>
<j:superclass>com.foo.bar.Person</j:superclass>
</j:class>
<itu:class xmlns:itu="http://java.sun.com/class">
<itu:code>MATH101E</itu:code>
<itu:name>Mathematics 1</itu:name>
<itu:language>English</itu:language>
<itu:credits>4</itu:credits>
</itu:class>
ITU : Istanbul Technical University
XML namespaces are defined with XML Namespace (xmlns) Attribute. The XML namespace attribute is placed in the start tag of an element and has the following syntax:
xmlns:namespace-prefix="namespaceURI"
When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace.
If this tutorial is not enough for you can read these articles:
Thursday, December 6, 2007
Kill A Process By Name
My favorite shell command is kill. Don't worry I'm not a serial killer.
If you know the process id and if you have enough permissions you can kill any process you want . It is easier to kill a process by name. Here is the command.
If you know the process id and if you have enough permissions you can kill any process you want . It is easier to kill a process by name. Here is the command.
kill -9 `ps -ef | grep $1 | grep -v grep | awk '{print $2}'`
kill -9 processId sends SIGKILL signal to specified process. You can use a list of process ids as kill command argument. kill -9 pid1 pid2 pid3
ps -ef|grep $1Lists process that matches $1
ps -ef | grep $1 | grep -v grepList process that matches $1 except the process that runs grep command
ps -ef | grep $1 | grep -v grep | awk '{print $2} Lists only process ids of processes that matches $1 except the process that runs grep command.awk '{print $2}' lists the second column of the
ps -ef | grep $1 | grep -v grepcommand output.
Save kill -9 `ps -ef | grep $1 | grep -v grep | awk '{print $2}'` in a file called myKill.sh
Give execute permission to the myKill.sh file (chmod +x myKill.sh)
If you want to kill all java processes type
./myKill.sh javaOr you can use pgrep and pkill commands if they are available on your system.
Tuesday, December 4, 2007
Watch multiple log files with "tail"
Log files are the first place i look while debugging an application. To see the logs in real-time I am using the utility command "tail" with the "-f" option.
tail -f filename
When there are multiple log files to watch out, I used to open different xterm console to tail each file.But today I learned that "tail" can watch multiple files for changes. Example command and its output on my PC (Ubuntu 7.10).
tail -f logs/catalina.out InaWs.log InaWsUserActions.log
==> logs/catalina.out <==
[2007-12-04 09:39:18,746] INFO(ContextManager.java.initialize:56) - Context [vpn] initialized.
[2007-12-04 09:39:18,760] INFO(ContextManager.java.initialize:56) - Context [prepaid] initialized.
[2007-12-04 09:39:18,761] INFO(InaWsImpl.java.initialize:116) - Using auhentication factory : com.oksijen.inox.common.ws.auth.PlaintextAuthenticationFactory
Dec 4, 2007 9:39:19 AM com.sun.xml.ws.transport.http.servlet.WSServletDelegate
INFO: WSSERVLET14: JAX-WS servlet initializing
==> InaWs.log <==
[2007-12-04 09:39:18,743] INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] (InaWsContext.java.addAction:41) - Adding action. actionName[echoVpn]...
[2007-12-04 09:39:18,744] INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] (C3p0Impl.java.initialize:53) - Initializing C3P0 connection pool....
[2007-12-04 09:39:18,757] INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] (InaWsContext.java.addAction:41) - Adding action. actionName[echoPrepaid]...
[2007-12-04 09:39:18,758] INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] (C3p0Impl.java.initialize:53) - Initializing C3P0 connection pool....
==> InaWsUserActions.log <==
20071204093501054 REQ 117787e671a35c5c03e072efbd53bad3cea0ae49 root prepaid echoPrepaid [test]
20071204093501054 RES 117787e671a35c5c03e072efbd53bad3cea0ae49 1
20071204093520876 REQ 117787e671a35c5c03e072efbd53bad3cea0ae49 root vpn echoVpn [test]
20071204093520876 RES 117787e671a35c5c03e072efbd53bad3cea0ae49 1
20071204093530380 REQ 117787e671a35c5c03e072efbd53bad3cea0ae49 root mpbx echoMpbx []
20071204093546634 REQ 117787e671a35c5c03e072efbd53bad3cea0ae49 root mpbx listAgents []
20071204093549223 RES 117787e671a35c5c03e072efbd53bad3cea0ae49 100101
Monday, November 12, 2007
My favorite shell commands
The below one line shell script calculates the number of executions of commands and sorts the result.
history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rg
Here is the result of this script on my Ubuntu.
Try this script to see what commands you use frequently.
history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rg
Here is the result of this script on my Ubuntu.
66 ls 40 cd 32 sudo 32 mvn 31 ps 29 clear 26 more 22 vi 19 tail 18 kill 16 ssh 13 rm 13 eclipse 11 tomcat_start.sh 10 ll 10 find 9 locate 9 findJar 6 ifconfig 5 lnMost frequently used command is "ls". I was surprised to see "mvn" in the 4th place. As you can see I am developing (eclipse), testing-packaging (mvn) and deploying (tomcat_start.sh) web applications written in java these days. I have also "kill"ed a serious number of processes :)Try this script to see what commands you use frequently.
Subscribe to:
Posts (Atom)
