Friday 16 January 2009

How to read and search your blog page with the imaginative use of the 'regexp' in matlab

Just a quickie - there may be some application for this (?)

You start with your blog url:

>> url='http://thezestyblogfarmer.blogspot.com/';

read it in, then you can start searching through its contents:

>> text=urlread(url);

for example, I can list all the unix commands I have mentioned - its easy because they all start with a dollar sign

>> text_linux=regexp(text,'>\$[^<\r\n]*<','match')' which gives me the output:

'>$ sudo apt-get update<' '>$ sudo apt-get upgrade<' '>$ sudo apt-get clean<' '>$ sudo apt-get autoclean<' '>$ sudo apt-get -f install<' '>$ sudo badblocks -v /dev/sda1<' '>$ sudo aptitude install debsums<' '>$ debsums <' '>$ sudo apt-get install firestarter<' '>$ sudo apt-get install youtube-dl<' '>$ youtube-dl http://uk.youtube.com/watch?v=r9OjoPskf_c<' '>$ ffmpeg -i r9OjoPskf_c.flv people_everyday.avi<' [1x97 char] '>$ sudo su | sudo apt-get install skype<' '>$ sudo jhas -jh 837afm$^&qeiuhn>>KOUUIG4n we8f-&hcjku8hujbn ok?<' '>$ sudo su | python setup.py install<' [1x75 char] '>$ sudo dpkg -i skysentials_1.0.1-1_all.deb<' '>$ konsole<' or maybe the matlab commands which all start with 2 > signs:

>> text_matlab=regexp(text,'>\>>[^<\r\n]*<','match')'

'>>> cf=0; %current frame<' '>> for k=10:50 % identity matrix from [10,10] to [50,50]<' '>> clf;<' '>> plot(fft(eye(k))) %plot<' '>> axis equal; axis off; axis([-1 1 -1 1]); % sort out axes<' '>> pause(0.01) %take a break<' '>> cf=cf+1; %update current frame<' [1x87 char] '>> end<' [1x94 char] '>>KOUUIG4n we8f-&hcjku8hujbn ok?<' '>>> convert my_image.jpg -resize 200% my_new_image.jpg<' '>>> direc=dir([pwd,filesep,'*.','jpeg']);<' '>>> filenames={};<' '>>> [filenames{1:length(direc),1}] = deal(direc.name);<' '>>> filenames=sortrows(char(filenames{:}));<' '>>> mkdir([pwd,filesep,'james_and_the_giant_peach'])<' '>>> mkdir([pwd,filesep,'thumblina'])<' '>>> for i=1:size(filenames,1)<' '>>> system(['convert ',deblank(filenames(i,:))...<' '>>> system(['convert ',deblank(filenames(i,:))...<' '>>> end<' '>>> url='http://www.mathworks.com/moler/ncm.tar.gz';<' '>>> gunzip(url,'ncm')<' '>>> untar('ncm/ncm.tar','ncm')<' '>>> cd([pwd,filesep,'ncm'])<' '>>> [U,G]=surfer('http://www.thedailydanielblog.blogspot.com',200);<' '>>> fid=fopen('dansweb.txt','wt');<' '>>> for i=1:size(char(U),1), fprintf(fid,'%s\n',char(U(i,:))); end<' '>>> fclose(fid)<' '>>> pagerank(U,G)<' and finally how to list the websites you refer to - I can't post the code into my blog because it involves html code which blogger doesn't like - replace '>\>>' with '< [the first letter of the alphabet] href'


enjoy!

The big clean

One of the beauties of a Linux system is that it is so easy to keep current. The software's free, and it tells you automatically if there are upgrades available. I probably upgrade my ubuntu hardy heron (8.04) OS every couple of days!

It's just as easy to clean, so there isn't loads of junk lying about everywhere - a problem which just kills windows machines after a while. I've had this OS since it came out (on the 4th month of 2008, hence 8.04) so I thought it was high time to have a bit of, well considering the decent run of weather we've been having here, a spring clean

First, how to upgrade and clean up the software packages. This is a crucial step for someone like me who spends a lot of time downloading and checking out new software

$ sudo apt-get update

$ sudo apt-get upgrade (the only thing I installed was 'replacement guidance-backends' - whatever they are!)

$ sudo apt-get clean - this removes cached packages, to free up disk space

$ sudo apt-get autoclean - this deletes partially downloaded packages and various bits of computer detritus

$ sudo apt-get -f install - this does a check for packages which might have broken whilst you tried to install them

This next bit takes much longer - it checks for 'bad blocks' on your hard drive - its like the 'disk defragmenter' tool in newer versions of Windows. Basically, it checks your disk (mine is /dev/sda1 but yours might be something else - run 'fdisk' to find out) for physical defects

$ sudo badblocks -v /dev/sda1

Now I don't know about you but I have some software which crashes a lot, or just doesn't seem to work at all. Run these commands if you're worried about malicious software or corrupt pacakges

$ sudo aptitude install debsums - this will install the necessary package 'debsums'

$ debsums - this will run the check (warning - if your computer is as full as mine, this will also take a very long time - allow an hour or so)

Linux doesn't suffer heavily from internet viruses and malware/spyware, but it is known for even linux machines to become infected and it is becoming more common. So here's how to install a firewall (on ubuntu):

$ sudo apt-get install firestarter - firestarter is a fancy interface to the more general linux 'iptables' program. To see whether your firewall is configured type sudo iptables -L into a shell. If the output doesn't have a list of rows starting with 'ACCEPT', it is not configured.

Then go to System>Administration>Firestarter - follow the options easy peasy! Make sure when it first starts to select the option, under 'Preferences', 'minimise to tray on close'

The firewall will run in the background and monitor and do what it does when you're surfing the web. To activate the firewall, type 'firestarter' into a shell before you browse

Ok - cleaned, defragmented, firewalled. And drought over! Man, that was rather professional!