Import Subscriptions into Google Reader

July 3rd, 2008

 1) Go to http://www.google.com/reader (you must have a google  account)

 
2) Click Manage Subscriptions in the feeds pane as seen above.
 
3) Click the Import/Export Tab
4) Browse to the file you want to import
5) and then click Upoad
 

Greg How-To

Using Evernote and BlogJet Simplify my Wordpress Blogging!

July 2nd, 2008

Although I have been in the technology field for ~10 years, I am rather new to blogging, and am quite frustrated with how difficult is seems to be to post an entry which has a bunch of images in it. This is especially true when you are writing up a how to with screen shots and the like. I don’t want to FTP all the images up and then hard code references to them in my blog entry. That is painful, and we’ve come to far to be doing anything manually.

So what I do is the following, and uses a combination of BlogJet and Evernote.

Both have greate features, but like anything else in this world, unless google wrote it, you need 2 tools to do the job of one….so that’s what I do. Using this method streamlines image uploads in your blog and make the task of blogging absolutly painless…

*I invite you to please comment and let myself and others know a better way or the way you do handle your blogging.

HERE GOES….

The Net-Net of what happens is this:
1) Create Note In Evernote.
2) Export to HTML
3) Select all HTML page
4) Paste into BlogJog (images and text come too)
5) Publish Blog Entry using BlogJog.
 

First you must create the Note in Evernote. One of the many, many, many beauties of Evernote, is it allows to copy images, directly from the clipboard. So that when I am writing a tutorial, I can just paste everything directly into Evernote. Once your note is created….

Here are step by step instructions.

In the Evernote menu.
Note > Export
 
 
2 ) Choose your save location
 
 
3) Browse to your Save location
 
 
4) Open the Blog entry in your favorite Browser (Firefox of course)
 
 
5) CTRL-A or Edit > Select ALL (in firefox browser window)
 
 
6) Drag and Drop in BlogJet (image below in a past post pasted to BlogJet)
 
 
7) PUBLISH IT!!!!

Greg Cool Stuff, How-To

HOW TO Merge PDF files using PDFSAM

July 2nd, 2008

“PDF Split and Merge is an easy to use tool to merge and split pdf documents. Console and GUI versions are available. The GUI is written in Java Swing and it provides functions to select files and set options. It’s made over the iText library.”

You will need the Java Run Time environment installed on your PC. You may already have it it, but if not its a free download over at java.com


 
PDF SAM Home Page for downloading.
 
 
1) OPEN PDF MERGE will present the following.
 
 
Click on Merge/Extract
Then Click the Add Button
 
You will see a window like this.
 
 
Browse to the location of the PDF’s you’d like to merge.
 
Hold CTRL and Left Click the Mouse to select multiple (that’s for my mom) :)
Then Click the Open Button at the bottom
 
Should now look like this:
 
Under Destination output file: Click Browse.
 
 
Name the file in the file name field. Be sure to add the .pdf as the file extension
 
Click Open
 
Now Click RUN!
 
Should now have a file like

Greg How-To

FLEX 3 Custom Event Listener with Popup window

July 1st, 2008

Create the custom Event.

In this case I will need to pass an object along with the event.
Save the actionscript as ParseFixClickEvent.as
package modules.FIXParser.Events
{
import flash.events.Event;
 
public class ParseFixClickEvent extends Event
{
public var params:Object;
public static const PARSE:String = “parseEvent”;
public function ParseFixClickEvent(params:Object, type:String )
{
super(type);
this.params = params;
}
public override function clone():Event {      
     return new ParseFixClickEvent(params,type);
    }
public override function toString():String
  {
   return formatToString(”ParseFixClickEvent”,”type”);
  }
}
}
 
 
In my case I have a datagrid, where if I click an item in column 3, I fire an event that creates a popup window.
Here it is:
 
private function itemClickEvent( event:ListEvent ):void
{
            //loglink.visible = “true”;
            //details.visible = “true”;
            if (event.columnIndex == 2) {
            logdir = event.itemRenderer.data.rmi_ip;
            logserver = event.itemRenderer.data.Cluster_Name;
            var parseWindow:ParseFixForm = ParseFixForm(PopUpManager.createPopUp(this, ParseFixForm, true));       
        parseWindow.addEventListener(modules.FIXParser.Events.ParseFixClickEvent.PARSE,doParse);
        parseWindow.mylogdir = logdir;
        parseWindow.myserver = logserver;
        parseWindow.target = event.itemRenderer.data.CounterpartyCompID;
        parseWindow.sender = event.itemRenderer.data.CompID;
        CurrentDestination = event.itemRenderer.data.DestinationName;
       
}
 
When the event is fired from the popup, doParse is called.
 
public function doParse(e:ParseFixClickEvent):void {
var Parser:FIXParser = new FIXParser;
Parser.FixParameters = e.params;
Parser.label = CurrentDestination;
TN.addChild(Parser);
TN.selectedIndex = TN.numChildren - 1;
}

Greg FLEX

Free Windows Screen Capture Program

July 1st, 2008

Recently I’ve been trying to put some tutorials together and I needed a better application to handle my screen shots that windows PrintScreen and Alt-Print Screen. I wanted to be able to take small parts of an application without having to do an alt-PrintScreen and then edit it in my favorite image editor MS Paint  

My favorite place to search is SourceForge  

What I found was Zscreen 

Using Ctrl-Print Screen, I have the option to select part of my application and it stores it to the clipboard.

It even lets you automatically upload the image to an ftp site if you wish. Its pretty powerful as far as features, but I have not dug too deep as it was pretty easy to get what I wanted from the app with the stardard install.

I can then do with the image what I wish.

Here are some Screen shots of the Application.

 

If anyone has another option out there, please post a comment to the post.

Greg Cool Stuff

Using FireUploader to Move Files To And From Google Docs

July 1st, 2008

is is a video tutorial for using FireUploader (firefox plugin) to upload to GoogleDocs.

Greg Cool Stuff, How-To

Bypass Proxy with a Perl and Firefox Hack

June 25th, 2008

So being a developer, I rely on both my smarts and the smarts of others to get the job done.  One of the greatest ways to come up with a solution is using google to search to see how others have done similar things with code, and then crafting your own solution. The problem is many companies block blogspot, wordpress and other blogging urls thus making it impossible for you to access some of the very useful blogs out there. Luckily I run my blog off my own URL so its probably not blocked.

Well after enough frustration, I decided it was time to fix this problem. I spend 10-12hrs a day at the office, I don’t want to wait to get home to figure do my research.

I found a cgi script that acts as an http or ftp proxy from www.jmarshall.com/tools/cgiproxy/

Because I have a couple of websites up and running I had a readily available cgi-bin directory. I simply dropped the script on my server and WA-LA! I was given a form field which acted as an address bar. If I copy and pasted a blog link into this field, I was taken to the site! AWESOME!

I must mention one more thing. It actually wasn’t quite that simple. Websense was very smart at my company, and probably is at yours as well. When I first ran it, it said “Proxy Avoidence Detected!!”.

Ouch!!!!!!

Well, I obviously was not completely out of luck or I would not be writing this post…now would I?

The very simple solution which popped in my head within about 1 second of getting this error was……

You got it! Run in on a secure channel. HTTPS. This will require a certificate, but this I also already had with my ISP. So all I had to do was forward to HTTPS!

GREAT!!! I’m finally up an running!

After about a week of copying the links I found, Then visiting my https site, then pasting to the input box….I realized this was just too many steps. Ideally I’d be able to right click a link and say “OPEN WITH PROXY HACK” (and that is my next project). However, this was going to require me to learn to write a firefox extension (which i have not done yet).

So I opted for the very simple solution of adding it to my search engine drop down list on the upper right hand corner of Firefox.

Now I simply copy the link and paste it up in my search box and it forwards me to the site.

Here is the code for the FireFox Search Engine….You will just need to..
1) Edit the links.
2) Save the file as ProxyHack.xml (or whatever you’d like it to be.xml)
3) Copy the file to Path to Firefox\searchplugins
4) Restart Firefox!
5) Send me a thank you :)

Greg Perl

Perl Stochastic Math::Business::Stochastic

June 20th, 2008

I recently found a bug in the Perl Stochastic calculator which I have amended for myself and am now sharing with the world.

%D should be an xDay moving average of %K and SD should be the Moving average of %D. I have added 2 subroutines that make use of Math::Business::SMA.

I keep an array of %K values and pass it to my intializeSMA subroutine. This creates a SMA for %K based on $this->{d}. I do the same for SD. I keep an array of %D and then

keep calculate a SMA based on SD $this->{sd}.

Here is the updated Perl Module:

package Math::Business::Stochastic;

use strict;
use warnings;
use diagnostics;

our $VERSION = '0.03';
our ($kkk,@curK,@curD);
use Carp;
use List::Util qw(max min sum);

1;

sub new {
    bless {
        val  => [],
        days => 0,
    };

}

sub set_days {
    my $this = shift;
    my ($k,$d,$sd) = @_;

    croak "k must be a positive non-zero integers"  if int($k) <= 0;
    croak "d must be a positive non-zero integers"  if int($d) <= 0;
    croak "sd must be a positive non-zero integers" if int($sd) <= 0;

    $this->{k} = int($k);
    $this->{d} = int($d);
    $this->{sd} = int($sd);
    $this->{days} = int($k) + int($d) + int($sd) - 2;
	print "DAYS = " . $this->{days} . "\n";
}

sub query_k  { my $this = shift; return $this->{cur_k}; }
sub query_d  { my $this = shift; return $this->{cur_d}; }
sub query_sd { my $this = shift; return $this->{cur_sd}; }

sub insert {
    my $this = shift;
    my ($high,$low,$close) = @_;

    croak "You must set the number of days before you try to insert" if not $this->{days};
    croak "You must specify the high,low,close values" unless defined $close;
    croak "High value must be higher than low value" unless $high >= $low;
    croak "Low value must be lower than close value" unless $low <= $close;
    croak "High value must be higher than close value" unless $high >= $close;

    push @{ $this->{val_high} }, $high;
    push @{ $this->{val_low} }, $low;
    push @{ $this->{val} }, $close;

    $this->recalc;
}

sub start_with {
    my $this        = shift;
       $this->{val_high} = shift;
       $this->{val_low}  = shift;
       $this->{val}      = shift;

    croak "bad arg to start_with" unless ref($this->{val_high}) eq "ARRAY";
    croak "bad arg to start_with" unless ref($this->{val_low}) eq "ARRAY";
    croak "bad arg to start_with" unless ref($this->{val}) eq "ARRAY";
    croak "bad arg to start_with" unless @{$this->{val_high}} == @{$this->{val}};
    croak "bad arg to start_with" unless @{$this->{val_low}} == @{$this->{val}};

    $this->recalc;
}

sub recalc {
    my $this = shift;
    shift @{ $this->{val_high} } while @{ $this->{val_high} } > $this->{days};
    shift @{ $this->{val_low} } while @{ $this->{val_low} } > $this->{days};
    shift @{ $this->{val} } while @{ $this->{val} } > $this->{days};

    if( $this->{k} <= @{ $this->{val} }  ) {

        push @{ $this->{val_max} }, max( picklast($this->{k},@{$this->{val_high}}) );
        push @{ $this->{val_min} }, min( picklast($this->{k},@{$this->{val_low}}) );
        push @{ $this->{val_close_minus_min} }, $this->{val}->[-1] - $this->{val_min}->[-1];
        push @{ $this->{val_max_minus_min} }, $this->{val_max}->[-1] - $this->{val_min}->[-1];
        shift @{ $this->{val_max} } while @{ $this->{val_max} } > $this->{k};
        shift @{ $this->{val_min} } while @{ $this->{val_min} } > $this->{k};
        shift @{ $this->{val_close_minus_min} } while @{ $this->{val_close_minus_min} } > $this->{k};
        shift @{ $this->{val_max_minus_min} } while @{ $this->{val_max_minus_min} } > $this->{k};
    }
    if( $this->{k}+$this->{d}-1 <= @{ $this->{val} } ) {

	   push @{ $this->{val_d} }, sum(picklast($this->{d},@{$this->{val_close_minus_min}})) / sum(picklast($this->{d},@{$this->{val_max_minus_min}})) * 100;
        shift @{ $this->{val_d} } while @{ $this->{val_d} } > $this->{sd};
    }

    if( not defined $this->{val_max_minus_min}->[-1] or $this->{val_max_minus_min}->[-1] > 0 ) {

		if( @{ $this->{val} } == $this->{days} ) {
            $this->{cur_k}  = ($this->{val}->[-1] - $this->{val_min}->[-1]) / ($this->{val_max_minus_min}->[-1]) * 100;
			###This was added 6/20/2008 Keeps an array of %K and calculates %D as a SMA of %K then calculates Slow Stochastics using A SMA of %D
			push(@curK,$this->{cur_k});
            $this->{cur_d}  = intializeSMA($this->{d},@curK);
			push(@curD,$this->{cur_d});
			$this->{cur_sd} = intializeSMA($this->{sd},@curD);
        }
        elsif( @{ $this->{val} } >= $this->{days} - $this->{sd} + 1 ) {
            $this->{cur_k}  = ($this->{val}->[-1] - $this->{val_min}->[-1]) / ($this->{val_max_minus_min}->[-1]) * 100;
            $this->{cur_d}  = $this->{val_d}->[-1];
            $this->{cur_sd} = undef;
        }
        elsif( @{ $this->{val} } >= $this->{days} - $this->{sd} - $this->{d} + 2 ) {
            $this->{cur_k}  = ($this->{val}->[-1] - $this->{val_min}->[-1]) / ($this->{val_max_minus_min}->[-1]) * 100;
            $this->{cur_d}  = undef;
            $this->{cur_sd} = undef;
        }
        else {
            $this->{cur_k}  = undef;
            $this->{cur_d}  = undef;
            $this->{cur_sd} = undef;
        }
    }
    else {
        $this->{cur_k}  = undef;
        $this->{cur_d}  = undef;
        $this->{cur_sd} = undef;
    }
}

sub picklast {
    my $n = int(shift);
    return splice @_,-$n;
}

sub intializeSMA {
	my ($days,@values) = @_;
	my $sma = new Math::Business::SMA;
	$sma->set_days( $days );
	$sma->insert($_) for @values;
	my $ma = HandleResults($sma);
	return $ma;
}

sub HandleResults {
my ($sma) = @_;
my ($q,$value);
if( defined(my $q = $sma->query) ) {
      $value = $q;  

  } else {
      $value =  1;
  }
  return $value;
}

__END__

=head1 NAME

Math::Business::Stochastic - Perl extension for calculate stochastic oscillator

=head1 SYNOPSIS

  use Math::Business::Stochastic;

  my $stoc = new Math::Business::Stochastic;

  my ($k, $d, $sd) = (5, 3, 3);

  set_days $stoc $k, $d, $sd;

  my @high_values = qw(
      3 5 5 6 6 5 7 5 8 5 7
      8 6 8 6 8 7 8 8 9 8 9
  );
  my @low_values = qw(
      2 4 3 5 3 5 3 4 5 3 4
      4 5 6 6 6 6 6 7 7 6 7
  );
  my @close_values = qw(
      3 4 4 5 6 5 6 5 5 5 5
      6 6 6 6 7 7 7 8 8 8 8
  );

  for(my $i=0 ; $iinsert( $high_values[$i], $low_values[$i], $close_values[$i] );

      if( defined $stoc->query_k ) {
          print "Stochastic k:  ", $stoc->query_k,  "\n";
      }
      else {
          print "Stochastic k:  n/a\n";
      }
      if( defined $stoc->query_d ) {
          print "Stochastic d:  ", $stoc->query_d,  "\n";
      }
      else {
          print "Stochastic d:  n/a\n";
      }
      if( defined $stoc->query_sd ) {
          print "Stochastic sd: ", $stoc->query_sd,  "\n";
      }
      else {
          print "Stochastic sd: n/a\n";
      }
  }

  # you may use this to kick start
  $stoc->start_with( [@high_values], [@low_values], [@close_values] );

=head1 SEE ALSO

perl(1), Math::Business::MACD(3).

=head1 THANKS

Jettero Heller 

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2008 by NAGAYASU Yukinobu 

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.7 or,
at your option, any later version of Perl 5 you may have available.

=cut

Greg Perl

Yahoo Stock Screening Using Perl

June 19th, 2008

So you need to screen stocks? And you want to automate the process?
Well I have not found much out there in the “Free” world that lets you do this. Yahoo seems to be about the best screening tool especially for Trend Traders as it allows you to filter on BETA. The only thing I don’t like is it doesn’t screen for Average Daily Volume. However with the script below, you could get a list of high beta stocks and then loop through them to return AVG Daily Volume.

This script parses the Yahoo Screen page by page and returns the values sorted by BETA (descending order). If you make it better, please let me know and I can post it.

In my case I only cared about the price range and a BETA > 2. However if you create your own screen you could just hack up the URL to your liking.

#!c:\\perl\\bin
use strict;
use HTML::TableExtract;
use LWP::UserAgent::Determined;

our %STOCKBETAS = ();

###These could be changed into arguments....Set them to what you wish.
my ($minprice,$maxprice,$minbeta) = (10,50,2);

####THE SCRIPT###############
my $url = 'http://screen.yahoo.com/b?pr=' . "$minprice/" . "$maxprice" . "&beta=$minbeta" . "/&s=nm&vw=1&db=stocks&b=1";
my $capture = GetStockScreen($url);
my $count = extractCount($capture); ###gets the count of symbols from the first page of the screen (i.e showing 20 of 341 symbols);
GetSymbols($capture);

for (my $x = 20;$x <= $count; $x+=20 ) { ###Loop through pages to get stock symbols
	my $b = $x + 1;
	my $MYURL = 'http://screen.yahoo.com/b?pr=' . "$minprice/" . "$maxprice" . "&beta=$minbeta" . "/&s=nm&vw=1&db=stocks&b=" . "$b";
	$capture = GetStockScreen($MYURL);
	GetSymbols($capture);
}

###Print the Results by Beta Decending.
open(SCREEN, ">YahooStockScreen.txt");
foreach my $key (sort hashValueDescendingNum  (keys(%STOCKBETAS))) {
   print SCREEN "$key\|$STOCKBETAS{$key}\n";
}
close (SCREEN);
#END OF THE SCRIPT########################################

###Retrieve the count from the first page of the yahoo screen.
sub extractCount {
my ($capture) = @_;
my $count = 1;
my $te = HTML::TableExtract->new( depth => 0, count => 0 );
$te->parse($capture);
my $table = $te->first_table_found;
	foreach my $ts ($te->tables)
	{
		#print "Table found at ", join(',', $ts->coords), ":\n";
		foreach my $row ($ts->rows) {
			    if ($count eq 1) {
					$a = substr($row->[0],index($row->[0],"of")+3, length($row->[0]));
					$count = substr($a,0,index($a,")"));
				}
				}

	}
	return $count;
}

####Retrieve the list of symbols and Betas from yahoo page
sub GetSymbols {
my ($capture) = @_;
my @symbols = ();
my $te = HTML::TableExtract->new( depth => 1, count => 0 );
$te->parse($capture);
my $table = $te->first_table_found;
	foreach my $ts ($te->tables)
	{
		#print "Table found at ", join(',', $ts->coords), ":\n";
		foreach my $row ($ts->rows) {
				my $a = $row->[0];
				my $b = $row->[3];
				$STOCKBETAS{$a}=$b;
				print "$a,$b\n";
				}
	}
	return @symbols;
}

###go to login page and login.
sub GetStockScreen {
	my ($u) = @_;
	my $response = getURL($u);
	$capture = $response ->content;	

	return $capture;
}

###Download the URL it is passed. Uses LWP::UserAgent::Determined so its on a retry interval
sub getURL {
	my ($url) = @_;
	print "GETTING: $url\n";
	my $browser = LWP::UserAgent::Determined->new;
	$browser->timing( "10,15,20,30,30,30,30,30" ); ###get url on 10,15,20,30 second retry  intervals.
	my $response   = $browser->get($url);
	return $response;
}

####Sort the output in decending order.
sub hashValueDescendingNum  {
   $STOCKBETAS{$b} <=> $STOCKBETAS{$a};
}

Greg Finance, Perl

Using WordPress::XMLRPC Perl Module for posting to a Wordpress Blog

June 12th, 2008

The CPAN documentation for this is not entirely clear. Although you can look at the source code and try to back your way out to see what the module is expecting, this should make your life easier.

Here is a quick example of how to post to a blog. The most difficult thing was adding the category. It wants an array, but you can just pass it @categories. It has to be in brackets “[ ]“.


use WordPress::XMLRPC;

my $o = WordPress::XMLRPC->new({
username => ‘your username’,
password => ‘your password’,
proxy => ‘http://www.site.com/xmlrpc.php’,
});

$content_hashref->{title} = ‘The Title for your post’;
$content_hashref->{categories} = ['Category1','Category2'];
$content_hashref->{description} = “Here you put the content of your post”;
$o->newPost($content_hashref, 1); ### 1 is for publish. I believe its 1 by default and 0 for unpublished

You can find the module on CPAN

Greg Perl ,