Showing posts with label tinker. Show all posts
Showing posts with label tinker. Show all posts

Friday, September 26, 2008

1272: Diecimila

Finally, arduino is here after 15 days from the order( around 4 USD postal charge). Seems like postal service is not that bad after all .

For those who haven't yet been bored by my arduino references, well Diecimila is a microcontroller board with ATMega 168, and a USB Interface which makes microcontroller programming really easy. Effectively you can use Arduino as a small brain for anyTHING you want to build. The full set of functionality is available here . I hope to move on to/make Sanguino maybe in January 2009 ( around week 1285).
Though actual tinkering would require a bit of electronic minutiae purchase in my dear town. Just setting up basic infrastructure : avr-gcc , arduino ide ( :( a bit of java lurking around there, but not much of a direct issue i hope) USB Interfacing to electronic boards is really neat I guess, considering the fact that my laptop doesn't have a serial port. My megalith of a desktop does ( as an add-on), but in effect USB sounds like the future, or maybe I am already in the past with bluetooth and other wireless interfaces being the present.

For starters there is a whole set of interesting instructables at instructables.com . And well in the end there will always be reprap. But as you can see I am pretty far away from a self-replicating rapid prototyper.



If you think Diecimila sounds like a greek goddess or demon or something ( I thought so :P) well it is just 10k in Italian.

--

I really need to start coding on constraint satisfaction (brl-cad) more regularly. Very few changes since gsoc.

Saturday, August 30, 2008

1277: Tinkering with Plotrave

Maybe many of you already know about it , but arduino NG based Flexi is availabe in India from techsouls. I have given an order. Hopefully it comes in the next few days.

I have never really been a web guy and have never found web development interesting, never ventured into web-based programming? err.. whatever it is called..
Completely useless statistics though has always interested me. And when you do think about it, when is statistics really useful?
The above image was generated using google charts api, using data extracted from workrave statistics files using a perl script. As you can clearly see, I don't even know the equivalent in Perl of backslash in C. The scipt is a modification of this one, which just extracts data from the file into columns. 3 types of data are plotted and a line is drawn to denote the average computer usage. In particular, most things are hardcoded, like the date and scale . Maybe sometime later I can write a more parametric extractor.
#!/usr/bin/perl -w

use strict;
use integer;
use POSIX qw(strftime);
use Time::Local;

$ENV{'PATH'} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin";

my $timestring = "";
my $keystring = "";
my $averagestring ="";
my $average=0;
my $count=0;

sub dumpactivetime($)
{
my ($misc) = @_;

die "No misc at line $.\n" if !defined($misc);

no integer;
my $t = "@$misc{activetime}";
$count = $count + 1;
$average = $average + ($t-$average)/$count;
$timestring = $timestring.sprintf("%.2f",$t/540.0).",";
$averagestring = $averagestring.sprintf("%.2f",$average/540.0).",";
}

sub dumpkeystrokes($)
{
my ($misc) = @_;

die "No misc at line $.\n" if !defined($misc);

#my $miscstr = join(" ", @$misc{@$miscstats});
no integer;
my $t = sprintf("%.2f",@$misc{keystrokes}/1000.0);
$keystring = $keystring.$t.","
}

#
# Initialize RRD
#

my @miscstats = qw(activetime keystrokes); #mousemovement clickmovement movementtime clicks
#keystrokes);

my $step = 24 * 3600; # 24-hr steps
my $heartbeat = 4 * $step;

my (@DS);
foreach my $miscstat (@miscstats) {
push @DS, "DS:$miscstat:GAUGE:$heartbeat:0:U";
}
umask(022);

#
# Populate data
#
my $source = "$ENV{HOME}/.workrave/historystats";
my $first = 1;
my ($tmdate, $break, $misc) = (undef, undef, undef);
open(SOURCE, $source) or die "open $source: $!\n";
print "http://chart.apis.google.com/chart?cht=lc&chg=7,33.33,2,4";
print "&chxt=x,y,r,x,y,r&chxr=0,8772,8877|1,0,15|2,0,100000";
print "&chxl=3:|Day|4:|Hours|5:|Number&chxp=3,50|4,50|5,50";
print "&chco=4d89f9,008000,fd0f0f";
print "&chtt=Computer+Usage+Statistics";
print "&chts=ff9900,15";
while () {
chomp;
if (/^WorkRaveStats 4$/) {
# Ignore header
next;
} elsif (m/^D\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)
\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/x) {
if ($first) {
$first = 0;
} else {
dumpactivetime($misc);
dumpkeystrokes($misc);
}
$break = $misc = undef;
} elsif (m/^B\s+([012])\s+7
\s+(\d+)\s+(\d+)\s+(\d+)
\s+(\d+)\s+(\d+)\s+(\d+)
\s+(\d+)\s*$/x) {
next;
} elsif (m/^m\s+6\s+(\d+)\s+(\d+)\s+(\d+)
\s+([-0-9]+)\s+(\d+)\s+(\d+)\s*$/x) {
$misc = {
activetime => $1,
# mousemovement => $2,
# clickmovement => $3,
# movementtime => $4,
# clicks => $5,
keystrokes => $6,
};
} else {
die "Unrecognized line (line $.): [$_]\n";
}
}
close(SOURCE) or die "close $source: $!\n";
dumpactivetime($misc);
dumpkeystrokes($misc);
print "&chd=t:$timestring\b|$keystring\b|$averagestring\b";
no integer;
printf("&chm=r,f00000,0,%.3f,%.3f",$average/54000,$average/54000-0.002);
print "&chs=800x375&chdl=Activity|Keystrokes|Average Usage&chdlp=t\n";

--
Epilogue:

The subject (moi) is mostly a web-technology illiterate guy.

Let us substantiate the same.

Things the subject DOESN'T know : Javascript, VBScript, Java, CSS, CGI, Ruby, PHP, MySQL, AJAX etc . Beyond this, the subject is even unaware of the topic names , pointing to his complete ignorance.

The ONLY web services/technologies I use:
Mail : The subject was/is a great fan of gmx. But he mostly uses gmail via imap now. The author checks the mail approximately once a day.
IM: Jabber via talk.google.com using freetalk/gajim.
Social Networking-esque sites : Ohloh, LinkedIn
Blogging: blogger and wordpress
Games: chess.com, though active use is mostly a seasonal phenomenon.
Demonoid.com & textbooktorrents.com: The subject honestly hopes *they* don't send him to jail for this.

The subject also Passively uses
last.fm
sourceforge.net[1]


Valete
--
1. Due to the subject's involvement with open source he uses Subversion as per requirements.