FOSS meeting

Today I was at the malaysian FOSS community meeting.
As usual for this kind of meetings there were presentations.
Victor Yap told about Blender, changes between versions 2.49 and 2.50. Show several movies of Durian team (http://durian.blender.org) and movie of his team with nice girl and lion.
In next short presentations I got information about Hackerspace in Kuala Lumpur.
And next presentation was really interesting for me. Presenter told about Arduino (http://arduino.cc). Very nice hardware solution. I think I'll play with Arduino very soon.

rss.kg & twitter

I have no idea how to tweet posts on rss.kg. Now I tweet all of them. But some part of my mind says that it isn't true. There will be too many posts soon.
Getting started using twitter API was very simple.Just used this: http://code.google.com/p/python-twitter.

simple mysql dao class for python

This is DAO class for working with mysql which may help you if you need do something quickly and don't want to use ORM:

# encoding: utf8

import MySQLdb

class Singleton(object):
_instance = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
return cls._instance


class DAO(Singleton):
def __init__(self):
"""
Inits MySQL connection
"""
self._connect()
return


def _connect(self):
"""
Creates connection
"""
self.connection = MySQLdb.connect(host="localhost", \
user="mysql_user", \
passwd="mysql_password", \
db="mysql_db", \
port=3306)
return


def _get_cursor(self):
"""
Pings connection and returns cursor
"""
try:
self.connection.ping()
except:
self._connect()
return self.connection.cursor()


def get_row(self, query):
"""
Fetchs one row
"""
cursor = self._get_cursor()
cursor.execute(query)
row = cursor.fetchone()
cursor.close()
return row


def get_rows(self, query):
"""
Fetchs all rows
"""
cursor = self._get_cursor()
cursor.execute(query)
rows = cursor.fetchall()
cursor.close()
return rows


def execute(self, query):
"""
Executes query for update, delete
"""
cursor = self._get_cursor()
cursor.execute(query)
cursor.close()
return

How to fetch feed url from web page in python

Easyly.


import urllib2
from lxml import etree

webPageUrl = "http://www.osmonov.com"
try:
opener = urllib2.build_opener()
response = opener.open(webPageUrl)
if response.headers.__getitem__('Content-Type').startswith('text/html'):
html_element = etree.HTML( response.read() )
link_elements =html_element.findall('.//link[@rel="alternate"]')
if link_elements.__len__() > 0:
# so we can have several link tags, i use just the first
feedUrl = link_elements.__getitem__(0).get('href')

except urllib2.URLError:
# commander! do something violent

hi.kg API

Dear Sudar'! ^_^
Please! Try out hi.kg API.
It's implemented on json-rpc.
url: http://hi.kg/api.php
method: shorten
argument: url
return: shorten_url

Some examples:


<?php

require_once("jsonRPCClient.php");
$client = new jsonRPCClient("http://hi.kg/api.php");

echo $client->shorten( "http://www.osmonov.com");

?>



Also JSON-RPC PHP lib here

Have a nice shortening!

Адмирал

Представляете, квартиры в доме на месте ресторана "Адмирал" уже раскупили. Вот как расположение имеет значение. Кста, комплекс из двух жилых и офисных зданий сохранит старое название.