This the first version of a TextMate bundle for Prototype and script.aculo.us JavaScript libraries. The language grammar is based on from Justin Palmers Prototype Bundle but the other commands/snippets are all new.
Please let me know if you have any comments and/or improvements.
Add these lines to your ~/Library/KeyBindings/DefaultKeyBinding.dict (create the file if it isn’t already there) and the commands will be available in every application started afterwords.
When you type e.g ⇧2 for a double quote (as in swedish keyboard layout), it’ll automatically insert the ending quote as well and place the cursor between them. This will also work for “([{<”. Remember the shortcuts are for a swedish keymap so you might want to change that.
A real time saver when writing outside an editor without this functionality built-in (like TextMate).
Update 2006-08-07
Simplfied the commands based on Jacob Rus’ comment.
To keep my desktop nice and clean I have a folder called “Dump” where I put temporary stuff like apps I want to try, PDF:s to read later that day or files I’m currently working with. But sometimes I forget to look inside that folder to find out what’s there so I wrote this Folder Action to let the folders name reflect the number of containing files/folders. (I know I could just enabled “Show item info” from Finders “View Options” but I don’t want to see all info for my hard drives and iPod)
Just create a folder on your desktop, name it something like “Dump (temp)” and attach this Folder Action to it (Folder Actions need to be located in ~/Library/Scripts/Folder Actions).
-- Set item count as folder name.scpt
on adding folder items to this_folder
my update_name(this_folder)
end adding folder items to
on removing folder items from this_folder
my update_name(this_folder)
end removing folder items from
on update_name(this_folder)
set this_name to POSIX path of this_folder
set sh_script to do shell script "P=\"" & (POSIX path of (path to me) as string) & "\";echo ${P/%.scpt/.sh}"
set new_name to do shell script "\"" & sh_script & "\" \"" & this_name & "\""
tell application "Finder" to set name of this_folder to new_name
end update_name
The script needs a shell script to work (since I don’t like working with AppleScript that much). It should be named exacly as the AppleScript but with an .sh extension instead of .scpt and put in the same directory. Remember to make it executable (chmod +x "Set item count as folder name.sh").
#!/usr/bin/env bash
# Set item count as folder name.sh
# Since the folder has a custom icon and therefore a `Icon?` file I
# decrease the item count by 1. Bad solution but works for now.
NUM_ITEMS=`bc <<< "$(ls "$1" | wc -l) - 1"`
if [[ $NUM_ITEMS == 0 ]]; then
ITEMS="empty"
elif [[ $NUM_ITEMS == 1 ]]; then
ITEMS="$NUM_ITEMS item"
else
ITEMS="$NUM_ITEMS items"
fi
BASE=`ruby -e "puts %x(basename \"$1\").match(/(.+) \(/)"[1]`
echo "$BASE ($ITEMS)"
I first renamed the folder from the shell script but then Finder would visually move the folder one step down or left on the desktop for every update. Instead I just let the shell script generatr the new name and pass it back to the AppleScript that will rename the file as I want.
The other day, Oskar Karlin asked me how and when I use the OS X Terminal app instead of e.g. the Finder. I’m not by any means a hard core command line guy but ther are often and often situations where the Terminal is faster or/and easier to use for the specific thing.
To resize all PNG-images in the current folder to 600px width
find . -name "*.png" -type f -exec sips --resampleWidth 600 {} \;
To put in a “.thumbnail” in the file name
for file in *.png; do mv $file ${file/.png/.thumbnail.png}; done
When I needed to know how many tracks we (Pluxemburg) sent to ITMSfind Music/iTunes\ Producer/Playlists -name metadata.xml -exec grep "<track>" {} \; | wc -l
Copy a file to our Burnfield server (instead of launching a FTP-client)
scp myfile burnfield@bidwell.textdrive.com:
Basic, but to view the apache error log
tail /var/log/httpd/error_log
To view the source of this site’s feed
curl "http://burnfield.com/martin/feed" | head
And how FeedBurner gets it
curl --user-agent FeedBurner "http://burnfield.com/martin/feed" | head
This is the second version of the Colhour as iChat picture I posted the other day. The biggest improvment is that it will show both the hours and the minutes.
There’re two versions of the script. The first one uses a Ruby script together with RMagick to create every image on the fly with the current time. But since it requires some installation of Ruby gems and other libraries, I decided to make a version with all 1440 images pregenerated (created with a small Ruby script of course) so you wont need to install the other libraries. The AppleScript still uses some Ruby, but it’s included in OS X, and should (at least) work on a basic OS X 10.4 Tiger installation. Let me know otherwise.
Instructions on how to set up a cron job to run the script every minute is in the previous post. Both the on-the-fly generated version (update-gen.scpt) and the pregenerated version (update-pregen.scpt) are included in the zip file.
This is a small AppleScript to update your iChat picture from the Colhour system that I have created with Peter. From the beginning I wanted to update it every second, but since it used 60% – 80% CPU, I decided to go with an update rate of once a minute instead. So you’ll only be able to se the current minute from the iChat picture.
To install:
Download and extract somewhere on your hard drive. Edit your crontab file manually or with an app like Cronnix to run the script every minute. It should look something like this:
I suppose I should do this in the “correct OS X Tiger” way by using launchd instead, but that’s for next time. As well as update it to show the the full date in different squares (without seconds due to CPU usage) like the one on harald.net
Source included.
Version 0.2
Added a check in the script to see if iChat is running or not, so it wouldn’t launch iChat every minute.
Today when working with the pluxemburg.com-site I got really tired of uploading everything with Transmit. Since our host doesn’t have support for rsync or something like that, I made this really easy bash-script that will upload everything that have been changed since last time the script was runned.
cd ~/Projects/Pluxemburg/pluxemburg.com #local path to site root
find . -newer ./lastupload -exec open -a Transmit "{}" \;
touch ./lastupload
In Transmit, remember that both local and remote paths have been set, and “Use DockSend” enabled. I saved the script as an application using Automator (Automator –> Run Shell Script), and made an icon in 20 seconds.
Now I just run the app from QuickSilver or Finder and it uploads everything really fast and easy.
Update: This is for OS X and only tested in 10.4 Tiger