Quickies

Care ati auzit de Carpathia Hosting? Daca nu ati auzit o sa auziti acum…Carpathia a devenit peste noapte al treilea cel mai mare hub al traficului pe internet, mai mare decat Facebook sau Twitter. Megasite-urile detinute de Carpathia (Megaupload.com, Megavideo.com, Megarotic.com, Megaclick.com) genereaza aproape acelasi trafic cat genereaza Microsoft cu Bing, MSN si cele cateva sute de mii de site-uri de pe Azure.

Jucati Warhammer online GRATIS. Electronic Arts a decis sa permita pasionatilor sa joace gratuit pana la nivelul 10.

S-ar zvoni ca Google Chrome OS ar putea fi lansat saptamana viitoare.

Cica filmul 2012 ar fi un dezastru, si nu in sensul literar, chiar este de kko.

Client Twitter la linie de comanda, Twidge, super util celor care vor sa-si automatizeze contul sau sunt in limba dupa consola.

Trolling-ul pe web dauneaza creierului.

GeoApi.com lansat la apa.

14 modalitati de a folosi Twitter. Eu m-as incadra la punctele 4,5 si 6.

Dupa Noop, Google a mai lansat un limbaj de programare GO, un hibrid intre C++ si Python (desi personal vad anumite influente si din Erlang). M-am jucat si eu vreo 2-3 ore cu el, de fapt m-am jucat cu primul proiect facut in GO, un client de Twitter. Mi-am format si o parere, o sa raman la Python si Erlang.

Microsoft a patentat SUDO, comanda si arhitectura specifica Unix, Linux si MacOS. De fapt sudo dateaza din 1971 fiind implementata prima data pe BSD, cu 4 ani inainte de a se infiinta Microsoft.


URL shortening – How do they do it

URL shortening services had experienced a big push in the age of social networks rising, such as Twitter, where big urls collide with the 140 characters user input restriction.

So there was this need of magically transform URLs like this one http://raduboncea.ro/2009/04/01/twitter-autofollow-and-dm-using-python-twitter-imaplib-and-gmail/ into something like this http://tinyurl.com/cralfk.

Many would be tempted to think there is some kind of compression algorithm that would shorten a big URL and make it fit into a unique combination of 4,5 or 6 characters and then decompressed upon user request. Well it doesn”t work like this, mathematics prohibit it.

So how does it actually work?
A URL shortening service takes the big URL and saves it into a database along with an auto incremented numerical value, an id or sequence, so we would have the first big URL saved with ID=1, the second with ID=2 and so on. When someone would ask for http://tinyurl.com/1/ we would get from the database the big URL identified by ID=1 and redirect the user to that URL.

But there is a problem: having numerical ids does not shorten urls too much. For the URL number 1 million we would have 7 numerical characters. So the next step is to change base numerotation from 10 to a bigger one, lets say 36, so we include all a-z small latin letters or, why note, 62 which includes also the capital chars A-Z.
In 36 base we can save as much as 1.679.615 URLs into 4 characters. On base 62 we have 14.776.335 URLs fit into 4 chars, almost 10 times as much as base32 and 14.776 times base10.

Some security issues.
Many shortening services stopped to the algorithm above without digging into a very important security issue which is related to how redirects work. It is critical, before redirecting users to the URL they requested to check what’s behind that URL, to check if the URL is not yet another redirect which may result into a recursive loop and may disrupt the service.

A malicious user may save a URL to a page which will later modify to redirect back to the service URL and thus attempting to generate an infinite loop which could make the interpreter to hang.

To avoid this kind of DoS vulnerability, we must not allow redirects to our own links and to limit redirects to outside to a smaller finite number of depths analysis.

Beneath a small model-view example in django, using also urllib to check for redirects and the base10-base62 conversion algorithm similar to the base36 which is included in django.





Twitter autofollow and DM using python-twitter, imaplib and gmail

The script will:

  1. connect via imap to gmail
  2. select the imap directory TwitterFollow (you should filter twitter follow notifications and label them with TwitterFollow)
  3. fetch the headers of all unread mails
  4. retrieve the twitter user screen_name that is following you from the headers
  5. attempt to create a friendship aka autofollow. If an error occurs is probably due to the fact you previously followed the user
  6. Send a direct message to thank for the following
  7. Flag the message as read so it won’t be fetched next time script runs

You could also check Twitter autofollow and direct message using python mechanize libgmail which is basically achieving the same goal but operate differently using reverse engineering on gmail web site.


Twitter autofollow and direct message using python mechanize libgmail

Requirements:

  • a valid gmail account
  • label your twitter follow notifications (E.g. I use TwitterFollow)
  • mechanize : a stateful programmatic web browsing
  • libgmail : a GA reverse engineered library
  • python-twitter : a wrapper around the Twitter API

IMPORTANT: because Gmail does not provide an API and does not intend to do that because of the ads, hacking libgmail to fetch the threads is a VIOLATION of Gmail TOS. This script should be use for documentation only. For production please consider using POP3 or IMAP to fetch the threads. To avoid your account being suspended or locked run the script no more than twice a day.

Twitter Search Api example in use by Ecto Script – Python

Requirements: simplejson

The script gets the input from Ecto and prints the search results.

Ecto script – python feedparser my delicous

I recently started using Ecto as a blog editor instead of Blogo and I find it extremely useful, specially the Script feature which allows you to get the output of your scripts and paste it to the post. This feature gives you all the freedom in automates certain posts.

The Script Tool supports php, python, ruby, perl and bash after declaring compilers paths.

One simple example which I found useful was to parse my delicous bookmarks binded to a specific tag (myblogshare).

Python twitter api – extract friends who don’t follow back

A perspective different than the script I posted here which required python-twitter library.

Please excuse the lack of introspection, the script should be self explanatory.



Twitter friends list match against followers using python-twitter

One simple way to extract those who you follow but are not following back

Washington Times gândește opensource

Ieri washingtontimes.com a decis să împărtășească câteva din sursele folosite de ei pentru ziarul online.

Sursele sunt module ale platformei django, o platformă de dezvoltare a aplicațiilor web
dezoltată în python pe principiul MVC, tot mai larg adoptată de programatori, mai ales după ce Google s-a decis să sprijine comunitatea Django prin folosirea acestei platforme în dezoltarea aplicațiilor proprii (Google Sites ar fi un exemplu) și suportul platformei de către Google App Engine.

Ce conține repozitoriul:

  • django-projectmgr, așa cum zice și numele este o aplicație de management conflicte, buguri, task-uri, todo, etc
  • django-supertagging folosește api-ul de la Open Calais pentru a genera tag-urile cele mai relevante conținutului
  • django-massmedia. Modulul ăsta l-am testat personal și este aur curat. Permite management de media content (imagini, muzică, video) în toate formatele existente. Are auto slugging, poate fi integrat cu supertaggingul de mai sus. Se pot uploada bulk conținut arhivat și prelucrarea lor în masă.
  • django-clickpass permite autentificarea openid, permițând conturile de Google, Yahoo!, Facebook, Hotmail, etc.

Ca o notă, toate aceste aplicații necesită ultima versiune de django (1.0.2). Nu funcționează cu 0.96.



Python Twitter

Python-Twitter este o librarie client light in Python care foloseste metodele REST ale api-ului twitter. Nu parseaza decat in formatul Json, nu si XML.

Dependinte: SimpleJson