Archive for Technology

A day with C# and jQuery

jQuery Write Less, Do More

Days ago I tried  ASP.NET AJAX for an autocomplete text field in a form. The results were automatic, in no time you could have the most common and famous features you see in your favourite sites. But after dragging and dropping some controls here and there, and also adding a bunch of .dll’s to the project, a question appeared: what if I want a small modification?

Well, the answer wasn’t clear for me. Perhaps because my experience with ASP.NET is not so big enough to make some changes to a library that packs functionality in other language. Some times I want the things straightforward: from A to B.

So today I decided to reimplement the system using a javascript framework/library. I took a look to some of the libraries available on the net. I did a fast preview of these little amazing libraries and I liked them all. For my tests I chose jQuery.

Results: In one day not only was able to reproduce what I did with ASP.NET AJAX. I personalized the interface adding the functionality I wanted: calendars, creating new sections on the fly. And all this without a call to a piece of server code (except for the autocomplete part).

Before this change, even the javascript code was served using an aspx file server. For god shake! they’re static files! Do you really need to execute an aspx to serve a static file? Now I was able to setup the interface using XHTML, CSS and javascript.

But don’t think that .NET is the bad boy. I like a lot the “webservice” implementation it has. It can output JSON to feed your hungry AJAX/AJAJ applications. With a good web client for fast and quick tests.

Some other links I found interesting:

Tags:, , , , , »
No comment »

GSM 03.38 Encoding for Python 2.4

Vim screenshot of gsm0338 encoding

These days I’ve been working with SMS messages. Due to the fact that I work in a Greek company, the character set of these messages should be Greek (or able to contain greek letters). As far as I know there are 3 options to accomplish this:

  • Use unicode (UCS2, it’s like UTF-16). But you’ll get only 70 characters per SMS.
  • Use GSM 03.38 encoding. You get 160 characters per SMS, but a reduced set of characters.
  • 8 bit encoding. I wasn’t able to figure how this work with the Greek charset (yet).
So for our new SMS delivery system we decided to go with the almost universal GSM 03.38 encoding. Also we changed our hacked java SMPP client to pythomnic and it’s SMPP library.
That works great but the library doesn’t know anything about encoding. Using iso-8859-1 works, but for Greek we need some kind of “automatic conversion”. This was done using a python encoding module (for python 2.4).
From Greek to GSM 03.38 you have to understand that gsm supports only a few greek letters, they’re in uppercase and without tones. Therefore:
  • All lowercase greek letters are transformed to uppercase.
  • Tones and diaeresises are removed.
  • For some upper case letters, latin ones are used instead. Example: rho: ρΡ -> P (Even in a web browser is difficult to see the subtle difference).
Example:

>>> import gsm0338
>>> msg = u”Αναταράξεις στο πολιτικό σκηνικό προκαλεί η υπόθεση Siemens”
>>> msg.encode(”gsm0338″)
‘ANATAPA\x1aEI\x18 \x18TO \x16O\x14ITIKO \x18KHNIKO \x16POKA\x14EI H Y\x16O\x19E\x18H Siemens’
ANATAPAEI TO OITIKO KHNIKO POKAEI H YOEH Siemens
>>> print msg.encode(”gsm0338″).decode(”gsm0338″)
ΑΝΑΤΑΡΑΞΕΙΣ ΣΤΟ ΠΟΛΙΤΙΚΟ ΣΚΗΝΙΚΟ ΠΡΟΚΑΛΕΙ Η YΠΟΘΕΣΗ Siemens

If what you see is useful for you, here is the gsm0338.py encoding module for python 2.4.

Tags:, , , »
No comment »

Hostmonster + python 2.5 + subversion 1.4 + django-svn + mysqldb + fcgid

I’ve chosen Hostmonster as a shared hosting provider for one my projects using Django. I’ve been using hostmonster for this blog so I wanted to give it a try for more professional matters. The problem is that hostmonster is not django/python friendly. I’ve found the following problems:

As you can see:

$ python -V
Python 2.3.4
$ svn
-bash: svn: command not found

But not supported doesn’t mean impossible. You can have your python 2.5 and Django from subversion (And everything you want to install). You only need to install the software we need from scratch. If you want to know how, just read the rest of this entry.

Read the rest of this entry »

Tags:, , , , , , , »
Comments (16) »

Are you still using Internet Explorer 6?

Stop IE6

Are you one of those who uses Internet Explorer 6? This post is dedicated to you, fellow visitor who enjoys the web using a great piece of software. For you it’s time to Stop IE6.

Thanks to you, the development of the web is slower. And because you continue using IE6, web developers from all around the world have to implement fixes for you to enjoy the web. So please, make the world a favor: Update to Internet Explorer 7 (or Internet Explorer 8). Or even better: use other browsers like: Firefox, Opera or even Safari. IE6 was a great piece of software time ago, in 2001 when it was launched. But 6 years have passed and it’s time to move on.

For all the rest. I’ve been analyzing the support of some WEB standards on IE6, and it’s hell. It lacks the support of modern standards that makes life easier and web styles compact and easy to read (I won’t talk about bugs). So if you want to develop a webpage you have to spend extra time (and time is money) developing hacks for IE6. Some of those patches are available on the internet, but you still spend time taking care of an old museum piece.

So now I have to work with web development and then, when everything is finished, work to attach available hacks and implements what the hacks cannot patch.

And you, web developer who develops only for Internet Explorer (like eurobank e-banking). You, will be next. :P

Meanwhile, update your browser and try the alternatives :)

Tags:, , , , , , , , »
Comments (5) »

MySQL-python in Leopard.

Python and mysqldb

Installing the python library for MySQL in Leopard can be a bit tricky. If you’re an easy_install lover, the first thing to try would be:

$ sudo easy_install MySQL-python

But the results you’ll obtain will be not very encouraging.

Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python
Reading http://sourceforge.net/projects/mysql-python/
Best match: MySQL-python 1.2.2
Downloading http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz
Processing MySQL-python-1.2.2.tar.gz
Running MySQL-python-1.2.2/setup.py -q bdist_egg –dist-dir /tmp/easy_install-07GTpt/MySQL-python-1.2.2/egg-dist-tmp-t78bko
In file included from /opt/local/include/mysql5/mysql/mysql.h:47,
from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
In file included from /opt/local/include/mysql5/mysql/mysql.h:47,
from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
lipo: can’t open input file: /var/tmp//cczla7iC.out (No such file or directory)
error: Setup script exited with error: command ‘gcc’ failed with exit status 1

But the solution is there. As you can see, the command talks about an error in line 40 for some file called _mysql.c. We’re going to get to that file and remove one line.

First we need to download the package. We will use easy_install, but later. So now grab your wget or your browser to here. And when you have the file, uncompress it (terminal or through finder).

$ wget http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz

$ tar xzf MySQL-python-1.2.2.tar.gz

Now go to the directory that has just been created and open the file _mysql.c. Go to the line number 38.

35 #include “my_config.h”
36 #endif
37 #ifndef uint
38 #define uint unsigned int
39 #endif
40 #include “mysql.h”

Delete line 38, save and install your modified egg from the parent directory with:

$ easy_install MySQL-python-1.2.2
Processing MySQL-python-1.2.2
Running setup.py -q bdist_egg –dist-dir /Users/alff/tmp/MySQL-python-1.2.2/egg-dist-tmp-S4uIM7
ld: warning in /opt/local/lib/mysql5/mysql/libmysqlclient_r.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libz.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libssl.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libcrypto.dylib, file is not of required architecture
zip_safe flag not set; analyzing archive contents…
Adding MySQL-python 1.2.2 to easy-install.pth file
.
Installed /Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg
Processing dependencies for MySQL-python==1.2.2
Finished processing dependencies for MySQL-python==1.2.2

The problem was that _mysql.c defined the type unit and that type is defined again when it includes the file mysql.h. We remove the duplicate, the compiler is happy :)

Edit: If you installed mysql5 with MacPorts, and you get the error EnvironmentError: mysql_config not found when installing the egg. Just add a link from mysql_config to mysql_config5.

# which mysql_config5
/opt/local/bin/mysql_config5
# cd /opt/local/bin/
# ln -s mysql_config5 mysql_config

Tags:, , , , , »
Comments (2) »

You can find a Mac fan everywhere.

Mac fans everywhere.

Sometimes you walk in the street and you don’t pay attention to the multiple details the objects placed in your way offer to you. But also you have to stop form time to time to see what’s around you. And you can find hidden Mac fans like the one in the picture.

I went to pick money from ATM and I don’t know why, I walked around the area and found this Apple labeled scooter. As you know there are multiple places where to put that sticker.

Tags:, , , »
No comment »

Long days.

La Grande Bouffe - cleaning

These days have been a bit long without much sleep. At least yesterday I could enjoy the company of the International Pizza (group of friends from everywhere). We watched La Grande Bouffe. A strange film about four guys who decide to meet in a house to finish their lives eating and drinking themselves till death.

I had fun with the film. For some people some scenes can be a bit offensive, but it’s nothing disgusting, although it has some spicy scenes. The actors played really well, thus you get into the film from the very beginning and you enjoy it.

As a International Pizza meeting, we had dinner. I couldn’t make something for dinner because I arrived late at home and I didn’t have much to cook (sorry guys). But there is always a good place to order nice food :D

It feel pitty for the dinner. I wanted to prepare some omelettes and perhaps some fried rice, but these days I’m out of time. The film day I returned home at 8pm, but by team workmate received new specs at 9pm and stayed until 2am (joking: I guess he tried to beat my record of 2:30am). So next day was also quite long and I felt guilty (for leaving him alone) and angry (with the people who sent new specs at 9pm and expected results that day).

Now my anger is gone (but Wordpress it’s helping to get it back un-publishing my posts randomly), the dishes are clean (pic), and the house is clean a ready for another movie :)

Edit: more info about the event in Sascha’s lounge: here.

Tags:, , , , , »
Comments (2) »

Installing pycurl in MacOS Leopard

Lib Curl

Leopard comes with Python 2.5.1. And it’s nice to be able to use easy_install to add python packages, but it can happen that some of those libraries depend in their C/C++ counterparts, and they are a bit outdated in Leopard.

My case was with pycurl. Leopard python doesn’t come with pycurl. However it includes cURL and libcurl version 7.16.3.

$ curl –version
curl 7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IPv6 Largefile NTLM SSL libz

If I try to install pycurl from easy_install, I get this message regarding the version of the C version of the library

$ sudo easy_install-2.5 pycurl

Using curl-config (libcurl 7.16.3)
src/pycurl.c:55:4: error: #error “Need libcurl version 7.16.4 or greater to compile pycurl.”

I have also macports, so I tried to install the version requiered through macports. It´s not an upgrade, because you continue having the original Leopard version plus the new one in the /opt directory.

$ port search curl

curl net/curl 7.18.0 Tool for transferring files with URL syntax
$ sudo port install curl
—> Fetching curl
—> Verifying checksum(s) for curl
—> Extracting curl
—> Configuring curl
—> Building curl with target all
—> Staging curl into destroot
—> Installing curl 7.18.0_0
—> Activating curl 7.18.0_0
—> Cleaning curl

Seems that everything is ok. But before you run to run easy_install again, you have to realize that easy_install doesn’t know anything about your new curl installation of curl in /opt. easy_install will use curl-config to determine the location of the curl library. So, if you update your PATH (if you don’t ave it already) adding the /opt entry in the beginning, everything will be solved.

$ curl-config –version
libcurl 7.16.3
$ export PATH=/opt/local/bin/:$PATH
$ curl-config –version
libcurl 7.18.0

Now the installation will proceed:

$ sudo easy_install pycurl
Searching for pycurl
Reading http://pypi.python.org/simple/pycurl/
Reading http://pycurl.sourceforge.net/
Reading http://pycurl.sourceforge.net/download/
Best match: pycurl 7.16.4
Downloading http://pycurl.sourceforge.net/download/pycurl-7.16.4.tar.gz
Processing pycurl-7.16.4.tar.gz
Running pycurl-7.16.4/setup.py -q bdist_egg –dist-dir /tmp/easy_install-f4LJrU/pycurl-7.16.4/egg-dist-tmp-9l6i1M
Using curl-config (libcurl 7.18.0)
ld: warning in /opt/local/lib/libcurl.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libz.dylib, file is not of required architecture
zip_safe flag not set; analyzing archive contents…
Adding pycurl 7.16.4 to easy-install.pth file
.
Installed /Library/Python/2.5/site-packages/pycurl-7.16.4-py2.5-macosx-10.5-i386.egg
Processing dependencies for pycurl
Finished processing dependencies for pycurl

And we’re ready to rock’n'roll:

>>> import pycurl
>>> pycurl.version
‘libcurl/7.18.0 zlib/1.2.3′
>>> c = pycurl.Curl()
>>> c.setopt(pycurl.URL, “http://www.google.com”)
>>> c.setopt(pycurl.FOLLOWLOCATION, 1)
>>> c.perform()
… (dumped html) …
>>> c.getinfo(pycurl.HTTP_CODE)
200

:)

Tags:, , , , »
Comments (1) »

First steps with HD video II

DVI to HDMI 1360×768

As I wrote the last time I talked about this. I had some problems with the connection between my mac and my LCD TV. The problem was with the HDMI cable. I wasn’t able to get a good picture in the screen because resolution problems.

Well, the time passed and I didn’t give up (Perhaps the money given for the DVI -> HDMI cable did help). I tried the same setup in Windows XP. And here comes the surprise, this time the HDMI connection was crystal clear, but the VGA was quite awful. I noticed that ATI drivers in Windows have a special setting for HDTV connections, and the TV was detected as a HDTV when using the HDMI cable.

So today I was using the TV through the VGA connector, and I decided to give another try to Leopard + HDMI. It worked without touching anything. The overscan was active but this time it wasn’t overscaling so much. I got the perfect resolution and I don’t know why.

I applied some updates in Leopard, perhaps that’s the difference. Also I realized that even if the resolution is advertised as 1366×768 in the samsung webpage. The manual says 1360×768, and that’s what I have working right now. And after some color calibration DVI -> HDMI was working perfect.

In fact I rebooted and I plugged only the HDMI cable. I got a strange blinking effect in the top. Change to a different resolution and again back solved the problem.

The updated facts are:

  • Windows XP works with HDMI but not with VGA
  • MacOS works with VGA and HDMI.

Any difference beween VGA and DVI? Well, VGA was really sharp with good colors. But DVI is just better. I was difficult in the beginning, but I was staring at the TV and thinking: “my eyes feel something different”. They were right: more sharp image.

I feel a bit dumb because twice I tried and twice I failed, but the third was the good one :)


Comments (4) »

First steps with High Definition Video.

My lovely TV

It looks nice, doesn’t it? After some months saving money and with the help of the Christmas “gift” (gift = we (the company) take your money during half a year. We profit with it and we gave it back to you in Christmas like a present), I bought a TV. Or I should say a huge LCD Screen. And of course, after buying a piece of technology it’s time to get the most of it with some tweaks.

1. Some boring technical information.

Something to start with: What is High Definition Video? Nowadays it is considered the video displayed at resolutions of 1280×720 [width x height] (720p) or 1920×1080 (1080i or 1080p). For sure you have seen the 1080 and 720 numbers in your favourite electronics store. Think also that a DVD has a resolution of 720×576 (PAL 480p or EDTV for TV signals). So we’re talking about fine grained images with almost double quality.

And what about HD Ready and Full HD? Full HD are those Screens with a resolution of 1920×1080 (minimum). HD Ready if the screen has at least 1280×720. Even though it’s very very common to find screens (yes, TVs ) with a resolution of 1366×768, those screens are in the area of HD Ready resolutions. Of course any screen can show any kind of input, they upscale or downscale the image.

No I didn’t forget the television. The HDTV (High Definition TV) broadcast with resolutions of 720 and 1080 (For example sky HD). Do not confuse it with the extended-in-europe-but-not-in-greece-Digital-Terrestrial-Television (DTT). You can tune this using the tunners in the new TVs or using external ones (Even the on-telecom iptv box has an antenna input for DTT) The DTT quality is usually like DVD.

About connections. Think that almost all the new TVs/screens you can buy today are digital. Also all the good/high definition content is digital. Therefore connecting the content with the DVD using an analog cable can cause some quality loss. Here is where the words HDMI and DVI appear. DVI is a digital connector used mainly for computer screens. It can carry analog signals, but the idea is to carry the digital one to avoid any information loss converting from digital-analog-digital. HDMI is the consumer electronics brother of DVI. It carries digital signal for video and audio, and has been designed for simplicity: one cable for digital signals.

Plasma/LCD/DLP and so on and so forth. Those names are three of the most common names you will find in an electronics shop. What’s the best? Well, this can be a matter of taste and where do you want to place you TV/Screen. The first point, about projectors is: they work with no light (like in the cinema), but they can give you a huge (when I say huge is 100″ or more) screen for a nice price. For my personal taste, projectors are not made to watch the TV news everyday (also the bulb they use fades out quickly).

Plasma/LCD, go to the shop and see by yourself. Plasma was said to have the best quality, and nowadays cheap plasma tv beat cheap but more expensive LCD tv’s. Plasma screens need special care (just a little bit) to avoid static images to burn into the screen. LCD screens have an awful black and not so much contrast, but good ones are amazing (and expensive).

Ahm! and remember that analog TV looks like <insert a bad word here> in a Plasma/LCD screen. An analog TV usually can soften the image, but with the digital you will see high definition noise :P So check out your antenna or plug a digital source (today I enjoyed the digital TV offered by on-telecoms and it has nice quality).

2. Personal experience.

Well, my TV is a LCD HD ready one, it has a resolution of 1366×768 and therefore it supports 720p. You can also feed it with 1080p signals, but you will have to trust in the downscaling algorithm to get a nice image (Usually it works perfect). It has analog inputs: component, scart and VGA; and digital: two HDMI. Is the lowest in the Samsung series: LE37S86BD. It’s a 37″ screen.

So, how does it perform? Analog TV, better of. My antenna is not very good, and I had to make an extension. For company or documentaries is ok. Digital TV, quite better. The TV says that the signal quality is 40%, but I see no decoding errors. It’s a pity there are only 4 channels. I guess I will get ADSL with on-telecoms, for 35€ month I can enjoy good quality in greek channels and two Spanish channels too. (And If I win the lottery I can pay for NOVA satellite TV and get it without installing the dish, via the IPTV box).

Sound. Coca-cola can sound or what do you expect from two 5W speakers. I put my also-cheap-but-better 2.1 speakers in the TV for movies, and problem solved.

Movies and series. The first thing I did was to follow the theory: for a digital tv, a digital cable. So I scratched my pocket for a 30€ DVI to HDMI cable for my mac. Then I discovered that HDMI doesn’t support 1366×768, only the official 720 and 1080 resolutions. At first the mac sent an overscanned image to the TV, and some borders where lost (part of the dock and the menu bar). The other solution was to switch off the overscan and the TV would just put a 720p image in the center leaving borders alone. Also the colors weren’t so real, they some configuration and I wasn’t fully satisfied. I played transformers 72op movie without lights and that drowned my sorrows.

Ok, the problem was the resolution. So I thought that the VGA connection will be able to show all the resolution, even in analog mode, my computer will do the up/downscaling needed and the TV will just show what I want. I took an VGA for 0€ from the trash (yep, in my office they throw them some times for screens that are connected using DVI), and in the very first moment I plugged my mac to the TV using VGA. Voila! real colors. Or at least more real than with the expensive DVI->HDMI adaptor. The quality was so nice that I was browsing the net in the TV: reading the news in 37″ is a pleasure for the eyes :D

About HD movies. I do not have an HD player, neither HD-DVD nor Blue-Ray (I’ll wait until the war is over). So you can imagine the source of those movies ;) . 720p content plays well on my mac using VLC and video encoded using H.264. But 1080p is sluggish because: VLC doesn’t use more than one processor to decode, and it doesn’t use the GPU, although animation movies play nice in 1080p. The solution to this problem is go to windows. Why? Because there is: 1. a software decoder that uses both cores (but it doesn’t give so much quality), or use the Cyberlink H.264 decoder that uses the GPU (graphics card) to decode the video.

I forgot that even if this TV is one of the lowest in the Samsung LCD series. With a good input, it gives you a nice image.

Ahm! the last one: me playing with the toy:

Playing time!

PS: you’re invited for a movie with popcorn in my small dungeon in Athens.


Comments (3) »