Running AppleScript commands from the Terminal.app

1

Posted by Jaime | Posted in Coding, Tip | Posted on 30-06-2011

Tags: , ,

I found some pages on the web on how to run an AppleScript from the terminal, but this seems to be the only one that works in my situation:

?View Code APPLESCRIPT
echo 'tell application "Google Chrome" to quit' | /usr/bin/osascript

In my case, my keyboard stopped working so I wanted to safely shut down the programs via ssh before I rebooted the workstation.

More fun with symbols

0

Posted by Jaime | Posted in Coding | Posted on 27-06-2011

Tags: , , , , ,

I found some very useful environment variables you can set on the application you are debugging when you need to see what symbols are being recorded by dlopen when it opens all of the libraries in your application: click on me, click on me please!

So, from your Xcode project, double click your debug app:

Double click the debug app to get to the environment variables

Now, set the following variables to YES, or NO, depending on what info you need:

There are more details on the Apple developer site

You are going to get a ton of information in the debugger console, which is very useful when trying to figure out if there are any offending symbols that could be tripping up your project.

Here is a rundown of the variables:

  • DYLD_PRINT_LIBRARIES – Logs when images are loaded.
  • DYLD_PRINT_LIBRARIES_POST_LAUNCH – Logs when images are loaded as a result of a dlopen call. Includes a dynamic libraries’ dependent libraries.
  • DYLD_PRINT_APIS – Logs the invocation that causes the dynamic loader to return the address of a symbol.
  • DYLD_PRINT_STATISTICS – Logs statistical information on an application’s launch process, such as how many images were loaded, when the application finishes launching.
  • DYLD_PRINT_INITIALIZERS – Logs when the dynamic loader calls initializer and finalizer functions.
  • DYLD_PRINT_SEGMENTS – Logs when the dynamic loader maps a segment of a dynamic library to the current process’s address space.
  • DYLD_PRINT_BINDINGS – Logs when the dynamic loader binds an undefined external symbol with its definition.

Adobe Scripting Additions

0

Posted by Jaime | Posted in Coding, What's New | Posted on 20-06-2011

Tags: , ,

I’ve been getting warning messages in my Console log stating the “Adobe Unit Types.osax” has deprecated functions.

Then, when I starting scripting Xcode with AppleScript, I’ve been getting a bunch of errors about the above listed library.

Well, Adobe had something to say about that: http://kb2.adobe.com/cps/516/cpsid_51615.html

Ninja Glock

0

Posted by Jaime | Posted in Funny | Posted on 13-06-2011

Tags: , ,

Thanks to thefirearmblog.com for sharing this video:

How to duplicate one file … a lot

0

Posted by Jaime | Posted in Tip | Posted on 10-06-2011

Tags: , , , ,

I had to duplicate a file… over a thousand times, for a test.

For the MacOS, I created a shell script to do this:

#!/usr/bin/env bash
 
# I'm passing in the filename as a parameter to the shell script,
# which is accesible through $1
for (( i = 0; i < 2000; i++ )); do
	cp -p "$1" "${i}_$1"
done

On Windows, I opened a command window ( Start -> Run -> cmd.exe [Hit enter] ), changed directories to my pictures folder, then typed:

for /L %f in (1,1,2000) do copy MYDOG.JPG %fMYDOG.JPG

Thanks to my co-worker for showing me the Windows tip!

References:
http://www.webmasterworld.com/webmaster/3556284.htm

Apple announces iCloud

2

Posted by Jaime | Posted in What's New | Posted on 08-06-2011

Tags: ,

Apple announced the iCloud service and for someone like me, this is a great service.

For a while, I have been battling with the problem of having access to common data on multiple computers, whether that be documents, calendaring information, or other documents from multiple computers.

Having access to that data without having to rely on a USB key is a cool thing.

I like their pricing model too: FREE.

What I don’t like is the potential there may be to change that model from FREE to FEE like Apple has done before in the past with the .Mac service, now known as MobileMe.

Now, seeing this service being hosted from Apple, it makes me think about certain things:

  • Can I host something similar to this using my public web servers?
  • Can my dedicated FreeBSD servers offer me something similar using OpenSSL and Samba?
  • Can I actually make something as easy to use as what Apple has?
  • Is there someone out there that already has something similar?

This is an ongoing problem for me so it will be interesting to see Apple’s implementation in action.

I may or may not use it. If I do, I will have a contingency plan in effect since I’m not 100% sure that this service will be FREE forever.

Xcode Script Menu and P4

0

Posted by Jaime | Posted in Coding | Posted on 06-06-2011

Tags: , , ,

Here is another way that I am able to check out a file using the Xcode Script Menu and a keyboard hot key:

#!/bin/sh
# This shell script checks out the current file from Perforce
 
# Get the file's path components
FULL_FILE_PATH="%%%{PBXFilePath}%%%"
SRC_FILE=${FULL_FILE_PATH##*/}
FILE_PATH=${FULL_FILE_PATH%/*}
 
# This line brings in my settings so that Perforce knows what server I am connecting to
# This also assumes that the root of my project has a perforce.rc file
source ~/.bash_login
 
if [ -f $FULL_FILE_PATH ]
then
	cd $FILE_PATH
	/usr/local/bin/p4 edit $FILENAME
fi

The “Output:” and “Errors:” options were set to “Display in Alert”, not that this is actually applicable here, but that’s how I have it set up.

And here is what my .bash_login file looks like:

# Perforce settings                                                                                                                         
export P4CONFIG=perforce.rc
export P4PORT=mysuperawesomedomain.com:1666
export P4USER=jaimerios
export P4EDITOR=emacs
export P4PASSWD=haaaahahahaHahaHAA!

Oh, and if you want a good starter for how to work with the Script Menu scripts in Xcode, check out this site: http://www.mactech.com

Starting Google Chrome without restoring previous session

0

Posted by Jaime | Posted in Tip | Posted on 03-06-2011

Tags: , ,

If you ever needed to open Google’s web browser Chrome, without having the previous session brought back, you can actually do this from the command line.

On the MacOS, you can use the Terminal.app application to type in the following commands:

$ cd /Applications
$ ./Google\ Chrome.app/Contents/MacOS/Google\ Chrome --home

Google Chrome should start up for you without bringing up your old pages or old tabs.

Hooray for startup options!

References:
http://chromespot.com