Sunday, December 09, 2012

Running a Script in a Loop without Cron

There are times when using cron is an over kill for a small task so it makes sense to whip up a small script and use one of the many system commands to repeatedly call it in a loop. BTW, if you have a better way of accomplishing this, I would like you to share it.

That said, here's is an example. I wanted to perform a copy task every 12 minutes whilst working on a sample project. One quick option is to use the watch command - but if you find yourself requiring more cycle then a while loop would also help. But for now, this seems to get the job done. Not the best... hey, but it did  what I required

while [ 1 ]
do
  cp source dest
  sleep 12
done
Surprisingly, this worked quite well allowing me to take control of the script an its execution without resorting to the cron system. Nice and handy tip.

Now over to you - how would you run a script every specified minutes without using cron. Please post your thoughts in the comments.

On a totally different topic: I just finished my second Twitter app for another client. That brings together a total of 5 custom apps I've developed for private clients in the last 2 years. 

This last one took me less than a day to finish it. They wanted a specific feature which was the only thing that took me a bit of backwards and forward to finally finish. So, this weekend I did quite a bit more than I wanted, and I'm pleased with myself.

Friday, November 09, 2012

oDesk Making Freelancing Easier

We all like it when companies pay you for doing what you do everyday. This is what oDesk. is doing lately. They have changed the way their freelancing process works - which means you can now pick more than 5 jobs at a time. These are good paying tasks that any self-respecting software person out there can do.

The even have videos to show you how to get started. I thought I should post it here because in the last couple of weeks, I've been seeing lots of traffic to this blog - all looking for information on getting started with oDesk.

If however, you already know how their new system works, you may also want to check out Hubpages as well. I've only spent a few months on and off getting to know the site well.

Which ever works for you, please leave a comment below and would like to know your thoughts.

Anyway, I recently got a notification that 21st Century C has been released. As a former C programmer, I thought I should get a copy.

This book is ok, it does not present any thing new other than talk about different approach you could take today to solve the problems you had decades ago. C has not changed, but programming techniques, technology and design patterns have evolved - so that's basically what this book is all about. One thing though that this book has going for it is the POSIX standard that its used through out.

So, if you are looking to brush up your C experience, you might find this book quite useful. And writing C code that is portable across many different platforms will not be an issue because this book focuses on standard C.

Sunday, November 04, 2012

Simple XML Processing with DOM and SAX

It's been a while since I last had any need to process XML on the browser. Most of my processing of late has been on the server side which takes care of all the necessary work.

So, this evening, it was nice when I one of the Django application I have been working on required a fair amount of XML processing. In an effort to move some of the load to the client, I have decided that some of the job should only be performed when the require it.

What the application does is that it uses Geo and IP-mapping to detect where the visitor is and then provide them with the appropriate XML. The next stage is to  process that XML. So, to give you a very simple of how that XML is processed, I have included here both the XML and the DOM script for it.
 var doc = null;

function loadXML() {
    doc = document.getElementById("XMLIsland")
}

function DoIt() {
   var output = ""
   var records = doc.documentElement.childNodes;
   for ( var i = 0; i < records.length; i++ ) {
      townName = records.item(i).firstChild.firstChild.nodeValue;
      tempValue = records.item(i).lastChild.firstChild.nodeValue;
      output += "
Temperature in " + townName + " is " + tempValue;
   }
   document.getElementById("output").innerHTML = output;
}
I'm not sure why blogger is deciding to strip out all the formatting in my code above. But will fix it and try to show the code in full. It would be nice to show how you too could move some of your backend processing to the client.

As it turned out, the stripping of HTML tags is also happening o my JRoller page as well - where I originally attempted to post this blog.

Will update it when I find a solution.

Sunday, August 19, 2012

Updated My Twitter Script Today To Run In Python

Sunday evening and not much to watch on the telly, so I thought I should go back to a few of the Java programs I wrote years ago and bring them into the 21st century. Wel, if you are not currently programming in Python or Django, I consider that as someone who is still hiding in a cave in the 20th century :-)

So, what better way to bring them up to date than to give then a full rewrite in Python. For me, the flexibility, syntax and power of Python is what really made me rewrite it. I love Python - having used it on many projects in the last few years, it's quite easy for me to introduce new developers into programming with Python.

However, today, the Java program I rewrote today was a Twitter program that ran from a shell. Taking search input from the user, connects to remotely to Twitter website, and collect the 10 most recent tweets containing the terms. It then goes ahead and prints the time, user name, the tweet containing our search term.

Today I added a few more features. It's now possible to configure it run continuously using your keyword, when a new tweet comes in containing the keyword, it can either send them a reply tweet, send you an SMS, email you or simply log all the tweets into a database which you can later analyse.

The cool thing about the latest script is that everything is run from a shell. Supply the necessary parameters and away you go. I got these ideas from oDesk when I used to take on on the side programming gig there. So, if you have a few hours in the evenings and on weekends, check them out for some cool and exciting quick programming task.

If anyone wants to poke around the code and probably help in polishing is a bit more or add new features, please let me know.

Now, I'm going for a Sunday evening bike ride I've been indoors since Friday night.

Sunday, August 05, 2012

How To Check Your Django Version In Ubuntu

If you have been working with Django for sometime, you will have noticed how fast the framework development has been going. So, once in a while you need to check that you are not using a very old version.

It is quite easy to upgrade, but believe me, some people never bother at all. There are different reason for not upgrading, - either you have some production code that rely on specific packages in that version - and upgrading means that you will need to rewrite all those code, or you are simply just too lazy to do it.

But if however, you want to know what version is running on your server, simply running this command should do the trick.

helen@helen-server:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import django
>>> django.get_version()
'1.4'
>>>

As you can see from the output above, our current version is 1.4, which at the time of this blog post was the latest version.

If you see that your version is a bit older, then simply upgrade by using this command.
This is best simply because it is short and easy to remember for beginners out there.
% sudo apt-get upgrade django


Enter your root password and the upgrade will commence.

On a different note though:

This is for starters - but if you are interested, then see the Free GitHub Tutorial Videos here. But please mind the photos of the naked ladies :) You might also want to check oDesk as for freelancing opportunity if you have free time and would like to earn yourself some income in the process.

You may want to make some cool cash right now as a developer on oDesk simply by helping people with the programming problems. If Java is not your thing, then check out Python or any other programming languages.

Update: it is interesting that since 2012 when this post was first published here, a number of people have found it useful enough that the amount of traffic to this post is fourth on the list of the highest read post on this blog. It goes to show that even a small tip on how to accomplish something can be quite useful.

I guess you can also check the version of your installed Django on any platform with the command above - it doesn't necessarily have to only be on Ubuntu. I was primarily working on Ubuntu back then when this post was written so simply checking your Django version on any platform should work regardless.

Sunday, July 01, 2012

How to Discover Your Linux Configuration

Ok, it has been a while since I posted something here. Been busy with stuff that I will be writing about later, they are mostly programming related stuff. All those weekend projects and small time affiliate marketing stints.

I have also written my response to this post for which I will post later this evening. But until then, I just wanted to show you a small Linux tip for those who use Linux for hosting for as their desktop.

This particular tip is quite handy if you've ever wanted to know more about the version and configuration of your Linux server.

There are a lot more commands that can do the same thing, but this very tip from Hazem Saleh is one of the best simply because it short and easy to remember for beginners out there.

cat /etc/*-release

Just fire up a terminal and enter this simple command:

This will print out your server specification. Give it a try now.

Thursday, May 03, 2012

Free GitHub Tutorial Videos

I know this is a little late, but I was going through some of the videos I saved on my iPad and thought I should post the links here. By the way I'm writing this on my shiny new iPad to see how it works with Blogger. Will leave a full blog post on that till some other time. If you are interested, please see some of the links to the right on some reviews posted by my boyfriend.

Anyway, here's the links - save or bookmark it for any upcoming events. A lot of people attended that last Webinar which was a great fun.

If you are new to Git and Github, you've been missing a lot. Github is the home of the world's most popular distributed revisioning system.

Update
Sorry, the link is broken so had to be removed - will fix shortly.
In the mean time you can check out these books on Git.


You can still find some videos over .
Until next time,
happy programming!

Saturday, March 17, 2012

Cracking the Coding Interview: 150 Programming Questions and Solutions - Great for prepping for CS Students

Cracking the Coding Interview: 150 Programming Questions and Solutions is NOT a coding review. However, as a Computer Engineering student, I found that it offered really awesome concept review.

I'm looking forward to getting some money together and ordering it from Amazon; a friend of mine lent me a copy of it, and I just absolutely LOVE it. I'm currently in my second round of interviews for my dream job - and honestly, this book really gave me the confidence to pull it off.

Even if you have to borrow a copy to "try" it, I seriously recommend it to all of my friends/classmates who are currently in the interview process.

My Breakdown:

Pros: Great general concept review! If you haven't coded in a while, or (like my university) you found that you didn't get much of an overview for a certain concept, then this book will show you algorithms and solutions to questions that you Need To Know. Very practical and otherwise easy to navigate.

Cons: I think it needs some sort of reference section. I realize that it isn't a reference book, but seeing as it appears to be more of an overview for what you Need To Know, I found that most of my review came from looking at the solutions in the back of the book to brush up on concepts I hadn't formally been introduced to or that I'd forgotten.

Saturday, February 18, 2012

The Start-up of You: Adapt to the Future, Invest in Yourself, and Transform Your Career

Steve Jobs once called Apple the "biggest start-up on the planet". Because of its success at systemizing disruptive innovation, it is the most scrutinized company in the world, especially by its competitors. As secretive as Apple is, there are plenty of books and articles that examine Apple's culture in great detail. So why are most companies -- especially large, established corporations -- incapable of applying these principles themselves?

I bring up this question because the first time I read this book, I was disappointed. So many of the strategies seemed so intuitive, so obvious, that I didn't feel like I had gleaned as much insight as I had hoped. But as I looked over my highlights, I realized that, like Apple's competitors, I'd missed the point.

What you need to adapt to the changing world of work aren't cheap tactics and off-the-wall ideas and quick fixes to hack your career. Often, the best ideas *do* seem obvious and familiar. But what is less obvious and less familiar and, thus, is arguably more important and more useful, is a framework or blueprint or system that makes it easier to build the habits required to consistently and sustainably implement those ideas with every decision you make, day in and day out.

The framework this book offers is this: you must think and act like you're running a start-up.

But what does that mean? Here's an example. One deceptively simple philosophy in the book is the idea of helping first -- that you should find ways to create value for others before seeking value for yourself. It's so simple and obvious that it's easy to gloss over it, and yet, it is fundamental to every successful entrepreneur or start-up in the world, because you'll never get a single customer until you solve a problem for someone.

So how does one apply this philosophy? Here's what Reid does: whenever he gets the chance, he asks a simple question again and again and again: "How can I help?" Think about it: It sounds simple, and yet most people don't approach their careers or their relationships with this empathetic mindset. How often do you find ways to solve problems for the people around you? And if it isn't often, how do you change that? What habits does Reid have that you need to do this, too?

"The Start-up of You" will give you Reid Hoffman's -- and Silicon Valley's -- secret sauce, but it's not enough to know it, just like it isn't enough for Apple's competitors to know its philosophies. You have to understand that an entrepreneurial mindset requires different habits of thought and action. This is what the authors mean when they say you have to think and act like you're running a start-up. If you were running a start-up, how would you create a culture that instills the habits of thought and action you want your people to have?

Well, it turns out you *are* running a start-up: your career. How do you train yourself to have the habits of thought and action you need to thrive in the 21st century?

Or, put another way, what would an entrepreneur do?

Monday, February 13, 2012

Coding Bundle (jQuery, JavaScript, CSS)

This bundle includes three eBooks that will help you master the various areas of CSS, JavaScript and jQuery. Get the full hang of CSS: be it layouts, !important declarations, advanced CSS selectors, CSS specificity and inheritance, media queries or experimental CSS properties. The CSS eBook is a full compendium of advanced CSS techniques for professional Web developers.

Improve your JavaScript knowledge with valuable lessons from practice and learn your way around the new jQuery techniques. Of course, all three eBooks are available in PDF, EPUB and MobiPocket formats.

“Mastering CSS” (eBook, 365 pages)
Are you stumped by the rather sophisticated nature of CSS? Getting a grip on this still dewy technology isn’t quite as hard as you might think. Connecting the dots is easier when you have all the vital facts within reach. And that’s what “Mastering CSS” is all about. This eBook offers 15 hand-picked articles that overflow with professional advice and that reflect the deep experience of the Smashing Magazine authors you trust — authors who know exactly what they’re writing about.

Stop hiding behind cross-browser compatibility issues, and launch a counterstrike. Tame those advanced CSS selectors; learn your way around CSS3 media queries; pioneer the field of CSS3 keyframe animations. Get in the game, and learn how to use advanced CSS typography, CSS3 pseudo-classes and modern CSS layouts, while devising back-up solutions for older browsers.
Related Posts with Thumbnails