Showing posts with label blogging. Show all posts
Showing posts with label blogging. Show all posts

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!

Wednesday, 26 November 2008

Youtube karaoke

Ok - here's how to do karaoke to your favourite video track, and publish the results on your blog

First, you need to get the video. Youtube will have it, guaranteed. There's a neat little linux package you can install to download youtube videos:

$ sudo apt-get install youtube-dl

Then go to youtube, and find the url. I chose 'people everyday' by arrested development - an oldy, but a classic, and its something I knew the words to. Then get it:

$ youtube-dl http://uk.youtube.com/watch?v=r9OjoPskf_c

It will download a 'flv' (flash) format video called the last part of the url - in this case 'r9OjoPskf_c.flv'

This next part isn't strictly necessary, but for ease of future access you may want to rename it, and also get it into some format understood by pretty much everything, e.g:

$ ffmpeg -i r9OjoPskf_c.flv people_everyday.avi

Then you need to record your soundtrack. I found the easiest way to do this was to use a linux tool called 'sound recorder'. Applications - Sound/Video - Sound Recorder. just open a new file and press record - simple!

Oh, but its a good idea to open your video exactly when you press 'record' - to get background and timings

Then when you finish press 'stop'. save it - e.g. 'people_everyday.mp3'

Then use mencoder to mux the mp3 and avi file together, like so:

$ mencoder people_everyday.avi -o output.avi -ovc copy -oac copy -audiofile people_everyday.mp3

Your output file 'output.avi' is ready to go onto your blog - like so!

Happy thanksgiving!

Sunday, 23 November 2008

Fourier transform of an identity matrix

... and how to get your matlab plots into animated gifs, and into your blog!

I noted the other day that the fast fourier transform of an identity matrix can look really cool when plotted, and that stringing matrices of increasing size along in an animation looked really cool.

So when it came to sharing it this morning I came across a little fault in blogger which means that you can't directly load animated .gif files into your blog posts. The solution is to upload your image onto the web, get the html for the link, and embed that into your blog post. I used Tinypic - uploaded the image, and embedded the html code here:

Image and video hosting by TinyPic


Here's the matlab code for the animation

>> 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
>> saveas(gcf, sprintf('frame%d', 1000+cf), 'jpg') %save the current frame as a jpg
>> end

This next bit of code tells the operating system (the bang command, !) to use the unix program 'convert' to make an animated gif out of all of those frames (i've set it to compress and downsize by half to save on file space)

>> !convert -antialias -loop 1000 -delay 5 -geometry 50% -compress LZW frame10* ffteye.gif

Gif creation is my new favourite toy - watch out Daily Daniel!

Saturday, 15 November 2008

LaTeX equations in Blogger posts

Originally posted in The Daily Daniel
___________________________


Well, I know you are burning to know this one (!) Fetch the code directly from CodeCogs site and use in your website following this link

It uses beautiful

typesetting to create an image, which you embed in your blog posting. For example, the continuity equation for water waves:



Voila! Hope that's clear

CodeCogs - An Open Source Numerical Library