Data Best Practices

Accessing Intranet Sites Remotely

Posted by admin on June 21, 2010  /   Posted in Data Best Practices, Linux

If you are like me, maintaining a server at home is like a hobby.  There is a certain satisfaction to be able to install whatever we like without having to ask for anybody’s permission.

And sometimes thanks to our tinkering, we discover good solutions that are applicable to the task given to us at work.  Think about it as giving our employers a bonus.

One of the most important rules in running a server is to never expose unnecessary information publicly.  Want an example? how about an obvious one, your router’s administration application.  This should never be accessible from outside of your home network for an obvious reason, obviously.

But the benefit of this approach is also its own downside.  Consider the following (highly likely) case:

You need to urgently change a setting on your router, while you are not at home.

Yep, you can’t.  Not without doing something extra anyways.

And that something extra is SSH tunneling.  Now, there are at least two ways that I know of on how to accomplish this.  For simplicity’s sake, let’s talk about one now:

If you are on a Windows machine, get yourself Putty and follow the steps on this website while replacing the forwarded port numbers with the one that you are trying to use.

Basically, you are telling Putty to tunnel port number x from a machine within your home network to port number y on the machine where you are working on.

So in the above example, to access your router’s admin application, you can setup the tunnel from port 80 on your router’s ip-address, to let’s say port 8080 on the local machine (where you are working from).

In the UNIX world, that translates into the following:

ssh -L 8080:your_router_ip:80

After successfully loggin into your home serve remotely, you can start a browser (on the machine where you’re working on currently), then go to localhost:8080 and voila! you’ll see your router’s administration application as though you are at home.

Pretty handy, eh?

Running GUI Linux programs in Windows

Posted by admin on June 03, 2010  /   Posted in Data Best Practices, Linux, Microsoft Windows

Now why on earth would you want to run GUI Linux programs on Windows?

If you were to ask me that a week ago, I would not be able to come up with a good business scenario.  Other than the fact that I did it at home, because my main computer is a Windows box and my development stuff is on my Linux server.

But at the moment I am stuck with an old laptop at work — which, being a good corporate laptop, of course is running Windows XP — because the giant four-letter computer company has messed up the shipment for my new computer.

So to make lemonade out of a lemon, I have enlisted two powerful free software that can get me out of this jam: PuTTY and Xming.

The idea is to use a powerful Linux machine to host and run the GUI programs that I need to work with from my very resource-limited old laptop (Pentium 4 Mobile with 512 MB, anyone?).

What applications? you say…

Let’s pick a big one, how about the Eclipse IDE.

Step one:

You install Xming and fire up XLaunch.  Out of the three modes that Xming offered: 1) multiple apps in one window, 2) each app running in a separate window, 3) fullscreen mode, mode 2 is one that works the best in this scenario.

So I went ahead and created an .xlaunch file that basically fired up Xming in the background, ready to accept X-window connections on the old laptop. NOTE: Don’t forget to check a box that says “No Access Control” otherwise your Linux application will be rejected when it tried to connect to Xming.

NOTE: Xming has a file called X0.hosts (that’s X and zero, not the letter ‘o’) which is usually located in the Xming install directory.  This file may need to be modified to include the IP address of the linux box.  But only if it connects to Xming via another network domain (other than the primary one).

For example, I setup a virtual linux guest on my windows 7 machine, the local network subdomain looks like 192.168.56.x unlike the default network domain which is 192.168.1.x.  The latter is where Xming waits for connections from.  Therefore I need to add (the IP address of the linux machine) to the end of X0.hosts file (a line by itself), then Xming will work as expected.

A subnote, on my machine, windows 7 forces me to become administrator user to edit this file.  Although not as elegant as UNIX’s sudo command, the Switch User facility in windows makes this not as painful as it could have been.

Next, I fired up PuTTy.  I followed the steps to configure a PuTTy session that will allow X-forwarding and all that good stuff on this website.

Once you are connected to the Linux server, in which I already have downloaded the appropriate Eclipse distribution, ready to go.

All I need to do once I connected via PuTTy is:

  1. Set the DISPLAY environment variable to point to the laptop’s Xming instance: export DISPLAY=192.168.x.x:10.0 (the 192.168.x.x being the laptop’s internal IP address, of course).
  2. Run Eclipse IDE: ./eclipse &

And voila! Eclipse is running on the Linux server with every bit of its UI tunneled via X onto the old laptop.  Of course the performance depends on the network connection, but it is surprisingly snappy on a typical 100Mbps Gigabit Ethernet.  And I am talking about Eclipse loaded with a large project.

Now if this article does not make you run to the storerooms in the back and pull out those old laptops and give those out to your developers, I don’t know what else will :)

A Good IDE

Posted by admin on May 10, 2010  /   Posted in Data Best Practices, Linux

An IDE is a good idea.  If you as much as having the need to organize a couple of text files that you often write and change, you need one.

An Integrated Development Environment (IDE) is basically a multi-document text editor that assist you in managing a project.

Assist me how? you might ask.

Beyond reliably allowing you to edit your text files — be it your collection of barbecue recipes, love-letters, or your latest Cake PHP project — a good IDE should have the following features:

  • File-type recognition.  The IDE should be somewhat aware of what type of file you are editing.  The most popular file formats are a must, in my book, such as .html, .php, .java, .c, .py, .xml, .css, et cetera.
  • Syntax highlighting.  As part of the above feature, an IDE should highlight the common components of the said file type.   This is helpful especially when you are dealing with more than one type of files (typical if you are a software developer/web designer).
  • Auto-completion.  Another form of file-type recognition is to provide suggestions when we write a couple of letters.  For example, if I type “clearT”, the IDE should do a lookup for functions visible from the current code context and present it to me.  In this case, “clearThroat()” and “clearTupperware()” should be selectable.
  • Pair matching.  Pairs of what? Well, brackets, braces, HTML tags, multi-line comments, you name it.  Along with folding, this feature really makes figuring out your colleague’s code much easier.  Or your own code written six-months ago, for that matter.  Some IDEs out there go as far as auto-completing your brackets.  I find this annoying fifty-percent of the time, though.
  • Refined indentation control.  Try highlighting a few lines of code in a basic text editor like Gedit or Notepad and then hit the ‘Tab’ key.  If you are a developer, unconsciously you’d expect the highlighted lines to be indented.  Instead, you are rewarded with a blank space.  A good IDE also allows you to select between tabs and spaces.  I like spaces, four of them per indentation level.  No, not Fortran, Python.
  • Multiple-file Text Search. For you UNIX users, think of a built-in ‘grep’ command within the IDE.
  • Terminal/Console facility.  At the very least, a good IDE should have a way to execute compilers or other command-line tools that you may need to run your text file through.  At the most, an IDE can act as a GUI for your favorite application/web server.
  • Shortcut-keystrokes.  Preferably intuitive ones. As far as developer goes, I am an old-school, hands on keyboard, only reach for the mouse when needed -kinda guy.  I love shortcuts using key combinations.  They make tedious coding sessions a breeze.
  • Scriptable Macro Engine.  If you know even what this means, you have been coding long enough.  One of the “badges” of an veteran programmer is to be able to brag about how they wire their text editors to jump through hoops and play dead at their whim.  Yeah, nerdy; but in a good way.

Also, some features that are “nice-to-haves” like built-in graphical debugger, version control integration, or library-dependency manager.

In short, if an IDE does not do enough to relieve you from the most mundane editing tasks, then it’s useless.  On the other hand, if the IDE is so complicated to use that you’re losing hair trying to figure it out, it’s worse than useless.

A good IDE should be intuitive.  If I issued an Open file command from an active document, then I should be presented with the contents of that same directory.  Some editors I use always show me what’s on my home directory.

A Few Good IDEs

Now let’s take a look at some good IDEs out there.

  • Geany

This lightweight IDE runs on Linux and Windows. OS X and BSD users should be able to compile and run, in fact, I’d be surprised if there are not port install for it.

The lightweight-ness of this particular IDE cannot be stressed enough.  I am running it remotely inside Xming (an X-windows server for Windows) and I never noticed any performance hit at all.

Two things impressed me right of the bat:

1) it recognizes any file types I’ve thrown at it so far, and when I need to map a new file extension to an existing file format, I went to Tools > Configurations > filetype_extensions.conf.

It opened up the configuration file (formatted intuitively), add the new file extension, save and close, then Tools > Reload Configuration.  Done!

2) configurable shortcut-keystroke system, with defaults that make sense.  For instance, I can use Ctrl-PgDn to go to the next document on the right, Ctrl-PgUp to the left.  Just like how I navigate the tabs on Firefox. Very intuitive.

Most of the information that separates an IDE from an ordinary text editor is displayed on the lower panels.  Geany does not skimp on the  features.  As you can see below, the lower part of the IDE sports application status messages, compiler outputs, search outputs, a scribbling space, and a full blown terminal (or ‘console’ for you modern UNIX users):

A few features that I am missing: 1) a file browser/manager, 2) integration with souce-code version control systems such as SVN, 3) a scriptable macro engine.

Which, brings me to the last feature that I want to highlight.  Although billing itself as a lightweight IDE, the Geany developers are forward-thinking enough to embed a plugin infrastructure.  Perfect for implementing the ‘missing’ features I mentioned above.

It is my hope that as this IDE gets more popular, people would start writing plugins for it to make it even more powerful.  For now, I’m going to enjoy using it.

We serve businesses of any type and size
Contact Us Today