Archive for api

flickr api tip

In another quick and simple process, I personalized my About page a little with a bit of flickr html/java that they supply. Of course I’ve worked directly with their API, but in this case that’d be using a sledgehammer, since the good folks at flickr also provide a nice little javascript snippet to randomly select a couple of pictures/thumbnails to drop right in. I went to flickr’s badge generation page (logged in as moi, of course) to get started.

First I chose HTML. This is because I have serious issues with flash, although I admit the boxy thing it comes up with is pretty cool. On the next page, I was asked to choose which pictures to display. I chose to display any of my public photos although it’s possible to choose one or more tags or a particular set from which to select pictures for display. That could be useful for something fairly strong-themed: animal pictures for an animal focused blog, for example. Since I don’t have sexy computer photo shoots, I didn’t use either of those options. In the third step, flickr asked me questions about the layout: usage of buddy icon, number of photos, the size of the photos, and vertical or horizontal (or other, using personal style options) orientations. Finally flickr allowed me to specify colours and background for the snippet and gave me the code, which I dropped into my About page.

From there I made two modifications. The first was to add display:inline; and float:right; attributes to the table wrapper around the pictures so that it would display as I wished on the page. But I also cut out the <style> included with the snippet and put it in my css style file. That last is optional, and possibly not what someone else would want to do because changing the theme could lose the styling in that page. (Of course, I have my own workaround this situation, since I use a common.css that’s independent of theme styling which I accomplish via a private plugin that I should clean up and make available one of these days.)

del.icio.us:flickr  api tip  digg:flickr  api tip

Comments

delicious linkroll api tip

I just discovered a very quick and easy way to have a live list of delicous bookmarks on a Wordpress blog; although this will work anywhere that javascript can be dropped in.

First, I went to Delicious’ javascript generator page. I checked off the options I wanted, including showing the notes that I attach with each entry I make. This resulted in the following javascript (spacing and line breaks added for visibility):

< script type="text/javascript" src="http://del.icio.us/feeds/js/digitalramble?
extended;
title=my%20del.icio.us;
icon=s;
name">< /script>
<noscript><a href="http://del.icio.us/digitalramble">my del.icio.us</a></noscript>

I then opened up my WP’s admin pages, and started a Write->Write Page session (not Write Post). Then I copied the javascript generated by delicious into this page, with the title that I wanted, and saved the page. This now creates a static page (similar to the about page) but which will show my last 15 entries to delicious at any given time.

I tweaked the styles by finding the css styles used by delicious listed on style page, and adding that to my style.css file, with appropriate modifications. For the curious, this is what I wound up using:

 
.delicious-posts {
        margin: 1em;
        padding: 0.5em;
        font-family: sans-serif;
        font-size: 120%;
}
.delicious-posts ul, .delicious-posts li, .delicious-banner {
        margin: 0;
        padding: 0.25em;
}
.delicious-post {
        border-top: 1px solid #eee;
        padding: 0.25em;
}
.delicious-odd {
        background-color: #f8f8f8;
}
.delicious-posts a:hover {
        text-decoration: underline;
}
.delicious-posts a {
        text-decoration: none;
}

No further need for the plugin I used to use… If I wanted a quick list for the sidebar, I’d go back to the javascript page, and choose something like 5 entries, no notes, no titles or afterwards to make it as short and quick as possible, and then drop that into my sidebar.php file. Easy.

del.icio.us:delicious linkroll api tip  digg:delicious linkroll api tip

Comments

forays into local cpan installation

I really dislike having to install perl modules locally. But sometimes that’s the set of cards I get dealt. And in all honesty, once it’s properly set up in an account, it’s easy to add on any others at a later date. So. I generally start with a local perl directory, in $HOME/perl, to keep things tidy. Otherwise I wind up with a more generic bin and lib sitting out there, and there’s lots that use bin & lib that have nothing to do with perl.

I add env variables:

if [ -d $HOME/perl/lib/perl5 ]; then
        PERL5LIB=${PERL5LIB:+$PERL5LIB:}$HOME/perl/lib/perl5
fi
MANPATH=${MANPATH:+$MANPATH:}$HOME/perl/share/man
export MANPATH PERL5LIB

(or if you prefer csh style — which I do, but I haven’t bothered to switch these bash shells around yet — I may, if I get irritated enough)

setenv PERL5LIB      $PERL5LIB:$HOME/perl/lib/perl5
setenv MANPATH     $MANPATH:$HOME/perl/share    

You can use printenv in most shells to double check the settings and make sure they “stuck”.

There really doesn’t seem to be any one place that combines all the info I use for a local install. I usually start out with this one which is almost complete but it leaves out salient details such as exactly how to start up cpan (which I always forget, it has such forgettable syntax) and doesn’t really contain tips for troubleshooting (there’s always troubleshooting).

However, it provides a perfect MyConfig.pm file to get started with, so I copy that into the ~/.cpan/CPAN/MyConfig.pm and follow the instructions it has in the comment section at the top. After the localizing alterations, I can run perl -c MyConfig.pm in order to make sure I haven’t done something boneheaded.

Now I’m ready to rock and roll. Get into cpan via perl -MCPAN -e 'shell' and now I can start installing. The help file I listed before suggests checking the changes I make to MyConfig.pm via a make on Text::Autoformat. I don’t really bother anymore but it’s a handy way to check that the variables are all correct.

Let’s say I want to install Flickr’s API. So I go with install Flickr::API. It will ask me some questions. What I have found out about CPAN is that most of the time (as in 99% of the time), the default is a perfectly good way to go when it asks questions. Quite often when I install something, it will suggest other things that should be installed or updated, etc. I just go with the flow on all that.

When I nibble around this article you’ll see more tips and such on unprivileged perl installs. Obviously installing your entire local copy of perl isn’t the way to go for the most part (and neither am I actually trying to install Bugzilla, at least not in this little essay), and they discuss a slightly different way of setting up the MyConfig.pm file, but there’s other goodies such as force install which I can try if I get nasty messages after attempting a plain install. Also what frequently helps me is to try installing the noted dependency packages on their own. Take the Flickr::API — it also wants XML:: Parser::Lite::Tree:: XPath and will inform me of that while installing the Flickr stuff. And sometimes it will take care of it, and sometimes it won’t; doing a separate install on that often works.

The last bugaboo I generally wind up dealing with, especially since I mostly write perl for cgi scripts is the transition from running on the command line to calling it from a web page. All the previously mentioned steps get the perl working on the command line, but then it can still turn into a big ol’ Internal Server Error mess when I try to go online.

The problem is, of course, that the http client isn’t accessing my pretty MANPATH and PERL5LIB paths for the extra info. This is where tweaking the @INC array helps: I can be all perl hacky and do something like BEGIN{unshift @INC, "$HOME/perl/lib/perl5"} (note that $HOME itself won’t actually work here, I use it for shorthand notation — replace this with the full value of $HOME in this case). But I just discovered this tidbit when googling and trying the use "$HOME/perl/lib/perl5"; worked like a charm! I’ve posted this previously only at another location: the flickr slideshow. Because www.sclrr.org is on a different server than is www.io.com/~sclrr, I had to re-install the perl libraries, and find a different solution to the path problem.

del.icio.us:forays into local cpan installation  digg:forays into local cpan installation

Comments (1)

flickr slideshows

One of the problems with the SCLRR’s main page is that “slideshow” on it. It’s really an animated gif. Now there’s tons of (mostly Windows based) software out there for creating gif type slideshows as any google search will show you. But remember that I try to make this site pretty easily usable by the average volunteer. So for example that Dog of the Month you see is pulled out of the database with a bio that’s all done in the volunteer only section of the website. They don’t have to do anything more than check off the dog they want displayed and voila!

So I wanted something similar for the slideshow. I also wanted some way of uploading the pictures pretty easily. So I got the bright idea of using flickr. They’ve got an API. So the idea went something like this: I create a perl script that uses flickr’s API to pull out a list of pictures with a certain tag and then I rotate through those pictures in the file. So from the volunteer’s point of view. all they have to do is manage a set of pictures on flickr — which has a nice easy to use interface, and to which access can be given without compromising the shell account. Hey I love these people dearly, but I cringe at the thought of a non-technical person stomping all over the files in the account by accident. (I mean I have everything regularly backed up but still.)

del.icio.us:flickr slideshows  digg:flickr slideshows

Comments (1)

Bad Behavior has blocked 953 access attempts in the last 7 days.