Dreams of Thought

Are dreams thoughts… or are thoughts dreams..

RSS Feed

Tag Archives: Linux

SQLyog on Linux

0 Comments

Run SQLyog on Linux with WINE. You can download the sqlyog windows installer and just run it with WINE. SQLyog is my favourite GUI client. It is lightweight and powerful. I use the community edition which comes free. The paid versions of the app are awesome. I particularly miss the autocomplete feature. This feature autocompletes table names, field names, query commands etc. on tab press. I have used the MySQL query browser, but there's no comparison. The problem with SQLyog being that it runs only on windows :( . I tried alternatives - phpmyadmin, MySQL query browser - but none of them quite measured up against SQLyog. So I decided to try and get it working on my linux box ( Ubuntu Maverick - 10.10 ). I use Wine version wine-1.3.11 . Downloaded the latest installer from the community edition project page. Ran the installer with Wine and voila! That was it :) sqlyog running on wine in Ubuntu
Filed under code
Jan 16, 2011

vimdiff – the cool way to diff for vim users

5 Comments

Some of you using the vim editor may not know about a tool that comes with vim called vimdiff. Vimdiff is an awesome way to diff files if you are a vim nut. It gives you the power of vim + the power of diff.

How’s this different from opening 2 files in vim (with -O option) you ask ? The difference is that vim will highlight the diff for you.

Fire it up by giving the 2 filenames, say

$vimdiff old new

This will bring up a screen like this -

vimdiff

vimdiff

Now you can move around the 2 parts of the screen with your regular vim commands. For eg. use (Ctrl+w) + right arrow to move to the right half of the screen.

vimdiff with cursor on right half of screen

vimdiff with cursor on right half of screen

You can copy paste as well. Go to the 2nd line in the left half and press the y key twice to copy that line. Use (cntrl + w) + right arrow to move cursor to the 1st line in the right half of the screen. Press p to paste the copied line below the 1st line.

vimdiff with copy paste

vimdiff with copy paste

You can go to the first line and delete the two words “a new” by moving the cursor to “a” and hitting d2w key combo.

vimdiff deletes words

vimdiff deletes words

Insert “an old” there by going to insert mode(press i key) and then typing the two words. You’ll see that vimdiff does not highlight anything. This means that there is no difference between the two files.

two files with no difference in vimdiff

two files with no difference in vimdiff

Vimdiff is the same as bringing up vim with the -d option. You could do the same things you did above by using

$vim -d old new

Bonus :
You can also diff 2 URLs directly with vimdiff
Try
$vimdiff 'http://www.google.co.in/search?q=vimdiff' 'http://www.google.co.in/search?q=vim'
You’ll first see something like this coming on screen

:!curl -o '/tmp/v959288/1' 'http://www.google.co.in/search\?q=vimdiff'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
"/tmp/v959288/1" 4L, 5289C
:!curl -o '/tmp/v959288/2' 'http://www.google.co.in/search\?q=vim'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
"/tmp/v959288/2" 4L, 5253C
Press ENTER or type command to continue

Now press the ENTER key to see the diff

vimdiff also works directly with URLs

vimdiff also works directly with URLs

You can throw in ssh into the mix as well. Try something like this
$vimdiff old <(ssh user@host cat ~/new)

If you're a vim/vimdiff ninja and know some more tricks, do post them below :)

Happy hacking...

Filed under Linux
Oct 20, 2009

Copy files preserving the permissions

3 Comments

You might have come across a situation where your regular usage of the cp command for copying files in your linux box was not enough because while copying you needed to preserve the permissions of the files. Fret not, for help is at hand. Take a look at the man page for cp :

-p     same as --preserve=mode,ownership,timestamps

--preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, all

So that’s it. just use the -p flag to do the copying. Here’s an example where I copy a single file while preserving permissions.

cp -p oldfile ~/new_dest/

To copy a whole directory, I use the -r flag as well.

cp -rp some_dir ~/new_dest/

You can use the –preserve flag to keep whatever attributes you need. For the record, there’s one more related flag

--no-preserve=ATTR_LIST don't preserve the specified attributes

Filed under Linux
Oct 1, 2009

Copying files from one unix box to another with scp

4 Comments

ssh is a very powerful and widely used protocol in all the Unices. If you’ve used the ssh client in your Unix/Linux box, you must have realised how indispensable it is. There is another indispensable tool that uses the ssh protocol – scp (secure copy). scp was meant to be an alternative to unsecure tools like rcp. It has since replaced most such programs. Since scp uses the ssh protocol, the encryption it uses ensures security of your data.

Using scp is simple. It works almost like the regular cp command. The basic syntax is
scp SOURCE DESTINATION
In order to specify the SOURCE or DESTINATION we have a special syntax.
USERNAME@HOST:PATH

Let me give you an example :
$scp anirudh@box:/var/www/html/test.html gingerjoos@linux:~/test_dir/
Copy /var/www/html/test.html in the machine called “box” as user “anirudh” to the box called “linux” as user “gingerjoos” to the path HOMEDIR/test_dir/

That’s it :) Simple, right?

To copy the file to our localmachine, we could do this
$scp anirudh@box:/var/www/html/test.html ~/workarea/

This would copy the file test.html in the machine called “box” (as user anirudh) to the localmachine at path HOMEDIR/work_area/

Interchange the source-destination to copy file in your localmachine to the remote machine.

If you want to copy whole directories, use the ‘-r’ flag(recursive copy)
$scp -r ~/workarea/ anirudh@box:~/workdir/

Since scp is tied to the ssh program, the keys you use to set up passwordless login with ssh works for scp as well.

Got questions? Got something to add to this? Post your comments below :)

Filed under Linux, technology
Jul 31, 2009

How to join split files

0 Comments

This is sort of a follow-up to my previous post which talked about how you can use the split command in Linux to create split files which can be joined with hjsplit on Windows. My theory is that hjsplit does the same thing split does – which is just take the file and split it into the required number of pieces. No special headers or padding or compression or stuff. If that’s true, it should be easy as a pie to join the files split with hjsplit

To join files split with split, what I would do is use cat. Like this :
$cat xaa xab xac xad xae > debian-testing-i386-DVD-1.iso

Here xaa, xab, xac, xad and xae are the split files and debian-testing-i386-DVD-1.iso is the file after the join. I believe this should work fine for split files got from hjsplit too. Since I’m too lazy to go try it out in my friend’s Windows machine, I’ll leave it here at that. Do let me know if anyone’s tried it :)

Filed under Linux
Jun 24, 2009