Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 242011
 

How to get my Facebook App' access token?

Answer:

Assume you have your created a Facebook application, and you have the two things: App ID & App Secret.

You can get the access token by a simple curl command.

# curl -F type=client_cred -F client_id=APP_ID -F client_secret=APP_SECRET https://graph.facebook.com/oauth/access_token

Apr 182011
 

Show HTTP response header using curl

Answer:

To show the response of HTTP request to a specific server, you can use the "curl -i" command.

Example:

#  curl -i "http://www.example.com"
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

Update: Thanks Robin Clowers for the update.

Mar 242011
 

Allow a remote IP for incoming connection in UFW (Uncomplicated firewall)

Answer:

To allow a remote IP for incoming connection in Ubuntu's UFW (Uncomplicated firewall), you can use the following command:

# sudo ufw allow from x.x.x.x

Of course you need to reload the firewall.

# sudo ufw reload

Mar 162011
 

Render web page using PyQt

Answer:

Qt bindings to WebKit have been added since 4.4, so you can use PyQt to script the browser (Webkit based).

Firstly, make sure you have installed the need packages:

# sudo apt-get install libqt4-core libqt4-webkit python-qt4

Then you can write a simple script to test, e.g.

#!/usr/bin/env python

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app = QApplication(sys.argv)

web = QWebView()
web.load(QUrl("http://www.google.com"))
web.show()

sys.exit(app.exec_())