Greg Gannicott’s Blog


Ksh tip: Outputting Last Modified File

Posted in Technology by Greg on the September 24, 2008
Tags: , , , , , , ,

 

The following command will output the last file to be modified in the working directory:

cat `ls -lt | egrep -v ^d | tail -1 | awk ' { print $9 } '`

This command can be adapted to use commands other than ‘cat’ (eg. vi, cd, tail etc).

Why would you want to do this? Providing you are the only user using the directory, you might find you want to work on the same file. Rather than perform a ‘ls -ltr’, copy the filename and then paste it (which involves the mouse – an unnessary evil when using the command line), its good to use a set of commands that are written to work on the last updated file. I realise there are other commands around that help with this, but in the environment/shell I use at work (Ksh), these aren’t available. I have the following aliases setup in my .profile:

# VI the last modified file

alias vil='vi `ls -lt | egrep -v ^d | tail -1 | awk ' { print $9 } '`'

# Cat the last modified file

alias catl='cat `ls -lt | egrep -v ^d | tail -1 | awk ' { print $9 } '`'

# Display the last 1000 lines of the last modified file

alias taill='tail -f1000 `ls -lt |egrep -v ^d | tail -1 | awk ' { print $9 } '`'

# Change to the last modified directory

alias cdl='cd `ls -lt | grep ^d | tail -1 | awk ' { print $9 } '`'

So if I want to Vi the last modified file, I just type ‘vil’ and hit return.

These set of commands have proven to be much more useful than I first expected when writing them.

The Great Depression

Posted in Other by Greg on the September 24, 2008
Tags: ,

With all the talk of economic troubles, I thought I’d read up on what the Great Depression of the 1930s actually was.

Naturally I headed to Wikipedia. Here’s a sample of the entry. It sounds a little too familiar for my liking:

Debt is seen as one of the causes of the Great Depression, particularly in the United States. Macroeconomists including Ben Bernanke, the current chairman of the U.S. Federal Reserve Bank, have revived the debt-deflation view[citation needed] of the Great Depression originated by Arthur Cecil Pigou and Irving Fisher:[citation needed] in the 1920s, American consumers and businesses relied on cheap credit, the former to purchase consumer goods such as automobiles and furniture, and the latter for capital investment to increase production. This fueled strong short-term growth but created consumer and commercial debt. People and businesses who were deeply in debt when price deflation occurred or demand for their product decreased often risked default. Many drastically cut current spending to keep up time payments, thus lowering demand for new products. Businesses began to fail as construction work and factory orders plunged.
Massive layoffs occurred, resulting in US unemployment rates of over 25% by 1933. Banks which had financed this debt began to fail as debtors defaulted on debt and depositors attempted to withdraw their deposits en mass, triggering multiple bank runs. Government guarantees and Federal Reserve banking regulations to prevent such panics were ineffective or not used. Bank failures led to the loss of billions of dollars in assets.[citation needed] Outstanding debts became heavier, because prices and incomes fell by 20–50% but the debts remained at the same dollar amount. After the panic of 1929, and during the first 10 months of 1930, 744 US banks failed. (In all, 9,000 banks failed during the 1930s). By 1933, depositors had lost $140 billion in deposits.[8]
Bank failures snowballed as desperate bankers called in loans which the borrowers did not have time or money to repay. With future profits looking poor, capital investment and construction slowed or completely ceased. In the face of bad loans and worsening future prospects, the surviving banks became even more conservative in their lending.[8] Banks built up their capital reserves and made fewer loans, which intensified deflationary pressures. A vicious cycle developed and the downward spiral accelerated. This kind of self-aggravating process may have turned a 1930 recession into a 1933 great depression.

Where’s the Twitter Fail Whale gone?!

Posted in Technology by Greg on the September 7, 2008
Tags: , , ,

Has the “fail whale” gone for good?

Filezilla: My Kind of Update Notification

Posted in Technology by Greg on the September 4, 2008
Tags: , , , ,

I was just using Filezilla (a free FTP client – although I don’t think it has anything to do with Mozilla/Firefox) when it prompted me with a note saying a new version was available. The neat thing is, it included the change log as part of the notification. This meant I could see whether it contained any new features that made it worth me downloading.

This is a far cry from Apple where when iTunes has an update available I have to search the web and hope someone has posted the changes in a forum somewhere. When I do then download the latest version it attempts to push Safari and Quicktime on me in the process.

Google Chrome: So close!

Posted in Technology by Greg on the September 2, 2008
Tags: , , ,

Its not been available long (1 hour and 20 minutes in fact) but I’ve been giving Google’s new browser Chrome a run.

To sum up, I really like it… however its not enough to pull me away from Opera.

Credit where its due, its certainly tempting me to switch (more so than Firefox 3 did) but there are a few features its missing that prevents me from using it as my default browser:

  1. Most importantly for me, there’s no sync feature. With Opera I can add a bookmark at home and know full well that it will be available in work within the browser. Same applies to certain other functions. I just added a bookmark to Chrome and it felt like a waste of time. Daft I know, as I still get to use it at home, but its just not the same. The incentive isn’t there to get them right.
  2. The keyboard shortcuts aren’t up to scratch. I thought Google would nail this (as they’re the sort of company who puts in this attention to detail), but they’re lacking. The thing I like about Opera is the ability to navigate the web page with shift+up/down/left/right. This isn’t important to almost everyone, but I love my keyboard shortcuts. They make it so much quicker to get around at times. This is highlighted when I perform a search in Chrome. With Opera I’d hit F8, type “g <search term>”, Google would return results and I’d shift+down to the page I want. Usually the first result. With Chrome I hit F6, type “<search term>”, Google loads up with the result and then I have to reach for the mouse to choose it. Again, I don’t like reaching for the mouse if it can be helped.
  3. When you close the final tab, the whole app goes. Again, not a big deal to most, but I’ve got into the habbit of closing the final tab in Opera with Ctrl+W and the speed dial tab appears and I can start again (all without touching the mouse as well). Do the same in Chrome and the application closes. Doesn’t sound bad, but I then need to reach for the mouse to re-open it. I consider that poor design myself. It wouldn’t be so bad if you could change a setting so this doesn’t happen.

There are other minor faults as well, but they wouldn’t prevent me from using it as my default browser. For instance:

  • Certain features don’t work in Facebook (I can’t join a group for one – an Ajax issue).
  • Certain pictures don’t display on Techcrunch (the file format I guess..).
  • The ctrl+tab doesn’t work for tabs in the same way as alt+tab does for applications (as in you can go back and forth between the same two tabs (this happens correctly in other browsers). You end up cycling through them all from left to right). This isn’t the natural behavour expected, and again Google surprises me here because they’re usually good with that.
But I’d say for a first attempt, they’ve done really well. I’m that close to switching. If they could sort out the 3 niggles I highlighted, I’d switch.
So far I’ve only highlighted the negatives but its got some really good things going for it.
  • ‘Application Mode’ for certain pages. When I’m on Google Reader or Google Mail, I can choose to make it an app. What this does is (depending on your choices) add a link to the web app on your Desktop, Quick Launch and Start Menu – it even uses the .ico image as the icon. Its the little touches like that which completes things nicely. For this reason, although I may not use it as my default browser, I will likely use it for Google Mail, Google Reader, Google Docs and overtime other web apps.
  • Its fast. As a result it feels a pleasure to use.
  • The ‘default page’ is an improvement on Opera’s. Where as Opera allows you to select 9 sites for your default page (Speed Dial), Google offers your most visited ones. These are likely to be the pages you want on such a page. It also includes all your search options (more on this in a bit), recent bookmarks and recently closed tabs.
  • Chrome notices the sites you perform searches on. Do a search on Amazon and it will offer that to you on your default page (and when you start typing “amazon” into the Omnibar (Address bar))
  • Its nice to be able to drag a tab away and have it open a new window.
  • Its nice to drag a download to where you want it to go. Dragging is good. It feels natural. Natural is good. Its intuitive I guess.
  • It offers plenty of screen space for the actual web page. The tabs sit at the very top of the window (alongside the ‘red x’) with only the address bar below it. Every thing else is dedicated to the web site.
I could go on, but I think I’ll leave it at that. I’m sure the more I use it, the more faults and nice touches I’ll find. With it being a Google product I expect to see more nice touches than faults. I can imagine the Default Page and the fact it notices what you search will really come into its own after a while. If they could build that into a sync feature.. well, then I’m sold!
There are so many more things to talk about with regards to this browser. I’ve scratched the surface in terms of using it, but there’s other angles that are worth looking at if you’re an web industry obsessed geek like myself. Best place to start is Techmeme.