Jun 10 2008

Send an Email Later

Posted by Dean

A friend came to me with a small problem. She wanted to email her boss, but she didn’t want him to know she had been up late; she wanted to send it first thing in the morning, when she wouldn’t be awake, and she’s on a Mac.

Apparently, Outlook and Entourage can do this, and I hunted around for a way to do it in either iCal or Mail.app, but I couldn’t find anything. An Automator script would be great, but she was going to bed soon and needed something quick.

I made two quick-and-dirty solutions to this, using the at daemon. First you have to turn it on. From the terminal, run the following (without the leading ‘#’):

# sudo launchctl \
load -w \
/System/Library/LaunchDaemons/com.apple.atrun.plist

That just tells Apple’s launchd program to run the at daemon, atrun.

Next, we’ll make a job for at to run later. Here’s the quickest-and-dirtiest way:

# echo \
  "echo \
  'This is the message body.' \
  | mail -s \
    'Email Subject' 'you@example.com'" \
  | at 7:30am

(Note that at takes the command to run on stdin; thus the redundant echos.)

It may seem like a jumbled mess, but, assuming you don’t use any quotes in the email body or subject, you can just replace them (and the email recipient) with exactly what you want. (If your subject or body do have quotes, you’ll have to escape them properly, which I’m not going to cover.)

The next method, which is probably easier if you want to send an email with more than one line in it, starts by opening a text file and writing your email. You can use “TextEdit” or any plain text editor. The trick here is to put some headers up top:

From: me@example.com
Reply-To: me@example.com
To: you@example.com
Subject: Yay! Email!

Here is your email.

Yay, email!

Yours truly,
Chewbacca

PS - Rawwwwrrrr!

Save this in your home folder as email.txt. You need those headers on top for the sendmail program to be able to tell where to send it.

Then, in the terminal, we’ll make an at job that uses this file:

# echo \
"sendmail -t < ~/email.txt" \
| at 7:30am"

And you’re done! If you want to test the at command first, replace “7:30am” with “now + 1 minute” (which means “1 minute from now”; how about that?), and change the recipient’s email address to your email address.

Filed under : tutorial | 1 Comment »
Dec 19 2007

LSL HTTP Servers

Posted by Dean

XML-RPC in LSL, as it stands, demands centralized servers that are constantly bombarded with traffic. Kelly Linden has proposed a new solution that practically amounts to a prim having its own little web server. I highly recommend voting for it.

Filed under : link | No Comments »
Nov 05 2007

The Tyranny of Fetishistic Compulsion in Programming

Posted by Dean

For you programmers out there, this is for you. For everyone else, just humor me; this won’t take long.

I’m taking a brief primer on C# (which, granted, is almost a beginner-level tutorial, but I didn’t want to miss anything important that an expert programmer’s primer may have passed over), and I’m reminded of some very disturbing things about the world of strictly-typed programming languages:

They’re designed by people who have RSS and email inboxes of zero unread items; both count and avoid cracks, twigs, and cigarette butts on the sidewalk; and SUCK ON DIRTY TOES FOR SEXUAL PLEASURE. I might also accuse them of being fundamentalist automata, but automata don’t have the emotional baggage necessary to inflict such misery on their fellow beings.

I began my computer science education by learning these kinds of languages, and I can’t blame my professors; teaching students scripting in esteemed computer science departments was a huge no-no. And consequently, I was mostly oblivious to the unnecessary sadism that was being inflicted upon us. C++ was the first remotely object-oriented language I learned, and while I was, like many students, unhappy with the level of specificity it required, I was generally satisfied that C++ was A MAN’S PROGRAMMING LANGUAGE. No pussies allowed. Runtime garbage collection? What are you? A terrorist? Implicit typecasting? Fuck off, cross-dressing hippies. I had no idea that I would soon, voluntarily subject myself to a much more hideous example of computer science sadism: Java.

At least C++ didn’t force you to write object-oriented code. I took an elective Java lab course a few semesters later. At the time, I thought: Gee, what a consistent language! The rules are elegant and applied without discrimination. Everything’s OOP. Polymorphism is easy. Completely virtual classes are possible. No confusing multiple inheritance allowed, and neither is any silly object overloading bullshit. Terrific, right?

I must be, only now, coming out of a haze of type-lenient, quick-and-dirty scripting utopia, because it’s only now that I remember what made me run screaming from pure, strictly typed, enforced OOP. I still don’t even think I can completely quantify it. Is it the bloat? Sure. What about wasted time worrying about method and property restrictions? Yep. Even more wasted time spent writing subclass upon subclass upon subclass or implementing interfaces? Definitely. How about the frustration of fixing bugs through subclasses? Aye. The complication of working through insane namespace spiderwebs? The migraine-inducing procedure of visualizing polymorphism on multiple levels? The insanity of writing one-line accessor methods? Did I mention bloat? All of the above.

I may have been overly generous to grant the designers (or strict adherents) of these languages the relatively mild sexual deviance of sucking on dirty toes. This level of sadism, control, and even masochism can only force the human psyche to act out in much more destructive ways.

I’m well aware that the more monastic languages have their place, especially those applications where security, provability, and/or the protection of human life are required. But if you’re not doing that, take it easy, folks. Try out some BASH one-liners on occasion. Or (gasp!) PHP in line with XHTML. Maybe even some easy-go-lucky Python. If no one else has to read it, maybe even PERL. Throw some caution to the wind. Make it easy on yourself.

Filed under : article | 2 Comments »
Oct 31 2007

New Items For Sale

Posted by Dean

I’m now selling both Gazebo Fu and my silver park lamp on OnRez. Take a look!

Gazebo Fu

Silver Park Lamp

Filed under : pimp | No Comments »
Oct 13 2007

W. T. F.

Posted by Dean

You (or some guy at Keio University) can now control your Second Life avatar with your braiiiiiiin!

Filed under : link | No Comments »
Sep 30 2007

Gazebo Fu

Posted by Dean

I built this gazebo today for fun … instead of finishing my Upcoming Access Controller Project(!).

It’s on sale (also for fun), available here (SLURL) and here (direct map link).

Filed under : photo | No Comments »
Sep 14 2007

LSL Script Delays Hurt the Wrong People

Posted by Dean

At some point in the history of Second Life, Linden Lab decided that griefing and spamming were such terrible problems that they put in little speed bumps all over the place to prevent abuse of things like automated inventory offers, external URLs, object rezzing, instant messaging, and others.

For instance, say you want your script to offer inventory to the person who just clicked on your object. As a new LSL scripter, you do the straightforward, obvious thing:

  1. Detect a touch.
  2. Give a virtual nickel bag to the avatar who just touched the object.

You may even go so far as to detect multiple touches and offer everyone who just touched the object their own nickel bag. Soon you find that your everyone loves the quality of your hydroponic, closet-grown product, and people start complaining. “You got something against furries? Why I can’t I have a nickel bag?” Or “Your MJ vendor is broken, dude.”

You scour the documentation and soon find that there’s a built-in delay to giving inventory. In particular, llGiveInventory() has a built-in delay of three seconds. Crazy! How do you make sure to give everyone who wants it their own piece of chloroplastic heaven?

The most common technique seems to be what is affectionately known as the “multiple-slave-comm-script” trick, or as I prefer to call it, the “dispatcher-to-agents” technique. In this technique, there is one dispatcher and many agents. In this example, the dispatcher would work like this:

  1. Detect a touch.
  2. Send a message to one of the agents (via a link message).

An agent would work like this:

  1. Detect a message from the dispatcher.
  2. Offer a nickel bag to the avatar who touched the object.

The dispatcher should start with the first agent and work its way down to the last one before starting over. This way, only the agent is affected by the script delay. The dispatcher is immune and can happily go along ordering the agents around all day with no script delays. Beautiful!

If your happy grass gets really popular, you may start to notice that the dispatcher loops around to the first agent before its script delay is done; you got caught by the inherent race condition in this technique. So, to beat it, you make some more agents, and more agents, and more agents, until you discover that all of your agents stop working. “WTF?” you may ask. WTF indeed.

In yet another effort to reduce griefing and spamming, LL implemented further so-called protection. They knew people would use the dispatcher-to-agents method, and when a single object starts doing something griefy or spammy too quickly, they just disable the guilty scripts through some unknown means. There seems to be no warning. And all you can do is reset your scripts and start over. It also seems that this new “protection” only takes effect if there are enough scripts doing the griefy/spammy actions too fast. In my brief experimentation, 16 seems like too many, and the agents are quickly disabled, but 10 is too few, and they run along happily.

But for a popular vendor, 10 agents are simply not enough to avoid the race condition, but at this point, you give up and rationalize that you’ve mitigated the consequences of LL’s anti-griefing and anti-spamming measures as best you can. You console yourself that these protections are also stopping griefers and spammers from maliciously offering inventory too quickly.

But wait, aren’t you an honest avatar, trying to give away your pot in peace? You’re not spamming anyone. You only give it out to people who ask for it!

Here’s the problem with LL’s LSL speed bumps: They don’t prohibit griefers and spammers from working around the problem. When it comes down to it, does a griefer or a spammer really care if they hit the race condition? A spammer may, but they’re still able to spam. A griefer probably doesn’t. But you, the honest avatar who wants to write robust software that works reliably so your customers are satisfied is the one who suffers. The spammer still spams. The griefer still griefs. You and your customers suffer.

(On a side note, this problem is orders of magnitude worse when dealing with XML-RPC.)

What is a virtual person to do? Vote for JIRA issue MISC-686, and ask Linden Lab to remove script delays and grey-goo mitigation, and let honest developers write truly robust and reliable code.

Filed under : article | No Comments »
Sep 02 2007

iTunes Boots NBC

Posted by Dean

Apple issued a to-the-point press release earlier this week, saying they wouldn’t be carrying NBC TV content starting this month. Apparently, NBC wanted to charge five bucks for a single episode and thought Apple wasn’t doing enough to protect those shows against piracy.

Before your brain explodes from the sheer nonsense from NBC, have a look at Jeremy Horowitz’s retort, which takes NBC to task for its hypocrisy and says just about everything I would have.

Filed under : article | No Comments »
Aug 15 2007

They’re In My Ears!

Posted by Dean

Dear Apple,

Your stock iPhone headphones suck really hard.

I live in New York City. You might know it. It’s that place where people walk, loud noises happen, and tons of people love your products. Every day I walk to and from the train. Your headphones do not stay in my ears during this activity, apparently rare every else, except with some precision placement worthy of a champion Jenga player. Every day I walk under an elevated train to the coffee shop and ride trains that produce what some may know as “loud noise”. I love that nifty control button on the mic because I have to use it during these occasions to pause the audio, lest I miss several minutes of “Buzz Out Loud” or “TWiT” or “Science Friday”. In case you’re unaware, those are podcasts that you syndicate on your iTunes Store. Podcasts. Things you listen to. On the go. On your iPhone. In your ears.

These V-MODA headphones you offer are not an acceptable alternative. You remember that control button on the mic? They don’t have one. I think I may have use for that pause button since I can’t pause audio without unlocking the iPhone otherwise. I recommend you ban V-MODA from your store because of their inability to sell decent after-market products.

And these? Really? Do I really need to buy two things to listen to audio on the iPhone? And do I really need to use a clip to position the mic near my mouth? Please also ban Shure.

I not only come to you with criticism but with a solution! What is this miracle of ingenuity? This innovative new thinking? You know those other headphones you sold for the iPod? Yeah, those. Uhm, why not sell those for the iPhone with the same fancy mic and control button? Genius. I know you never thought of it because it’s been two months since I bought my iPhone and they’re not out yet. Therefore, I must be the first person in the universe to have this idea. You’re lucky to have me on your team, guys.

Sincerely,

Dean and His Pants

Filed under : article | No Comments »
Aug 14 2007

Buh-Bye, Linux

Posted by Dean

Tags: , ,

The hard drive on my Linux box failed today, which leaves me, for the moment, in a Mac-only household (well, just me): two iMacs, a MacBook, an Apple TV, and an iPhone.

While my attention as of late has been focused on development in Second Life (as it pays the bills), I had been resisting the urge to come to real terms with the “former” in “former system administrator”. I’m a developer now and will hopefully continue to be. Unfortunately, the Linux box was doing a few very important things. Most importantly, it was running backups on itself and my main iMac. That’s not something I can just ignore.

So now my choices are:

  • Get a new hard drive and repair the Linux box. This is simply not going to happen. In terms of daily life and of long-term planning, Linux and system administration are just diversions, distracting me from honing my development skills.
  • Run a virtualized Linux on the old iMac (or a new Mac Mini). If I were to ditch Gentoo, this might be easier, but for the reasons above, it’s not an option either. I don’t want to divert my resources.
  • Run backups on the old iMac (or a new Mac Mini) from Mac OS. This seems feasible. Assuming MacPorts is still an active project and they have builds of rsnapshot (the best backup utility I’ve used), this should be a no-brainer.

One problem remains, though. The filesystem on the backup drive (an external USB 2.0 and Firewire 400/800 drive) is ReiserFS over LVM. I have no idea if Mac OS can handle these natively, so I may have to do some swapping around with a virtualized Linux just to get my backups out.

In any case, I guess I’ll be Linux-free by the time this is all over.

Filed under : article | No Comments »