Jun 23 2008

How to automatically version a Flex application

Tag: code, pythondenis @ 4:11 pm

I recently added automatic versioning to my Flex projects. This is quite useful when you want to know exactly which version of your application is currently running when it’s being debugged, deployed, tested, etc. This basic example will generate a version string containing a major version number, minor version number, svn revision number and a build number. The build number is incremented every time your application is built. It assumes you have python installed and use SVN as your version control system.

Storing your version information

We will use a simple text file to do that and we’ll call it .version. Its format will be:
major_no
minor_no
build_no
revision_no

Updating the version data

A small python script is used to do that. A build number is incremented each time and the revision number is retrieved from SVN. Here’s the versioner.py script (make sure it’s executable):

#!/usr/bin/python
v = open('.version')
major = int(v.readline().strip() or '2') # can change 2 for any major version number you'd like
minor = int(v.readline().strip() or '5') # idem
build = int(v.readline().strip() or '0') # idem
build += 1
import os, re
ri, ro = os.popen2("svn info", 'r')
rev = ro.read()
ri.close()
ro.close()
revre = re.compile('Revision: ([\d]+)')
revision = revre.search(rev).group(1)
o = open('.version', 'w')
o.write("%d\n%d\n%d\n%s\n" % (major, minor, build, revision))
o.close()

Running the version script

If you’re using Flex Builder, this is easily done:
Go to project properties.
Under the Builders tab, click New
Name it anything you like
Select the versioner.py script in location
Select the folder containing your .version file as the working directory
Check “During manual builds” and “During auto builds” in the Build Options
Once your builder is created, make sure it’s at the top.

Using the version information

You can embed it in your Flex application using the following code:

[Embed(source="../.version",mimeType="application/octet-stream")][Bindable]
 
public var version:Class;

and then you can access it at runtime using a function like this:

public function getVersion():String {var v:Array = String(new version).split('\n');
 
return v[0] + '.' + v[1] + '.' + v[3] + ' build ' + v[2];;
 
}

which will return something like ‘major.minor.revision build’.


Apr 17 2008

django epydocs

Tag: Uncategorizeddenis @ 7:04 pm

I couldn’t find it, so here it is: Django epydocs


Apr 11 2008

top commands

Tag: Uncategorizeddenis @ 12:40 am

2ni:~ denislaprise$ history|awk ‘{a[$2]++} END{for(i in a){printf “%5d\t%s\n”,a[i],i}}’|sort -rn|head
120 cd
97 ls
45 ssh
41 vi
19 svn
13 scp
13 python
12 make
11 find
10 wget

via Tom


Apr 02 2008

downloading google maps tiles using modestmaps

Tag: codedenis @ 1:14 pm

ModestMaps is one the nicest mapping API out there: it just feels right. I especially love the python version, which I used to download some Google Maps tiles (anyone remember gMerge?). The following script gets a Google Maps permalink and downloads the tiles all the way down to the maximum zoom level. You may need to alter the file retrieval and naming logic. The beauty here lies in the fact that ModestMaps allows you to download any layer from many APIs (Google, Virtual Earth, Yahoo Maps and OpenStreetMaps) by changing the Google.AerialProvider() call.

import sys, urllib2, re,os, Image, httplib
 
def parselink(link):
 qs = link[link.index('?')+1:]
 vals = [v.split('=') for v in qs.split('&')]
 params = {}
 for v in vals:
  params[v[0]] = v[1]
 zoom = int(params['z'] or '0')
 center = map(float, params['ll'].split(','))
 span = map(float, params['spn'].split(','))
 ne, sw = list(center), list(center)
 ne[0] += span[0]
 ne[1] += span[1]
 sw[0] -= span[0]
 sw[1] -= span[1]
 return ne, sw, zoom
 
def fetch(pt):
 if pt.zoom > Core.Coordinate.MAX_ZOOM:
  return
 
 if download(pt):
  z = pt.zoomBy(1)
  fetch(z)
  fetch(z.right())
  fetch(z.down())
  fetch(z.down().right())
 
def download(pt):
  url = layer.getTileUrls(pt)[0]
  try:
   os.makedirs("tiles/%d/%d" % (pt.zoom, pt.row))
  except: pass
  fn = "tiles/%d/%d/%d_%d.jpg" % (pt.zoom, pt.row, pt.row, pt.column)
  if os.path.exists(fn):
   try:
    m = Image.open(fn)
    a,b,c,d = m.getbbox()
    return d > 1
   except:
    return False
  print url
  try:
   # should use urllib2 to fake user agent here
   data = urllib.urlopen(url).read()
   out = open(fn, 'w')
   out.write(data)
   out.close()
   return True
  except urllib2.HTTPError, e:
   if e.code == 404:
    #empty tile
    out = Image.new('RGB', (1,1))
    out.save(fn)
    return False
 
  #should not reach this point. add better error handling
  sys.exit(-1)
 
if __name__ == "__main__":
 sys.path.append('trunk/py/')
 from ModestMaps import *
 
 layer = Google.AerialProvider()
 bbox = parselink('http://maps.google.com/maps?f=q&hl=en&geocode=&q=new++york,+ny&ie=UTF8&ll=40.75506,-73.969917&spn=0.100907,0.197926&t=h&z=13&iwloc=addr')
 ne = layer.locationCoordinate(Geo.Location(bbox[0][0], bbox[0][1])).zoomTo(bbox[-1]).container()
 sw = layer.locationCoordinate(Geo.Location(bbox[1][0], bbox[1][1])).zoomTo(bbox[-1]).container()
 cur = ne.copy()
 while cur.row <= sw.row:
   while cur.column >= sw.column:
    fetch(cur.copy())
    cur = cur.left()
   cur.column = ne.column
   cur = cur.down()

Or get the file here


Mar 26 2008

survol du rôle foncier montréalais

Tag: economy, montrealdenis @ 2:39 pm

Voici quelques données extraites du rôle foncier de Montréal*

Valeur moyenne des bâtiments: 232,473$
Valeur moyenne des terrains: 91,696$
Année de construction moyenne: 1962

Les 10 plus gros propriétaires sont:

VILLE DE MONTREAL 2,074,874,601$
LA VILLE DE MONTREAL - SERVICE DE LA GESTION IMMOBILIERE 1,270,319,400$
COMMISSION SCOLAIRE DE MONTREAL 865,440,600$
GOUVERNEMENT FEDERAL MINS DES TRANSPORTS 766,472,200$
SOCIETE IMMOBILIERE DU QUEBEC 565,518,300$
UNIVERSITE DE MONTREAL 554,217,800$
THE ROYAL INSTITUTION FOR THE ADVANCEMENT OF LEARNING 531,381,400$
9145 4090 QUEBEC INC(EMPHYTEOTE) 515,000,000$
COMPAGNIE DES CHEMINS DE FER NATIONAUX DU CANADA 476,320,700$
UNIVERSITE DU QUEBEC A MONTREAL 463,720,200$

Liste des priopriétaires possédant le plus de logements:

OFFICE MUNICIPAL D’HABITATION DE MONTREAL 7,327
IMMOBILIERE SHQ 6,717
SOCIETE D’HABITATION ET DE DEVELOPPEMENTDE MONTREAL 3,578
F D L COMPAGNIE LTEE 2,709
SOCIETE D’HABITATION DU QUEBEC 2,083
IMMOBILIERE SHQ(EMPHYTEOTE) 1,659
GROUPE IMMOBILIER EDDY SAVOIE INC. 1,454
IMMOBILIERE SHQ(SUPERFICIAIRE) 1,449
3630005 CANADA INC 1,357
1541651 ONTARIO INC(EMPHYTEOTE) 1,351

Nombre total de locaux commerciaux: 37,037
Nombre total de logements: 904,583

Et maintenant, la valeur totale de la ville: 137,633,428,804$

* Extrait à partir de 446772 propriétés dans les arrondissements suivants:
Ahuntsic/Cartierville
Anjou
Côte-des-Neiges/Notre-Dame-de-Grâce
L’Île-Bizard/Sainte-Geneviève
LaSalle
Lachine
Mercier/Hochelaga-Maisonneuve
Montréal-Nord
Outremont
Pierrefonds/Roxboro
Plateau Mont-Royal
Rivière-des-Prairies/Pointe-aux-Trembles
Rosemont/Petite-Patrie
Saint-Laurent
Saint-Léonard
Sud-Ouest
Verdun
Ville-Marie
Villeray/Saint-Michel/Parc-Extension


Mar 21 2008

video spam?

Tag: randomdenis @ 2:34 am

I just stumped upon those two links, which I believe are spam:

http://www.howcast.com/videos/1865-How-To-Get-FREE-Online-Video-Advertising-For-Small-Business
http://www.howcast.com/videos/945-How-To-Use-Golf-To-Glean-Moneymaking-Information

The first one looks like it’s good text-to-speech with an animated 3d avatar. The second one tries to looks amateur, but it’s interesting to see how much they seem “genuine”, at least compared to emails we receive each day…


Feb 22 2008

power, cooling and data centers

Tag: economydenis @ 2:35 pm

Essential report to anyone involved in the data center business. The scary facts:

A 1MW Data Center takes 177 Million kWH
– Worth approx $17mil over it’s 10 year life (at .10 cents per kWH)
source: APC-MGE
• By 2008, 50% of today’s Data Centers will have insufficient
power and cooling;
– By 2009, energy costs will become the 2nd highest cost of a Data
Center
source: Gartner
• By 2010, half of all (Enterprise) Data Centers will have to
relocate or outsource applications to another facility.
– During the next 5 years, 90% of all companies will experience some
kind of power disruption. In that same period one in four companies
will experience a significant business disruption
source: Data Center Institute
• Humans created 161 Exabytesof data in 2006.
– Approximately 3 Million times the information in all the books, ever
written
source: IDC

Power and cooling being the key issue here, I can’t understand why there is no booming data centers business in Québec, a province with huge water resources, cheap electricity and fiber availability.


Feb 20 2008

libcurl for your iphone

Tag: iphonedenis @ 2:41 pm

1. get it
2. build it, the light way:
./configure –prefix=/usr/local/iphone –host=arm-apple-darwin –disable-shared –disable-crypto-auth –without-gnutls –without-ssl –without-zlib –without-libssh2 –disable-ipv6 –disable-manual –disable-telnet –disable-tftp –disable-ldap –disable-file –disable-ftp
3. fix it:
in lib/config.h:
uncomment #undef HAVE_GLIBC_STRERROR_R
uncomment #undef HAVE_POSIX_STRERROR_R
comment #define HAVE_STRERROR_R 1
4. make it:
make && sudo make install
5. enjoy it.


Feb 06 2008

encore de la p0rn foncière

Tag: Uncategorizeddenis @ 1:01 am

alors, dans le même ordre d’idée que précédemment:

âge moyen des bâtisses: 1967.

le compte de taxe moyen en 2007: 4665$.

hausse moyenne des taxes de 2006 à 2007: 346.57$. ceci correspond à une hausse moyenne de 4.519%.

il y a 200365 logements et 16389 commerces à Québec. c’est en moyenne 1.96 logements par propriété à logement.

le plus grand terrain est l’aéroport, avec une superficie de plus de 5 millions de m2!

semble-t-il que l’université laval vaut plus cher que Les Galeries de la Capitale, avec une valeur totale dépassant le demi-milliard ( 530 887 000$ ).

la valeur des établissements religieux s’élève à 142 603 800$.

les hôpitaux? 586 191 000$

et pour terminer, la question qui me hante depuis le début: combien vaut Québec?
35.15 milliards (35 151 335 472$). c’est ~10 milliards de moins que ce que microsoft est prêt à payer pour yahoo. eh oui, 400 ans de dur labeur pour en arriver là.


Feb 04 2008

quelques statistiques sur les rôles fonciers de la ville de Québec

Tag: Uncategorizeddenis @ 1:37 am

Voici quelques faits tirés du registre foncier de la ville de Québec*:

Quel est le plus vieux bâtiment?
2 bâtiments partagent ce titre:

48 à 50, Côte du Palais, date de 1604.
34, Rue du Petit-Champlain, date de 1604.

Quel est le bâtiment avec la plus haute évaluation foncière?
Les Galeries de la Capitale, avec une valeur totale de 320 millions $. Ceci en fait aussi le plus gros payeur de taxes (théoriquement?), soit 11617600$ en 2007 (pour le centre commercial seulement).

Valeur moyenne des terrains: 54 645$

Valeur moyenne des bâtiments: 176 852$

Qui a le plus de logements?

Propriétaire Nb logements
SOCIÉTÉ IMMOBILIÈRE DU QUÉBEC 4039
CAPREIT APARTMENTS INC. 1905
OFFICE MUNICIPAL D’HABITATION DE QUÉBEC 1653
LA CORPORATION HEADWAY LTÉE 1080
GESTION LABERGE INC. 1071
FIDUCIE BOARDWALK QUÉBEC 1 965
LA SOCIÉTÉ MUNICIPALE D’HABITATION CHAMPLAIN 953
SAMUEL HOLLAND HOLDINGS COMPANY 811
LABERGE, LAURENT 754
LABERGE, MAURICE 749

Qui possède le plus de bâtiments?

Propriétaire Nb bâtiments
SOCIÉTÉ IMMOBILIÈRE DU QUÉBEC 112
GAGNON, ANDRÉ 75
FONDS DE PLACEMENT IMMOBILIER COMINAR 64
TREMBLAY, MICHEL 54
GAGNON, MICHEL 47
GRENIER, RAYNALD 42
CÔTÉ, ANDRÉ 41
BÉDARD, MICHEL 41
CÔTÉ, PIERRE 40
ROY, ANDRÉ 38

Propriétaires ayant la plus forte valeur foncière totale:

Propriétaire Valeur
LES GALERIES DE LA CAPITALE HOLDINGS INC. 359825000
OMERS REALTY CORPORATION 328012000
IVANHOÉ INC. 315752000
SOCIÉTÉ IMMOBILIÈRE DU QUÉBEC 221551600
FONDS DE PLACEMENT IMMOBILIER COMINAR 206294800
IVANHOÉ STE-FOY INC. 167000000
FIDUCIE DE FONDS DE PLACEMENTIMMOBILIER COMINAR 161240000
2000942 ONTARIO INC. 118000000
2000943 ONTARIO INC. 118000000
CAPREIT APARTMENTS INC. 104838000

* Données non-officielles, ne comprenant que les propriétés taxables, donc à prendre avec un grain de sel. Seulement les arrondissements suivants sont inclus:

L’Ancienne-Lorette
Laurentien
La Haute-Saint-Charles
Beauport
Saint-Augustin-de-Desmaures
Les Rivières
La Cité
Sainte-Foy-Sillery
Limoilou


Next Page »