mardi 18 juin 2013

Category tree, left node, right node.


Given a Category lambda, left node, right node., I want to know the parent node.

"""
node* get_parent(node* N)
{
    //define parent of nullptr to be nullptr
    if (!N)
        return nullptr;
    while (true)
    {
        if (N->left)
        {
            //N->left is either the previous sibling or the parent
            if (N->left->child == N) //N->left is the parent
                return N->left;
            else //N->left is the previous sibling
                N = N->left;
        }
        else //a node with left==nullptr is the root, so its parent is nullptr
        {
            return nullptr;
        }
    }
}
"""

samedi 15 juin 2013

Financisto Cash Management Software port to Google Map API V2

  • How to display my location on Google Maps for Android API v2 ?
  • How to directly move camera to current location in Google Maps Android API v2 ?
  • How to reverse Geocode in Google Maps API 2 Android ?

Google Maps Android API v1 VS Google Maps Android API v2

When you browse the web looking for solution you will find a lot of reference to the V1 but any new key delivered by the Google API Console will not work and you'll get:

  • get android google maps Service unavailable (code=1), 
  • Google Maps Android API v2 crashes with NoClassDefFound Error
  • Couldn't get connection factory client

Remember not not mix the both  imports for example GeoPoint vs LatLng !

The Google API Console deliver keys only working for V2

You 'll need two keys:

  1. one signed with the debug key (under eclipse do Window > Preference > Android > Build)
  2. one signed with the certificate you sign the app for example on of the best finance software of the Play Store. - replace with your , the one you use for sign and secure your app under Play.
With the SHA1 footprint generate two api key with the  Google API Console .
  1. Service > Google Maps Android API v2 > On
  2. Api Access >  Simple API Access > Create new Android key ...

Automatically geotagged transaction, building the project

As described Here:

  1. Select File > Import > Android > Existing Android Code Into Workspace and click Next.
  2. Select Browse..., enter /extras/google/google_play_services/libproject/google-play-services_lib, and click Finish.

Alternatively in order to compile I had to double check that android-support-v4.jar is in financisto/libs/.

And check this is checked in Project > Properties > Android. - in the bottom section library -

The sources are here : Read the source Luke

Backed with a strong privacy,  Flowzr is the best Financial Software of the Play Store!
Suited for Personal and small business. It doesn't send you this mail: 2 days left - Exclusive offer - Save 20% on Mvelopes Annual Membership or that one this is an automated email from LessAccounting.com Money Snapshot In the past 7 days $0.00 Income $0.00 Expenses $0.00 Net Profit!

mercredi 16 février 2011

Dell PowerEdge 2950 and Debian GNU/Linux 2.6.32 from Squeeze

The current stable distribution of Debian GNU/Linux version 6.0.0, codenamed squeeze is wrongly reported as without the support of the Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet on Dell PowerEdge 2950.

It is possible to load non-free firmware from official repository and make the Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet works.

It is necessary to activate the non-free repository or as you don't have network yet to use a usb stick or a cdrom:

From http://ftp.fr.debian.org/debian/pool/non-free/f/firmware-nonfree/ grab :
- http://ftp.fr.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-bnx2_0.28_all.deb
- http://ftp.fr.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-bnx2x_0.28_all.deb
- http://ftp.fr.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-linux-nonfree_0.28_all.deb

- http://ftp.fr.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-linux_0.28_all.deb

And then install them using dpkg -i in that order. After a reboot the network card can be found with the bnx2i directory as shown with dmesg :


[ 28.794064] bnx2 0000:07:00.0: irq 33 for MSI/MSI-X
[ 28.908007] bnx2: eth0: using MSI
[ 28.908209] ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 30.619141] bnx2: eth0 NIC Copper Link is Up, 100 Mbps full duplex, receive & transmit flow control ON
[ 30.619320] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[



CD-Roms and Usb sticks can be found under sdX and srX in the dev directory so survivals commands are :

source /etc/bash_completion
mkdir /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
cd /mnt/cdrom
dpkg -i ./firmware-bnx2_0.28_all.deb ./firmware-bnx2x_0.28_all.deb ./firmware-linux-nonfree_0.28_all.deb ./firmware-linux_0.28_all.deb
modprobe bnx2i
dmesg
reboot


Happy install !

jeudi 14 octobre 2010

.:: Managerial Finance Software :: Artwork ::.

Visit Flowzr finance software homepage for more information. Flowzr is an intuitive, full-featured finance software that helps you monitor account balances at a glance. It deals with account payable, account receivable, VAT, can also be used to store accounting documents (invoices, receipts, …). Flowzr help you keep an enlightened vision of your finances so you can concentrate on yout real job.








lundi 20 septembre 2010

FLOWZR is the new brand name for project codename Crebits-AAA

FLOWZR deals with bookeeping, accounting (pro-active), managerial finances.

FLOWZR is the new brand name for project codename Crebits-AAA wich is now the property of Direct Raise Sarl. I'm no longer active on the project  Crebits-AAA even if I participated in the intial stage of it's development.

I think it is a very promising software in particular with :
-the ability to attach document such as receipts, bills, invoices with unlimited archive and datastorage.
-the ability to publish receipts and invoices using Google Docs as templates
-the many possible uses in communication, accounting certification, placing,  and death-warrant.
-the power, the possibilities and the warranty offered by the underlying infrastructure (it's pure cloud computing).

More information on FLOWZR's blog

Stay in touch.

About FLOWZR :
FLOWZR is a managerial finance software. It can keep track of your debits and credits. from various kinds of accounts such as bank accounts, cash accounts.

About Direct Raise Ltd. :
Direct Raise Ltd. is a company based in the Kingdom of Morocco which provide long-term process  for companies with strong potential. 

dimanche 22 août 2010

Preview version of Flowzr is available.

Scheduled release of Crebits-AAA is set to September, 21 2010.
This release will be a complete functional version of the finance management software.
Actually I use it to  track expenses and invoices for two different companies in two currencies.
It graphs balances but also debits and credits, by account or by category.
I use it to put watches on scheduled expenses and to anticipate my balances.
It is also useful for tracking allowances I made, by the way preparing the payroll.
Many other usage are possible starting from managing allowance to distributed cash-close or micro-credit industries. 
My bookkeeper is also using it to collect missing informations about transactions I made.
The business model have been set :
" We don't like advertisement.
   We don't believe in setting limits.
   So the 4$US pay-as-you-go subscription includes all features, upgrades and support."
More features information there:  finance, money, check-book, finance,  management software.

dimanche 15 août 2010

Internationalization and Localization under Google App Engine framework

I was thinking about for one or two year before. One month ago I started to code for a new web application. That project have to be available for the biggest number of users. So it have to be in the most scalable architecture. And it have to a got a good internationalization framework (i18n).

So I had to make Locales works (specially date formats), and efficient translation (gettext) works under google app engine.
So in a few word our problematic is how to make efficient localization and internationalization under state of the art MVC framework using python language.
Language ares evolving and each time I code something like the code below I ask me if I am doing the right way :
def dateToLocalizedString(pDt,strFormat):
  return {
  'Y-m-d': str(pDt.year) + '-'  + str(pDt.month) + '/' + str(pDt.day),
  'd/m/Y': str(pDt.day) + '/'  + str(pDt.month) + '/' + str(pDt.year),
  'm/d/Y': str(pDt.month) + '/'  + str(pDt.day) + '/' + str(pDt.year)
}.get(strFormat) 

Topic #1 making i18n works

Google app engine offers to work on an customized version of the Django framework wich is able to handle effective i18n,as described here . Others frameworks exists that can run under Google app engine and do the same :
<title>{% trans "This is the title." %}</title>
I didn't tried to make the upper code work. Also as Google says, "apps must load quickly order to scale in the cloud". That should always have been the case.

While learning app engine technology I rapidly heard that my views in the software have to load quickly. I didn't tried but I guess that it is "CPU costing", possibly in the exact term as far as Google will charge me for CPU usage.
Generate once, runs in every language code ! So I had to use gettext to generate my Django templates. man xgettext told me :
Choice of input file language:
-L, --language=NAME
recognise the specified language (C, C++, ObjectiveC, PO, Shell,
Python,   Lisp,  EmacsLisp,  librep,  Scheme,  Smalltalk,  Java,
JavaProperties,  C#,  awk,  YCP,  Tcl,  Perl,  PHP,  GCC-source,
NXStringTable, RST, Glade)
My goal was to use gettext to generate sort of HTML.
I search the web for project facing the same issue but I didn't found something that correspond to my needs. For reference I'll mention xml2po.py and gnunited .
I found an interresting article about using gettext to generate static files, that put me on the way...

The key idea is to use PHP to generate the Python's templates offline.

An empiric situation suggested me to generate Django templates (HTML-like) and insert PHP code in their. I used a PHP loop (undisclosed) on the development size to generate templates for each languages once and not at each load.

PHP: about 7,670,000,000 results
Python: about 32,100,000 results

Python is the language that let me wrote my cleanest coding for web application. I suggest to use PHP for offline generation of template. Django templates will look like this :
<b><?php echo _("Welcome"); ?> {{user.email}}</b>

|<a href=?action=index><?php echo _("Home"); ?></a>
|<a href={{user.logout_url}}><?php echo _("Sign out"); ?></a>

Templates are generated in different directories and called like this :
payload = dict(user=main.user,etcs=etcs)
template_file = os.path.join(os.path.dirname(__file__),
'../tpl/' + main.user.defaultLang +'/tpl.html')
main.response.out.write(template.render(template_file, payload))
Note that main is called from myApp.py as described in app.yaml and in my case main.user is a model in the datastore terms.

Topic #2 Formating date format

To make the app engine work I did like described by Yu-Jie Lin (livibetter) in it's tutorial Using Django's I18N in Google App Engine.
We use the Django templates to do the work, using the |date argument in Django template, then the Google app engine framework will do the rest as based on version 0.96 of Django that can handle this.
Using the |date argument in Django template, like this :
<input type="text" id="sampleDate"
name="sampleDate" value="{{myobject.sampleDate|date}}" size="9">
To make the app engine work I did like described by Yu-Jie Lin (livibetter) at in it's (very good) tutorial Using Django's I18N in Google App Engine. Our main.py or whatever I have referenced in app.yaml looks like this :
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myApp.settings'
from django.conf import settings

# Force Django to reload settings
settings._target = None
from google.appengine.ext import webapp
from django.utils import translation
from crebits.util import Cookies
#There where other imports cutted for sample .

class MainPage(webapp.RequestHandler):
#MEMCACHABLE
def get_myAppUser(self):
  #So you can edit only logged users.
  user = users.get_current_user()
  if user:
    query = db.GqlQuery("SELECT * FROM myAppUser where email=:1",
                        user.email())
  myAppUsers=query.fetch(1)
  user_exist=False
  for myAppUser in myAppUsers:
    myAppUser.defaultJsDateFormat=myAppUser
                      .gotHookToHandleJSFormat()
    user_exist=True
    if user_exist !=True:
      myAppUser=models.myAppUser()
    myAppUser.email=user.email()
    myAppUser.defaultCurrency="USD"
    myAppUser.defaultDateFormat="m/d/y"
    myAppUser.put()
  return myAppUser

def initialize(self, request, response):
  self.user = self.get_myAppUser()
  if self.user:
     self.user.logout_url = users.create_logout_url("/")
  self.request=request
  self.response=response
  request.COOKIES = Cookies(self)
  request.META = os.environ
  self.reset_language(request, response)
  webapp.RequestHandler.initialize(self, request, response)

def reset_language(self, request, response):
 language = translation.get_language_from_request(request)
 if self.user.defaultCutOff==None:
   self.user.defaultLang=language
 translation.activate(language)
 request.LANGUAGE_CODE = translation.get_language()
 settings.DATE_FORMAT=self.user.defaultDateFormat
 # Set headers in response
 response.headers['Content-Language'] = translation.get_language()
 translation.deactivate()

#-------------------
# Main post handler
#-------------------
def post(self):
  user = users.get_current_user()
  if user:
    (user.email(), users.create_logout_url("/")))
#---------------------------------------------------------------
# Main authentified controler switch action param (post method)
#---------------------------------------------------------------
   {
   'index': views.index,
   'index2': views.index2
   }.get(self.request.get('action'),views.index)(self)
 else:
   self.redirect(users.create_login_url(self.request.uri))

application = webapp.WSGIApplication([
('/.*', MainPage)

],
debug=True)
def main():
run_wsgi_app(application)

if __name__ == "__main__":
main()

Conclusion

I dont think it's a new idea as far as you can see things like this with in many softwares open source projects, that templates templates such as torque for example. But I think it's the less CPU costing and also the easiest way to make i18n under the app engine.
It is possible that, as some loading of the Django i18n framework is made for the date localization part of the problematic is dooming the expected gain while generating internationalized offline.
Please tell me throught comments.
Best Regards.

Additional references: Entropy (provide php-cli with gettext support on MacOSX) , gettext tutorial, gettext manual .