Quantcast

Un-fuX0ring Skype on Mac OSX

Skype is poorly-designed software, but I use it to chat with people who refuse to use anything else. I’ve already written how Skype is the worst software installed on my Mac, but now I have two new frustrations:

1. Skype doesn’t gracefully deal with my laptop going to and waking up from sleep. When my laptop wakes up from sleep, Skype should change my status back to online, but it doesn’t.

2. The control to change the Skype status message, which they called the mood message, is so hidden away that it’s difficult to change, and since you don’t see your own status in your buddy list, it is frequently out of date.

These are two things that iChat has no problem with. We could easily sync our iChat status with Skype if both applications supported AppleScript. We know that iChat supports AppleScript, but does Skype?

It turns out that Skype’s AppleScript support is limited to just one command that you can use to call Skype’s public API. That’s good enough for us, and an interesting solution to dealing with how frustrating it is for app developers to support AppleScript.

Here is a script that syncs iChat’s online status and status message with Skype. You can run it periodically via launchd, as described here.

#!/usr/bin/perl
 
use strict;
use warnings;
 
my $iChatStatus = `osascript -e 'tell application "iChat" to status'`;
chomp $iChatStatus;
 
my $skypeStatus = '';
 
if ('available' eq $iChatStatus) {
	$skypeStatus = 'ONLINE';
} elsif ('away' eq $iChatStatus) {
	$skypeStatus = 'AWAY';
} elsif ('offline' eq $iChatStatus) {
	$skypeStatus = 'OFFLINE';
}
 
if ('' ne $skypeStatus) {
	`osascript -e 'tell application "Skype" to send command "SET USERSTATUS $skypeStatus" script name "s1"'`;
}
 
my $statusMsg = `osascript -e 'tell application "iChat" to status message'`;
chomp $statusMsg;
 
`osascript -e 'tell application "Skype" to send command "SET PROFILE MOOD_TEXT $statusMsg" script name "s2"'`;

Pros and Cons of Wordpress Posting

As far as blog software goes, I think WordPress is pretty great. It’s open source, has a cool logo and is highly configurable. It’s also the only system I know …. because I would rather write stuff than learn about all the different blog software out there, each system with it’s own quirks and rules. Posting through the WordPress web interface has become a bit tedious though.

PRO

  • post from anywhere
  • image uploader is nice to have
  • post preview displays exactly as it will on the site
  • fabulous documentation in the Codex
  • XML-RPC interface, compatible with MovableType api

CON

  • post preview is far from the source text, so the preview workflow is slow
  • lack of AJAX means lots of waiting for the preview to load
  • by default posts are tagged as “Uncategorized,” and no warning when I forget to tag. This is more annoying than it sounds.
  • the “Uncategorized” tag apparently can’t be deleted
  • fully manual HTML, no help with image, href, or other tags.

So I’ve been doing my last few posts with ecto a client side blogging program for Mac and Windows. This is a big improvement over using the web interface, although Ecto is a bit clunky as well (feature overload).

Link to ecto blogging software.

Crashes in WebKit: Dodge or Parry?

I love WebKit. It allows you to embed an HTML view anywhere in your app. It’s an HTML view that behaves exactly like Safari because …. well, Safari uses WebKit. Having a fully functional HTML view is an important part of almost any modern application. Unfortunately though there are some bugs, some of them crashing bugs, especially if you use WebKit in a way that is outside the common path that Safari uses. And these bugs won’t be fixed for most users until Leopard ships next year.

Here is an example. I was debugging this for many hours. Somewhere a piece of the WebView is getting over-released and causing a crash. This type of bug is notoriously hard to analyze and fix. I thought it was in my code, but it turns out it was in WebKit.

2005-07-24 01:29:26.070 macbook[4264] *** Selector 'release' sent to dealloced instance 0x8faf1e0 of class WebHTMLView.
Break at '-[_NSZombie release]' to debug.
2005-07-24 01:29:26.086 macbook[4264] *** -[NSAutoreleasePool dealloc]: Exception ignored while releasing an object in an autorelease pool: *** Selector 'release' sent to dealloced instance 0x8faf1e0 of class WebHTMLView

So what can I do? A major feature of my application is downloading a load of web pages and converting them to PDF files. WebKit is a great way to do this. Well, really it’s the only way to do it. Except for the crashing part. So after giving up on fixing this over-release crash, I split out my html-to-pdf code into a separate, small command line program. It works great, and is just the thing for “defensive programming.” For example if some random web page I load has a plugin that crashes webkit, it will only crash my helper program, not the app itself. iChat uses a similar technique for video conferencing (look around for “vencoder”). My command line webkit program size is 68kb.

So to any other developers seeing this crash, or to anyone thinking about using WebKit as a data processing tool rather than a web browser: fork off a separate process. It will save you a lot of heartache and make your application crash much less.

Link to the WebKit Homepage

Update! … rajbot sez:

The great thing about WebKit being Open Sores is that you can embed the latest versions of the frameworks in your app, and set the right env variables to tell WebKit to use those instead, like the nightly Safari builds do..

That’s a good point. I might just do that. And that way I can just fix the bugs myself if I need to… yay! :-)

Steampunk Goggles!!

mikest made these gorgeous steampunk goggles with machined and polished brass, hand sewn attic leather, and dichroic filters from an old cyberlight. The quality of Mikey’s work always blows me away!

How to count in SQL

Your average programming language has a way of doing the same thing over and over again multiple times. Maybe a few different ways. After all, that’s why god invented computers. I mean what’s programming language without iteration? Python has a neat way of doing this. You can say:

[python]
for i in xrange(x, y, s):

[/python]
xrange generates a list of integers (conceptually) from x to y, incrementing by s, so it’s a quick and clean way to do your repetitive business. True to Python minimalism, the first and last arguments are optional. If you leave them out the loop goes from 0 to y.

Sadly, SQL has no analogue. A local SQL veteran here has confirmed to me that SQL has no way of generating lists … you have to put stuff into a table. Give that this is the case, I decided to put my small but useful sequence (integer dates representing the past 48 hours, hour by hour) into a temporary memory table. Here’s how to do it:
[sql]
CREATE TEMPORARY TABLE hourlycal ( id INT AUTO_INCREMENT PRIMARY KEY, date int(11)) ENGINE = MEMORY;
INSERT INTO hourlycal (date) SELECT NULL FROM reporting.Session LIMIT 48;
UPDATE hourlycal SET date = FROM_UNIXTIME(UNIX_TIMESTAMP(),”%Y%m%d%H”) – id*3600;
DROP TEMPORARY TABLE hourlycal;
[/sql]

There you go. Very handy. At least for me. Note that it takes a table to make a table :-). You have to select from something in order to insert the NULL’s. This is based on ideas from Artful Software.

Link to Artful Software

whaddya look like?

So I was reading over here today about a silly thing wherein you type “[your name] looks like” into Google for some fun results. Unfortunately, since my name is a verb and a month, I got lame results. However, you two got some fun ones :-)

  • Raj looks like a typical young American.
  • Raj looks like he’s going to kill me.
  • Raj looks like Thackeray, wears Thackeray style glasses, dresses like him, talks like him, draws cartoons like him, believes in non-violent politics like …
  • Raj looks like any normal guy- he’s 6’2 175 lbs, and is successful in school.
  • Raj looks like he’s about to swallow a carrot!
  • Jesse looks like a hedgehog.
  • Jesse looks like a good role-model for oil-addicted, car-obsessed testosterone-high American men
  • Jesse looks like he could revert to his school self.
  • JESSE LOOKS LIKE A DRAG QUEEN!!!! HE USED TO BE HOT
  • Jesse looks like he has money.
  • Jesse looks like he has a few days of growth on his face.
  • Jesse looks like someone else
  • Jesse looks like he is going to make it
  • Miss May looks like it’s beyond precious!
  • The strangely styled MonoMachine may looks like the mutant offspring of an old Amstrad PC.
  • For example this file may looks like so: Your request has been accepted. We will reply as soon as we can.
  • They haven’t been this high since Katie left in May. Looks like everyone wants to see Meredith’s point of view.

Zara, Frisbee Dog!


I taught Zara how to catch a frisbee today.. It only took about twenty minutes. How long do you think it would take to teach her ultimate?

Should We Go to Hack Day?

Hackday-Countdown

So there seems to be some confusion among <TR> board members. On the one hand, Yahoo Hack Day looks pretty geeky. On the other hand, it’s probably a good thing for us to go to. We should go and show our mad AJAX skillz!

What do you think?

Link to Yahoo Hack Day

Twitter Implements Callbacks!

Less that one day after I called them on the phone, the good folk at Twitter have already pushed out callback support, and we’re now using it on this site!

Here is the email I just got:

Hi!

Cool stuff you are working on =)

I’ve just deployed callback support for the api:

http://twitter.com/statuses/user_timeline/6760.json?callback=myCallback

If you have any questions, etc.. let me know.

Ciao!
Florian

Note that this URL is different from their standard badge URL.. Thanks Twitter!!!

Here is a short tutorial on how to add your twitter badge to your webpage, in such a way that it doesn’t slow down the initial page load.

1. Put this html snippet somewhere on your webpage. Replace USERID with your actual twitter numeric id.

<div id="my_twitter_status_USERID"><img src="spinner.gif"></div>
<div id="my_twitter_status_time_USERID"></div>

2. Add an onload attribute to the BODY tag in your html:

<body onload="initTiki();">

3. Add three javascript functions to the HEAD portion of your webpage:

<head><script type="text/javascript">
function twitterCallback(obj) {
	var id = obj[0].user.id;
	document.getElementById('my_twitter_status_' + id).innerHTML = obj[0].text;
	document.getElementById('my_twitter_status_time_' + id).innerHTML = 'sent ' + obj[0].relative_created_at;
}
 
function twitterStatus(url) {
	var twitScript  = document.createElement("script");
	twitScript.setAttribute("type", "text/javascript");
	twitScript.setAttribute("src", url);
	document.getElementsByTagName('head')[0].appendChild(twitScript);
}
 
function initTiki() {
	twitterStatus('http://twitter.com/statuses/user_timeline/USERID.json?callback=twitterCallback&count=1');	
}
</script>
</head>

That’s it. If you want to be sure that your badge is very up-to-date, you can get around some JS caching issues like by adding a random parameter to the url. This is more of an issue for IE users, and since we don’t know any of those, and we don’t like waiting, we don’t use this technique. Here is an example, tho:

function initTiki() {
	var rnd = '&rnd=' + Math.random();
	twitterStatus('http://twitter.com/statuses/user_timeline/USERID.json?callback=twitterCallback&count=1'+rnd);	
}

MY IDEA!



Holy crap this site is funny.

Why are people always stealing my ideas?

Like penis in vagina sex. MY IDEA.

Link to ..:Things My Boyfriend Says:..

TwitterTronix

Want to know why Web 2.0 is sooo much better than Web 1.0? It’s because I just talked to Jack from Twitter ON THE GODDAMN TELEPHONE, and he’s says they are going to implement a callback param for their web API, just because I asked :)

Web APIs that return JSON are great, but not all browsers fire onload events for script elements, so if you want to load the JSON asynchronously/dynamically/on-demand, you need to think of something else.

One good way of doing this is wrapping the returned JSON in a callback function, which is best done by adding a callback param to the API, as shown below:

http://twitter.com/t/status/user_timeline/6760?count=1&callback=myCallback

This returns the exact same JSON, just wrapped in a call to your callback function:

myCallback([{"user": {"name": "rajbot", "id": 6760, "screen_name": "rajbot"}, "text": "enjoying the second summer :)", "id": 35084, "relative_created_at": "about 3 hours ago", "created_at": "Mon Sep 25 22:20:49 UTC 2006"}]);

Very simple, and it works in all browsers, so it’s wonderful that Twitter is going to update their API. But what if you are impatient like us and want to use this technique RIGHT NOW? Well, if you don’t care about error checking, you can wrap the existing Web API with three lines of your favorite scripting language:

<?php
	$id = $_REQUEST['id'];	
	$result = file_get_contents("http://twitter.com/t/status/user_timeline/{$id}?count=1");
	echo "twitterCallback($result);";	
?>

We now display the twitter status in the header. Since we call the Twitter Web API after the entire page finished loading, our readers no longer have to wait for the Twitter servers to respond before reading our babble. We expect this bump up global productivity by several minutes!

Update: Twitter has implemented callbacks! That was fast :)

A CMS in Every Bedroom….

Jamie tipped me off to Radiant, a CMS (content management system). I didn’t even know what a CMS was. To me it looks like a really pretty and easy to use wiki type of thing. I guess that’s what content management is. “It’s just a bunch of stuff that happened.” Oh, and Radiant is an open source project based on Rails.

Surf NYC!

Even though mang has moved to NYC, he’s still a San Franciscan at heart. Here’s a phonecam shot I got yesterday from mang, taking his surfboard from Manhattan to Long Beach on the train!

Incidentally, we went to the Exploratorium yesterday and got to see the very fun exhibit mang worked on this summer. Everybody loved it! We’re going again on Oct 4, and you should come!

Welcome to 2.0, part 2: Google Reader

So I recently learned (a few years too late) that the way to keep up with a 1000 pounds of RSS is to use a news reader. Actually, that’s not true .. it’s just that I didn’t enjoy using the client-based readers I tried. Server side sounds better, less intrusive than an email gateway and keep all the subscriptions in one place.

Google Reader is an improvement, but I still feel some “friction” using it. Luckily while test driving Google Reader I found an O’Reilly article about how to use AJAX to build an RSS Reader. Custom RSS readers … an essential part of modern lifehacking?

Google Reader
RSS and AJAX: A Simple News Reader.

Lie Down on the Tracks

Today I’m learning what this Ruby on Rails thingy is all about. As you can see from the screencasts, it’s a web development environment optimized for Hackers on Speed. But I’m thinking I might be able to crank out a page or two. Apparently textmate is required equipment.

I think my CGI.pm days are over :-(

Link to Ruby on Rails

Updating Twitter via iChat or AIM status message

Update: Here is a Cocoa version that is easier to use!

May did a good job selling us on Twitter, so now you can see my twittr status in the sidebar.. I wished that changing my Twitter status was as easy as changing my iChat status, so I hacked up this bit of perl that will update it when your iChat status changes. It runs every five minutes via launchd, and uses the newly-announced Twitter API.

[perl]#!/usr/bin/perl
use strict;
use warnings;
use URI::Escape;

my $user = ‘user@example.com’;
my $pass = ‘pin’;

my $isAvailable = `osascript -e ‘tell application “iChat” to status’`;
chomp $isAvailable;

exit if (‘available’ ne $isAvailable);

my $status = `osascript -e ‘tell application “iChat” to status message’`;
chomp $status;

if (” eq $status) {
$status = ‘lazy’;
}

my $savedStatusFile = ’savedStatus.txt’;

my $savedStatus = ”;
if (-e $savedStatusFile) {
$savedStatus = `cat $savedStatusFile`;
}

if ($status ne $savedStatus) {
#status changed, update twitter

my $encStatus = ’status=’ . uri_escape($status, “^A-Za-z0-9″);

`curl -s -d ‘$encStatus’ -u $user:$pass http://twitter.com/statuses/update.xml`;

open (FILE, “>$savedStatusFile”) or die “can’t open $savedStatusFile for writing”;
print FILE $status;
close FILE;
}
[/perl]

You can get launchd to run the script every five minutes by creating a file called ~/Library/LaunchAgents/net.tikirobot.status.plist that looks like this:
[xml]

com/DTDs/PropertyList-1.0.dtd”>


Label
net.tikirobot.status
ProgramArguments

/Users/user/status.pl

StartInterval
300
[/xml]

And then load the job using:
launchctl load ~/Library/LaunchAgents/net.tikirobot.status.plist

Update: The script now uses URI::URL and POST. Fixed a typo.
Update2: Now uses URI::Escape

Get your own exploding dog drawing!

ifyoutellmeicanhelpyou.gif
if you tell me i can help you…

Next to Andrew Bell, Sam Brown makes my very favorite web doodles. All of his drawings are based on titles that people submit to him…And if you send him a title for a drawing by September 30 (via snail mail), you’ll get an actual drawing back! (via snail mail). Here’s what he says:

from monday october 2st to friday october 6th i will be doing drawings from titles mailed to me. mailed in a truck. i will mail you the drawing back to you. in a truck.

mail me an self addressed stamped envelope, and include a note with the title you want. you must include a title. even it is just a throw away title. please have it arrive my mailbox before september 30th.

i am just trying this out, i am not promising anything. the drawings might be good they might suck.

for the self addressed stamped envelope. you can mail me any size envelope you like as long as there is enough postage to get it back to you.
if you send me an envelope that can hold a 8.5 x 11 inch paper, i can use some cool paper and don’t need to bend or mash it to get it in the mail.

all mail goes to:

sam brown
explodingdog
po box 274
derby ct 06418

The Canon SD700 is awesome

Go out and buy one … seriously. I’ve always been skeptical of “Image Stabilization Technology,” but check out this shot taken hand-held at 1/8 second up on Nebraska street:



Anybody want to buy my old camera?


… that’s the new one on the right.



I also made a SD700 shootout Slide Show with a bunch of example shots. These photos are unedited so as to show the results of the camera itself. Most of them were taken using full auto mode.

More Parking

May beat me to the post! Here are some photos of the PARK(ing) spots that I rolled by this morning on my bike



Link to “parking” on Flickr
Link to Rebar

PARK(ing) Day

sf_parking_5.jpg
Today is Park(ing) Day here in SF – a day to temporarily transform a metered parking spot into a PARK.…at least until the meter runs out! Here’s an email Arena sent about it

Today I will be volunteering to help deploy the “Temporally Displaced Open Space” in the downtown area of San Francisco — part of PARK(ing) Day. Or, to put it more succinctly, I’ll be hauling dirt with my bicycle trailer.

If you get time today (Thursday), check out some of the installations all around downtown (one near Axis Cafe in front of CCA(c) and one in front of Ritual Roasters on Valencia). This is a one day art installation to visualize the potential of parking spaces as green spaces.

Consult the map:

http://communitywalk.com/map/19478

or the website:

http://rebargroup.org/projects/parkingday/index.html

and please pass those links on to anybody that you think would be interested …or make a PARK(ing) space of your own, it’s an open-source project.

Buy Rite is the Future!

Three years ago, when I had ants in my pants to start my own business , I had an idea. The idea was inspired by Delicious Library. DM had very cleverly made use of the the Mac’s iSight Camera to read in the barcodes of your DVDs, CDs and so on. All the better for cataloging your loot. “But” …. I was thinking … “there are cameras on cell phones too. What if you were in a store, scanned the barcode of something you want to buy with your phone and then your phone instantly showed you whether the product was made by a Sucky Company or not. Based on your own definitions of suckiness, of course.”

I was very happy today to see the iBuyRight project, which attempts to do exactly that! (Thanks to Adam for the link).

Unfortunately it appears there is some drama between one of the founders of iBuyRight and the UC. Down with parasitic institutions! Support Lilia Manguy!!

Link to Lilia Manguy’s experience.

All Tied Up

etsyCord01.jpg

I love surprise packages, and this one just came in the mail! It appears to be a hand-knit electrical cord of some sort from Etsy, though I think Bandit thinks it’s her new toy. (Bandit’s my brother’s cat who I’ve been cat-sitting for the past month). whoever sent it…thank you!!! :-)

bandit01.jpg

bandit02.jpg

Ah Youth, Wasted on the Kittens…

This is one of those videos that you just can’t help laughing at, no matter how many times you watch it.

Titled “Really Expensive Cat Toy” on YouTube…..

It’s Otto!

Ethan and Emily are fostering Otto, a *very adorable* pup-pup for two months. Maybe when Otto is finished recuperating he can go to the beach with Zara and they can chase frisbees and dig some holes in the sand :)

Twittering!

twitterLogo.jpgYou guys have probably noticed this already but I added a little twitter status thingy to our sidebar! so you can uh, keep track of my twittering (not sure why you’d want to, but let’s just pretend you do :-) I’ve been playing with it for a couple months and I really like it! It’s sort of like IRC via SMS, the benefit being that I don’t have to be at my computer to send messages (cause I can’t carry my laptop with me everywhere…and important things could be happening…like that time I couldn’t decide between Cherry Garcia or Chunky Monkey, where were you people????) Anyways, you can decide whether you want to get updates or not – just turn them on or off anytime from your phone. No need to go to the web to manage all your options – check out all the commands you can issue via SMS on the fly! (I sent you guys invites so you can add your twittering to our sidebar too :-)

Older Posts »