Archiving Perl PHP RUBY Scripts to Evernote using File Auto Import and Some Perl Scripting
Archiving Perl PHP RUBY Scripts to Evernote using File Auto Import and Some Perl Scripting
Today Evernote released a new version which added the ability to drag and drop pictures or text files directly to evernote.
For a while I’ve been thinking about putting all my perl scripts in evernote, but was not in the mood to
[…]
Monitor GMAIL Account Activity Using Perl
As recently noted over at my favorite website lifehacker.com…Google has recently added a nice feature to GMAIL that allows you to see your account activity.
If you scroll to the bottom of you Inbox, you will see something that looks like this.
This really got me thinking. This is a great feature, however its lacking in a few areas.
1) I’d like to know when suspicious activity is occuring. Although the likelyhood is low (that someone is trying to hack in…at least I think), I’d still like to have alerts that tell me there is an issue.
2) I’d also like tracking details in case there is an issue, I can try to figure out who it is,and where they are coming from. Actually, when I first looked at this, I noticed someone or somethign was hitting me from 67.228.182.163. Using my technical efficentcies…I was able to track it back to Xoopit. Another service I found over at lifehacker.com.
The process was basically taking the IP in the activity window and doing a whois lookup. The problem is that the whois, generally returns the ISP. However, luckily there was an RWHOIS available. That pointed me to Xoopit!
Well, from here I decided to write a script that will run every 30 mins, Alert me if something looks suspicious.
It does the following.
1) Logs into Gmail.
2) Pulls up Account Activity Page
3) Parses Page.
4) If IP is not in the whitelist…
a. does a Whois Loopup on the IP
b. generates
5) If the count of suspicious IP’s is > 0. Sends and email using Gmail as SMTP server to whomever cares to know.
HERE IS THE CODE: Use it as you wish. If you have issues or like it, please leave comments.
#!c:\\perl\\bin
#use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::TableExtract;
use Net::Whois::IP qw(whoisip_query);
use chilkat;
our $count = 0;
my %Whitelist =
(
‘67.228.182.163′ => ‘Xoopit’,
‘ip.ip.ip.ip’ => ‘Work’
);
my $capture = GetGoogleActivity();
my $HTML = ParseActivity($capture);
print "Count = $count\n";
if ($count > 0) {
DoEmail("GMAIL: Possible Suspicious Activity", $HTML);
}
sub GetGoogleActivity {
###go to login page and login.
my $url = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1k96igf4806cy<mpl=default<mplcache=2&hl=en";
my $username = "someone@gmail.com";
my $password = "password";
my $mech = […]
Bypass Proxy with a Perl and Firefox Hack
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 […]
Perl Stochastic Math::Business::Stochastic
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 […]
Yahoo Stock Screening Using Perl
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 […]
Using WordPress::XMLRPC Perl Module for posting to a Wordpress Blog
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 […]
Login To Google Using Perl
In this case I was particularly interested in logging in, so that I could programmatically download my Financial Portfolios, to see information the way I’d like it. I though about building my own database, but why? Google does a fantastic job of doing this for me, and as long as I can grab it with […]
Parse A CSV String Using Perl
Parsing a CSV file with perl is probably one of the simpler thing’s you’ll have to do in life. You could use something as simple as
my @line = split(/,/,$somedata);
Or even simpler, you could use the Perl Package Text::CSV, which I would recommend because if you are like me you parse financial data alot! So When […]
Perl HTML::TableExtract Table Finder Loop
This script parses a web page and prints out all of the coordinates for tables found. This should make your life easier as far as determining the location of the table you are looking to parse.
#!c:\perl\bin\perl.exe
use LWP::Simple;
use LWP::UserAgent;
use HTML::TableExtract;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
my $url = “http://www.drudgereport.com/”;
my $capture = get($url);
$depth = 0;
$count = […]
Yahoo Finance Economic Events to XML with Perl
This is a very simple script which gets yahoo economic events from the yahoo finance website and converts it to XML.
#!c:\perl\bin\perl.exe
use LWP::Simple;
use LWP::UserAgent;
use HTML::TableExtract;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
my $url = “http://biz.yahoo.com/c/e.html”;
my $capture = get($url);
#http://www.treasurydirect.gov/xml/PendingAuctions.xml
print $cgi->header(-type => ‘application/xml’); # make browser expect xml
$te = HTML::TableExtract->new( depth => 0, count => 5 );
print […]

