Remember to check your emoticon path for Expression Engine!

Getting ready to move a site from dev to production. I often use Charles just to make sure paths are doing what they are supposed to do. I had done an initial test moving from localhost to an actual IP address just to run through the process. I got everything except emoticons and it took a little while to track it down:

Expression Engine Migration Notes | WikiLab Notes

go to Admin > SYSTEM PREFERANCES > Emotican Preferences

Voila. Problem solved. To aid with this sort of thing in the future, this older post has some very helpful tips.

Configuring Expression Engine for multiple servers

The one remaining problem is that, upon installing EE, it hard-codes your site URL and application installation path all over the place, from config files to options stored in the database. This is what makes Expression Engine so unportable — moving from one server to another, say from development to production, requires updating this URL and path information in literally about a dozen places.

To aid with this process, a kind soul has written this ruby script:

Migrating ExpressionEngine from development to production – deeden.co.uk

I’ve never succeeded in migrating successfully using the manual method. I always miss something and have to deal with some small problem that inevitably crops up. Finally, I decided to make it easier on myself, so I wrote a script to perform the update for me. This will not be for everyone, however if you’re comfortable with command line scripts and ruby this may do the job for you.

I haven’t tried the config method or the ruby script yet but it’s good to know.

Python and PHP serialization

I have some data that I am pulling via Amara. I need to put that in a database. The app that uses that data is in PHP and would prefer the data to be serialized. Fortunately, there is help! :)

Scott Hurring: Code: Python: PHP Serialize implemented in Python: v0.4b

This is a python implementation of PHP’s native serialize()
and unserialize() functions.

Taken along with my perl serialize implementation,
this code will enable you to transfer simple data structures
between PHP, Python, and Perl using PHP’s data serialization format.

This code aims to be a very lightweight data transport
layer between PHP, perl and python using PHP’s native
serialization format.

grep instead of python?

I have an xml file with a listing of images that I need for a site. Typically I fire up IPython with Amara and do my xml wrangling there. But I also needed the files. I thought about using python to also grab and save the files but a little search led to this post. Ironically, while the tip to use Python is good, there was a tip to use curl to get the feed, grep to parse the images, and finally xargs to feed it to wget for downloading.

Thinking Serious » Using Python to Grab Images From a Web Site

curl -s http://99designs.com/contests/6999/feed | grep -Po “src=\”.*(png|jpg)” | grep -o “http.*” | xargs wget -q

My situation is a bit different though. There are no extensions on the files, they are in a tag, and I need to rename them with extensions. After a little Googling I used this which worked very well.

curl -s http://domain.tld/feed | egrep -o "<tag>.*</tag>" | egrep -o "<tag>(http.*)</tag>" | sed -e 's/<[^>]*>//g'
for f in *; do mv ./"$f" "${f}.jpg"; done

I still need to do some xml wrangling with Amara but the files are now just need to be moved to the right directories. Nice.

Notes: Photoshop Sparklines Script

Tufte Sparklines Photoshop Script | La Photo Vita

Sparklines can be hard to produce. Most graphing packages are designed to produce large graphs or charts, and it can be very hard to generate the wide-but-thin lines for incorporation in documents. This was the motivation for writing a Photoshop script that would automate the production of sparklines. It works by reading a data series from a text file and plotting a sparkline image as a Photoshop path, and then stroking it with the pencil tool. This produces a bitmap image which can then be cut-and-pasted into the target document. The user retains control of the color and line style of the sparkline by setting the Photoshop foreground color and pencil tool settings before running the script.

Notes: LOMO Photoshop script

Flickr: Discussing Fake-LOMO Adobe Photoshop Script in Technique

I saw that there are some PS actions for doing LOMOing but they don’t seem to handle multiple sized images well. I threw together this PS script to handle multiple sized images as well as non-flattened images.

Notes: Photoshop recursive save to web script

Ovidiu Predescu’s Weblog: Recursive export to Web in Photoshop CS3

Yesterday I was looking for a way to take a subset of the pictures I
have and convert them to JPG. I want to use the JPGs on a small Mac
Mini to make presentation in FrontRow using a newly acquired Canon SX7 digital projector (more on this in a later entry).

Unfortunately Adobe Lightroom does not offer such a functionality.
You can export all the pictures in a directory to JPG, but there’s no
way to take a directory, and recursively export all the pictures within
it to JPG while maintaining the directory structure they are in.

I could have written a small shell script to do this, but I have a
mixture of TIFF, JPG and RAW images that had to be processed. I wanted
to get the image processing capabilities from Lightroom or Photoshop,
instead of using dcraw. Adobe Lightroom doesn’t have a way to script
it, so I looked at Photoshop CS3 to do it.

Photoshop can be scripted in JavaScript, in addition to AppleScript. I came up with a small script that does the conversion.

Getting an int from math calculations in javascript

Javascript – Casting to integer on arithmetic division… – Rexiology… – MSMVPS.COM

As Javascript been a weak-typed language, sometimes it’s not able to
cast a variable from one type to another. as in arithmetic division, if
one wants to output an integer instead of a double or else, here is a
way learned from this article that’s useful:

a = ( b / c ) | 0

by using a bitwise OR operation to cast a float / double
back to an integer, to have a way casting some numeric values back to
desired form.

As Javascript been a weak-typed language, sometimes it’s not able to cast a variable from one type to another. as in arithmetic division, if one wants to output an integer instead of a double or else, here is a way learned from this article that’s useful:

a = ( b / c ) | 0

by using a bitwise OR operation to cast a float / double back to an integer, to have a way casting some numeric values back to desired form.

Overflow:visible IE6 bug workaround

I can’t believe it but it actually seems to work!

Is there any workaround to this bug (overflow:visible;)?

> #sidebar { overflow: hidden; }<br /> /> #sidebarContents { position:relative; }<br />

Good AS2 class for textfields

Just taking a note on this. It looks quite useful.

Easy Custom Scrollbar Class for TextFields (AS2) | Taterboy.com: Graphics, Multimedia and Such

Here is the twin brother of the Easy Scrollbar MovieClip Class
that works with TextFields. It does not require the masking and is
perfect for Input TextFields. It has all the features of the MovieClip
version except for easing. TextFields scroll one line at a time which
is not very smooth.

I simple have to check this out

openflux – Google Code

OpenFlux is an open-source component framework for Flex which makes radically custom component development fast and easy.

The era of free everything is ending?

Well not exactly. But building something and hoping it scales to massive numbers to be funded by advertising is not the big game plan as much any more… or at least it’s changing. Anyway, I just wanted to keep tabs on Hank’s site. Good stuff there.

Why does everything suck?: Web Meets World (a.k.a. Web Meets Money)

The last five or six years have been all about community, “social media” and other related types of communications. That era has ended and the next phase of the Web will be about *real* productivity. That means products that make you more efficient, and more effective. It means software that saves you money or makes you money. And yes, we are really going to have to start paying for the good stuff.

Adding a PHP nature to a project

I have a remote project already online and the PHP project type functions weren’t working, i.e. the PHP Explorer, the Outline view, Command(Ctrl) clicking an item to jump to it’s definition, etc. Those are really helpful! Not to mention auto completion! What was needed was the .project file on the server had to be updated to have the PHP nature suc as that below. That did the trick. Just make sure the tag has the real name of your project.

I haven’t tried adding Include Path’s though so that’s another issue altogether. Can’t get the code to display quite right… trying again…

[news.eclipse.tools.pdt] Remote System Explorer + Include Path

<?xml version="1.0" encoding="UTF-8"?>

<projectDescription>

        <name>MyProj</name>

        <comment></comment>

        <projects>

        </projects>

        <buildSpec>

                <buildCommand>

                <name>org.eclipse.php.core.PhpIncrementalProjectBuilder</name>

                        <arguments>

                        </arguments>

                </buildCommand>

                <buildCommand>

                        <name>org.eclipse.wst.validation.validationbuilder</name>

                        <arguments>

                        </arguments>

                </buildCommand>

        </buildSpec>

        <natures>

                <nature>org.eclipse.php.core.PHPNature</nature>

        </natures></projectDescription>


Pythonic grep sort of

Looking for a way to crank through files and search for specific text within matching files. Found this and it’s very neat.

Python: find files using Unix shell-style wildcards « Muharem Hrnjadovic

The download though was a little hard to find so I just got the source tar.gz file from here:

http://ppa.launchpad.net/al-maisan/ubuntu/pool/main/s/scriptutil/

[update]In the end I tried grep which was significantly faster, just reading the output of the command in while looping through a list of files:

def fgrep(the_string,the_files):
    all_lines = []
    for the_file in the_files:
        command = 'grep "%s" "%s"' % (the_string,the_file)
        response = os.popen(command,'r')
        lines = response.readlines()
        for line in lines:
            all_lines.append(line)
    return all_lines

OS X, XDebug, MAMP, Zend Optimizer

It’s true… disable the Zend Optimizer. I had the same issue and this resolved it.

Installing XDebug with Mac OS X MAMP: disable PHP Zend Optimizer | AgaricDesign.com

After getting rid of (commenting out) the three lines about Zend optimizer in php.ini, it failed a couple times but then started working.

Recursive grep on OS X

grep -nr -C2 text *

Using Charles to test a SWF from a remote location

I just wanted to make sure I keep this note handy. Charles is already very cool. This just makes it cooler. :-)

Testing a SWF From a Remote Location (Deitte.com)

Map Local
allows you to map URLs to local directories. This means that you can
test a SWF that should be on a remote site. It’s incredibly useful for
the large project problem I was having or for debugging problems on a
live site.

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

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.

A good short-list of PHP frameworks

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

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.

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

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')

use

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

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.

Loading assets in AS3 and Flash

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

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

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.

There’s
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
addFrameScript().

Flash CS3 Open Source “Liquid Components” by Byte Array

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

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.