Special web hosting offer - LIMITED TIME ONLY

May 13
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

There are times - many in fact - when I need to find a file, or multiple files containing a particular string. For example, I’m developing a web application, and need to find out which pages call a particular class method, say, all the files which call the getTopTenCDs() method - I can do this by opening a Terminal, and running grep (Global Regular Expression Print), with a couple of options:

grep -r -n 'getTopTenCDs()' /var/www/cdcollection/*

This will return a list of files, and the lines within those files, and the line numbers containing the string ‘getTopTenCDs()’ in the directory /var/www/cdcollection/. The -n option tells grep to output the line numbers, the -r option tells grep to search recursively through the sub-directories too, and * tells it to look in all files - which can be changed to *.php etc: /var/www/cdcollection/*.php

So, the output would be something along the lines of:

/var/www/cdcollection/viewcd.php:192:   $topTen = $cd->getTopTenCDs();
/var/www/cdcollection/sidebar.php:215:   $topTen = $cd->getTopTenCDs();

If I just want a list of files without the lines containing the search string, I can use the -l option:

grep -r -l 'getTopTenCDs()' /var/www/cdcollection/*

which would simply return:

/var/www/cdcollection/viewcd.php
/var/www/cdcollection/sidebar.php

As the name implies, grep uses Regular Expressions, and therefore the search string can contain the usual RegEx operatiors: . ? * + {n} etc. RegEx is out of scope for this post I’m affraid - there are dozens of great tutorials available on RegEx, and applying RegEx to grep.

One final point about grep: if the search string begins with a hyphen (minus sign, or whatever you want to call “-”), the search string needs to be preceded with the -e option:

grep -r -e '-starts with a hyphen' /var/www/cdcollection/*

so that grep doesn’t mistake the search pattern for an option! Forget the -e option, and you’ll get:

grep: invalid option -- $
Usage: grep [OPTION]… PATTERN [FILE]…
Try `grep –help’ for more information.

Also, remember the ever useful pipe | and output to file > commands. If the list printed by grep is huge, you can simply pipe it to more:

grep -r 'getTopTenCDs()' /var/www/cdcollection/* | more

or, if you want to save it to a file to peruse later:

grep -r 'getTopTenCDs()' /var/www/cdcollection/* > ~/grep_output.txt

Always useful.

Finally, remember to take a look at the grep man page:

man grep

Which contains a world of useful information, including a wealth of options I haven’t covered.


written by Hodge \\ tags: , , ,

Apr 21
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I love Photography, and any oportunity I get, I try and take photos. I have a great camera, and living in the jungle, fantastic surroundings and photo oportunites everywhere I look. The only thing I’ve been lacking is a digital darkroom for Linux. OK, so we Linux users have GIMP, CinePaint (a fork from GIMP 1.0.4 specifically for photo/movie frame editing), and ufraw - a RAW digital image processor, along with a bunch of other great tools for image processing, but I just wanted to try something more. I’ve tried installing the trial version of Adobe Photoshop Lightroom with wine, but with no success, and as such, have continued my search for a viable Linux based digital darkroom…

A couple of days ago, I set up a makeshift studio at home so I could do a photoshoot of my wife and new baby (well, I say studio - it was in fact a couple of dark blankets I found about the house, no lighting, reflectors, or any of the expensive professional gear!). Once finished, I really wanted to process some of the better shots to send to my family, and so was determined to find something I could install and use on Linux.

Tenacity prevailed, and I finally discovered Lightcraft’s Lightzone - a Java based digital darkroom, with versions available for Mac, Windows and Linux! The Linux version is currently in Beta, but in all honesty, having used it for the past few days, I couldn’t tell. Installation is as simple as you can get - download the archive (registration is required, but it’s worth it), extract the files, enter the new directory, and run the LightZone executable:

tar -zxvf LightZone-3.4.tar.gz
cd LightZone
./Lightzone

After a dialog appears informing how many days of the trial are left, the splash screen displays as the program loads. The GUI is incredibly intuitive, and within minutes, I managed to process a couple of pictures worth sending to my family. When the application first opens, it’s a simple case of using the pane on the left to navigate to a directory containing photos. LightZone automatically generates thumbnails, and a larger preview of the chosen thumbnail with an option to edit. A single click on “Edit” brings up a whole array of processing options to play with.

After a few clicks, and mainly fumbling around the system, I managed to turn this raw image:

into a Black and White 10×8 Portrait that my Mum will love:

I’m incredibly happy with the results of a few minutes clicking and fumbling around an unfamiliar system! If this is what can be achieved by doing so, I’m really looking forward to getting my teeth into the system, and learning it’s many features - HDR (High Dynamic Range) support, Zone Systems, and many more.

Unfortunately however, I only have 9 days left on the Trial, since the Linux version is still in Beta, and therefore not available for purchase. I have no idea how much the Linux version will be when it’s finally released, but the Windows and Mac versions retail at $129.95 for the Basic version, and $199.95 for the Pro version. Unfortunately, both out of my price range for the time being (that’s a hell of a lot of money where I live!), but I’m certainly going to enjoy the Beta version while I can, and dream of when I can afford to buy the Pro version! Still, I’ll see if I can make some time to write a couple of tutorials and post them.

LightZone is a fantastic product. The only thing extra I would like to see, is a 64 Bit version.


written by Hodge \\ tags: , ,

Mar 05
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

IEs4Linux LogoI do a lot of Web Development, and try to build W3C Standards Compliant web sites - that’s why I always develop a website for Firefox first, and it’s also why I despise - with absolute passion - Micro$hite Internet Explorer (including version 7, which although is closer to following W3C’s standards than any previous version, is still crap), because I invariably have to spend twice as long as it took to design and develop the site, hacking CSS and JavaScript code to get it looking anywhere near as good as it looks in FF, in IE. That was a rather long sentence, that, had I been using M$ Word to write this, it would have probably suggested I revise and fragment it. positioniseverything.net has some great articles on IE specific CSS Bugs…

Also, as a Lnux user, and despite the fact that I have a dual boot system, I really resent having to reboot my laptop into a substandard operating system, to test my websites with a substandard web browser. Also add to this the fact that it’s a real pain in the arse to get more than one version of IE installed in XPoo. That’s where IEs4Linux comes in to play…

Admittedly, it borders on Heretic to install such dismally poor software in a Linux environment (I’m talking about IE here, not IEs4Linux!) , but for web development, it’s an unfortunately necessary evil. IEs4Linux works with Wine, and is a small set of scripts which automatically downloads and installs the IE 5.0, IE 5.5, IE 6, and with the latest beta version of IEs4Linux, IE 7 binaries. It also requires cabextract - a small application used to extract M$ Cabinet files.

I already have Wine, and cabextract installed on my Ubuntu, but if they’re not present, they are easy to install:

sudo apt-get install wine cabextract

So, I downloaded the IEs4Linux package to my ~/Documents folder - it can also be downloaded using wget:

cd ~/Documents
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-2.99.0.tar.gz

Once downloaded, I unpacked, and entered the new directory:

tar -zxvf ies4linux-2.99.0.tar.gz
cd ies4linux-2.99.0

Within the new directory is an executable, ies4linux, which if run:

./ies4linx

IEs4Linux GUIopens a GUI for installing the Internet Explorer binaries. Via the GUI, it is possible to select the IE versions to install (for IE 7, the option is in the Advanced section), along with the Adobe Flash plugin, and also the option to install Desktop and Menu icons/shortcuts. Unfortunately, I ran into a couple of problems running the GUI, and IE didn’t install correctly. Thankfully, however, it is also possible to run the ies4linux executable with command line options, and bypass the GUI all together, with the –no-gui flag. Now, since I didn’t have the GUI to select the extra options, I had to set a bunch of other flags to install everything I wanted, including IE 5.0, 5.5, 7, core fonts, and no desktop shortcuts:

./ies4linux --no-gui --install-ie55 --install-ie5 --beta-install-ie7 --no-desktop-icon --install-corefonts

IE 6 and Adobe Flash are installed by default, but can be switched off with the –no-ie6 and –no-flash respectively. Running ./ies4linux –full-help displays a list of all the options available.

I actually had to run the script a couple of times, since the downloads from the M$ servers timed out, but the script detects what’s already been downloaded, and continues as necessary. Other than that, it was a simple, painless process! I now have IE 5.0, 5.5, 6 and 7 polluting my system, which can be accessed via the menu Applications -> Internet -> IE. The only thing I’ve noticed so far, is that IE 7 is a little clunky and slow, and the Adobe Flash plugin doesn’t always work with IE 7, but other than that, it works well. For IE…

Now, I only wish there was an easier way to get a Standards Compliant website code to work in IE…


written by Hodge \\ tags: , , , , , , ,

Feb 23
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

There are some great posts in forums and other blogs about getting the Broadcom 43xx Wireless card working in Ubuntu, which really helped me get on the right road to setting mine up (see the end of this post). However, I’m running 64 Bit Ubuntu on my Acer Aspire 5052, so I had a little trouble finding the correct Windozzze drivers to use with ndiswrapper. The drivers can be downloaded from this post, if anyone needs them - Broadcom 43xx Windows 64 Bit drivers.

This is the method I used to get my Wireless up and running, which is a combination of a few different posts:

First, open a terminal window (Applications -> Accessories -> Terminal), then run:
lspci | grep Broadcom
You should see something along the lines of:
08:04.0 Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)
If you don’t, stop reading now! If you do, then continue…

Download the drivers and extract them to your Desktop, or wherever you want:
tar -zxvf broadcom-64bit-win-drivers.tar.gz
You should now have two files extracted - bcmwl5.inf and bcmwl564.sys. If your Wireless was recognised by Ubuntu when it was first installed, but is simply not working, then it needs to be blacklisted, so that ndiswrapper can take over. Open the /etc/modprobe.d/blacklist file:
gksu gedit /etc/modprobe.d/blacklist
I added “blacklist bcm43xx” to the end of the file:
# blacklist bcm43xx wifi driver, and use ndiswrapper instead
blacklist bcm43xx

Now save the file, and reboot. Open a terminal window again, and cd to the directory where the extracted driver files are - e.g.:
cd ~/Desktop/wireless
If ndiswrapper isn’t installed, run the Synaptic Package Manager (Stsyem -> Administration -> Synaptic Package Manager) and search for “ndiswrapper”. Install ndiswrapper-common and ndiswrapper-utils-x.x (where x is the version number). Go back to the terminal window to install the new driver, and type:
sudo ndiswrapper –i bcmwl5.inf
sudo ndiswrapper –m

Then, edit the /etc/modules file:
gksu gedit /etc/modules
Add:
ndiswrapper
to the bottom, and press “Enter” to add a new line. Save the file, and reboot! The Wireless card should be working, and should be able to connect to a wireless network.

If removal of the driver is required, you can run:
sudo ndiswrapper –e bcmwl5
Then, delete the entry from /etc/modules:
gksu gedit /etc/modules
Delete “ndiswrapper” and save… and un-blacklist the bcm43xx driver in /etc/modprobe.d/blacklist:
gksu gedit /etc/modprobe.d/blacklist
Delete “blacklist bcm43xx”, save and reboot.

Hope that helps somebody!

References:

Broadcom 4318 Using NdisWrapper, posted by brainwrecked-tech @ ubuntuforums
HOWTO: Broadcom 4318 Wireless Cards, posted by compwiz18 @ ubuntuforums


written by Hodge \\ tags: , , , , , , , , , ,

Webloogle Blog Directory