Nadav and the wonders of the web


Archive for February, 2008

A few useful Linux commands for the newbie

Saturday, February 16th, 2008

Here is a list of a few useful Linux commands for us newbies. =]

This are most of the commands that i have come to use in Linux, this are the ones that I think it’s worth to at least know. You never know when it will come in handy…

  1. ls - Works the same as “dir” in DOS, lists all the files and folders at the current path.
  2. cat filename - Pasts the contents of filename to the screen.
  3. man command - Loads the manual file for the command\program.
  4. wget url - I think this actually a program but it will most likely be available on every Linux system you will use. It fetches the file\page at the url.
  5. mkdir name - Create a directory named name.
  6. rm filename - Delete filename.
  7. rmdir foldername -Delete foldername.
  8. ps - Lists processes.
  9. passwd - Change the password of the current user.
  10. chmod - Read about this one, this is used to change the rights regarding read/write/execution of a file or folder.
  11. chown - Used to change the owner of a file or folder.
  12. cp filename1 filename2 - Used to copy files from filename1 to filename2.
  13. df - Used to review hard-drive space, personally, I use it with “-hT”.
  14. fdisk /dev/*** - Used to partition a hard-drive, usually the drives location will be /dev/hda or /dev/sda or /dev/hdb and so on…
  15. find key - Find files on the file system. I am not very familiar with it but I know that sometimes you would prefer to use locate.
  16. grep regularExpression- used to find lines that correspond with the regularExpression usually used in parallel to another command like ps. [ps | grep cups]
  17. ifconfig -Lists the available network adapters and their status.
  18. kill - Stop a process by PID[Program ID].
  19. killall - Stop a process by name.
  20. lsmod - Lists currently loaded modules[this is a subject of it's own].
  21. rmmod mode - Unload a module from the kernel.
  22. lsusb - Lists all USB devices.
  23. mount - Used to mount a device/partition to a certain path.
  24. umount - Used to un-mount a device/partition.
  25. dig serverAddress -Used to query the DNS server.
  26. sftp - ftp, but secure!.
  27. ssh address - Connect to a SSH server at address.
  28. su username - Start using the shell as username.
  29. sudo command - Run command as if you were root. This command is currently used in many different distros to re-authenticate the user in order to make sure this is not some kind of a harmful program.
  30. tar - Create or restore file from a tarball.
  31. traceroute address - Shows the entire route it takes a request in order to get to address. Useful when trying to find bottle necks in networks.

For more info on any of this commands either use “man” or call the command and “–help” or “-h” after the command(or click the link…). It should list the different possibilities of usage to that command.

Hope this helps you with your Linux endeavours. BTW - most or at-least some of the commands should work on UNIX based systems as well. This is due to the fact that both Linux and UNIX adhere to POSIX.

Until next time, have a good one! =]

Nadav

Cool Visual Studio 2005 stuff.

Friday, February 15th, 2008

Lately I stumbled upon a few cool things you can change in the Visual Studio 2005 to get some nice to have features.

Here they are:

  1. Change the start-up behavior:
    If you’re like me and you don’t like the fact that it takes a while for VS to load, partially because of the start-up screen, while you don’t use it anyway… then this for you !
    Go to: Tools->Options->Environment->Startup
    And choose whatever fits you best.
  2. Enable line numbering:
    Some times when you use a log file or you look in the windows event handler you will see certain errors you want to check in the code, but while looking for the right line you keep looking at the status bar to see in which line you are. NO MORE!
    Go to: Tools->Options->Text Editor->[Choose your language or All Languages]->General
    And set the check box at the bottom named “Line numbers”.
  3. You might want to go through the “Formatting” section and set it up to your liking.
  4. If you don’t like it that when you implement an Interface VS automatically wraps it with a #region than you can go to the same place but look at [Language]->Advanced
    And unset the check box at the bottom under “Implement Interface”
  5. If like me you don’t use the WYSIWYG editor for HTML than you might want to go to:
    Tools->Options->HTML Designer
    And choose “Source View” at the top.
  6. A cool and not so known feature of VS is that you can set special keywords to show up on the Task List.
    First, what you want to do is open the Task List window, you do this by View->Task List(or just Ctrl+T).
    Second, go to Tools->Options->Environment->Task List. Here you can set up your own keywords or removed ones you don’t like. this can be used so when you need to do a little fix in your code at a latter time you put a little “//TODO: ….” comment there, then, when you look at the Task List not only you will see all the TODO’s[and other keywords] comments but a double click on it will bring you to the exact line. Now that’s a time saver! no more searching the entire solution for those TODO comments.
  7. Another very cool and probably not very known feature of VS is that you can Import and Export your settings! this means that after you go through all the settings and set everything to your liking you can save it so the next time you install VS you will easily set it up in no time.

Hope you found this informative and that it helped you a little.

Until next time, have a good one =].

Nadav

Which is faster? switch or if-else ?

Thursday, February 7th, 2008

Every time I have a state where I need to use switch\if-else-irritation I can’t quite figure our which is the better choice. I am pretty sure there is no one answer to this question, but i did stumble upon an interesting test:

Link

This test shows that, as i suspected all along(Mu-ha-ha), the switch is faster, and in a significant way.

I’m sure that some people will still state if-else is more readable, but personally, i do not agree with that.

What do you choose when you face this issue? if-else/switch? or an entirely different mechanism?

Have a good one, =]
Nadav

How to: Control the keyboard(SIP - Soft Input Panel) on Windows Mobile

Friday, February 1st, 2008

As you might have noticed, what I do here in this blog is write about the things I look for, than, when I can’t find them or I find too complicated and evasive answers I write simple ones here.

So, let’s get to the reason we’re all here.

I will give here an example on how you can change the visibility of the keyboard and you will probably be able to figure out the rest.

the steps are as follows:

  1. Add a reference to Microsoft.WindowsCE.Forms.dll
  2. Create our new class:
    using Microsoft.WindowsCE.Forms;
    
    namespace Environment.Keyboard
    {
        public class Keyboard
        {
  3. Create our private InputPanel member:

    private static InputPanel m_inputPanel = new InputPanel();
  4. Create the property to check if the Keyboard is open:

    public static bool KeyboardOpen
    {
        get { return m_inputPanel.Enabled; }
        set { m_inputPanel.Enabled = value; }
    }
  5. Were done!

It’s that simple. the Enabled property in the InputPanel signifies if the keyboard is currently open or not.

Check out this link for a more comprehensive article.

See you next time,

Nadav

Jajah is the VoIP player that brought you web-activated telephony.