You cannot programatically 'Like' something using the Graph API on Facebook

I'm going to repeat that because type is cheap:

You cannot programatically Like something using the Graph API on Facebook.

You may be attempting this because it seems completely rational; you may even have seen this working on big sites, y'know, custom Like buttons. You are wrong.
It's not that these sites have a special relationship with Facebook, or that Facebook are worried that you'll make an Add To Cart button that actually
makes your visitors Like Equestrian Pornography websites, it is actually because you are an alien*. And wrong.

Sorry.

*Evidence that you are an alien.
http://forum.developers.facebook.com/viewtopic.php?pid=235590

Comments (0)
Posted
by Effisfor 

CSS Positioning awry with new HTML spec

This is just sheer ignorance on my part [again]. If you have suddenly noticed all your CSS relative or absolute positions are slightly off, take a look to see if you've changed the HTML spec of the page. I changed mine to match the recommended Facebook spec and all my positions went askew by 5 pixels.

Comments (0)
Posted
by Effisfor 

jQuery UI + Droppable Drop Event

My Droppable 'Drop' Event wouldn't fire. Pooh.

I had an image in my drop area div.

I removed it and it now fires the event. Yippee.

All other events fired as you'd expect, so I think this is a bug.

Moral of this woeful little tale: Keep your images in the background of your div, or get hacking.

Comments (0)
Posted
by Effisfor 

Postgres with Rails

I needed to get my Rails app running with a Postgres DB today (so I could take advantage of the excellent Texticle) , but found it a little trickier than expected.

Here's what I had to do (using Ubuntu Karmic)

1/ Install Postgres

This is as easy as sudo apt-get install postgresql for Ubuntu folk.

2/ Make a yourself a superuser

By default, Postgres uses 'ident sameuser' so you don't need a password when connecting from the same machine. I did:

sudo -u postgres createuser --superuser $USER
sudo -u postgres psql

which will take you to the psql command line. Set yourself a password with:

postgres=# \password $USER

This password is used (I think) when connecting to the DB remotely. The only time I've had to use it is to do a db:pull with taps.

3/ Install the postgres and postgres-pr gem

I'll be honest. I don't remember if both are necessary (I could have sworn it was just postgres), but I've got both installed so it can't hurt to have both.

They required some dependencies which were resolved by installing libpq-dev. On Ubuntu, this is:

sudo aptitude install libpq-dev

Now you're free to do

gem install postgres
gem install postgres-pr

4/ Set your database.yml

Finally, set the config/database.yml file in your Rails app to mimic:

development:
  adapter: postgresql
  database: db_name
  pool: 5
  timeout: 5000

No need for a username/password because of step 2.

Fin.

Comments (0)
Posted
by email 

Fun and games with repeating jQuery animations

If you've ever been tempted to start new animations in a jQuery callback closure, then don't. Bad things happen.

Exhibit A:

$('div.one').animate({'opacity':0}, 200, 'linear', function(){
  $('div.one').css('display', 'none');
  $('div.two').animate({'opacity':1});
});

So far so good. All's fine and dandy with this first animation on div.two, but if you later try to animate div.two a second time, weird stuff starts happening in which this first animation repeats itself several times after your new animation finished. Very annoying and hard to track down as (as far as I'm aware) there's nothing 'wrong' with doing things this way. I'm not sure if this bug always crops up, but it certainly did for me today. You might be lucky.

I'm now achieving the same thing with...

$('div.one').animate({'opacity':0}, 200, 'linear, function(){$(this).css('display', 'none')}');
$('div.two').delay(200).animate({'opacity':1});

...where I use jQuery's lovely new delay method to get things happening in the right order. Huzzah!

Comments (0)
Posted
by email 

Vimeo gem on Rails

When I followed the instructions on github to install the Vimeo gem on my Rails app, I kept getting a "Missing gems:   vimeo" error,
I found the answer in the issues section, courtesy of sealabcore:

gem install oauth-client
gem install httpclient

Not before messing around for a good couple of hours trying to fix it though. Yay?

Comments (0)
Posted
by Effisfor 

Git add, commit and push to heroku in one command

If all of the following apply to you:

  • You are making a heroku app
  • You are playing with something that needs to be tested live on the server (eg Incoming mail script)
  • You are lazy and the three commands to add stuff to your git repo, commit it and push to heroku are just too much for you in the wee hours of the morning
  • You don't understand why using the message "changed" for a version control contribution would ever be frustrating for someone else
  • You don't care
Then do the following:
  • Make a script called up (no extension) in your script folder alongside generate
  • Put this in the file:
    git add .
    git commit -m "minor change for live test"
    git push heroku
  • In Terminal, navigate to your app's folder, and type chmod a+x script/up
Now you can:
  • Commit your files and push them live in one simple command: script/up

Comment (1)
Posted
by Effisfor 

Template variables don't load in Sinatra/HAML

Having trouble seeing variables render in your HAML templates with Sinatra?

That's because the lightweight server doesn't reload your code.

I'm using Shotgun to achieve this, reloading code on every request. Only for development mind.

$ sudo gem install shotgun
$ shotgun -p 4567 sinatra_app.rb

Thanks

Comments (0)
Posted
by Effisfor 

Google is so sensitive these days

Check case of all your Google App Engine static files, as it would seem it's much pickier live, than local.

Working locally, not live


<script type="text/javascript" src="/scripts/jquery.jcrop.min.js"></script>

Works on both


<script type="text/javascript" src="/scripts/jquery.Jcrop.min.js"></script>

 

Comments (0)
Posted
by Effisfor 

Around the houses, App Engine stylee

I'm quite aware of the depths of my e-stupidity, but the only way I could get an image out of an email attachment sent to a Google App Engine app and uploaded to S3 using Boto, was this absurd backflip (literally).


class LogSenderHandler(InboundMailHandler):
    def receive(self, message):
        attachments = []
        if message.attachments:
            if isinstance(message.attachments[0], basestring):
                attachments = [message.attachments]
            else:
                 attachments = message.attachments

        for filename, content in attachments:
            img = images.Image(content.decode())
            if img:
                img.rotate(360)
                sitehelpers.upload_to_s3(filename,
StringIO(img.execute_transforms(output_encoding=images.JPEG)),
message.sender)

Yes, I did just rotate an image for the sake of it, the only way to get a stream accepted by Boto (GAE Image will just send an object), is to flip the image around 360 degrees and then execute the transformation.
Anybody out there in the land of tWeb is welcome to call me on this, but in case you are struggling and need any solution possible, this works a treat for me. Ask Jeremy Clarkson about performance.

 

Filed under  //  app engine   mail  
Comments (5)
Posted
by Effisfor