Monday, June 12, 2006

Excel and php without activeX

By Justin Silverton


Spreadsheet_Excel_writer is a PEAR component for creating Excel files without the need for COM components. The files generated are in the Excel 5 (BIFF5) format, so all functionality until that version of Excel (but not beyond) should be available.


The most common use for Spreadsheet_Excel_Writer will be spitting out large (or not so large) amounts of information in the form of a spreadsheet, which is easy to manipulate with a fairly ubiquitous spreadsheet program such as Excel (or OpenOffice).

Example 1:


// Creating a worksheet
$worksheet =& $workbook-&gtaddWorksheet('My first worksheet');

// The actual data
$worksheet->write(0, 0, 'Name');
$worksheet->write(0, 1, 'Age');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 18);

// Let's send the file

The first thing you should notice, is that we created a workbook before any worksheets. All worksheets are contained within a workbook, and a workbook may contain several worksheets.

Another important thing, which you should have in mind when programming with Spreadsheet_Excel_Writer, is that ampersand sign (&) that appears when we created our worksheet. That ampersand means we are referencing a Worksheet object instead of copying it. If you don't know what that means, don't worry, all you have to remember is to always use ampersands when calling addWorksheet() for creating a worksheet, or addFormat() for creating a format.
Saving to a regular file

You may have noticed also the following line:

// sending HTTP headers

What that means is that we are sending our spreadsheet to a browser. But what if we just want to save the spreadsheet in our machine? Well, you just have to omit that line and give a valid file path to the workbook constructor.

For example, if we wanted to save the same spreadsheet we created in our first example to a file named 'test.xls', we would do it like so:

Example 2:

addWorksheet('test worksheet');

$worksheet->write(0, 0, 'Name');
$worksheet->write(0, 1, 'Age');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 10);

// We still need to explicitly close the workbook

More info and documentation on this component can be found here

Sunday, May 28, 2006

Adding friends to myspace using perl

By Justin Silverton

I came across this perl script today that allows you to add friends to your myspace account using perl.main website is HereTaken from the website: " This is a perl script, and it’s certainly rough around the edges. If you’re running on windows, there are applications available for cheap that will do the job better and with more support. I’m on Linux, so I needed a cross-platform script that did just what I needed.

That said, this little bit of code should run on any machine with the proper perl modules installed (WWW::Mechanize, HTML::TokeParser::Simple, and Text::CSV). It’s open source, released under the GPL."DownloadThe script can be found Here

How do I run this?

On Linux

If you’re running on Linux, running this code is fairly simple. Just invoke it with perl GlitchCastFriendAdder.pl

If it complains that it’s needs certainly libraries, you can add them with CPAN, apt, or yum.
To add the necessary libraries using apt on Fedora Core, Red Hat, CentOS, Debian, Ubuntu, and others, run this command as root: (package names may differ slighly across distros. If one does not appear available, search for it with apt-cache search packagename) apt-cache search mechanize
brings up libwww-mechanize-perl
apt-cache search tokeparser
brings up libhtml-tokeparser-simple-perl
apt-cache search csv-perl
brings up libtext-csv-perl
now that I’ve found the package names (I’m using ubuntu, so this exact command should work for all debian distros with universe and multiverse enabled)
apt-get install libhtml-tokeparser-simple-perl libtext-csv-perl libwww-mechanize-perl
You could of course use CPAN to install these modules instead, but I’m less familiar with that method. If you know how, please email me at GlitchCastFriendAdder A.T. GlitchNYC.com Now that you’ve got all your modules, the code should run just fine. Be sure that you’ve added at least one MySpace URL to friendPagesToScrape.txt - you’ll have to make that file if you haven’t already.

Running on a Mac

I have no idea. In theory, this should be fairly similar to the process above. If you get it to work, let me know how you did it!

Running on Windows

This should be possible using ActiveState perl. It’s been a while since I used it, but if memory serves, there is a GUI that allows you to choose the packages you need. Just select these: * WWW::Mechanize * HTML::TokeParser::Simple * Text::CSV
I’ve now had my first report of this working on windows! To get the firefox captcha routine to work, you’ll need to change the firefox executable path. This is as simple as commenting one line and uncommenting another. It’s right below the username and password at the top of the code.

Running the script

First, enter your username and password at the top of the script
Second, paste a bunch of myspace url’s containing people you want to add into the file friendPagesToScrape.txt in the same directory where the main script is.
UPDATE: The URLs should be one per line! (this is a change from version 1.0)
HINT - It’s easy to change just the “page” variable when you paste in the url’s to get multiple pages of friends of one group/person.

The script will parse that file, and then go to each page in the list, getting all the friend IDs on the page. Once it has grabbed all the friendIDs, it adds each of the friends, prompting you if it needs a captcha. I’ve tuned it to be fairly patient (1 friend added every 5 seconds or so) so as to not anger the myspace gods and incur lots of captchas, but you can tune as it runs by following the prompts if you start to get too many captchas.

Sunday, May 21, 2006

Convert your pdf files directly to html

By Justin Silverton

There is this great program I found called pdf2html. It is an opensource, free, program that will allow you to convert your pdf files directly to html.

It can be downloaded here (the win32 gui version): http://guiguy.wminds.com/downloads/pdf2htmlgui/

original sourceforge project: http://sourceforge.net/projects/pdftohtml/


The idea for this web-site was a culmination of events that began in my efforts to find a simple utility for a very specific task (I wanted to convert my rm video clips to anything else). After what seemed like months of searching, I was finally able to locate a command line utility that promised to do the trick (Tinra).

I found it in a help forum where others were asking for a graphical user interface (GUI) for it. I decided to make TinraGUI as a way of showing thanks to the group for helping me find what I was after. I soon discovered, however, that I couldn't attach the program I made to my reply on the forum, so I needed a web-site to host it. I put up a quick site at Tripod for the purpose. But when it seemed that it was going to be more popular than I first thought, I imagined a web-site like this one where I could make simple Windows programs and GUI's for people on request and for free.


I personally found this tool to be very helpful. I was able to convert nearly all of my .pdf files to web pages with almost no errors or mistakes.

Wednesday, May 17, 2006

Connecting to Authorize.net with PHP

By Justin Silverton

What is authorize.net?

The Authorize.Net Payment Gateway is a secure Internet bridge between merchant businesses and the credit card and electronic check payment processing networks. We provide merchants with fast, reliable and secure passage for transaction data via a 128-bit Secure Sockets Layer (SSL) Internet Protocol (IP) connection, and manage the complex routing of payment information to the appropriate credit card processors. See a diagram that illustrates a typical Authorize.Net credit card transaction.

The Authorize.Net Payment Gateway is available to merchants seven days a week, 24 hours a day. The payment gateway offers many features and options that can be tailored to specific merchant business models.

Where do I start?

The first thing that you need to do, is signup with a test account. This will allow you to test out transactions to make sure your scripts are interfacing properly with their API. Here is the URL for getting your account:


API documentation can also be found here:


after signing up, you should receive your new account info within 48 hours.

The Code

I have a library available here: (URL). It is originally written by Micah Carrick and is under the GPL/GNU public license. I have made some important additions to the main library, which are needed for it to function properly.

you can get it here: http://www.electronicfiles.net/files/1773/authorize_lib.zip

Requirements: PHP version 4 and above with the CURL extensions enabled

The following 3 files are contained in the above .zip download:

authorizenet.class.php - main class library for connecting to the authorize.net gateway
demo.php - an example driver file that shows how to use the library file. A test transaction is made to the main gateway.
ca-bundle.crt - main certificate file required by CURL for SSL transactions (windows users can place this in c:\windows\system32)

Important Variables that you need to change

Location: authorizenet.class.php

curl_setopt ($ch, CURLOPT_CAINFO,"c:\\windows\\system32\\ca-bundle.crt");
curl_setopt ($ch,CURLOPT_CAPATH,"c:\\windows\\system32\\ca-bundle.crt");

change the 3rd parameter "c:\\windows\\system32\\ca-bundle.crt" to the location of your CRT file.

Location: authorizenet.class.php

var $gateway_url = "https://test.authorize.net/gateway/transact.dll";

it currently points to the authorize.net gateway for test accounts. If you have an account that is performing real transactions, change this variable to the following value: ""https://secure.authorize.net/gateway/transact.dll"

Location: demo.php

$a->add_field('x_login', 'YOUR_USERID');
$a->add_field('x_password', 'YOUR_PASSWORD');

change x_login to your Login ID (not partner ID)
and x_password to your password

You should have received both of these in an email from authorize.net

Sunday, May 14, 2006

An Excel Killer

By Justin Silverton

I came across this ajax application today called ajaxXLS. It's an ajax execl application that can read and write excel files. It is one of the best ajax apps I have seen to date and displays the power and capability of AJAX.


On this first release of the ajaxXLS viewer, you can expect to open spreadsheet files with all your common cell formatting categories such as text style, decimals, currencies, date, and time. ajaxXLS will preserve your formulas, backgrounds and borders from the files created in Microsoft Excel or OpenOffice. ajaxXLS is platform independent and can be used with any operating system. Unlike typical office programs that you install on your computer, features will continue to be added to ajaxXLS and made available to you immediately without the need for complicated reinstallation or reconfiguration of software. Try ajaxXLS today and see for yourself how AJAX applications are redefining the way you use software.

With this release, we're publishing the methodology whereby any search engine, email client or other software developer can provide a link to an existing .xls document (hosted online) so that anyone can open it using ajaxXLS. See for yourself how a spreadsheet document can be launched right from my web page by clicking on this sample revenue.xls.To obtain the code to create a link on your website that opens any spreadsheet in ajaxXLS, please click here.

Redefining Software

AJAX programming techniques allow web-based software to function smoothly without the waiting around for page uploads that you normally associate with the Internet. The benefits of web-based software are so compelling, we feel that they are the future of the industry. These benefits include:

  • Global access, all you need is an internet connection
  • Platform independent, you can use it with any operating system
  • Automatic updates and upgrades, no more computer restarts or missed patches/updates
  • Server side management — all the busywork is done for you

AjaxXLS is just a small step forward in this software revolution, and we are proud to be a part of it.

Test it out for yourself

To test it out, go here (it requires FireFox): http://www.ajaxlaunch.com/ajaxxls/internals/ajaxxls-nojscript.html

Saturday, May 13, 2006

mysql vs postgres

By Justin Silverton

postgres/mysql comparison chart

FeatureMysql 3.xMysql 4.0Mysql 5.xPostgres 7.x
Foreign Key RelationshipsNoYesYesYes
Foreign Key ConstraintsNoNoYesYes
Indexing (non-trivial types)NoNoYesYes
Table InheritanceNoNoNoYes
Async. NotificationsNoNoNoYes
Select IntoNoYesYesYes
Stored ProceduresNoNoYesYes
Row-Level LockingYesYesYesYes
Table-Level LockingYesYesYesYes
Geospatial datatypesNoYesYesNo
Native ReplicationYesYesYesNo

Companies using postgres

These are links to case studies, showcasing the successful usage of postgres in an organization

BASF (PDF format)
Mohawk Software
Proximity (PDF format)
Radio Paradise (PDF format)
Shannon Medical Center
Spiros Louis Stadium (PDF format)
The Dravis Group OSS Report (PDF format)
Vanten Inc.

Companies using mysql

Patypoker.com (PDF format)
Greyhound bus - data website (PDF format)
Sandstorm (PDF format)
Leapfrog schoolhouse (PDF format)
Sony (PDF format)
Dell (PDF format)

So which one is better?

Both postgres and mysql have had success on large-scale websites and they each have their benefits:

Where postgres wins:

1) faster with more complex queries

2) ACID compliant

3) embedded language capibility (Perl, PHP, TCL, and PG/PLSQL)

4) on average, can handle more concurrent connections

where mysql wins:

1) more wide-spread support and usage with ISPs and the open source commuity

2) robust replication

3) easier for newcomers to use

4) on average, faster per query

Wednesday, May 10, 2006

tech resume tips

By Justin Silverton

Here are some tips that may help you when you apply for your next tech job:

Top Ten Technical Resume Writing Tips

  • List your technical knowledge first, in an organized way. Your technical strengths must stand out clearly at the beginning of your resume. Ultimately, your resume is going to be read by a thoughtful human being, but before it gets to that point it often has to be categorized by an administrative clerk, and make its way past various sorts of key word searches. Therefore, you should list as many directly relevant buzz words as you can which reflect your knowledge and experience. List all operating systems and UNIX flavors you know. List all programming languages and platforms with which you're experienced. List all software you are skilled with. Make it obvious at a glance where your strengths lie - whether the glance is from a hiring manager, a clerk, or a machine.
  • List your qualifications in order of relevance, from most to least. Only list your degree and educational qualifications first if they are truly relevant to the job for which you are applying. If you've already done what you want to do in a new job, by all means, list it first, even if it wasn't your most recent job. Abandon any strict adherence to a chronological ordering of your experience.
  • Quantify your experience wherever possible. Cite numerical figures, such as monetary budgets/funds saved, time periods/efficiency improved, lines of code written/debugged, numbers of machines administered/fixed, etc. which demonstrate progress or accomplishments due directly to your work.
  • Begin sentences with action verbs. Portray yourself as someone who is active, uses their brain, and gets things done. Stick with the past tense, even for descriptions of currently held positions, to avoid confusion.
  • Don't sell yourself short. This is by far the biggest mistake of all resumes, technical and otherwise. Your experiences are worthy for review by hiring managers. Treat your resume as an advertisement for you. Be sure to thoroughly "sell" yourself by highlighting all of your strengths. If you've got a valuable asset which doesn't seem to fit into any existing components of your resume, list it anyway as its own resume segment.
  • Be concise. As a rule of thumb, resumes reflecting five years or less experience should fit on one page. More extensive experience can justify usage of a second page. Consider three pages (about 15 years or more experience) an absolute limit. Avoid lengthy descriptions of whole projects of which you were only a part. Consolidate action verbs where one task or responsibility encompasses other tasks and duties. Minimize usage of articles (the, an, a) and never use "I" or other pronouns to identify yourself.
  • Omit needless items. Leave all these things off your resume: social security number, marital status, health, citizenship, age, scholarships, irrelevant awards, irrelevant associations and memberships, irrelevant publications, irrelevant recreational activities, a second mailing address ("permanent address" is confusing and never used), references, reference of references ("available upon request"), travel history, previous pay rates, previous supervisor names, and components of your name which you really never use (i.e. middle names).
  • Have a trusted friend review your resume. Be sure to pick someone who is attentive to details, can effectively critique your writing, and will give an honest and objective opinion. Seriously consider their advice. Get a third and fourth opinion if you can.
  • Proofread, proofread, proofread. Be sure to catch all spelling errors, grammatical weaknesses, unusual punctuation, and inconsistent capitalizations. Proofread it numerous times over at least two days to allow a fresh eye to catch any hidden mistakes.
  • Laser print it on plain, white paper. Handwriting, typing, dot matrix printing, and even ink jet printing look pretty cheesy. Stick with laser prints. Don't waste your money on special bond paper, matching envelopes, or any color deviances away from plain white. Your resume will be photocopied, faxed, and scanned numerous times, defeating any special paper efforts, assuming your original resume doesn't first end up in the circular file
Finalizing Your Resume
  • Resumes should be concise and in a manageable document length.
  • Your Name and Page Number should be located on every page, just in case pages become separated while in the hands of the prospective employer.
    (The Name and Page number can be in the Header or Footer part of the resume, or at the top of the page using a smaller font size, to avoid distracting the reader. Page Numbers can be written as: Page 2, Page Two, Page 2 of 3, or Page Two of Three.)
  • Do not put a photograph of yourself on the resume. Potential employers will not be hiring you based on your looks! However, International candidates will need to send their scanned photograph to the Systems Integration Solutions, Inc. International Department representative along with the final formatted resume.
  • Type your resume in a word processing document and back it up on a disk. Updating your resume then becomes easy. If you are not a typist, ask a professional to type it.
  • Use one typeface such as Times New Roman, Arial, or other traditional typeface. The standard font size is 11 point. Headers may be increased to 12 point.
  • Margins should be no less than one inch on sides, top, and bottom. The white space serves as a border and keeps the resume from looking cluttered.
  • Avoid underlining within the resume narrative. If you have written the statements well, they will need no further emphasis.
  • Always do a print preview of each page of your resume, to view the layout and spacing.
  • E-mail your resume document, with a short introduction letter to your Systems Integration Solutions, Inc. contact. The document can then be opened, printed, and distributed to clients.
  • Laser-print your completed resume or have it professionally typeset.
  • Give or mail an interviewer your resume printed on an off-white, tan, or light gray quality bond paper. Never give them a photocopy of your resume.

is AjaxOS worth the wait?

By Justin Silverton

What is AjaxOS?

ajaxOS is a Linspire-based operating system with some revolutionary new features to support the adoption of web-based software. Some of the cool new things you can expect to see on ajaxOS include:

Automatic launch of AJAX software when clicking on a supported filetype.Ability to save files to virtual storage.Ability to navigate through a file browser to the files uploaded to virtual storage as well those on your local computer.

ajaxOS will be available for download in the next few weeks. You can register to receive notification of the ajaxOS and other AJAX software releases or visit http://www.ajaxlaunch.com/ to read the official announcements.

Benefits of using ajaxOS

Information Security – Your files and documents are safe from computer crashes, laptop theft, viruses and other virtual attacks on your computer since they are all saved on ajaxOS remote storage.

Web-based Software Applications Included – Save money. No need to purchase expensive software – it's all included in ajaxOS.

Updated and Upgraded Automatically – Spending time and money on software updates and upgrades is also a thing of the past, most ajaxOS applications are upgraded automatically.

Full file compatibility – applications are compatible with all standard file formats, allowing you to easily transfer your existing files and share files created using AJAX software with others.

View ajaxOS presentation at Desktop linux summet of 2006: http://boss.streamos.com/download/marketing/dls2006/mbr_dls2006-session4_edit_060425.rm

I'm not really sure if ajaxOS will even be worth downloading. The release notes discuss "revolutionary new features". The screenshots look nice, and it is based on linpire (a linux distro), but it looks like they are basically just integrating a web storage service (which is not a new idea) into a linux distribution.

Even though I don't think it is anything revolutionary or special, I still think I will download it when it is finally released.