Getting a local version of Cufon running on a Mac
Posted by admin in Web design & development on August 3rd, 2010
The easiest route to web fonts, Cufon, is suffering a couple of issues at the moment – somebody may be trying to give the service a hard time with a nasty font.
If you ever have this trouble getting a local version on your MAMP server is no problem…
First you’ll need to get the open source fontforge package. If you have MacPorts installed that makes it a breeze… (installing MacPorts is also a breeze). As instructed at the fontforge site; just type this into Terminal: sudo port install fontforge. It’s not particularly quick – took about 15 minutes – but that ain’t too bad. No.
Then go to cufon’s github repo and download the source files. Get these files into your Sites folder (e.g. to ~/Sites/cufon/)and all that’s left to do is edit ~/Sites/cufon/generate/settings.ini so that it points to the MacPorts install of font forge: fontforge=/opt/local/bin/fontforge. (If I remember rightly all MacPorts binaries go there.)
Now your local copy of Cufon should be working just go to ~/Sites/cufon/generate/convert.php and all should be hunky dory.
How to tile a print using Adobe’s Creative Suite (CS5)
Posted by admin in Graphic arts on August 2nd, 2010
Do you need to print an oversized graphic document onto multiple sheets of paper (that your printer can handle) so you can then assemble/[Sello]tape/mount an accurate large format version?
This is a very simple task but strangely difficult to find an answer for. It’s not readily possible with any of the main Adobe CS5 (design premium) apps but Adobe Acrobat Pro can do it without breaking a sweat. Just print the document: if it’s too big for your printer then you’ll be able to select “Tile all Pages” in the Page Scaling pop-up menu. The options are quite limted but at least you can have crop marks and page information printed on each sheet (a definite plus).
To get decent trim/bleed settings I’d go to Illustrator and set up multiple accurately aligned artboards (multiple artboards a feature of Illustrator since CS4) and print them.
Anyway now I can get on with printing large format [proofs and "art" prints] without having to go to the next town…
Safari: how to restore all windows from last session using Time Machine
It’s really very simple – everything you need is in ~/Libaray/Safari/LastSession.plist just quit Safari and restore that file from when it was good and you’re done.
What’s this about?
Well I tend to use open Safari windows/tabs to help keep me focused on foreground tasks while minimising backround/interesting/to-do articles etc. Occasionally I forget to restore all my windows after restarting Safari for a quick session (usually whilst preparing for shutdown/restart/software update).
Next time you try to restore all your windows and don’t get what you expected – remind yourself this is why that extra Time Machine disk was such a useful investment.
Hope this helps.
DIY Canon macro lens: howto video…
Posted by admin in Photography on June 28th, 2010
Lovely eight minute video – very likely shot on a Canon 5D mkII. How to convert a stock kit lens into a macro. This is a stellar bit of cottage industry engineering:
via Gadget Lab
Avoid WordPress Trackbacks within your own site
Posted by admin in Web design & development on June 15th, 2010
So you’re doing the right thing and crafting internal links within your site to give the thing meaning and usefulness (or SEO) but WordPress is marking these links with superfluous trackbacks in the comments of the pages/posts your linking to…
There’s plugins to prevent this do this of course – but no need to bother with these as it’s very simple thing to prevent; just stick with best-practice and make any internal links root-relative rather than absolute: ie link to /example-post/ rather than http://example.com/example-post/.
There’s an added advantage in that should you ever change your domain – all your links will stay good.
Rotating Twitter Tweet feed in WordPress
Posted by admin in Web design & development on June 12th, 2010
Again, this is for one my current projects: my mate Phil’s digital DJ tips site…
OK – so there’s loads of plugin’s out there that do this kind of thing but I’m not after anything fancy (or bloated), I’m happy to code this into the theme files with a bit of PHP and well – it’s something slightly new to learn …
Primary requirements:
- We want this thing to use the SimplePie feed parser and cacheing system, as already included with a standard WordPress install. This will copy the latest tweets into WordPress and avoid running-off to bother Twitter every time our WP site gets a visit. This will also make the thing more robust as Twitter does occasionally… fail.
- A raw Twitter feed will include your user name at the beginning of each tweet. This unnecessary when the blog and tweets are from the same person/identity/brand so we’ll need to remove that.
- We need the SimplePie cache to expire fairly regularly – not enough to bust Twitter’s balls with extra requests – but enough to keep the tweets fresh
- We may want to trim the tweets (yes even less than 140 characters!) so they fit on one line without having the set an explicit width or css “overflow:hidden;”. [This is a graphic design call here as I like backgrounds fills to match the variable length of text (inline) rather than be fixed-width with trailing whitespace of block level element - makes each tweet look like the unique thing it is.]
- Once this is done it goes into a simple carousel to rotate through the last x tweets.
The code comes in a couple of pieces:
The main engine: get the twitter feed – pack it up and process it.
I put the following into an include file to keep it all wrapped together for easy access. This code mostly based on the excellent WordPress codex article “Function Reference/fetch feed“. The String replace reference came from the classic tizag PHP guide and the shorten to the nearest whole word came from somewhere else
<?php
// Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/feed.php');
// Get a SimplePie feed object from the specified feed source. CHANGE THE USER ID BELOW!
$rss = fetch_feed('http://twitter.com/statuses/user_timeline/126881491.rss');
if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
endif;
// shorten string function
function short_str( $str, $len, $cut = true ) {
if ( strlen( $str ) <= $len ) return $str;
return ( $cut ? substr( $str, 0, $len ) : substr( $str, 0, strrpos( substr( $str, 0, $len ), ' ' ) ) ) . '...';
}
?>
<div id="djt-twitter-feed"><!-- djt classes and ID to be replaced by something that is useful to you -->
<ul id="djt-tweets" class="jcarousel-skin">
<?php if ($maxitems == 0) echo '<li>No tweets!</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li class="cfn">
<span><a href='<?php echo $item->get_permalink(); //or hardcode link to Twitter homepage ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php //get tweets (but remove twitter ID before displaying)
$djt_twitter_tweet = $item->get_title();
$djt_twitter_tweet = str_replace("YourTwitterUsername: ", "", $djt_twitter_tweet) ;
echo short_str( $djt_twitter_tweet , 140, false) //OK - not actually doing any shortening with this line now ;
?></a></span>
</li>
<?php endforeach; ?>
</ul>
</div>
Set the cache expiry in functions.php
// Alter expiry lenght on feeds (set in seconds)
add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 480;') );
Finally make it pretty with jCarousel
The idea was to have one tweet visible at a time – scrolling/rotating through the list. Grab your copy of jCarousel (it’s much bigger than jCarousel lite but by the time I’d figured out the trouble with my wp_head() it was time to leave well enough alone. To be revisited when there’s some time to optimize.) I’ll not go into the CSS – that’s there online.
<!-- jCarousel -->
<script type="text/javascript">
function mycarousel_initCallback(carousel) { };
jQuery(document).ready(function() {
jQuery('#djt-tweets').jcarousel({
auto: 8,
wrap: 'last',
vertical: false,
scroll: 1,
animation: 0,
initCallback: mycarousel_initCallback
});
});
</script>
WordPress jQuery conflict solved
Posted by admin in Asides, Web design & development on June 12th, 2010
After several hours of thinking I’m being a idiot (happens occasionally) I discovered that sometimes you’ll need to call
<?php wp_head(); ?>
before any jQuery scripts (or concatenated scripts in my case).
It’s been hours and I couldn’t figure out why none of the Carousel scripts I was trying today wanted to work – while all other scripts and plugins carried on just fine.
And yes – I am calling already trying to prevent jQuery conflicts with
<?php wp_enqueue_script("jquery"); ?>
So if your carousel (or other) scripts don’t want to work – try shaking up your head.