Tuesday, December 1, 2009

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.

Sunday, November 29, 2009

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

Wednesday, October 21, 2009

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

Tuesday, October 13, 2009

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!

Monday, August 10, 2009

Адмирал

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

Thursday, August 6, 2009

Trip to Sary-Chelek.

Sary-Chelek is a lake in the south of Kyrgyzstan. Recently we had trip there. "Bishkek-Osh" highway connects the north and the south of my country. The highest point in road, ~3300 meters altitude, is Tyo-Ashuu pass. It was cold there but it's beautiful all seasons.

We had breakfast in Ala-Bel pass near Chychkan river and found nice car.

Water of Toktogul reservoir twists generators of Toktogul hydro electric station which powers all country with electricity.

After Toktogul reservoir Naryn river becomes blue-green color cause of depth.

Sary-Chelek is in ~1800 altitude. At the entrance to lake's plain there are place called Panorama.

At place.



Find the difference in pictures. :)





View all photos in album

Soon I'll post photos from the second trip to Sary-Chelek.

Wednesday, July 29, 2009

ме сага

(12:06:41 AM) Никита Федяшев: Калыс, напиши что-нибудь в блог )
(12:06:46 AM) Никита Федяшев: почитать хочется )

читай

Monday, July 27, 2009

блог не открывается ><

фигня какая-то.
http://www.blogger.com и *.blogspot.com открываются, а custom домены (http:/www.osmonov.com, http://www.abraliev.com) с акнета нет. с хомы открывается. причем, пинги нормальные, коннект происходит, firefox грит waiting for ... и усё.

Звуки-муки

Открыл для себя, что гул от кулеров компьютера сильно мешает работать тем, что я засыпаю под его монотонные звуки. Когда компьютер включенный, этот звук незаметен, но когда выключаешь комп и наступает тишина, уши и мозг испытывают такое облегчение.

Если у тебя есть такая проблема, то быстро решай его. Выноси системник на балкон, приобретай ноут, ставь жидкостное охлаждение, что угодно, но работать ты должен в тишине.

Вот так вот.

Friday, June 5, 2009

УНЬЮЮЮЮЮЮЮЮЮАААААГГГЪХ!!!!!

НЯЯЯЯЯЯЯЯЯЯЯРГЪЪЪЪХ!!!!
КУКЛЫ ДЕЛАЮТ МЕНЯ ДОБРЕЙ!!!
ДОБРАЯ ДЕСА ЛЮБИТ ДЕТЕЙ!!!
ШИНКА И ХИНА ПОССОРИЛИСЬ С НЕЙ!!1
НО ВСЕ ПОМИРИЛИСЬ И СТАЛО ВЕСЕЛЕЙ!!!!!
УНЬЮЮЮЮЮЮЮЮЮ!!!!!
Я ЧУВСТВУЮ ЗАПАХ РОЗ!!!!!
УНЬЮЮЮЮЮЮЮЮЮАААААГГГЪХ!!!!!
Я ЧУВСВТУЮ ЗАПАХ РОЗ!!!!!
НАДО ОБНЯТЬ И ЛЮБИТЬ ДО СЛЁЗ!!!!!
НОЧЬЮ ВНЕЗАПНО! В ЗЕРКАЛЕ ТУМАН!
СУЙГИНТА ЗАДУМАЛА ХИТРЫ ОБМАН!!!!
РУТНАЯ ЛАМПА РОЗЫ СИЛЬНЕЙ!!!
НО ВСЕ ПОМИРИЛИСЬ И СТАЛО ВЕСЕЛЕЙ!!!!
УНЬЮЮЮЮЮЮЮЮЮЮЮЮ!!!!!111!!
Я ЧУВСТВУЮ ЗАПАХ РОЗ!!!!!1!
УНЬЮЮЮЮЮЮЮЮЮАААААГГГЪХ!!!!!!!
Я ЧУВСТВУЮ ЗАПАХ РОЗ!!!!!!
НАДО ОБНЯТЬ И ЛЮБИТЬ ДО СЛЁЗ!!!!!!!!!!

отсюда http://nya.sh/post/4109

Saturday, May 30, 2009

Friday, April 17, 2009

Client certificates with urllib2

First let's get pem formatted file with certificate and key from your *.pkcs12 or *.pfx file with openssl.
openssl pkcs12 -in file.p12 -out file.pem -nodes


Now we need to extend standart HTTPSHandler( I found it here. I added timeout to getConnection method. ) and sent instance of it to urllib2's build_opener.
import urllib2, httplib
class HTTPSClientAuthHandler(urllib2.HTTPSHandler):
def __init__(self, key, cert):
urllib2.HTTPSHandler.__init__(self)
self.key = key
self.cert = cert
def https_open(self, req):
#Rather than pass in a reference to a connection class, we pass in
# a reference to a function which, for all intents and purposes,
# will behave as a constructor
return self.do_open(self.getConnection, req)
def getConnection(self, host, timeout=300):
return httplib.HTTPSConnection(host, key_file=self.key, cert_file=self.cert)

opener = urllib2.build_opener(HTTPSClientAuthHandler('/path/to/file.pem', '/path/to/file.pem.') )
response = opener.open("https://example.org")

print response.read()

Thursday, April 16, 2009

Harmonica

Harmonica was one of things I want to have. It's small and sounds cool. I associate it with Wild West and cowboys.

A month ago I saw a harmonica in music store and I said myself to buy it.

Today I purchased another one than I saw. I didn't know types, how to play on it. The thing I assess was count of  holes )). I choose Yamaha SS 220.

I found that it needs to inhale too, not only blow )). It takes half an hour to understatnd positions of note and I played simple melodies.

Found some information on web about harmonicas. Type of mine is Chromatic Single. It has two rows of holes. Upper row gives C# scale and lower gives C scale. There are 44 holes, 22 on each row.

P.S. There, in Yamaha music store, I played on electronic drums. They're sooo coool. I wish them. Drums are compact it's important for my appartment. You control a volume and also they're pluggable to headphones. Aaaaaaa!!! I want I want  I want them. With my real drums I feel discomfort when I play cause of my neighbors and thin walls. Somebody, give me 1500 dollars!

Tuesday, March 31, 2009

Friday, March 6, 2009

Thursday, March 5, 2009

Wednesday, February 25, 2009

message driven beans

Заюзали Message Driven Beans EJB 3.0.
Классное решение для работы с очередями.

В инете полно информации по нему, вдаваться в детали тут не имеет смысла, просто хвастаюсь :).

Friday, January 30, 2009

epay.kg

запарился писать на инглише. ну и его нафиг.

хочу рассказать о проекте epay.kg. это еще одна платежная система.
клиент почти весь на javascript с jquery.
именно для этого проекта я изучал data gridы. в результате чего, ни один грид мне не понравился и я написал свой... с классами Record, DataSource, XmlDataSource, Grid, Filter, Pager офигеть, да? )))


стырил у гмейла идею с выводом MessageBox и ErrorBox наверху,






вот такие вот дела

Monday, January 12, 2009

redirect to blogspot

I found that a lot of domain registrars with dns server don't allow to create CNAME to main domain (your-domain.com). You need to create subdomain (www.your-domain.com or blog.your-domain.com) for CNAME to ghs.google.com. .

It's good if you have homepage (your-domain.com) and blog(blog.your-domain.com).

But blogspot for me is homepage and blog )). So i redirect from your-domain.com to www.your-domain.com( CNAMEd ghs.google.com).

I use apache mod_rewrite and php.
.htaccess

RewriteEngine on
RewriteRule ^(.*)$ index.php?$1 [QSA,L]


index.php

<?php
error_reporting(0);
$uri = $_SERVER['QUERY_STRING'];
$uri = str_replace("index.php&", "", $uri );
$uri = str_replace("index.php", "", $uri );
header("Location: http://www.your-domain.com/{$uri}");
?>

Wednesday, January 7, 2009

Tuesday, January 6, 2009

Dissappeared sites which I developped


  • nph.kg site of Neman company

  • apteka.kg online drugstore of Neman company

  • ar.kg Asian Realty real estate agency

  • stroimarket.com.kg Building materials online-store

  • karabalta.org "Initiative Support Center" non-government organization

  • streetchild.net "Children Protection Center" non-government organization

  • asianroads.net "Asian Roads" travel agency

Powered by Blogger.