Archive for August, 2006

Keep Alive in Transmit

Thanks to Leslie at Panic.com for a speedy reply to my inquiry. I have had a problem for some time with a couple of FTP servers killing or timing out my connection. Where this gets to be a real headache was when editing ftp files through BBEdit or TextMate; if the connection timed out and I tried to save the file, half the time it would overwrite my file on the server with an empty file - which was really *not* good. Transmit back in the day had a preference that you could check to send a “tickle” to the server to make it think you were occupied, and thus not kick you off.

Transmit 3.5 or greater provides a similiar, albeit more hidden, functionality. To enable this keep-alive functionality:

1. Go to the Transmit menu, hold down the Option key, and click Advanced preferences. You will see a list with only (Default) in it.
2. Click the “+” to add a new server specific setting.
3. Enter the offending kickoff server address in the address field, and check the checkbox “Keep connections alive during long transfers.”

This should do the trick. If you would rather create your own home-grown applescript version, the refresh command was recently added to the Applescript library for Transmit, which you can trigger by sending the session in question a “refresh list their stuff files” command in applescript. (perhaps more on that later)

Add comment Thu, 2006 Aug 31, 5:51pm

Wear PlasticWare - Where? Now on CafePress

You can now visit the PlasticWare [Wear?] Shop at cafepress.com. After getting tired of the ordeal of going through the “contest” approach of getting a t-shirt made through Threadless, I decided to forego all that in the interest of getting what I wanted, which was a t-shirt that I had been wanting for a while. I know, CafePress is kind of over-priced and the selection isn’t stupendous, but hey, I can now have my shirt. Featured right now is the spanking old Commotari design, which is a mash-up of a couple of old geeky logos. I put up a few different shirt selections in case anyone other than me happens to be interested…

Add comment Thu, 2006 Aug 31, 12:48am

Actionscript Interface Implementation Error

Just to add this to the web search realm, a quick note on a fairly annoying discrepancy in the Flash IDE. When compiling flash movies that utilize interfaces, there is the possibility of getting the following error:

The implementation of the interface method doesn't match its definition.

Despite the fact that MTASC has no problem with it.

*I believe* that it is acceptable according to ECMA script standards to define functions in interfaces by supplying the types of the parameters, rather than the names and types. Compare:

public function moo(Object, String):Void;

vs:

public function moo(cow:Object, foo:String):Void;

The former is handled fine by MTASC; however, when compiled in the Flash IDE, the error “The implementation of the interface method doesn’t match its definition.” is returned for every function defined in the interface that has input parameters. The solution is to define the methods is in the latter example; however, for the Flash IDE to compile without errors, not only do the parameter types have to match, but also the parameters names have to match.

Hopefully that will help someone searching for this error…

Add comment Wed, 2006 Aug 30, 8:01pm

Smb Connector Applescript

*Update (2007-01-05) - forgot to change this a long while ago, but was looking at some posts online and remembered that I hadn't updated this. The .nsmbrc file, as it turns out, isn't really necessary, as the finder will likely prompt you to enter the password for a share that you are trying to mount using the code in the applescript included here. If you like, at that point, you can enter your password and save it to the keychain, which is more secure than saving the password in the .nsmbrc file. Original article follows:

--

More may follow on this later, if I can determine a decent way of implementing this as a distributable applet, but what follows is a decent way of getting around the awkward samba dismount problem that I discuss in my earlier post.

To recap, there are some problems when developing on your Mac where you need to utilize a consistent volume location through an smb connected shared drive. (A good example of this is developing a project through Eclipse and wanting to write an Ant script that as one of its targets installs the build on the samba connected volume (which could be your development server environment).) A) Sometimes, remounting the shared volume results in unexpected naming in your /Volumes directory - so a windows share "D$" now becomes "D$-1", so now your Ant script will fail. B) Personally, I have grown to dislike the OSX connect to server dialog window - there is a lack of control there and a lack of knowing exactly what is going on. C) Running a mount_smbfs begins to solve the problems above, but is only part of the solution.

So, as I said, the mount_smbfs command in the terminal does allow you to specify a particular directory to use as your mount point for a shared volume. However, without tweaking your system, you can only access the share through the terminal (Ant scripts running through Eclipse can't access the drive either). The following is the [hacky, convoluted] solution:

Change the permissions on /Volumes
For any of the users on your machine to access /Volumes for what we need to do, the permissions must be changed. Changing the permissions also allows the mounted directory to be accessed via the Finder (and Eclipse, etc.), rather than just in the terminal. Launch the terminal. (NOTE: you must have the root user enabled.) Type the following, hit enter, and enter the root user password when prompted:

sudo chmod 777 /Volumes

Define Your Variables
Figure out what the different pieces of information are that you need (will be used in the following sections).
{shareAddress} = the ip address or computer name to which you are linking
{shareLoginName} = the user name used to login to the remote computer
{computerShare} = the sharepoint on the computer (such as C$ if C: were shared on the windows machine)
{sharePassword} = password for the share
{shareWorkgroup} = the workgroup for the share login
{localMountDir} = the directory which is aliased as the remote mounted drive - name this what you want (I used "wsd" for windows shared drive).

Edit your .nsmbrc File
Go back to the terminal and navigate to your user folder (type "cd ~/" and return). Edit the .nsmbrc file using pico (type "pico .nsmbrc" and hit return). Type the following in the pico editor (substituting the terms in the curly braces with the info you collected above):

[{shareAddress}:{shareLoginName}:{computerShare}]
addr={shareAddress}
password={sharePassword}
workgroup={shareWorkgroup}

If the file already has contents, just enter the lines below what exists (leave a blank line in between). When you are done, hit Control-X, then hit Y to agree to save the changes, and you are done with that (back to your prompt in the terminal). Now chmod that file to 0600 (type "chmod 0600 .nsmbrc" and return). The .nsmbrc file is referenced when you call the mount command, so that the login information and password is ready-at-hand. Chmod'ing it to 0600 provides system permissions protection for your password therein.

Create a little Applescript app (why not?)
Open the Application/Applescript/Script Editor application and create a new script (probably will open a new one by default). Enter the following code in the window, again replacing the curly bracket terms with your information.

CODE:
  1. set shareUser to {shareLoginName}
  2. set shareLoc to {shareAddress}
  3. set mountDir to {localMountDir}
  4. --
  5. set volumesDir to ":Volumes:" & mountDir
  6. set cmdDir to "/Volumes/" & mountDir
  7. --
  8. try
  9. alias (volumesDir)
  10. -- // do nothing if it exists
  11. on error
  12. -- // create the file if it does not exist
  13. do shell script ("mkdir " & cmdDir)
  14. end try
  15.  
  16. do shell script ("mount_smbfs //" & shareUser & "@" & shareLoc & " " & cmdDir)
  17.  
  18. display dialog cmdDir & " is mounted."

Basically, this applescript determines whether or not the directory to which you would like to mount the smb volume already exists (which the OSX connect to server fuctionality doesn't do), and if not, creates it. Also, unlike the connect to server window, you can specify what you want it to be called. The shell command is then called to mount the shared volume. As a final touch, when the volume is mounted (which can take a little bit of time), an alert pops up to let you know that the smb mounted drive is ready to go.

Now, in Script Editor, choose File/Save As. Enter a name to save as, choose the File Format of "application bundle" from the drop down menu, click off the "Startup Screen" checkbox and save. (incidentally, application bundles are now universal binaries, and I believe the application format is still run through Rosetta on the newer Macs)

Now you should be able to simply double-click your little applescript app whenever you want to connect to the remote server of interest without opening the terminal or the connect to server window. You can access the shared drive by navigating to Volumes on your hard drive. At some point here, the drive will show up as a server in your finder window and will be named whatever its name is designated on the remote machine - regretably, clicking the eject button won't dismount it (this method isn't perfect after all). You can unmount the drive by typing "umount /Volumes/{localMountDir}" in the terminal and hitting return...

1 comment Sat, 2006 Aug 26, 1:16am

Interfacing in Actionscript

It wasn't until recently that I actually had the occasion where it made/makes a good bit of sense to use interfaces in any of my flash projects. Part of the reason has to do with formerly lacking the time to actually put together projects the right way, under crazy timelines, and part of it has to do with the fact that I'm working on something that needs to stick around for a bit and will possibly be augmented by persons other (and including) myself.

In most flash projects, interfaces are a bit convoluted and require thoughtfully building out to what amounts to an extra class. Most of the time in smaller projects, subclassing "default" classes pretty much gets the job done. To backtrack slightly for those unfamiliar with the term, an interface is an abstract type which is used to designate how classes can be accessed and manipulated. To use the terminology, an interface specifies the interface that must be implemented by a set of classes.

Utilizing Interfaces

Interfaces in actionscript are particularly useful when creating a set of classes that all have the same methods; the interface strictly defines the guidelines that must be followed when creating a new class of this type.

As an example, let us suppose that we are creating a set of shape classes; we will be creating a circle class and a square class. Let us suppose for now that the only method that we want to implement is the getArea() method. Here are our classes:

Actionscript:
  1. class Circle {
  2.    private var __radius:Number;
  3.    private var __type:String = "Circle";
  4.    
  5.    function Circle() {}
  6.    
  7.    public function getArea():Number {
  8.       return (Math.PI * Math.pow(this.__radius, 2));
  9.    }
  10. }

Actionscript:
  1. class Square {
  2.    private var __side:Number;
  3.    private var __type:String = "Square";
  4.    
  5.    function Square() {}
  6.    
  7.    public function getArea():Number {
  8.       return (Math.pow(this.__side, 2));
  9.    }
  10. }

So, both implement the same methods here. We can define an interface for all new shapes that get created, which must all allow for the calculation of their area (note that by convention, interfaces usually begin with the letter "I"):

Actionscript:
  1. interface IShape {
  2.    function getArea():Number;
  3. }

You must then go back and change your class definition line in each of the two classes to

Actionscript:
  1. class Circle implements IShape {

and

Actionscript:
  1. class Square implements IShape {

The interface defines how we can interact with shapes. The big advantage of this when working on projects is that when using environments such as Eclipse with FDT, you can specify that something is an IShape without knowing what shape it is specifically, thereby allowing you to build more flexible projects. In addition, rather than the alternative, which would be to type them as Object, you have a way of typing them that works with syntax checking and code hinting, which saves you time in the long run.

Combining Interfaces with Inheritance

Another handy trick to help when coding is to combine the use of interfaces with inheritance. Let's suppose we want to create a Shape superclass as such:

Actionscript:
  1. class Shape extends MovieClip implements IShape{
  2.    private var __type:String = "Shape";
  3.    
  4.    function Shape() {}
  5.    
  6.    public function getArea():Number {
  7.       return undefined
  8.    }
  9.    
  10.    public function setColor(newColor:Number) {
  11.       theColor = new Color(this);
  12.       theColor.setRGB(newColor);
  13.    }
  14.    
  15.    public function toString():String {
  16.       return ("Shape of type: " + this.__type);
  17.    }
  18. }

So, our definitions would change as such:

Actionscript:
  1. class Square extends Shape implements IShape {

Now we have a few added benefits. Our shapes are now subclassed as MovieClips and Shapes, which means that they can inherit methods from the Shape class. All of our shapes have a __type and all are now MovieClips, so all of them can inherit toString() and setColor().

The cool part about this is that in this case, we now can implement the IShape interface (remember, all classes that implement an interface are required to implement the designated methods) without declaring ones inherited from the superclass unless we choose to do so. This means that we don't have to add toString() and setColor() unless we want to override the ones in the superclass. This is really great when you have several private variables with getters and setters that you want required by the interface, but don't want to have to duplicate and comment in every single subclass.

Another advantage of using interfaces is that, unlike extending superclasses, classes can implement as many interfaces as you want. For example, you could have a set of Shapes that implement an IAnimation interface as well as the IShape interface. Other types of objects could also implement this same IAnimation interface, so you could call the method pulse(cycleDuration) the same way on both types of class, and your code hinting would tell you that the method pulse requires a number input. This is probably the biggest advantage -- being able to type an object as an interface when passing it to another object that wants to treat it as something that has the methods that the interface requires.

Add comment Fri, 2006 Aug 25, 7:02pm

If Bobby Brown gets a street name…


Why can't any person living in Atlanta? And...I'm not talking about one of those signs on the side of the road that says you paid to adopt a half a mile of highway. I'm talking street names here. Honestly...

Norman Berry in East Point turns into Bobby Brown Parkway. BBPkwy turns into Toffie Terrace, which pretty much dead ends into the Atlanta airport...

Add comment Thu, 2006 Aug 17, 12:57am

Lastfm + jukebox

So I recently signed up for an account at Lastfm.com (intafon), which for those unknowing is like a version of flickr mixed with MySpace where you have playlists instead of photo sets (well, there is other stuff as well). I've been working from home, and set up a user account on my old grey G4 that does nothing but open iTunes, the LastFm app, and OSX vnc with remote apple events turned on so that I can use my old machine as a jukebox that just runs all day, and I can log into it via Chicken of the VNC if I need to, or run Remote Remote or iTunes Remote if I just want to control iTunes from my laptop. (Remote Remote has a smaller footprint and seems to be a bit more stable as a client for controlling the remote computer iTunes.)

It takes a few minutes for your tracks to start showing up on LastFm once you are running the "Scrobbler" app as I think they call it (it "scrobbles" your played tracks to LastFm, I guess via flying turkeys or something). After a few days to a week, you start getting "neighbors" and recommended radio and what-not. The freaky part is the "neighbors," or people with similarities in their playlists. My number 1 neighbor has a startling number of the same top artists, which is weird since my track plays so far have ranged from James Brown to Boards of Canada to Thee Michelle Gun Elephant to King Tubby and Mos Def to Boris the Sprinkler and Nation of Ulysses and the Birthday Party. Not to sound self-eclecticized, but I decided to just let my library play at random, which represents all the music from the past 15 years or so of Jenna and my music purchases (so I'm effectively channeling 2 people's diverse tastes).

Anyway, check it out, its pretty interesting if you're into that sort of thing...(you know, blindly gathering contacts that you don't know from Adam or Eve on the internet based on some sort of herding algorithms...)

Add comment Thu, 2006 Aug 17, 12:37am

OSX Graceful SMB Dismount (umount)

For the time being - until I get some extra code cash, I've switched back over to Eclipse, as I've been doing a good bit of Flash and Javascript coding, and my dev box is a Windows 2003 virtual machine on a server somewhere in California, on which I can also handily run Eclipse. So, until I really optimize my process, I'm sidelining TextMate a bit (as my trial period is about done). So, I've been writing some Ant build scripts to optimize the process (more on that perhaps a bit later), and have configured a couple of targets in my flash project to auto-install my distribution tar.gz file onto my dev box.

This works great most of the time -- I connect to the dev VM via a windows share using an SMB connection from my Mac, so the Ant scripts point to the remote box as /Volumes/D$. Unfortunately...

...my router is flaky and times out my cable connection about 2-3 times a day, rendering my connection to my dev VM non-existent. Here is where the slight problem occurs - the mount-point on the Windows box is D$, so when OSX makes an SMB connection, it creates a D$ temporary folder in the /Volumes directory on the Mac. When the connection is unexpectedly broken, the clean-up to remove that directory fails, and when the share is reconnected, OSX creates a new version of the directory, as "D$-1" (or -2, -3, etc.), which breaks the Ant scripts.

The solution, simply, is to open the Terminal after such an unexpected disconnect, and perform the command:

sudo rmdir /Volumes/D$

to remove the unmounted directory.

I have tried to connect directly to the smb share in the terminal utilizing the specific share directory:

sudo mount_smbfs -W workgroupname //username@ipaddressofserver/D$ /Volumes/D$

but unfortunately, you have to su in the terminal (switch to root user) in order to access the contents -- otherwise the directory is read only. When running the Ant scripts from Eclipse, you don't have root user permissions, and copying to the remote machine fails. Anyone have any thoughts on this?

2 comments Wed, 2006 Aug 16, 11:46pm

TextMate - Continue Block Comment

The current release of TextMate seems to be missing the capability to allow for the auto continuation of block comments when editing actionscript files. To fix this, you can add a new snippet to the actionscript bundle in the bundle editor.

  1. In TM, go to the menu Bundles/Bundle Editor and choose Edit Snippets...
  2. Open the ActionScript section on the left, and click the "+" button at the bottom left and choose to add a new snippet.
  3. Name the new snippet, such as "Continue Block Comment".
  4. In the text area where is says Syntax Summary, delete the contents, and paste in the following:
    ${TM_CURRENT_LINE/(.*\*\/$)|.*?(\/\*(?!.*\*\/)).*|.*/(?1:
    :
    (?2: )* )/}
  5. Now click the Activation menu below (says "Tab Trigger") and change it to Key Equivalent. Click the field next to it, and hit the key (or the key if you prefer). The return key symbol should show up.
  6. In the scope selector field, type
    source.actionscript comment.block

    - this will set the snippet to just work inside actionscript block comments bounded by "/** */"

You can now close the bundle editor, and while typing in block comments in actionscript files, the return key should drop you to the next line, preserve the indent, and type in an asterisk followed by a space.

2 comments Wed, 2006 Aug 09, 12:31pm

Open Spaces

So, my question for the day is, how long can Apple keep usurping technologies from smaller vendors before it is no longer seen as the good guy? I guess the answer is - how long can Microsoft stay evil? After looking more at the Leopard preview from yesterday, it appears that "spaces" is really just Desktop Manager (http://desktopmanager.berlios.de/) built into OSX. Remember Konfabulator (aka Dashboard) that was recently bought by Yahoo? Anyway, its interesting to me that a seemingly substantial part of Apple's public market value as a company continues to rest on the fact that they are not Microsoft. Now, I prefer Macs, don't get me wrong...

In regards to Spaces, I was hoping that the combination of Spaces with Time Machine was going to herald a technological situation where a) spaces would actually be playing multiple "terminals" on the machine and that b) it would support multiple OS's as well...{sigh}. The BeOS had work spaces back in 1996 which actually supported multiple resolutions and color depths, which was great for testing. Time Machine seems to indicate that you will be able to have what amounts essentially to OS undo states, a concept which is very familiar to those of us with experience dealing with virtual machines.

For developers, it would be great to have Spaces support multiple instances of OSX, Linux, and Windows at the same time and be able to switch between them as one does in Parallels or when hot swapping between logged in users. Perhaps on the horizon Parallels will be swallowed up as well? ;)

Add comment Wed, 2006 Aug 09, 11:13am

Previous Posts


Site Decryption

info = { PlaIns: "the section of the PlasticStare site, the digital external brain-repository of Ryan Todd, whose brain otherwise occupies space in San Francisco, CA", ryota: "mungified version of ryan's name", haikuBio: "robotic from birth. hears sounds - listens to music. makes pixels act." }

Calendar

August 2006
S M T W T F S
« Jul   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Posts by Month

Posts by Category