http://www.win-vector.com/blog/2009/09/survive-r/
Wednesday, September 30, 2009
Wednesday, September 16, 2009
pl/sql function to round down to nearest minute interval
create or replace function nearest_min(dt IN DATE, interval_minutes NUMBER)
return DATE
is
newdate DATE;
BEGIN
newdate := trunc(dt,'HH')+(trunc((dt-trunc(dt,'HH'))*24/(interval_minutes/60)))/(60/interval_minutes)/24;
return newdate;
END;
/
Thanks to http://www.freelists.org/post/oracle-l/Fun-with-SYSDATE-TRUNC-and-rounding,1 for the logic behind the calcuation.
Tuesday, August 25, 2009
Using Imagemagick to create an animated gif from .png files
With R, I created a series of charts, each representing a sample snapshot at a given time. I wanted to animate them, and found a wonderful command-line set of utlities called ImageMagick. I had to jump through quite a few hoops to install ImageMagick on Mac OS X (will post details if/when I get the time), but I'm glad I did.
Here's a sample session where I combine the files into an animate gif:
~/r/tmat>ls
tmat02.png tmat04.png tmat06.png tmat08.png tmat10.png tmat12.png tmat14.png tmat16.png tmat18.png tmat20.png
tmat03.png tmat05.png tmat07.png tmat09.png tmat11.png tmat13.png tmat15.png tmat17.png tmat19.png
~/r/tmat>convert -delay 20 -loop 0 * page_transition.gif
Here's a sample session where I combine the files into an animate gif:
~/r/tmat>ls
tmat02.png tmat04.png tmat06.png tmat08.png tmat10.png tmat12.png tmat14.png tmat16.png tmat18.png tmat20.png
tmat03.png tmat05.png tmat07.png tmat09.png tmat11.png tmat13.png tmat15.png tmat17.png tmat19.png
~/r/tmat>convert -delay 20 -loop 0 * page_transition.gif
Thursday, July 23, 2009
pig on hadoop: count all rows
pt = LOAD 'data'
B = GROUP pt ALL;
C = FOREACH B GENERATE COUNT(pt);
DUMP C;
actionscript 3: dynamically add attribute to xml element
pf is an XML object, cols is an array of attribute values, and headers is an array of attribute names.
The @[variable name] syntax works the magic.
The @[variable name] syntax works the magic.
for(var cn:int=0;cn<cols.length;cn++){
var col_name:String = headers[cn];
pf.ROW[rn-1].@[col_name]=cols[cn];
}
Subscribe to:
Posts (Atom)