Saturday, April 26, 2008

SubEthaEdit as a Journal

I really like SubEthaEdit, a text editor for Mac. It's mostly geared towards programming, but I find that it's a really good editor for anything text-only. For example, my journal is plaintext to avoid file format changes.

I created a script for use within SubEthaEdit's AppleScript menu. It's silly stupid, and doesn't scratch the surface of what SEE's scripts can do but it fits my needs (laziness). Basically, I wanted the same template for all my entries so if I ever want to process them, I have labeled metadata to work with. I also wanted to automatically save them into my Journal directory with a timestamp for sorting.

I know there are other journals, heck I could even use Blogger. But I don't trust online security and other Journal apps either lock you into a file format or are bloated (or both). 

So here's my script. I hope it's useful to someone.
on seescriptsettings()
return {keyboardShortcut:"^~@n", displayName:"TKJournal", inContextMenu:"no"}
end seescriptsettings

-- You should type and select the title before invoking this script
tell application "SubEthaEdit"
set mySelection to contents of selection of front document as text
set myHeader to "title: " & mySelection & return
set myHeader to myHeader & "Date: " & (current date) & return
set myHeader to myHeader & "Category: " & "Personal" & return
set myHeader to myHeader & "Tags: " & "journal" & return & return

set contents of selection of front document to myHeader

set myFilePath to POSIX path of (path to home folder)
set myFilePath to myFilePath & "Documents/TKJournal/"
set {year:y, month:m, day:d} to (current date)
set myDateString to y * 1 & "-" & m * 1 & "-" & d * 1
set myFilePath to myFilePath & myDateString & "-" & mySelection & ".txt"
try
save front document in POSIX file myFilePath
end try
end tell

Friday, April 04, 2008

Food

I have been in California for 2 years and this is the second time I've had Chinese food in that time. Don't get me wrong, I've had Japanese, Thai, Vietnamese, Korean, Mongolian, Philippino, and other Asian cuisine's which would all be lumped together under one roof and called "Chinese" in Colorado. Chef Chu's in Palo Alto was delicious, but like the other place I went to, they didn't even have what I would call Chinese food staples such as Sesame Chicken, Sweet and Sour Pork, etc. The menu was slanted towards seafood, even the hot & sour soup had shrimp in it. I'm sure there's something to be said for authenticity, but sometimes you crave what you're used to.

On the other hand, I am much more sensitive to regional food now. When someone asks if I want to eat Indian, I usually ask whether the restaurant is North or South Indian (I prefer the vegetarian South Indian food). If someone wants to go to a Brittish Pub, I look forward to curry because it's going to be the best thing on the menu (besides the beer).

Wednesday, March 26, 2008

Laziness

I remember when I first realized I wanted to be an engineer, I was working at Target and I was constantly thinking of ways I could replace myself with a machine. I was fascinated with the "LRT" scanners and thought of so many ways to make the process better. "Efficiency is intelligent laziness" has been my motto ever since.

This is in stark contrast to the first time I actually tried programming, my eventual major and career. It was so hard, and took so long to do anything that I hated it. I think it was one summer during middle school when I went across the street to learn wood working with my neighbor's father and my neighbor came over to learn programming with my Dad. I think it's pretty cool that we carried the tradition of apprenticeship and I hope my own son will have a similar experience. But I digress. This experience of programming was to write "Hello World" to the screen using c++. It required so many files, a header and an implementation, not to mention the CodeWarrior project file and I was a hunt and peck typist at the time so it took over 2 hours to copy the program from a paper print-out. If it was so hard to write two words to the screen, how would I possibly write a game with graphics?!

One way or another, I stuck through it and now I am a software engineer and I have found ways to apply my motto to school and work. I still hate all the setup of programming though, especially for scripting languages. I wrote these programs to a.) learn them and b.) have a mkscript script that I can use to create a template for new programs. I think it's pretty cleaver that the template comes from the program itself!

Okay so I know perl, that will be obvious by how much better the perl program looks (or maybe perl is better??). But I thought it was lame to claim this is a good method for learning and not put it into practice, so I did Python and Ruby too.


#!/usr/bin/perl

use strict;

foreach my $file (@ARGV) {
if(not -e $file) {
open (FILE, ">$file");
open (READ, "$0");
while(my $string = <READ>) {
chomp $string;
print FILE "$string\n";
}
system("chmod u+x $file");
}
}





#!/usr/bin/python
import sys
import os.path

def main(argv):
for i in range (1, len(sys.argv)):
if False == os.path.exists(sys.argv[i]):
writeFile = open(sys.argv[i], 'w')
readFile = open(sys.argv[0], 'r')
try:
for line in readFile:
writeFile.write(line);
finally:
readFile.close()
writeFile.close()
os.system("chmod u+x " + sys.argv[i])

if __name__ == "__main__":
main(sys.argv[1:])





#!/usr/bin/ruby

for file in (ARGV) do
puts file
if not File.exist?(file)
writeFile = File.new(file, "w")
readFile = File.new($0)
while (line = readFile.gets)
writeFile.puts(line)
end
system "chmod u+x #{file}"
end
end


If it means anything, I knew perl so that one was easy. I knew Python in College, hated it then and hated it now as I wrote this script. Ruby, I have never used and I must say, I'm impressed. I learned and wrote that script faster than I wrote the Python script, which I should still remember. I still like Perl best, but I'd give Ruby a shot if I needed to.

Thursday, January 24, 2008

How I get things done

When I was in High School, I figured out how to take the shortest shower possible. The secret is one of those things that is really simple when you say it, really simple when you apply it, but really hard to accomplish day after day. Letting my mind wander while hot water pours over my body is the only reason I can get out of bed quickly, and since there's no such motivation (except the clock or water heater running out) to get out of the shower I usually hang out for a while.

So what's the secret? Two things: 1.) Use both hands to clean at all times and 2.) Get out when you're done. People will have other tricks like top to bottom washing or soaping dry but really, if you can keep moving you will be clean in under 5 minutes. If you're clean, why are you staying in the shower? (Except girls who shave in the shower, I'm not going to complain :)

This turns out to be the basis of my strategy for getting things done in the new year. 1.) I need to always use all the tools at my disposal. 2.) I need to stop when I am finished.

So far I've blown through a bunch of things that otherwise would have been forgotten, or done at the last possible minute. I got my car registration done which required an oil change, emissions, check writing, getting stamps and mailing. I cleaned out my closet and will take 3 bags of stuff to good will once I also go through my dresser. I researched and got a new credit card. I'm more productive at work also.

In addition to getting a lot done, I've noticed that this is exhausting and I go to bed tired every night. But it is one of those good fatigues that makes you sleep hard and wake up refreshed. I'm making such good progress that I can soon start on something I really want to do verses these things that I needed to do.

Tuesday, January 08, 2008

2008 Goals

As 2007 was the first year I created goals, I think it went pretty well. This year I'm going to focus on doing more awesome stuff. Not only adventures, but also completing projects and generally living my life more efficiently.

To help with that, I'm going to try out the GTD craze that everyone has been talking about. I may have missed the fad, but I think it could still help me stay focused and Get Things Done.

Maybe later I'll talk about the actual things I want to get done, and that will be my real set of "goals" this year but if I am going to do more, I need shorter deadlines.

Friday, December 28, 2007

2007 wrapup

for all practical purposes, this is the first year I made new year's goals since it's the first time they have been written down. So how did I do?

- Do something awesome:
Not many people know this, but I had a patent filed this year. I wont know for a couple years whether it is accepted but I have a copy of the patent application in my desk at work.

- Do something stupid (in the pursuit of awesome):
Although I never finished the story on my blog, my mustache fits this category quite well. Everybody hated it, and I loved it.

I have to tell this story because stories are what this goal was about. I shaved my mustache off and trimmed my sideburns on Christmas eve after everyone went to bed. I wanted to have Christmas eve pictures proving how long it got, but not ruin Christmas day pictures. Over the 2 months I grew it, it had become fairly thick and everyone noticed my mustache so I didn't have the embarrassing situation of people not noticing right away. I wondered if people noticed it because it was out of place on my normally boyish face, so I didn't tell anyone I had shaved it. Waking up, cooking and eating breakfast, gifts, and getting into the car to a movie were all family affairs and nobody noticed. Kyra was watching a video on her camera from Christmas eve and I said, "aww, remember when I had a mustache? Those were good times." Suddenly the car was in an uproar :) Lots of fun.

- Perform something in public:
I'm going to bring this one back to work, which wasn't the intention of the goal but it still fulfills it. I got to speak in front of over 300 people at WWDC this year. I was so prepared to be nervous speaking in front of lots of people that I didn't even consider that the lights would be too bright to see anyone. It was like practicing to an empty room, and it shocked me so much that my presentation was sub par.

- Keep the plants on my deck alive:
Absolutely failed. No excuses, it just didn't happen.

- Plan and take a vacation:
I went to Panama!

So there you have it. I give myself a 3.5 out of 5, since 3 were total successes and one was sub par. New goals will be made on the new year :)

Thursday, November 08, 2007

Update


My moustache is trickling in at a steady rate. It's good enough now that people can notice and laugh. I'm extending my donation's promise to this claim: If you donate to a good cause, you will be assured immunity towards making fun of me :) I think the entire lunch table at work ought to donate now.

In other news, I'm flying back to Colorado... now-ish. So if you live there, call me up and we'll chill.

Friday, November 02, 2007

Horse Racing

Today Apple had a party at the Horse Races. It was actually a lot of fun. We were given a voucher for some money to play with, and some drink tickets and food. They reserved the entire top section for us and had extra staff around to help teach us how to bet.

One thing I find interesting, not only in this situation but also in life life is how we throw around percentages, and which ones matter. If you can drive across town to save 10 cents per gallon of gas, you save one dollar per tank. I fill up every two weeks so that's 26$ for the year, .03% of my salary. If you just paid off your credit cards earlier, you could be talking about whole percentages saved, quite a bit more than stressing about frugal gas purchases.

Or how about savings? If you move your your extra savings into the stock market, you take on a small risk and (hopefully) your money grows much faster. The goal of any investor is to "beat the market", to get above that magic 20% return that you receive by simply investing in an index fund. But when you go gambling, you don't really feel happy unless you double, or triple your money.

If you played horses like you play the stock market, you would be extremely happy to get 20 cents per dollar. And I don't think that would be very hard. I guess there's some draw to "Winning Big" such as lottery and gambling, that supersedes the plain old "winning".

Thursday, November 01, 2007

Movember


The idea is simple. Bring awareness to prostate cancer by growing out your mustache. How hard can that be? If you're a skinny blond kid like me, it may be a little hard. But I'm going for it anyway. There's a website where you can support my peach fuzz.
https://www.movember.com/us/donate/donate-details.php?action=showrego®o=142643&country=us

I'll even make a deal. I will keep the mustache for 1 month AFTER November for every 5$ you donate. If you want to laugh at my stubble until next year, all you need to do is donate 60$ to prostate cancer (tax deductible). Maybe by then I can grow enough to wax it and curl up like the oldtimey studs. (I'm going to honor the max contribution, so if one person donates 5$ will keep it until the new year, 15$ will keep it through Valentines day)

I'll keep this blog updated with pictures. Be sure to check out Ryan Bruels for a real stud who will probably outgrow me by a meter.
https://www.movember.com/us/donate/donate-details.php?action=showrego®o=141291&country=us

Monday, October 29, 2007

Yosemite

How to have an adventure:

Go to Yosemite and walk around. It's a very beautiful place full of trees and tall rock formations.

Take a hike on one of the many trails. We went to Glacier point, and it was a crime how many people drove to the top rather than hiking. The path is so sheer you can get a sense of accomplishment as you look over the valley.

Walk home in the dark. It's scary, and probably more than a little stupid but the stars were perfect and the extra effort really bonded the four of us together.

Fly there. Driving is for wimps. Get some of your Google buddies to hop in their private plane and take you to Yosemite. Did I forget to mention that before?

And that's my weekend folks!

Saturday, October 27, 2007

Happy Leopard day

I'm going to ignore the pink elephant in the room and just talk about anything but. If you know me, ask about the pink elephant and I'll let you in but the web is no place for pink elephants.

But in other news, Leopard shipped! Work wrapped up a little bit ago for us because they need to put all the shiny disks in the plastic boxes but it's extremely nice to be able to talk about it finally. You should definitely check out iChat, which uses QuartzComposer to make you look even funnier while video chatting with your friends. There are also some pretty sweet iTunes visualizers and new image filters that are really nice. Of the three new QC screensavers, one started out as a little test I did to make sure the Noise patch was working.

Of course if you're into art or programming or any combination thereof, be sure to install the Quartz Composer editor application by installing the Developer tools. Real live features I put into Leopard are available for you to play with.

Hope you enjoy!