LinuxPlanet Blogs

By Linux Geeks, For Linux Geeks.

Archive for the ‘programming’ Category

My Web Workers Toolkit

without comments

Ahh, it’s been far too long since I have had anything to say here. I have to say that I have been *legitimately* busy this time. As many of you know, we have come to a close on the first season of The LinuxLink TechShow. That’s 365 (about) 2 hour long episodes over the course of the last 6 years. We are due to start our next 365 at the Ohio Linux Fest in a month. This leaves an enormous amount of prep work and a fair bit of reorganization to keep things exciting and help us start out with a bang.

One of the *surprises* in store brings me to my current topic at hand, my web workers toolkit.

People all have differing opinions about what you really need to do decent web work. As an old commandline jockey, I thought I would share my own.

1) Vim.
Quite possibly the best text editor in the world, I use vim for darn near everything. As a system administrator, it’s indispensable (for scripting) and I find it similarly necessary for web work. Vim has a fantastic (imho) syntax highlighting system which does quite well for html and php highlighting. The only caveat is to make sure to set “set background=dark” in your .vimrc file, unless, of course, you are one of those wierdos who uses a light background in your terminal.

2) tidy or the w3c validator.
I DEFY you to write good code without one of these. There is NOTHING as nice as standards compliant code and without a good validator, you will have nothing like standards compliant code. The reason I listed both of these is that tidy is a program you can use locally to check your code and the w3c validator will check any pages that are accessible via the web.

3) Many different browsers.
Unfortunately, all browsers are not made equal. You can be sure that all mozilla based browsers like Firefox, etc., will display things very similarly, and maybe even throw Google Chrome into that mix, but you may really want to check your code with Safari and IE to be sure things still look the way you had intended, and let’s not forget about a text browser like lynx or w3m to make sure your pages are readable and navigable that way too.

4) Lastly, for me, some good reference material.
One can hardly be expected to remember everything and having some reference material handy for those odd css commands and perhaps php/perl/python/someotherprogramminglanguage could really save you some time and frustration. Never underestimate keeping your old code around for example and never ever underestimate the power of the power of the Google Search!

In a nutshell, that’s generally what keeps me cranking out websites and webpages. What kinds of things do you use? What am I missing out on? Send a long a comment and let us all know what works for you! ( Unless, of course, you use emacs :D )

Written by linc

August 17th, 2010 at 7:44 pm

Appending Python Path Under Windows7

without comments

Today I bought a new laptop() via Windows7 Home Premium. I was curious about Python, that’s why i downloaded and installed Python2.6 as soon as possible.

Everything seems well, but when I tried to run my example.py file via command line, it was failed. If you want to use Python via command line, you have to append Path to system. Let’s have a look, how to append this path.

To do list:

1. Right click to My Computer icon on your desktop and then choose Properties.
2. Choose Advanced System Configurations from the left side of new pop-up panel.
3. A new pop-up screen named System Properties must appear.From this pop-up choose Advanced tab and from the bottom side choose Environment Variables menu.
4. From the System Parameters you can edit Path of Windows7, for Python you ave to add this C:\Python26 (Be careful about Python version)

That’s all. From now on you can use python foo.py command uner command line.


Written by titus

July 2nd, 2010 at 3:30 pm

Posted in Linux,programming

I’m Back Again

without comments

For a few months I’ve been working as a software engineer for Turkish Army Forces. Yesterday my first step of education was completed and i was promoted to Lieutenant Engineer.

From now on, i am gonna be responsible for cryptography of all communication system on Aegean Region. Never-ending nights with full of code are waiting for me ;)

All the best.


Written by titus

July 1st, 2010 at 2:07 am

How To: Loops with Linux Bash

without comments

If you’re using Linux, often you have to write some small scripts for helping you.(For example my last script aims to sync datas over the my hone network.) Today I realized that some of my computer engineer friends have wrong knowledge about loops.

I decided to prepare this how to for giving basic examples about loops. First of all, loops are similar to other programming languages (C, Python, Perl etc.), but they are just similar not the same.

For Loops:

#!/bin/bash
for i in $( ls ); do
echo item: $i
done

While talkig about loops, our magic words are do and done. These words respectively indicates loop started and finished. Also done, lock value of $i variable during loop is executed. After done line, $i variable can take new value. (Pay attention here, it is the most important part)

Above mentioned script, lists us the respond of “ls” command.

While Loops:
One of other most useful loop is While.


#!/bin/bash
VARIABLE=0
while [ $VARIABLE -lt 10 ]; do
echo The value is $VARIABLE
let VARIABLE=VARIABLE+1
done

Above mentioned script, write out the variable number(between 0-10), but this example is a little bit different from the For Loops.
Here is the difference:
In While Loop example you have to change the value of $VARIABLE variable before the done line, for this you have to use
let VARIABLE=VARIABLE+1 command.

Until Loops:
This loop is similar to While loop. You can see the difference below mention script:


#!/bin/bash
VARIABLE=20
until [ $VARIABLE -lt 10 ]; do
echo Value $VARIABLE
let VARIABLE-=1
done

As you can see, you don’t have to write $VARIABLE=$VARIABLE+1 instead of it you can use let $i+=1 or $VARIABLE=$VARIABLE-1 instead of it you can use let $i-=1


Written by titus

April 5th, 2010 at 2:28 pm

Playing catch-up

without comments

I decided that on my vacation I would do some catch-up work. I have many times mentioned that I am a consummate procrastinator, and if you combine that with me being just generally whooped tired after 12 hours away from home on any average day, you understand why my computers seem to go uncared for. I think it’s the same as the whole “the mechanics car is never fixed” thing.

I mentioned a couple days ago that I installed ESXi on one of my home servers (redundant servers) to fix a strange problem I had been having with VMware Server 2.x. That was the first job I needed to so, or at least the most important, and so far it has been doing beautifully.

Next on the list was Mint 8 on the old laptop. It has been running Mint 7 since the distro was released and it was time for an upgrade. Everything was working just fine on 7, I just wanted to catch up the latest/greatest. As expected, the upgrade was a no-brainer and it’s running gorgeously, as Mint does.

Today, so far, I decided to upgrade my desktop machine to Mint 8. This machine, a P4 3Ghz with 3Gb of ram runs like absolute crap. I don’t exactly know why, but it always has. Now I have replaced the cpu fan a couple times and also the power supply at least twice. The computer is noisy, whiny, but not physically broken that I can tell. It just seems to run slower than hell and always has. The installation of Mint 8 on it did make it prettier, but sure didn’t make it seem to run any faster. I think it just dogs over the dual display and craptasticly old Nvidia card. Perhaps if I bought it a new quiet power supply, a better working and quieter cpu fan, a new better video card and a new dvdrom drive (yeah that’s pretty broken too), I could resuscitate this thing so that I could stand using it again. But then again, I could probably buy a whole new desktop computer for what I would spend on repairs to this one. Dang.

So, what’s next? Well, I should install ESXi on my redundant server now that I am satisfied with how the other one is running. I should also upgrade to Mint 8 on my Acer Aspire All In One netbook (notice a pattern here). Other than that, I am not sure.. Maybe work on some code projects I have been stringing along for months and months.

So what kinds of great computery projects are you all up to? Or what SHOULD you be up to :-)

Written by linc

February 8th, 2010 at 6:19 pm

Learning Development, or Developing Learnment :)

without comments

My background is not typical of a Systems Administrator. I started my life in IT as a marketing intern, the some time doing basic server administration and Desktop support; to now find myself working fully on Linux Servers. It's a long way from the Psychology and Business degree that I graduated with back in June '07.

I've never been a bedroom hacker, despite very much wanting to be. The majority of my time spent learning has been during waking hours, in the office. I've had a few projects that I've taken home with me, but due to my limited background, I found myself limited to fixing things other people had written, rather than writing stuff from scratch. I'd mostly learnt how it shouldn't be done, rather than how it should be done.

Ironically, this has meant that until now I've been fixing other people's problems, tidying up others designs, and adding my voice to conversations pointing out logical discrepancies and extending other people's ideas. This is one of the great freedoms that Open Source software has given me - I don't have to write anything from scratch - someone else has already done it for me.

However, I'm acutely aware that sooner or later my weaknesses are going to land me in hot water. It may be a casual observation, but most of the time I come across something that completely baffles me, I'll come back to it in a couple of weeks after either doing a bit of research on it or playing with something similar - and I get to understand it. There have been a few moments when I've looked back at decisions I've made and in the meantime have new knowledge that would have made the decision a "no-brainer", when at the time it seemed like a 50/50 split.

The more I experience these moments though, the more I realise that it's all about growth, and experience. I'm sure there are many CS graduates or other programmers out there who have got certain gaps in their knowledge that get filled over time. I'm sure there are many who are going through the same angst that I am, wondering "am I good enough to be doing this.. have I missed something?" In hindsight I'd say that's a brilliant attitude to have, because being overconfident about one's ability is likely to end you up in an even bigger spot of bother.

I guess the key is to never fool yourself into thinking that you've learnt enough. I've got a couple of books in the post, covering 'Pragmatic Programming' and 'Design Patterns' - I'm sure they'll provide me with the material I need to keep plugging my gaps, and improving my technical thinking, whether I end up moving into programming rather than Systems Administration, or some other field entirely.

Written by Andy

January 18th, 2010 at 3:21 pm

Ubuntu 9.10 and Grub 2

without comments

ubuntu
Yes, another post about Ubuntu 9.10. I know I tried it out before, but I put it on this new (old) laptop and am giving it a little better run this time. I still believe 9.10 (Karmic) to be a fine running distribution and this time I got to test out my method of installing all the codecs I want on there, along with messing with Grub 2 a little bit.

When you are travelling abroad where it’s legal to do so, as i was just the other day, you might want to have access to all those codecs that make life worth living on a linux box. Things like listening to your mp3s and watching your dvds and miscellaneous media files are very dificult without them.

I realise that Ubuntu has, for some time now, been able to detect that you need so and so codec to play so and so media and ask you if you really want it installed, but I find that particularly irritating. I like to already have that functionality there when I want to use it. To do that, I have a little script that I use that generally takes care of that for me, along with installing most of the programs I need to make my day to day use hassle free.

#!/bin/bash
sudo wget http://www.medibuntu.org/sources.list.d/karmic.list -O /etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
sudo apt-get install mozilla-thunderbird php5-common php5-cli php-pear subversion openssh-server clusterssh imagemagick vim synergy smbfs curl vlc libdvdcss2 ubuntu-restricted-extras w32codecs mplayer mencoder build-essential sqlite dia expect mysql-client

Feel free to modify and use this, but basically I derived this from paying attention to the programs I need and use and making a list. It really does save a lot of time to do this.

The other thing I wanted to mention is Grub 2. For some reason, someone decided it was time to move from the original Grub to Grub 2. Time alone will tell whether that was a smart move or not. I know I certainly had a tough time of it for a day or two. Everything has moved and the methodology has changed as well. The short of it is you have some config files in /etc/grub.d that you can now manipulate, along with issuing a “update-grub”, that will build your /boot/grub/grub.cfg, which is pretty much the equivalent of the old /boot/grub/menu.lst file. The fun part is figuring out how all this works because, as it happens with open source many times, the documentation sucks.

What I needed to do was to add another linux distribution to grub so I could dual (or multi) boot it. This is accomplished in that /etc/grub.d directory. Now it’s worth mentioning here that if you do multiple OS installs on your machine and just issue a “update-grub” on your base Grub 2 enabled OS, it will (or at least mine did) auto detect this installation by default and add a boot option for it into the grub boot menu. The problem is, like mine, it probaly won’t boot your other OS.

The way to fix this is to go into /etc/grub.d and “chmod -x 30_os-prober”. After that you won’t be auto-genning entries. Next you can make a copy of the 40_custom file (I named mine 41_centos) and edit that file to have the correct boot parameters to boot your other OS. This is especially fun without having a good grasp of the correct syntax. For instance it took me hours to figure out that the “kernel” line that the old Grub used has been replaced with a “linux” line now. Other than that, though, just make sure that if you are booting another linux to use the correct root label and kernel and initrd image names and locations. My correct and working CentOS entry looks like this for reference:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the ‘exec tail’ line above.
menuentry “CentOS 5.4″ {
set root=(hd0,3)
linux /boot/vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-164.el5.img
}

Have fun!

Written by linc

December 1st, 2009 at 5:00 am

News : Memepress (Yahoo! Meme) WordPress Plugin Version 0.3 is available

without comments

Memepress (Yahoo! Meme) Wordpress Plugin

Memepress is a wordpress plugin which provides wordpress widgets for displaying public posts from Yahoo! Meme. Memepress is SEO ready and provides options to noindex/nofollow your Meme posts. New version fixes a few bugs and provides enhanced style control for the widget.

You can download memepress version 0.3 from wordpress plugin page.

For details on usage/installation instructions, please check plugin homepage.

Related Posts

Fedora Tutorials and Videocache by Kulbir Saini.


Written by Kulbir Saini

November 6th, 2009 at 11:30 am

Memepress Ready to be Translated (Supports Turkish now)

without comments

Yahoo Meme Memepress Wordpress Plugin

Thanks for an awesome response to the Memepress (Yahoo! Meme) Wordpress plugin. A lot of people have blogged about it and contacted me via email for enhancements. New version also fixes the bug regarding image size in posts. I have also updated the plugin to support internationalization(i18n). Now you can translate about 20 strings in your local language and you’ll have Memepress in your own language.

Turkish Translation

Huge thanks to Yalçın Erdemir for translating the plugin to Turkish :)

How To Translate

If you are interested in translating Memepress plugin in your language, then download the memepress.pot (POT file) and open it in your favourite text editor. Now for every string against msgid should be translated to your language and populated in quotes against msgstr. See the example below.

Before translation

#: memepress.php:37
msgid "Title"
msgstr ""

After translation

#: memepress.php:37
msgid "Title"
msgstr "_WHATEVER_TITLE_IS_WRITTEN_AS_IN_YOUR_LANGUAGE_"

Once you are done with translating all the strings, save the file and mail me at kulbirsaini25 [AT] gmail.com .

Related Posts

Fedora Tutorials and Videocache by Kulbir Saini.


QPasm 1.1 RC1

without comments

The last few days I’ve been improving the small pseudo-assembler interpreter/IDE that I had created. I am quite happy with the result.

The new version of QPasm has the following new features:

  • Code editor with intelligent syntax highlighting, line numbering, visual breakpoints and undo/redo functionality
  • Debugging features: breakpoints, manual step, timed step, pausing
  • On-the-fly editing of data in the register or the memory
  • On-the-fly symbol resolving: labels can be used in assembler apps, and when modifying memory when the program is running the labels are resolved automatically
  • Integrates well with light and dark system themes. Highlighter chooses its color theme based on the darkness of the theme automatically, but colors and fonts can be configured manually as well
  • Layout, font and color settings are stored locally in a portable config.ini file
  • Input format is very flexible: white space may occur before, after and between instructions, instructions are case insensitive, comments are supported anywhere
  • Pseudo-assembler apps which are run using the run-function run in a separate thread which has a system preventing the GUI from freezing by limiting the amount of simultaneous signals to the GUI. Assembler apps which cause an endless loop cannot freeze the GUI

More information, binaries and source code are available at http://code.google.com/p/qpasm/

Written by Wesley

September 9th, 2009 at 3:11 pm