日期Calendar
QuicksearchCategories |
Wednesday, May 6. 2009Run Script at Mac OS X Login
I know alot of people want to know how to do this. The solution is usually creating a shell script and naming it with the '.command' extension so it'll launch the Terminal.
The cleaner way is through a simple launchd plist placed in your ~/Library/LaunchAgents folder. Here's my example: $ cat ~/Library/LaunchAgents/com.latcarf.loginscript.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.latcarf.loginscript</string> <key>ProgramArguments</key> <array> <string>/bin/bash</string> <string>/Users/latcarf/Documents/script/loginscript.bash</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> # Start it up $ launchctl load ~/Library/LaunchAgents/com.latcarf.loginscript.plist # Or just reboot or logout and back in to kick it off. # Only runs once at login. Sunday, March 15. 2009It's not MAC!
Just a little pet peeve I need to get off my chest.
I know all you PC folks are coming over to the Mac in droves and that's a great thing. It's great for you and for me. You'll have a much better computing experience (and life in general) on Mac and I'll still have a job making software for you. So win-win all around! One little behavior we need to correct though, is how you write about your new computer. In the Windows world it's normal to write PC, or DELL, or IBM in all capital letters. Heck, in DOS (all caps there too) it's even proper to write FOLDER NAMES in capital letters as well, isn't it? In the Mac world however, it's wrong to write Mac in all caps (and generally wrong to write folder names in all caps - it just looks like you're yelling). Yeah, I know it's a hard habit to break; writing Mac vs. MAC. I mean, you're gonna have to hold down the shift key a little less, and that's tough, but you should be getting used to doing things with less effort now that you have a Mac, right? Besides, you don't need to yell about your Mac. We all know how much better they are (we've been using them for years) and Mac users generally appreciate a little more subtly (you'll understand that as you get used to using your new Mac). Anyway, Mac is the first three letters in the word Macintosh, which is a kind of an apple. Apple makes computers (and other hardware) and a Mac is a kind of Apple computer. See the correlation here, kind of witty huh? Anyway, you never see the word Macintosh with all caps for the first three letters: MACintosh. That just looks weird right? Well, using MAC to talk about Mac computers looks weird too. So, if you could just please not do that, it would be great. Oh, before you go there is one instance where you'll want to use the all capitals version of the word MAC. That's when you need to talk about the "quasi-unique" identifier that's assigned to your network adapter. It's known as a Media Access Control address. All computers that can connect to a network have these and they're certainly not limited to Mac. Hey, I guess you also might want to use the all capitals version MAC when you're talking about MAC cosmetics as well, but that has nothing to do with computers. Ok, so just to make sure we're on the same page... Use Mac and not MAC and we'll all get along great. Thanks! Tuesday, February 26. 2008Comments (0) Trackbacks (0) Fink on Leopard With Blocked CVS Port
Recently I wanted to use Fink on my Leopard machine at work. This sounds simple but there are a few complicating factors. First, there are no Fink binaries for Leopard as of this writing. Ok, so that's not a big deal, I can compile it easy enough, Fink made an easy to use bootstrap script for that purpose. Secondly, as far as I know, as of this writing, we can't use rsync mode during Fink's self update on Leopard. So, the solution is to use fink selfupdate-cvs. This leads to the third problem which comes from the fact that my company is strict about blocking ports. Unfortunately the cvs port 2401 is blocked. Fortunately however, SSH (port 22) is not. So my solution is to temporarily port-forward cvs through ssh to my home server so I can run fink selfupdate-cvs to pull down all the great package descriptions I need for my fink install.
Here's are my notes on what I did: # I needed to find where the cvs urls were set so I grepped in /sw cd /sw grep -R fink.cvs.sourceforge.net * # That eventually turned up the following potential places to make changes: lib/fink/URL/anonymous-cvs:fink.cvs.sourceforge.net:/cvsroot/fink lib/fink/URL/cvs-repository:fink.cvs.sourceforge.net lib/fink/URL/developer-cvs:fink.cvs.sourceforge.net:/cvsroot/fink lib/perl5/Fink/SelfUpdate/CVS.pm: my $cvsrepository = "fink.cvs.sourceforge.net:/cvsroot/fink"; # Since I only needed to get package descriptions I figured /sw/lib/fink/URL/anonymous-cvs # was the file I wanted change to handle my port-forward solution. cd /sw/lib/fink/URL/ sudo cp anonymous-cvs anonymous-cvs.orig nano -wz anonymous-cvs # Here I changed: fink.cvs.sourceforge.net:/cvsroot/fink to: localhost:/cvsroot/fink # Then it was a simple matter to create an ssh tunnel to an external server where I have # the ability to login and its port 2401 is not blocked. ssh login@domian.example -L 2401:fink.cvs.sourceforge.net:2401 # Finally, I ran the fink update command: fink selfupdate-cvs # Hooray. Now everything works as expected and I probaly don't need to use it again unless I need # to update package descriptions sometime in the future. So, I changed things back: cd /sw/lib/fink/URL/ sudo mv anonymous-cvs anonymous-cvs.custom sudo mv anonymous-cvs.orig anonymous-cvs # Probably I should create a shell alias like: finkselfupdatecvs to handle it all when I # I find I want to update package descriptions again. But I'm too lazy and besides, that's # why I've put it in my blog. Thursday, September 13. 2007Software I Use
I often get people asking me what Mac software I use alot and if there's anything I can recommend to them. I recently put together a list of stuff I use at work (this doesn't include the *NIX stuff) for a colleague and figured others might benefit from it.
Monday, June 18. 2007Vana'diel Time
I recently started working on a Vana'diel (Final Fantasy XI) clock written in Cocoa. My reasoning for doing this (when there really isn't any need for another Vana'diel clock) is two-fold:
1. I want to learn Cocoa and a good way to learn something is to associate it with something you already enjoy (ie. Final Fantasy). 2. The only Mac OS X Vana'diel clock out there is old, lacks some info I'd like it to have, and doesn't really have the nicest interface (text only - no eye candy). The biggest hump for me so far was figuring out how to calculate the time. I looked at some javascript clocks people had written but I didn't like the fact that they all seem based on some arbitrary date. I wanted something that could go all the way back to the beginning of Vana'diel time. The Vana'diel epoch (the Vana'diel big bang, if you will). I decided, I wanted to write the algorithim myself, differently from all the ways I've seen it done. Fortunately, I found a great resource explaining some of the critical information needed to understand how Vana'diel time works. Thanks Miwarre! I wanted to rapidly prototype a simple clock to test my algorithm and I figured I could do it easily and quickly enough using Applescript. I've posted the script here for anyone else trying to work with Vana'diel time. When I re-wrote this for Cocoa, I didn't use the "seconds since epoch" constant I used here because I found a cleaner way with NSCalendarDate. The jist of it is that I can create an NSCalendarDate object using the "earth" date that corresponds to the Vana'diel epoch date and the effect is the same. I have to give a big special thanks to my girlfriend who checked my work (by hand!) and found that I'd originally used the wrong value in the unix_seconds_since_epoch_at_vana_epoch (it was missing the extra 86400 seconds for the 1968 leap year). This has since been corrected in this script. The Applescript simply returns the current Vana'diel date. set unix_seconds_since_epoch to do shell script "date \"+%s\"" set vana_rate_mod to 25 -- Vana time runs 25 times faster than earth time. set vana_seconds_per_day to 86400 set vana_days_per_week to 8 set vana_days_per_month to 30 --This value is derived from the amount of seconds that elapsed between the --Vana'diel epoch (0001/01/01 00:00) which is 1967/02/09 15:00 and the --UNIX epoch which is 1970/01/01 00:00. This includes a leap year (1968/02/29) --which adds an extra 86400 seconds. Since all calculations are based off seconds --since the UNIX epoch, we need to add this value to any UNIX seconds we use. set unix_seconds_since_epoch_at_vana_epoch to 91270800 -- Find out the Vana'diel minutes since the Vana'diel epoch. set vana_seconds_since_epoch to (unix_seconds_since_epoch + ¬ unix_seconds_since_epoch_at_vana_epoch) * vana_rate_mod set vana_days_since_epoch to ¬ (vana_seconds_since_epoch / vana_seconds_per_day) set vana_weeks_since_epoch to ¬ (vana_days_since_epoch / vana_days_per_week) set vana_months_since_epoch to ¬ (vana_days_since_epoch / vana_days_per_month) set v_year to round (vana_days_since_epoch / 360) rounding up set v_month to round ((vana_months_since_epoch) mod 12) rounding up set v_day to round (vana_days_since_epoch) mod 30 rounding up set v_hour to round ((vana_seconds_since_epoch mod ¬ vana_seconds_per_day) / 3600) rounding down set v_minute to round (((vana_seconds_since_epoch mod ¬ vana_seconds_per_day) mod 3600) / 60) rounding down if v_minute is less than 10 then set v_minute to "0" & v_minute end if set v_second to round (((vana_seconds_since_epoch mod ¬ vana_seconds_per_day) mod 3600) mod 60) rounding down if v_second is less than 10 then set v_second to "0" & v_second end if set v_wday to round (vana_days_since_epoch mod vana_days_per_week) rounding up set week_days to {"Firesday", "Earthsday", "Watersday", "Windsday", ¬ "Iceday", "Lightningsday", "Lightsday", "Darksday"} return (v_year & "/" & v_month & "/" & v_day & " " & ¬ v_hour & ":" & v_minute & ":" & v_second & " " & ¬ item (v_wday) of week_days) as string |
Syndicate This BlogRecent Entries
|
|||||||||||||||||||||||||||||||||||||||||||||||||


