Disabling Adobe Acrobat PDF viewer in Safari 4
[UPDATE There’s an easier way to do this. Launch Acrobat. Go into Preferences -> Internet and uncheck “Display PDF in browser using: ...” That should do it (at least in CS3). OTOH, moving it around on the command line is very satisfying…]
If you’ve installed Adobe CS2 or CS3 on your Mac, you’ve probably experienced it’s aggressive approach to Safari.
It installs its own Acrobat plug-in viewer that gets invoked by Safari (and other apps) when you view a PDF.
I find that really annoying – it takes forever for the initial page to load, i’s much slower than the built-in PDF viewing, and takes up a huge chunk of memory). Damn you Adobe!
So, if you want to disable it, here’s what to do (assuming you have admin privileges).
1. Launch Terminal (Applications -> Utilities -> Terminal)
2. Type:
# sudo mkdir "/Library/Internet Plug-Ins.disabled"
# sudo mv "/Library/Internet Plug-Ins/AdobePDFViewer.plugin" "/Library/Internet Plug-Ins.disabled"
Now if you restart Safari and go look at a PDF, life will again be fast. If you decide you are becoming too productive, you can always revert the change:
# sudo mv "/Library/Internet Plug-Ins.disabled/AdobePDFViewer.plugin" "/Library/Internet Plug-Ins"
Enjoy!
Getting ssh (and by extension, rsync) to work in cron with Leopard (OS X 10.5)
I didn’t find this elsewhere, so I’ll give you my kludgey solution to a problem created by Leopard.
Leopard now helpfully launches an ssh-agent for you and will keep your passphrases in the keychain.
That’s all well and good, but the SSH_AUTH_SOCK changes with every boot (as near as I can tell).
AFAICT, there’s no easy way to get the SSH_AUTH_SOCK value which means you can’t easily set it in crontab which means cronjobs that you want to have use passphrase-protected ssh keys won’t work.
Here’s my solution.
At the top of your crontab, put:
SSH_SETUP='export SSH_AUTH_SOCK=`find /tmp -follow -user $LOGNAME -regex ".*/launch-.*/Listeners"`'
then, where you might’ve had a crontab line like:
1,16,31,46 * * * * /Users/yanowitz/bin/backup_igtd.rb
@daily /usr/bin/rsync -aqz --delete --rsh="ssh -i /Users/yanowitz/.ssh/id_dsa_rsync" /Users/yanowitz/Pictures/iPhoto\ Library mini.local:/Volumes/raid
you instead write:
1,16,31,46 * * * * eval $SSH_SETUP; /Users/yanowitz/bin/backup_igtd.rb
@daily eval $SSH_SETUP; /usr/bin/rsync -aqz --delete --rsh="ssh -i /Users/yanowitz/.ssh/id_dsa_rsync" /Users/yanowitz/Pictures/iPhoto\ Library mini.local:/Volumes/raid
Yeah, that sucks, I know. But it’s better than nothing.
Please let me know what obvious and superior solution I am missing.
(And yes, I’m too lazy to write launchd plist scripts. I’m sticking with cron. It would also be more of a hassle to do this solution, because you’d be invoking /bin/sh to do the rest of the work).
how to get ActiveRecord Schema Dumper to dump out larger columns
(This assumes you are using mysql, but similar changes will work for postgres, etc.)
If you are using Ruby on Rails and are trying to store large objects in a column, you may run into the following problem:
create_table :bogus do |t|
t.text :big_column, :limit => 1024*1024
endThat will create the table as expected, but mysql with automatically turn the text column into mediumtext (rails/ActiveRecord has no idea). The same think can happen with longtext, mediumblog, longblob, etc.
That’s all well and good, but when you run schema dumper (e.g., rake db:schema:dump), you’ll get this:
create_table :bogus do |t|
t.text :big_column
endand then you are screwed. Especially when you go to run tests (which can invoke the schema dumping).
There is a fairly easy fix for this. There is even a patch for it on the rails trac site (thanks Will Bryant!). But, until it gets fixed in the rails core…
Assuming you are using Rails 2.0 (edgerails as of now), which introduces support for initializers, create a file config/intializers/active_record_tweak.rb:
##
## from http://dev.rubyonrails.org/ticket/7424
##
module ActiveRecord
module ConnectionAdapters
class MysqlColumn
private
def extract_limit(sql_type)
if sql_type =~ /blob|text/i
case sql_type
when /tiny/i
255
when /medium/i
16777215
when /long/i
2147483647 # mysql only allows 2^31-1, not 2^32-1, somewhat inconsistently with the tiny/medium/normal cases
else
super # we could return 65535 here, but we leave it undecorated by default
end
else
super
end
end
end
end
end(If you have an earlier version of Rails, just put this code in config/environment.rb)
This isn’t perfect – the original limit information in your migration will get lost, replaced with whatever the maximum is for that column, but it’s a quick fix to get everything working again.
NOTE: If this solves a problem you were having, please go to the original ticket on railstrac and add a comment (you have to register and login to add a comment) saying:
+1 solves the problem without side-effects for me
(See this report for more info on this comment.)
Creating a Higher Resolution Life Poster 2
Last year, after reading Life Poster, I tried making my own. I wanted to change it in a few ways:
- Higher resolution print
- More poster dimensions flexibility than iPhoto gives you
- Less expensive
- Different photo sizes (not just a grid of photos) in the poster.
I ended up with a 22×32 inch poster. The picture size is 20×30, with a 1 inch border all the way around. This has the advantage that it looks great even without matting. I just have it dry mounted to foam core and a simple frame put on it.
I found a place (Perfect Posters) that is about half the price of Apple’s Kodak fullfillment, and it’s 300 DPI (instead of 200 DPI). Standard disclaimer: I have no connection to Perfect Posters other than finding their service great.
Here’s what I did. I used iPhoto v6.2 and Photoshop CS 2. I also looked at Posterino but found I didn’t like its interface.
- Choose your dimensions (I went with 20×30), how many photos you want across and down (I went with 8 and 16), which means I can have up to 128 photo “slots” and the photos should be cropped to a 4×3 ratio. (20 inches across / 8 = 2.5 inches across. 30 inches down / 16 = 1.875. 2.5 / 1.875 = 4×3.)
- Choose your photos. I create a new album in iPhoto cleverly named “My Poster.” In this case, I need about 128 photos. I actually picked a little less than that, because some of them I am going to make bigger than 1 slot (more on that below). I recommend trying to use photos with a mix of colors (and as many from nicely lit places as possible).
- Lay them out. Once I’ve picked all my photos, I make the iPhoto window as big as possible and then set the thumbnails to a size that allows me to see them 8 across [you can use the slider on the lower right of the window].
- Making a photo extra large. In order to break up the grid and to highlight photos I really like, I make some of them larger. In the above poster, I have 2 photos which take up 4 “slots” in the poster. To aid layout, I make 3 duplicates of the photo and then place them in 4 spaces I want the photo to use. Later, in Photoshop, I’ll make it one larger photo.
- Including portrait (3×4) photos. I use a similar approach for photos that are longer in the vertical direction. I use two slots for these and crop the photos to 4×6. I duplicate the photo once so that I can place it in the two slots it will use.
- Going crazy Broadway style. You could have a photo take up a 3×3 grid, or crop a photo 8×3 and have it take up two slots side-by-side (I did that in the upper right with a picture of Amira trying to stand).
- Export them. Once you’ve picked all your photos and laid them out, you have to export them from iPhoto. Select all the photos in the album (Command-A). Go to File->Export. Click on the “File Export” tab in the dialog box. Select Format: Original, Full Size Images, and Use Album Name. Click Export. Then create a new folder and the images should all get saved into them. In my case, I had 128 images, named “my poster – 001.jpg” through “my poster – 128.jpg” If you don’t end up with as many images as you were expecting, you probably only had a subset of the photos in your album selected when you went to do the export.
- Import them in Photoshop (I used CS 2). Select File->Automate->Contact Sheet II. In the dialog box, select the folder you saved all the photos in, choose 20×30 for the image size, 300 DPI, RGB, Flatten Layers, Place Across First, Columns 8, Rows 16, Use Auto-Spacing. After you hit OK, Photoshop will begin doing its magic. Several minutes later, you will have a contact sheet.
- Resize your canvas. Image->Canvas Size Width: 22, Height: 32. This will give you a one inch border all the way around. Save your project (File->Save)
- Adjust for your larger photos. This part takes the longest. If you have a photo you want to take up 4 slots, open it up (you can use some simple math to figure out which of your 128 files it was) in Photoshop. Then select Image->Image Size and enter the new width and height. In this case, if I want it to use 2×2 slots (4 total), and a slot is 750 pixels across (20/8*300), then I want this photo to be 1500 pixels across. After the resize, do Select->All (Command-A) and Edit->Copy (Command-C) . Now in your life poster, zoom way in. You are going to want to select the full area that you want to paste this poster into. There’s probably a better way to do this, but I just zoom in super far and draw a box around the four photos I had laid out as a marker for the one big version that I want to insert. Once I’ve selected the area (and you want this to be pixel-perfect so everything lines up), you do Edit->Paste Into and zoom back out to make sure it looks good. I am inept, so it takes me several tried to get the area selected properly. I am guessing there’s a way to just paste into a specific area of a poster, which would be a lot better, but I am a Photoshope neophyte.
- Save as a jpg. File->Save As->[select jpg] On the next screen, I use a quality of “10” which produces about a 16 megabyte file.
- Upload and print. If you use Perfect Posters, make sure you select “cut to exact size” during the checkout process if you are using my approach of a one-inch white border.
The difficulties of detecting missing images with flickr and javascript.
So, we put up a new website, slideshowr for viewing your flickr slideshows. There are a number of things I don’t like about the existing flickr slideshows, in particular, the lack of photo titles, the size of the photos, and the lack of music. So we fixed all that. The resolution I most often want to view my photos in is “large”. Flickr only makes “large” photos if the resolution exceeds certain limits. The only way to find this out ahead of time (via the api) is to request the size info for every photo. That can take awhile.
So, I thought, why not try to load the photo and if that fails, rewrite the URL so we grab the original sized one. Well, that would be all well and good, EXCEPT that there is no way to get at the HTTP return code in Javascript (to see a 302 redirect) nor does the Image object get updated with the actual src used to load the image (in the instance of a redirect to http://www.flickr.com/images/photo_unavailable.gif).
The solution? The Image object does get the height and width of the photo_unavailable gif (375×500) and we can look for that, that the src ended in _b.jpg, and then try to get _o.jpg instead. The nice thing is that a flickr “large” image will never be 375×500, so this will Just Work (until they change the dimensions of their unavailable gif)
Kludgey, but it works. Sometimes the corner case limitations of javascript amaze me.
Tab-completion in IRB
I came across this while poking around programming is hard which led me to the rails wiki
Make this your ~/.irbrc and enjoy tab completion:
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = [] unless
IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?(‘irb/completion’)
IRB.conf[:LOAD_MODULES] << ‘irb/completion’
end
Aaah. Sweet, sweet laziness.
Upgrading Typo 1
At the risk of becoming a blog about maintaining a blog, I just wanted to make a quick note on how easy it is to keep this software up-to-date (which is important given the security holes found in Rails this week.)
- sudo gem update -y
- typo install TYPO_INSTALL_LOCATION
Now, perhaps it would be nice if “install” had an alias like “upgrade” so you didn’t have to get that sinking-feeling-in-the-stomach for even a moment, but in the end, no biggee.
Soon, I shall blog about something other than blog software.
Committing files in bitkeeper from the commandline shell
(Now, if you’re like me, you’re only finding yourself commiting a file via the commandline because you’re working on a remote machine. Which probably means that you are taking part in a Bad Programming Practice, because Thou Shalt Always Test Locally And Only Then Release. But let’s set that aside. Sometimes, shit happens.)
If you are really like me, you probably made a change in an account named something like “mrbuild” or somesuch. IOW, not a real user. So before you commit files in that account, set BK_USER to your username, so the cset gets the correct name (and blame) and so the bk licensing doesn’t get confused.
Step 1. Figure out what’s changed.
bk sfiles -cp
If that looks right…
Step 2. Tell bitkeeper to add them to a changeset
bk sfiles -cp | bk ci -
(add comments as instructed)
Step 3. Commit the changes
bk commit
Step 4. Push the changes
bk push
(If you’ve been really bad and added a bunch of files in this account, you can run:
bk sfiles -x
to make sure the new files are what you expect, and then
bk sfiles -x | bk add -
Enjoy. And I hope you can learn to live with your shame.
Getting typo installed under debian
Installing typo on my OS X box was a breeze (assuming one already had rails installed, etc. etc.).
However, when I went to install it on my linux vhost running Debian 3.1, I ran into a few issues.
First, I had to sudo gem install mkmf.
Then I got this error
checking for sqlite3.h... no
And then a bunch of banging-head-against-the-wall ensued because after googling and discovering I need to do:
sudo apt-get install sqlite3 libsqlite3-dev
I then got this error:
checking for sqlite3_open() in -lsqlite3... no
So I looked in the logs:
less /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/ext/sqlite3_api/mkmf.log)
for more detail. It seemed to indicate that the sqlite3 lib didn’t have sqlite3_open in it. An objdump of the lib revealed that to be untrue. The actual errors of note in the file were:
conftest.c: In function `t':
conftest.c:4: warning: implicit declaration of function `sqlite3_open'
/usr/lib/libc_nonshared.a(elf-init.oS)
(.gnu.linkonce.t.__i686.get_pc_thunk.bx+0x0): In function `__i686.get_pc_thunk.bx':
: multiple definition of `__i686.get_pc_thunk.bx'
/tmp/cci4MfWc.o
(.gnu.linkonce.t.__i686.get_pc_thunk.bx+0x0):
/tmp/sqlite3-ruby-1.1.0/conftest.c:3: first defined here
collect2: ld returned 1 exit status
After typing a bunch of stuff by hand, I realized that my rbconfig.rb was gashmongled. Specifically, -fPIC was declared too many times and that was producing another error (too many thunks), which was the actual error to care about in the log.
sudo vim /usr/lib/ruby/1.8/i486-linux/rbconfig.rb
look for -fPIC on the cflags line and remove it.
Then, and only then, does
sudo gem install typo
actually run to completion. Ahhhhh…
(As an aside, during this process, I ended up installing my own version of sqlite3, but I don’t know if that was necessary).