July 20, 2008

Codeigniter Excel and PHP’s Spreadsheet Excel Writer Pear Package and how to not have to use PEAR

Filed under: codeigniter, cool, php, tip, xls — michaelangela @ 3:08 am

Well that’s a long title but it sums it up. I wanted to generate Excel from Codeigniter. Because of that I needed a way to use it whether or not PEAR is running/installed, etc. My local dev box doesn’t (yet) have it but that’s a story for another time.

The talented developers at Pizza SEO repackaged one of the recent versions of Spreadsheet Excel Writer as a set of classes together. No PEAR, no installing of separate items, etc. Normally I would like PEAR and it is on the deployment server but I wanted a portable flexbile version that worked within CodeIgniter and this fit the bill. Give them a visit! 🙂

PHP Excel Creator library | Pizza SEO

Pizza SEO has developed library for writing Excel (XLS) documents in PHP from former PEAR class Spreadsheet Excel Writer (see PEAR). We have cleaned this class, so PEAR installation is not required anymore and class is available as the standalone class.


July 14, 2008

A good short-list of PHP frameworks

Filed under: dev, mvc, php — michaelangela @ 7:08 am

I have had to come back to PHP after a long hiatus. I prefer Python but recent projects require PHP and thus my return. I did a project recently with CodeIgniter which really is a spiffy project. But I would like a true OOP PHP5 MVC fast lightweight framework that has user auth, session management and a lightweight ORM. Or be able to plug one in. Perhaps Kohana, based off of CodeIgniter, would fit the bill. Something about “Keep Kohana Alive” makes a little nervous though…

PHP: MVC Based Popular Framworks | Jit V. Tiwari

PHP: MVC Based Popular Framworks

Custom Flex Calendar controls

Filed under: as3, cool, dev, flex — michaelangela @ 3:17 am

I have worked with customizing the Flex calendar components and will probably need to do so again in the future, but this is pretty neat. I’ll have to look into this more soon.

Refreshingly new Flex Calendar controls « My journey in the world of RIA

Flex is a very flexible language and I’m here to prove it again.

Today, I’m posting these two new cute flex calendar controls which uses inbuilt “CalendarLayout” class for functionality and has a completely new layout and interface defined in MXML.

July 6, 2008

Getting rid of the dreaded “can’t encode” errors with Python and MySQL and SqlSoup

Filed under: automation, cool, dev, mysql, python, sqlalchemy, sqlsoup, tip, xls — michaelangela @ 10:47 pm

So I was getting problems inserting data that has the ‘™’ symbol in it. Brutal stuff. Couldn’t find a way around it. Did it by hand in the end. Nasty. The problem was that I was getting

UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2122' in position 12: ordinal not in range(256)

where the '\u2122' is the ‘™’ symbol. There were some others as well. Finally happened upon this post which, fortunately, cleared it up. To use this tip with SqlSoup, the connection string needs a couple of extra parameters.

Instead of

db = SqlSoup('mysql://user:password@host:port/database')


db = SqlSoup('mysql://user:password@host:port/database?charset=utf8&use_unicode=0')

The requirement of course is that the database tables are set up with the UTF-8 charset.

But now I can thrash data at will! Mwahahahaha! Sorry… but now I can pull in unicode data from an Excel file and throw it into a database with rediculous ease. OK not rediculous ease but wow this simplifies it.

[edit]I like to use iPython to do my data thrashing with SqlSoup and SqlAlchemy. If you use the second connection string with the charset and use_unicode options, don’t reset the db connection to the previous one without those. Once doing that I couldn’t set it back and had to exit and restart the session. Bummer.[/edit]

mysql unicode issues – sqlalchemy | Google Groups

a. have use_unicode=0, set charset=’utf8′ on the connection, AND

b. ensure you have
table options = {‘mysql_charset’: ‘utf8’} when creating tables, and
all should be well.

Python Excel file reader

Filed under: cool, python, tip, xls — michaelangela @ 1:36 am

This thing is just brilliant! I am working on a project that uses PHP. But I still do my data mangling with Python because of tools like SqlSoup running under SqlAlchemy. Using those under iPython has saved incredible amounts of time. I actually like working with data in this way. It just makes it more fun. Well, I have some data in an Excel file that has multiline text in it. That can be a pain with CSV files. A little digging located a Python Excel writer which had stopped development, with the suggest to use a Python port of a Perl writer, which while cool for writing, has trouble reading… but a helpful post pointed to xlrd. A quick “sudo easy_install-2.5 xlrd” later and I was able to do:

import xlrd
book = xlrd.open_workbook("myfile.xls")
sh = book.sheet_by_index(0)
for r in range(sh.nrows)[1:]:
print sh.row(r)[:4]

Sweet. Indeed. All of the Unicode elements and multilines are intact and good to go. Good stuff.

Python Package Index : xlrd 0.6.1

Library for developers to extract data from Microsoft Excel ™ spreadsheet files

Extract data from new and old Excel spreadsheets on any platform. Pure Python (2.1 or later). Strong support for Excel dates. Unicode-aware.

July 5, 2008

Loading assets in AS3 and Flash

Filed under: as3, dev, note, tip — michaelangela @ 8:39 pm

Loading up assets can be a pain to track so this set of code aims to simplify that. Need to check it out later though.

AYAN RAY | AS3 / Flash: Introducing the AssetLoader Class

In Actionscript 3, there are many different ways to load external assets from the Internet. Unfortunately, this can become tiresome to find different ways to load each one in it’s own individual way. With this problem in mind, I have created the AssetLoader class.

Animated Skins in Flex

Filed under: as3, flex, note — michaelangela @ 8:38 pm

Very neat. Very cool. You have to check it out if only to see dancing Gingerbread men in Flex… 😛

Tink » Blog Archive » Seamless Animated Skins in Flex

In Joey Lotts session on styling Flex at FOTB (where he did a great job), one of the attendees asked about animated skins.

obviously many ways to approach this but I thought I’d do an example of
how you can have seamless transitions between these states using frame
labels inside the symbol in Flash, and by adding code using

Flash CS3 Open Source “Liquid Components” by Byte Array

Filed under: as3, component, cool, flash, note — michaelangela @ 8:37 pm

I am just about to wrap up a project using Flash CS3 and… I wish I saw this earlier… 🙂

Liquid Components for Flash CS3 [ by Didier Brun ] < ByteArray.org

The “Liquid Components” have been created for the Flash people, freelance coders and designers who wish to integrate fully skinnable components in their website, games or little RIA applications.

AS3 URL class

Filed under: as3, note — michaelangela @ 8:35 pm

Not having access to the mx URL utils with Flash (though I haven’t looked at the possibility just yet) I found this. Could be quite helpful!

AS3 – URL Class | Manfred Weber`s Weblog

I could not find it in the net so I hacked something together quickly. A simple URL class that parses an url string.

Problems using navigateToURL

Filed under: as3, note — michaelangela @ 8:34 pm

Was just dealing with this… must check out!

Problems using navigateToURL – aron / philipp development blog

Hi there… we’ve been busy these past couple of days so there
wasn’t much time for new posts – sorry. But here is a little update.
While developing a flash website (AS3 & SWFObject2.0)
that heavily depended on opening URLs in a new browser window we came
across the popup blocker problem that the use of navigateToURL causes.
When trying to open a new window firefox’/IE’s popup blocker will block
the window and display its warning. After googling for some time we
came across some neat workarounds:

1) How to prevent pop-up blocking in Firefox by Sergey Kovalyov

2) The Nightmare that is “_blank”: Part II (resolved???) by The Saj

putting these two approaches into one AS3 util-class, this is what we came up with:

Flex SDK coding conventions and best practices

Filed under: flex, note — michaelangela @ 8:32 pm

Coding Conventions – Flex SDK – Confluence

This document lays out the coding standards for writing open-source Flex framework components in ActionScript 3. Adhering to these standards makes the source code look consistent, well-organized, and professional.

Some of these standards are completely arbitrary, since there is not always a “best way” to code. Nevertheless, in the interest of consistency, all commits to the Flex SDK project will be expected to follow these conventions.

Actionscript 3 Excel library

Filed under: as3, dev, flex, note — michaelangela @ 8:31 pm

Adobe – Flex Extension

An Actionscript 3 library for reading and writing Excel files. Currently reading numbers, text, and formulas from Excel version 2.0-2003 and writing numbers, text, and dates to Excel 2.0 is supported. No server-side help is needed.

Blog at WordPress.com.