Recently posted to the wiki, a jQuery example of how to do pop-ups:
You are currently browsing the archive for the code category.
I finished the web site I have been working on with a little help in figuring out the style sheet and putting some of those fancy-shmancy rounded corners on things. Oh so trendy!! Anyway, I’m glad I got it done, it was touch-and-go for awhile.
(more after the break…)
Yet another ruby script
This time, taken from Rails Cookbook by O’Reilly. Checking in your spankin’-new Rails app to and SVN repository: http://tamaratemple.com/pub/ruby/svnizerails.rb. (It’s a little more complicated than it seems; hence the script.)
Over the weekend, I wrote a small utility in ruby to backup my /Users directory to my external backup drive. Here it is: (script is downloadable here)
[code lang="ruby"]
- !/usr/bin/env ruby
- Created by Tamara Temple on 2007-03-16.
- Copyright (c) 2007. All rights reserved.
require 'FileUtils'
include FileUtils::Verbose
LIBRARY_DIRS =
["./Library/Application Support",
"./Library/Keychains",
",/Library/Mail",
"./Library/Mozilla",
"./Library/Preferences",
"./Library/Safari",
"./Library/StickiesDatabase",
"./Library/Workflows"]
def getBackDir(timestamp)
prefix = "/Volumes/BootBackup/Users"
suffix = timestamp.strftime("%Y%m%d.%H%M%S")
backupdir = prefix + suffix
print "** backupdir: ", backupdir, "\n" if $DEBUG
backupdir
end
def getUserList(parentdir)
userlist = Dir.entries(parentdir)
if (!userlist.kind_of?(Array)) then raise "Internal Error: Dir.entries did not return an array." end
userlist.delete(".") # remove the working directory from the list (this will not affect
- the directory on the disk)
userlist.delete(".localized") # remove an extraneous file from the /Users directory
print "** userlist: ", userlist.join(", "),"\n" if $DEBUG
userlist # return the userlist
end
def getFileList()
files = Dir.entries('.')
if (!files.kind_of?(Array)) then raise "Internal Error: Dir.entries did not return an array." end
files.delete(".") # remove the reference to the directory itself. (note this will
- not remove the directory - files is an array not the directory)
files.delete(".Trash") # don't backup the trash
files.delete("Library") # remove the Library directory as we don't want it all in
- the backup
begin
libdirs = Dir.entries("./Library")
rescue Errno::ENOENT
libdirs = []
ensure
if (!libdirs.kind_of?(Array)) then raise "Internal Error: Dir.entries did not return an array." end
end
- Remove extraneous entries
libdirs.delete("..")
libdirs.delete(".localized")
libdirs.map! {|l| "./Library/" + l} # Need to add in the path to the
- Library subdirectories
libdirs = libdirs & LIBRARY_DIRS # get the intersection of library
- directories with the set we want
- to keep in backup
files = files + libdirs
files.map! {|f| "'#{f}'"} # need to quote file names for find() command
- in backupUsers() procedure
files # return the file list
end
def backupUsers(userlist,backupdir)
for user in userlist
mkdir("#{backupdir}/#{user}") unless $DEBUG
print "** mkdir #{backupdir}/#{user}","\n" if $DEBUG
cd(user) do # change directories in a block, at the end of the block, direcotry will go back to previous working directoryfiles = getFileList()
begin
`find #{files.join(" ")} -print | cpio -pdv #{backupdir}/#{user}` unless $DEBUG
print "** find:", files.join(", ")," | cpio: ", "#{backupdir}/#{user}","\n" if $DEBUG
rescue
warn "Error with backing up #{user}: #{$!}\nContinuing with next user."
end
end
end
end
backupdir = getBackDir(Time.now)
mkdir(backupdir)
cd("/Users") do # change directories in a block, at the end of the block,
- directory will go back to the previous working directory
userlist = getUserList("/Users")
backupUsers(userlist,backupdir)
end
[/code]










