Been wanting to do this for a while so my Adium contact list will show on all spaces, it’s not as straight forward to do as with most unix window managers…
Category Archives: Tech
good speed from comcast
auto-dimming display on macbook pro
it seems like a good idea, but I block the light sensor all the time and it’s pretty annoying… here’s where you go turn that off…
to turn off or get better control of the backlit keyboard, use Lab Tick.
Pair your mac with just 1 remote
If you have a Mac with a FrontRow remote, by default any remote will work with your Mac. I was setting up my security preferences on my new Mac and saw that you can pair your Mac with just 1 remote, pretty neat.
I actually haven’t even opened my remote coz I’m just gonna use the one from Sherry’s MacBook.
MacBook Air
Technorati Tags: apple, MacBook Air
Been a while since I’ve blogged, moving on, again…
Sorry for the lack of updates and daily photos, I’ve been busy with work, new puppy, and then the holiday. I got back to San Francisco and decided I’ve had enough unpaid employment (well, paid with equity that is pretty much worth nothing until proven otherwise), so I updated my resume and started a series of interviews with the a number of startups in and around SF. After sorting through a lot of bullshit, strange business models, or just stupidity in general, I found a startup I really like: Context Optional. I am starting next Tue. The founders are really chilled and the work is really exciting. We work with some of the top brands to use social applications for promotions in social networks. You can read more about what we do here. So you can look forward to new and cool Facebook and Open Social apps by me. I will continue to be using RoR and RFacebook, and probably also something like Shindig and Caja for OpenSocial.
I will move into a background role at OnMyList, we have yet to figure out what to do with it. We plan to keep the site running coz we do have people who are really into the site. I had a great time doing OML, learned a shit load of stuff, and worked with some awesome people.
How to use attachment_fu in a rake task (i.e., without using a form)
We’re launching a new Facebook app soon at OnMyList, and we need to pre-populate hundreds of celebrity images, so instead of doing it manually I wrote a cute little rake task to do them all. Took me a little while to figure this out, the trick is to do a class_eval to add the required fields to make attachment_fu happy. This works pretty sweet, the images are resized and uploaded to Amazon S3.
Thought I’ll blog it hoping someone out there will find this useful. 🙂
desc 'adding celebs' task :add_celebs => :environment do dir = '/tmp/celeb_images' Dir.foreach(dir) do |img| path = File.join(dir, img) if File.file?(path) f = File.new(path, "r") (class < < f; self; end).class_eval do alias local_path path define_method(:original_filename) {img} define_method(:content_type) {"image/jpeg"} define_method(:size) { File.size(path) } end u = User.new u.celeb_name = File.basename(img, '.jpg').titleize u.picture = Picture.new u.picture.uploaded_data = f u.save! p "added user #{u.celeb_name}" end end end |
Technorati Tags: attachment_fu, rails, rake task, RoR, ruby, rubyonrails
Flickr stats!
I’ve used Flickr exclusively for my pics for years now even though I have my own server and can do it myself. One thing I really miss is web stats and logs to see referrers and where my images are linked from. Flickr just announced yesterday that they added stats! You have to activate it though, they don’t collect data for you by default. I just activated mine and should see some information tomorrow.
Activate your stats today!
FBJS autocomplete/typeahead in Rails
Facebook released FBJS a while back to allow some JavaScript in Facebook applications. It is basically a JavaScript parser that modifies the scripts to make them a little bit safer. Ray and I have been working on a new app for OnMyList and we want an text input box with autocomplete to suggest names. If you’re using Rails outside of Fb, or if you’re using IFRAME for your Fb app, then autocomplete is really easy, you basically only need to add 2 lines, one like this in the controller:
auto_complete_for :user, :name |
where user is the model name and name is the field you want to autocomplete for inside the users table. And in the view, you add something like this:
< %= text_field_with_auto_complete :user, :name %> |
This will generate everything you need to have an autocomplete textbox. However, this assumes that you can load the Prototype and Script.aculo.us js libraries, and if you want your app to use FBML, these libraries do not work as FBJS.
Autocomplete with FBML is a little bit more work. Facebook’s Developer Wiki has an FBJS typeahead with AJAX example, I don’t love hacking JavaScript so I just borrowed the code there to use in my view. That page shows you how to write a PHP AJAX endpoint, to make it work with Rails, I tried to make it so it would take the data returned by the auto_complete_for method, it turned out to be a bit too much JS changes for me, I’d like to leave the FBJS as close to original as possible. I also prefer writing Ruby more than JS so I ended up implementing the endpoint in the controller, it took a while to get it working, so to possibly save you some time, here’s how it looks like at the end:
def auto_complete_for_user_name names = User.find(:all, :conditions => [ 'LOWER(name) LIKE ?', params[:suggest_typed].downcase + '%'], :order => 'name ASC', :limit => 10).map { |n| n.name } render :text => "{fortext:#{params[:suggest_typed].to_json},results:#{names.to_json}}" end |
I tried render :json but it didn’t work, coz the typeahead JS is expecting a certain format, but render :text works just fine. Hope you find this post helpful. I will also edit that Wiki entry to include the Rails version of the handler.
Technorati Tags: ajax, autocomplete, facebook, fbjs, fbml, javascript, js, typeahead
aybaybay
“blog even if you’re wrong”…