Archive for the ‘tutoriale’ Category

How to run a Flask application in a subpath, using Apache mod_proxy

Although there are much better solutions for running wsgi applications (mod_wsgi for Apache or uwsgi, gunicorn for nginx), I’ve been cracking my head trying to set it up using mod_proxy and in a subpath.

What I wanted to achieve is:

http://ex.com/appname/ <-> http://localhost:5000/
http://ex.com/appname/redir -> http://ex.com/appname/destination

(because http://localhost:5000/redir -> http://localhost:5000/destination)

Said and done, having an instance of the app running on :5000, most of the pages on the internet suggest the next apache configuration (including the mod_proxy official docs):

ProxyPass /appname/  http://localhost:5000/
ProxyPassReverse /appname/ http://localhost:5000/

Wrong! The correct setup, for a domain ex.com, is:

ProxyPass /appname/ http://localhost:5000/
ProxyPassReverse /appname/ http://ex.com/

The explanation stays in the ProxyPassReverse reference: it will will do a string replace in the HTTP Location headers. Our app redirects to ex.com, which translates to /appname/ (because of ProxyPassReverse), which translates to our localhost:5000 server (because of ProxyPass).

Please correct me if I’m wrong, but this was the only setup proved to be working.




Howto: Gmail Voice and Video Chat on Ubuntu Linux

This information is outdated and should not be used, since there is a version of Google Talk Plugin working wonderfully on Linux.

The Gmail Team at Google recently released Voice and Video chat for Gmail, available via a browser plugin. Unfortunately the plugin is only available for Mac and Windows systems.

Digging a little, I found that is possible to use this functionality also on Linux, in my case Ubuntu 8.10 Intrepid Ibex. As far as I tested, this method offers only audio (voice) functionality, because of some Wine limitations.

For this to work, you’ll need the browser plugin to be installed on Windows.

What you have to do is:

  1. Install the latest version of Wine.
  2. Download Firefox 3 for Windows and install it under Wine. LE: also install Adobe Flash Player
  3. Modify this file, replace alex with your username.
  4. Using wine’s Registry Editor (~/.wine/drive_c/windows/regedit.exe) import gmail.reg.
  5. Copy from a windows installation the next files from Documents and Settings (preserving directories structure) into ~/.wine/drive_c/windows/profiles/alex/ (replacing alex with your username):

/Local Settings/Application Data/Google/Google Talk Plugin/googleadapter.dll
/Local Settings/Application Data/Google/Google Talk Plugin/googletalkax.dll
/Local Settings/Application Data/Google/Google Talk Plugin/googletalkplugin.dll
/Local Settings/Application Data/Google/Google Talk Plugin/googletalkplugin.exe
/Application Data/Mozilla/plugins/npgoogletalk.dll

Open Firefox from Applications->Wine->Programs->Mozilla Firefox and check if the Google Talk Plugin NPAPI appears installed (Tools->Addons->Plugins).

If everything went right, you may now happily use the voice capabilities of the new Gmail Videochat feature, on your Ubuntu Linux Installation!

LATER EDIT: Because of the popularity of this post (+1000 views), I also made a small script doing all of this for you, you can download it from here and use it at your own risk.

Gmail Voice and Video chat on Ubuntu using Wine




Despre cum să-ţi începi ~prost~ săptămâna

Tot ce trebuie să faci este să:

  • te trezeşti la 8:55 când ai laborator la 10:00
  • să răspunzi la un telefon (pe care nu-l poți refuza) şi să aştepţi…
  • să aştepţi din nou, troleul
  • troleul să se defecteze la grădina botanică; după botanică, să prinzi aglomerație în intersecție la leu :|
  • să ajungi la 10:09 şi să nu mai poţi intra la rețele locale – laborator care nici măcar nu se poate recupera
  • să ajungi la cn2 unde nu pricepi mare lucru şi să predai tema… care temă să nu o ai gata
  • să cauți bezmetic un scanner, pe care să-l găsești abia târziu într-o gură de cămin
  • să fugi în Ștefan cel Mare…

În fine, totuși azi n-a fost așa o zi proastă: mi-am scos telefonul din service ca să constat că mi l-au înlocuit cu totul. Așa că am un nokia 6124 classic nou nouț, care nici nu este blocat în vreo rețea. Mai mult de atât, mi-au adus la zi și firmware-ul. Kewl.

Mă duc să mă joc cu Gmail for Mobile v2.




Cum să activezi stiluri ale mesajelor în Pidgin

Pidgin cu tema Adium

Temele vizuale pentru mesaje sunt o funcționalitate pe care alți clienți de IM precum Adium, Kopete sau Google Talk o au de mai demult.

Pentru a activa aceste teme și pe Pidgin, în cazul Ubuntu este nevoie să faci următorii simpli pași, așa cum am descoperit aici:

sudo gedit /etc/apt/sources.list

Adaugi la finalul fișierului deschis:

deb http://ppa.launchpad.net/webkit-team/ubuntu intrepid main
deb-src http://ppa.launchpad.net/webkit-team/ubuntu intrepid main

Salvezi și apoi:

sudo apt-get update
sudo apt-get install pidgin-dev libwebkit-1.0-1 libwebkit-dev

Descarci apoi arhiva de la: http://simo.h.mattila.googlepages.com/pidgin-webkit (pidgin-webkit-r60.tar.bz2). O deschizi și o dezarhivezi pe spațiul de lucru într-un folder pidgin-webkit.

Apoi:

cd ~/Desktop/pidgin-webkit
make
make install

După asta, descarci o temă de aici și o dezarhivezi în dosarul ~/.purple/message_styles. Abia acum pornești Pidgin (sau îl închizi și redeschizi), mergi la Module și activezi Webkit Message Styles.

Rezultatul ar trebui să fie cel de mai sus. Spor!




Moving from Blogger to WordPress

Because today I moved my blog from Blogger to a local WordPress instalation, I was trying to move all my posts & comments here.

The Blogger Import function from WordPress 2.6 (available in Admin -> Manage -> Import -> Blogger) didn’t work, maybe Google doesn’t want to authorize WordPress to access my blog data.

Anyway, what I did was:

  • first, export my Blogger posts, using a function available only in the draft version (beta) of Blogger as stated in here. I’ve got a big XML file.
  • then, using the RSS import module in WordPress (Admin -> Manage -> Import -> RSS), I imported all the posts. LE: for categories to work, use the modified module from below;
  • after that, I exported all the comments from Blogger, using <blog url>/feeds/comments/default?max-results=1000 -> Save As… -> comments.xml
  • finally, I modified the RSS module to accept also the comments file format; PHP file, rss.php, is available for download here, compressed; I moved it to <wordpress installation dir>/wp-admin/import/rss.php ; with this new one, I imported the comments.
  • That’s it!

Note: this solution only works as described before and is provided “as is” without warranty of any kind. It is just a workaround till one of Blogger authorization/Wordpress import plugin gets fixed.

It took me 5 hours of googling, browsing wp documentation, analysing xml, coding php, to get it to work, but I’m happy, and I’m blogging about it!




How to: S60 3rd ed phone memory + Ubuntu

Because recently I got a new smart phone (Nokia 6124c), I was struggling to get it working with my Ubuntu Linux. Googling around, I found this solution, based on obextool. It worked, but I found it rather complicated, and the tk interface of obextool – a really mess.

So, I found this simpler solution:

Step 0 – Requirements: pc, S60 Phone with mini-usb, mini-usb cable, ubuntu or other linux distro, internet connection.

Step 1: download latest ObexFTP, ObexFS source packages from: here. Note: it doesn’t work with repository packages of obexftp, obexfs.

Step 2: compile and install (usually ‘./configure && make && make install‘ but you might need some dev packages installed, including tcl-dev, libfuse-dev)

Step 3: create a mount point: `mkdir ~/Phone’

Step 4: connect the phone via usb cable, then mount it with: `obexfs -u 1 ~/Phone’

This is it, you may browse your phone memory in Nautilus or whatsoever file-manager you use.

There is also possible to use bluethoot as the connection between phone and PC, but I don’t have one, so I can’t tell how. Anyway, `obexfs –help’ will tell you what to do.

Further reading: Open Obex Trac.




Cum activezi mod_rewrite in apache2 pe Ubuntu 7.04

Modulul mod_rewrite al serverului Apache este responsabil de url-urile frumoase. Astfel, in loc de:

http://www.siteulmeu.ro/index.php?q=pages&page=Contact

utilizatorul poate “vedea” in browser:

http://www.siteulmeu.ro/pages/Contact

Pe scurt, m-am lovit de problema activarii acestui modul, si, desi solutia este simpla, am avut un pic de sapat dupa ea. Solutia se aplica la serverul apache2 pe distributia Ubuntu.

Deci, ce trebuie facut:

$ sudo a2enmod rewrite

apoi:

$ cd /etc/apache2/sites-available/$ sudo gedit default

se face modificarea liniei AllowOverride din None in all:

<directory>
Options IndexesFollowSymLinks
MultiViewsAllowOverride all
Order allow, deny
allow from all
</directory>

( /var/www putea fi alt folder, folderul root pentru apache, de exemplu la mine este /home/alex/htdocs )
si in final:

$ sudo /etc/init.d/apache2 restart

Asta e tot, mai departe tot ceea ce trebuie facut este sa completezi folderele care te intereseaza cu fisiere .htaccess corespunzatoare (de exemplu /var/www/.htaccess). Un exemplu de continut foarte simplu al fisierului .htaccess este:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z\/0-9\ ]*)$  index.php?url=$1

Legaturi: http://www.gtrev.it/ubuntu-edgy-modrewrite-e-drupal
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html