Luís Ramalho Entrepreneur & Developer

2014 so far

My previous post was a bit more than a year, thus I reckon it is time for an update on what I have been up to.

Sinemys

In September 2011 I co-founded with two other partners a web development company, and in late 2013 we decided it was time to close it.

The reasons are multiple, but the most important one was the lack of a clear mission statement. The company simply did too much.

We signed the final closing papers this month.

Porto.rb

Unfortunately with the departure of Sinemys, another project had to die.

I started a ruby meetup in Porto called Porto.rb which gathered a total of 50 great Rubyists. It is sad to see it go, and would be happy if someone takes over. Let me know.

GITM master’s program

Life goes on, and after some reflection I have decided that I would benefit from a better understanding of IT management. Thus, I applied to the Master's Degree Programme in Global IT Management offered by the University of Turku, to which I was admitted.

Classes will start in the end of August.

How to get the Facebook Access Token, the Extended Page Access Token that never expires

You will need:

  • [APPLICATION_ID]
  • [APPLICATION_SECRET] (https://developers.facebook.com/apps/[APPLICATION_ID])
https://www.facebook.com/dialog/oauth?client_id=[APPLICATION_ID]
&scope=manage_pages,publish_stream
&response_type=token
&redirect_uri=https://www.facebook.com/connect/login_success.html

When you see 'Success' then you have a URL like:

https://www.facebook.com/connect/login_success.html#access_token=[ACCESS_TOKEN]&expires_in=[SECONDS]

Grab the [ACCESS_TOKEN] then,

https://graph.facebook.com/oauth/access_token?client_id=[APPLICATION_ID]
&client_secret=[APPLICATION_SECRET]
&grant_type=fb_exchange_token
&fb_exchange_token=[ACCESS_TOKEN]

Finally, you will see your extended page access token that never expires

access_token=[EXTENDED_ACCESS_TOKEN]
https://graph.facebook.com/me/accounts?access_token=[EXTENDED_ACCESS_TOKEN]

Backup PostgreSQL from AppFog

Backing up a PostgreSQL database from AppFog is as easy as typing two commands:

af login

Attempting login to [https://api.appfog.com]
Email: [YOUR_EMAIL]
Password: [YOUR_PASSWORD]
Successfully logged into [https://api.appfog.com]

af export-service [POSTGRESQL_DATABASE]

Exporting data from '[POSTGRESQL_DATABASE]': OK
http://dl.eu01.aws.af.cm/serialized/postgresql/[DATABASE]/snapshots/[FILE_NUMBER]?token=[TOKEN]

Restore using pg_restore

If you want to restore that backup in your localhost, then just execute the following command:

pg_restore -c -d [POSTGRESQL_DATABASE] -U [USERNAME] -W [DUMP_FILE]

[YOURDUMPFILE] is inside the file that you just downloaded when you exported the database.

These are the meanings of the flags used:

-c --clean Clean (drop) database objects before recreating them.

-d dbname --dbname=dbname Connect to database dbname and restore directly into the database.

-U username --username=username User name to connect as.

-W --password Force pg_restore to prompt for a password before connecting to a database.

You can read more documentation http://www.postgresql.org/docs/8.4/static/app-pgrestore.html

Restore on AppFog with pgdump & pgrestore

PGPASSWORD=[LOCALHOSTPASSWORD] pgdump -Fc --no-acl --no-owner -h localhost -U [LOCALHOSTUSERNAME] [DEVELOPMENTDB] > [DEVELOPMENT_DB].dump

Upload the .dump to your AppFog

RAILSENV=proxied-appfog pgrestore --verbose --clean --no-acl --no-owner -h localhost -p [PORT] -d [POSTGRESQLDATABASE] -U [USERNAME] [DUMPFILE]