Sunday, November 24, 2013

Edit Webpages in Google Chrome

  • Open DevTools (View page elements Ctrl+Shift+I).
  • Open Elements panel.
  • Select html or body or another element you want.
  • Open console by Esc.
  • Type $0.contentEditable = true
The edits are not permanent. However, useful to get insights into the webpage construction. Another useful tool is too see the webpage in 3D (in Firefox).

Friday, November 22, 2013

Mention Directory/Filename as 02 format

x = 3;

modisFold =  (sprintf('MODIS_july_%02.f/',x))

will result into 'MODIS_july_03/'.

This is a nice trick using sprintf as it avoids need to do for loop like I used to for date<10.

Thursday, November 14, 2013

Save Matlab Figure png same as screen appearance with annotation box

Problem: When I save matlab figures, the plots are saved distorted.
% Get screen size

scrsz = get(0,'ScreenSize');
h = figure('Position',[1 scrsz(4)/2 scrsz(3) scrsz(4)/2]);  % set figure size wrto screen size
% Position is set as  [left bottom width height]
% This is for setting fig size

h1= subplot(1,3,1);

% annotation box
p1 = get(h1,'Position');
t1 = get(h1,'TightInset');
x1 = p1(1)+t1(1); y1 = p1(4)-p1(1);
t = sprintf('R = %0.4f \ny = %0.2f + %0.2fx\nN = %i\nRMSE = %0.2f',g(1,2),p(1,2),p(1,1),length(outputs),RMSE);
% yes, I had few stuffs going on in there.  R, y=mx+c, Number of data, and RMSE
% axis   square
annotation('textbox',[x1 0.7 0.30 0.20],'String',t,'FontSize',14,'FitBoxToText','on');

h2= subplot(1,3,2);

axis([0 100 0 100])
% axis   square
p1 = get(h2,'Position');
t1 = get(h2,'TightInset');

x1 = p1(1)+t1(1); y1 = p1(4); % this will fix the annotation box

% axis   square
annotation('textbox',[x1 0.7 0.30 0.20],'String',t,'FontSize',14,'FitBoxToText','on');
% one more subplot

% Get png right for saving
% Set units
set(h, 'Units', 'centimeters')
set(h, 'PaperUnits','centimeters');
pos = get(h,'Position');

% Set paper size to be same as figure size
set(gcf, 'PaperSize', [pos(3) pos(4)]);

set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0 0 pos(3) pos(4)]); % yes, bottom right corner!

% Print as png figure file
print(gcf, '-dpng', [fnPRE, num2str(nneurons),'-loop',num2str(i),'ipdea',num2str(testm{numvarcase})])

Sunday, November 3, 2013

Empty that Full Swap Memory #Ubuntu

Well, I just did not like the 100% swap memory usage being shown after my process was done done done!
So I swap-offed and onned (there are no such words, but why not!).
You see that green line going from 100% to 0%. Yeah, that!

sudo swapoff -a
sudo swapon -a

Saturday, November 2, 2013

Find the number of days in given year range

% Find Number of days in an year
% This needed for finding indices to process
countindices1 = 1
year = 2005;
countdays = 0;
while year<= 2010
   disp(['year', num2str(year)]) 
    countdays = countdays+yeardays(year);

    disp(['starts@', num2str(countindices1)])
        disp(['ends@', num2str(countdays)])
        array= [countindices1:countdays];
        whos array
    countindices1 = countdays+1;
         year = year+1;
disp(['totaldays = ',num2str(countdays)])