RSS

Tag Archives: django

In defense of dynamic languages

There are a good many truths and there are a better set of likelihoods. Given the current state of dynamic languages today they are less performance than static and functional languages, however, it is also true that dynamic languages are more productive than static and functional languages. (I am not talking about savants)

Don’t optimize your code at the first stage. First make it right, then (if necessary) make it fast (while keeping it right). –erlang programming rules

It is likely that regardless of the size of your project, the size or makeup of your team, or the breakthrough that you think the project represents… that your project is going to have average results at best. The Google’s, FaceBooks and Twitters of the world are extreme edge cases. As proof, look at the iPhone app store. There are over 600,000 apps and only a very small fraction of those apps have the following that Angry Birds does.

So before you go off in a corner reinventing the wheel in your favorite language consider this. WHat is going to be your return on investment? I cannot blame you for learning a new language or tool that would enhance your marketability or even just for hobby sake. But if your intent is to make some money and maybe a little independence they you really need to consider your ROI. And if you’re making money then rewriting your killer app in whatever killer fast programming language is available (and popular) will make make plenty of sense.

This is why I’m hot on python and python’s django, tornadoweb, flask; perl and perl’s mojolicious; ruby and ruby’s sinatra and rails; redis, sqlite, zeromq.

PS: While I’m not a fan of erlang, partly because of what it represents, I really like it’s Programming Rules and Conventions(PRC). By comparison python’s PEP-8 is amateurish. The PRC starts off with ideas like the one quoted above and giving you ideas on how best to approach the problem. This is like python’s PEP-20 but again it’s like signing your name with a crayon instead of a fountain pen.

 
Leave a comment

Posted by on 2012/05/03 in architecture, ProgLang

 

Tags: , , , , , , , , , , , ,

Where is Google now?

Over the past few days there have been press reports that Google was deprecating some of it tools as evidenced by google’s own project pages (link1, link2) What has me concerned about this policy is that I might have an idea for the next great webapp or I might have a client using some critical tools that Google is deprecating… now what?

Being an observer it’s too difficult to know what projects are in or out. It’s probably safe to say that GMail and Google Apps are in. While GMail is a free and there is a free version of Google Apps; there is a commercial component here too. But what about AppEngine? Well, there seems to be an ecosystem here and they just released GO v1 for AppEngine. But while this is fun and interesting for geeks and internal Googlers what does it mean for external businesses?

I think that Google is a riskier play than say deploying on a virtual or dedicated host or even another cloud vendor. And until someone can corner Google management with a commitment it might be better to pass on AppEngine for now.

That said, the platform development strategy going forward will be either be Java or Python (probably Python) making certain that the code is compartmentalized into libraries that will work on either platform… giving the client flexibility. The good news is that Django also works in both spaces.

 
Leave a comment

Posted by on 2012/04/25 in architecture

 

Tags: , , ,

Django project folder format

It seems that the Django has changed the project directory structure with version 1.4. This stackoverflow post does a good job describing the new layout. I’m in the process of refactoring an asterisk dashboard so that it’s multi-tenant and runs from a single server instead of one per tenant. This is just the first stop.

 
Leave a comment

Posted by on 2012/04/24 in architecture, web

 

Tags:

Your Next Web Application Framework?

Suppose you are the person who has to make the decision as to what language and framework your startup is going to use to deploy it’s application.  What would you choose? There are so many interesting and qualified frameworks that are already powering a good portion of the internet.

(You don’t have to know the language and framework but enough to argue what makes it idea.)

What would it be?

For example: I read an article several years ago that strongly recommended Erlang. At the time it was a great idea. The author suggested that using Erlang would attract smart people and keep the actual number of respondents to something manageable. Since then I implemented several applications that in hindsight: (a) impossible to attract new talent. (b) the more time that passes the more fragile the app gets because my detail recollection is fading (c) and it lacks common tools that would make allow generalized apps to give access to “operators” instead of programmers.

Other examples include: perl, ruby, python… mojolicious, rails and sinatra, flask, tornadoweb, and django.

I have my ideas… what are yours?

 
Leave a comment

Posted by on 2012/04/12 in architecture, future, web

 

Tags: , , , , , , , , , , ,

CRUD-fest : grails, rails, django shootout

The mission is to deploy a CRUD implementation in all three frameworks by reverse engineering my schema from an existing Postgres Database which I will construct with raw SQL. Later I would like to add some data to the tables so let’s see how it handles some ETL (export transform load) in the form of a CSV file into some REST calls that I’d implement or some other type of messaging.

What I did not do! I think O’Reilly has the most comprehensive map of the history of all computer programming languages, however, GitHub has a list of languages that would seem to be current or relevant. Granted that some of this, to be effective, would mean investigating popular frameworks within the domain of languages. Well of that semi-complete list from GitHub I picked out this set: php, go, lua, haskell, erlang, scala, clojure, perl, javascript, rhino, nodejs, iOS, Objective-C, C++, C, Pascal, Pro-SQL, CoffeeScript, OCaml, Scheme, tcl, Smalltalk, Visual Basic. I think they are the most relevant. As it goes, however, either they do not reverse engineer schema from a PG (postgres) connection like most ORMs, or they do not have web or other application frameworks in order for a user to interact with the data, and many do not have IDEs or version managers they way that Ruby and Python do. (I cover the IDE topic later.) I think I picked the sweetspot of frameworks to test and skipped the ones that would distract me from the task.

Code Wars: PHP vs Ruby vs Python – Who Reigns Supreme [Infographic]

Let’s start with the schema design. The actual SQL is here. The “message” represents an ISO8583 message. You can follow the link to read more about the message. What’s important to know is that it represents the standard message used between certified credit card acquirers and their associations like Visa, MasterCard, Amex, Discover and many others.  It also represents the message used between the associations and their issuing processors. The message format is also reused by many POS terminal software vendors as well as gateway and technical acquirers/processors. Each association has slightly different implementations depending on their specific needs, however, most of the fields have common names and usage.

When building an endpoint or a gateway or any point in between there is a need to support ISO8583 and a bigger need to test the endpoint. As part of the testing phase it’s important to build a test harness that can generate the necessary test transactions. Depending the application’s position in the network it will have different testing needs. One thing for certain is that the messages and their contents need to be modeled, testable and repeatable. One huge challenge is TDD (test driven development) and another is simple regression testing. It’s my personal belief that a well defined toolset could be deployed in such a way that vendors across the board could contribute data a code for regression testing thus reducing the load on everyone. PS: while this mission is ISO8583 there is no reason why a request/response transaction could not be JSON, XML or S-exp; it’s a general enough schema.

  • TABLE: message_field_dictionary – this is a list of the field names and their formats. Nothing else.
    • FIELD: id (PK)
    • FIELD: field_id (FK)
    • FIELD: field_name
    • FIELD: field_description
    • FIELD: field_format (i.e.; ‘YYYYMMDD’)
    • FIELD: data_types (a, an, ans)
    • FIELD: default_values (i.e.; ’1′, ’2′, ’3′, ‘abc’…)
  • TABLE: message_request – this is the set of fields used in a particular request transaction. It is also possible that this represents the incoming request pattern. If the pattern does not match then that’s separate issue.
    • FIELD: id (PK)
    • FIELD: test_case_id (FK)
    • FIELD: field_id
    • FIELD: request_type
    • FIELD: field_value
  • TABLE: message_response – this is a set of fields in the response generated from the response. This might also represent a response message based on the incoming request pattern.
    • FIELD: id (PK)
    • FIELD: test_case_id (FK)
    • FIELD: field_id
    • FIELD: response_type (i.e.; absent, required, optional, conditional)
    • FIELD: field_value (i.e.; a value, regex, or a combination set, private function or other field_id)
  • TABLE: message_test_cases
    • FIELD: id (PK)
    • FIELD: test_case_id (FK)
    • FIELD: short_name (FK)
    • FIELD: description
    • FIELD: expected_results
    • FIELD: elapsed_ceiling
    • FIELD: is_active
    • FIELD: group_name
    • FIELD: sub_group_name
  • TABLE: message_test_results
    • FIELD: id (PK)
    • FIELD: test_case_id
    • FIELD: started
    • FIELD: finished
    • FIELD: elapsed_time
    • FIELD: results
    • FIELD: request
    • FIELD: response
    • FIELD: errors
    • FIELD: trace
  • TABLE: test_cards – I decided to put the test cards in a separate table because if contributors provided test transactions the actual card numbers and magstripes would be considered confidential data… and the associations do not want anyone recording that info with one possible exception.
    • FIELD: id – (PK)
    • FIELD: card_number (FK)
    • FIELD: serial_number (FK)
    • FIELD: expiration_date
    • FIELD: issue_date
    • FIELD: street
    • FIELD: zipcode
    • FIELD: pin
    • FIELD: atm_pin
    • FIELD: CVV
    • FIELD: CVV2
    • FIELD: track1
    • FIELD: track2
    • FIELD: track3
    • FIELD: reset_balance
    • FIELD: is_decrement
    • FIELD: actual_balance
    • FIELD: open_to_buy

The schema is self explanatory. I did not create any real indexes. I’m not certain (right now) whether I’m going to create any FKs or referential integrity. It depends on how much reverse engineering the different frameworks are going to execute. One thing for sure, this is not intended to be a lesson in DB design. Maybe another time. FKs might be required in order for the reverse engineering to work properly. Specially if I use tables to populate pulldowns and select lists.

The IDE I decided to use was RubyMine, PyCharm and IntelliJ. It is purely by coincidence that I decided to use this family of IDE from jetbrains. (for the record I’m currently using the demo version. I’m hoping that the licenses do not expire before I finish this article… this paragraph was written before coding began). What makes them interesting is that they support Django, Rails and Grails out of the box. After agonizing over it IntelliJ was the only reason why I included Grails. Java does not have a version manager like Ruby or Python, however, you can get there by collecting your jar files in a single folder alongside the JDK you’re using. And since many binary distributions of the JDK are in version folders it makes resetting the CLASSPATH and PATH easier… but still more manual than the ruby and python versions.

RubyMine heads up. When I originally installed RubyMine I had not installed RVM. I found a post from the folks at JetBrains about version 2.0.2 where they probably added RVM support. Anyway they said it just worked. That after a restart RubyMine would give you access to your tools. That was not the case. I had to take one extra step. I had to go into the preferences and navigate through the “Ruby and SDK” page. I also navigated through the gem sets for good measure. Now when I created my project I had access to my Rails version; previously unknown. I had a similar problem with PyCharm and it’s support for VirtualEnv but I will have to verify it with Django. (Shame on me. My desktop virtualenv did not have django installed. I will likely have to do a complete install based on my notes which were originally installed on my virtual machine and not my desktop).

Getting Started

Now that I’ve managed to crawl through the minutia of project preparation it’s time to start putting the project together. So Now that I have installed IntelliJ, PyCharm and RubyMine I have to create my project. I’m calling the project crud_fest_rb, crud_fest_py, and crud_fest_j.

Creating an empty rails and an empty django project was pretty simple. Specially after all the setup I’ve done in preparation. The one observation I’ll make is that there are a lot more artifacts in an empty rails project than there are in a similar django project. The Grails project has a lot more artifacts than that and since there is a compilation step it takes a lot longer to get started. One thing that bugs me about IntelliJ is that it starts the browser to a default page once it’s ready to run.

This project was not meant to be a JetBrains tutorial, however, I’ll mention a few more things. Rails started right away. Django required the user to enable the admin function, update the settings file to point to the proper DB, and then you had to manually execute the ‘manage.py syncdb’ command in order to create a default admin  user. This step will be required later in order to sync the db schema to the model. Rails and Grails are still under investigation.

One nice thing about the Rails and Django projects is that they respect SQLite3. Not that Grails goes out of it’s way to reject SQLite3 but the support is hard to come by. This means that when I put my SQL together it will need to support but SQLite3 and H2. Which will probably work but what a pain. I suppose I could use Postgres but there is nothing easier than a ‘cp’ command to reset the DB to it’s default. And if this project is successful then copying the output table to the target application means that that the SQLite DB file is now the config file.

The Schema

I have created the SQL. I was not going to embed the code directly but the Gist is here. It’s only six small tables and the foreign keys are few. There are a few constraints which should be removed when the constraints are fully represented in code instead of schema. (Keep in mind that when calculating performance things like O(log<n>) no longer makes sense when there are cascading reads based on constraints. And frankly it does not make any sense to have the constraint modeled in code and SQL at the same time.)

Import the Schema

… into the project is the next step.

Django

PyCharm could execute the following commands but currently it feels better to execute them manually from the command line.

The first step is making sure that the DBs are configured properly in the settings.py file. In a recent version of Django the developers made it possible and easy to support multiple and different databases simultaneously. That means I could connect to one DB for one set of actions and another DB for a different set. There are plenty of interesting use-cases here. So let’s configure the DB:

DATABASES = {
 'default': {
     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
     'NAME': '/tmp/crud_fest.db', # Or path to database file if using sqlite3.
     'USER': '', # Not used with sqlite3.
     'PASSWORD': '', # Not used with sqlite3.
     'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
     'PORT': '', # Set to empty string for default. Not used with sqlite3.
 },
 'messages': {
     'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
     'NAME': '/tmp/crud_fest_py.db', # Or path to database file if using sqlite3.
     'USER': '', # Not used with sqlite3.
     'PASSWORD': '', # Not used with sqlite3.
     'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
     'PORT': '', # Set to empty string for default. Not used with sqlite3.
 }
}

(The indenting is not exact here but that’s a WordPress thing)

The second step is to make certain that the admin functionality that we previous enabled (and now stored in the default database: crud_fest.db) has been sync’d properly. (you’ll need to answer some questions about the admin user including the username and password.)

/Users/rbucker/git/flafreeit/crud_fest_py/manage.py syncdb

Now that the admin tables have been created, you’ll need to create the actual crud_fest_py tables.

cd ${HOME}/git/flafreeit/crud_fest_db
sqlite3 /tmp/crud_fest_py.db <./setup.sql

And then the last step is to dump or reverse engineer the table(s) into a models.py file.

/Users/rbucker/git/flafreeit/crud_fest_py/manage.py inspectdb > /Users/rbucker/git/flafreeit/crud_fest_py/test_config/models.py

Looking at the models.py file you’ll see something like (looks like I have some trimming to do; the admin tables were included):

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.
from django.db import models
class MessageFieldDictionary(models.Model):
    id = models.IntegerField(null=True, primary_key=True, blank=True)
    field_id = models.IntegerField(unique=True, null=True, blank=True)
    field_name = models.CharField(unique=True, max_length=25, blank=True)
    field_description = models.TextField(blank=True)
    field_format = models.CharField(max_length=200, blank=True)
    data_types = models.CharField(max_length=200, blank=True)
    default_values = models.CharField(max_length=200, blank=True)
    class Meta:
        db_table = u'message_field_dictionary'

This is just a sample of the tables that inspectdb generated… because there is one final step. Now that we have a models.py file with the individual schema we need to tell Django about the tables and the individual fields that need to be editable. There are some shortcuts; the online docs are really good. So we are going to create an admin.py file like this.

from django.contrib import admin
from myproject.myapp.models import MessageFieldDictionary

class MessageFieldDictionaryAdmin(admin.ModelAdmin):
    pass
admin.site.register(MessageFieldDictionary, MessageFieldDictionaryAdmin)

Once this last step is completed then you need to launch the django server and navigate to the admin site with your favorite browser. All of your tables should be there. You might still need to customize the widgets but this is the place where we stop.

One Final note. Sadly my decision to use SQLite means that I might have to do all of this all over again. It seems that the foreign keys have not been incorporated into the results of the ‘inspectdb’ command. There is a pragme in SQLite that enables FKs but it has to be compiled in beforehand. There was also at least one multi field constraint that does not appear.

But this is a good place to stop for now.

Rails

The first thing I noticed is that there is no code in Rails for reverse engineering a legacy database the way that Django does. So I had to install a missing gem.

gem install rmre

Then I had to reverse engineer my DB.

cd ${HOME}/git/flafreeit/crud_fest_rb
rmre -d /tmp/crud_fest_py.db -o ./app/models/

After the command completed I was returned to the command line. There were no error messages so I assume that it completed OK. I looked in the ./app/models/ directory and noticed that there were a handful of new files. These files were 1:1 with the table names. Here’s an example:

class MessageFieldDictionary < ActiveRecord::Base
    set_table_name 'message_field_dictionary'
end

This is a little hinky because none of the field names or types have been included. After doing some searching I found that this is OK and that ActiveRecord will fill in the blanks. I don’t know if I buy that. I like that Django fills in the holes and this sparse programming … *sigh*.

There is another command that is interesting:

rake db:schema:dump

This will dump the schema into a file db/schema.rb. It represents the complete schema. I suppose that this code could be copied to the model files. But for the moment this is not required… I think the db:migrate command will regenerate this db/schema.rb file when it completes.

Another caveat here is that it is possible to have multiple databases configured in the database.yml file. The difference, however, is that ActiveRecord needs to know which database goes with which definition. So there is some manual work to be done here. There are some simple google searches you can execute and most of them make perfect sense. It’s a little beyond the scope here even though I described the python version.

Grails

Grails supports multiple databases in it’s DataSource.groovy file. Since I’m working with Grails 2.0.0 there is a possibility that the latest Hibernate is included. Hibernate is the ORM that Grails uses to communicate with the DB. But the tool for reverse engineering needs to be installed.

cd ${HOME}/git/flafreeit/crud_fest_j
grails install-plugin db-reverse-engineer

The output was pretty simple.

rbucker@rmac[crud_fest_j]$ grails install-plugin db-reverse-engineer
| Plugin installed.

… but I have no idea which version was installed. So we move forward for the moment. The next step is to locate the h2 command line version.

java -cp ${HOME}/lib/grails-2.0.0/lib/com.h2database/h2/jars/h2-1.2.147.jar org.h2.tools.Shell

You’ll need to answer a few default questions. You can accept the default values for the moment.

Now that H2 is running and pointing to the same repository as the DataSource.groovy, now we need to run the SQL to create the database tables as we did previously. (I had to make some changes to the code because there are some differences with H2.

Now we try to do the reverse engineering…. actually, it’s not going to happen. I’m going to leave this up to the reader to complete. And if anyone wants to contribute, please, by all means. For the moment This is the end of the road for this project.

Conclusion

It is safe to say that I’m done with this project. While it seems plausible that I could reverse engineer a database using the Grails Plugin – the amount of configuration required just amazes me. Spring is heavily dependent on XML config files and it appears that Grails uses some of each. One thing for certain is that Java has these huge namespaces everywhere so just the slights config requirement for reverse engineering is so incredibly painful. I’m really surprised that the Grails guys did not do more Groovy scripting for this sort of thing.

Ruby/Rails on the other hand still required an outside GEM in order to perform the reverse engineering. I’m surprised that with Rails3 and 3.2 that they never addressed the issue directly. And not to mention that the resulting models were still sparsely emitted.

Finally, Django seems to have gotten it right. It emits the code in it’s entirety. Getting to the CRUD is a simple matter of some manual labor which the user could script easy enough. My vote is going to Python as the all around winner and Ruby a close second. The Java code is on hold, maybe we can call this a “did not finish”. The overall performance of the dependencies and the compile step make it a less valuable experience.And let’s not forget the JDK version madness.

So for the time being I’m inclined to purchase a license for PyCharm and RubyMine just because this is where I’m going to be spending my time for a little while… and it’s my money.

 
 

Tags: , , , , , ,

My New Python Project Setup

[update 2012-01-18] postgres has been updated to 9.1.2; the latest version as of today.

[update 2012-01-17] feel free to ignore my comments about Lua. While Lua might sit in an interesting place between Python and Java in an embedded/scripting place. The fact that lunatic-python does not compile and lupa depends on LuaJIT2 which is compatible with Lua 5.1 and the current Lua version 5.2 was recently released… and the comment from the LuaJIT team about adoption was a little snarky. I gotta think about something else.

[update 2011-12-29] I forgot to add twitter’s bootstrap CSS/JS. I’ll cover that in a future post when I also discuss modern-package-template

It’s pretty simple to set things up. There are some prerequisites and some basic install packages that need root access but the intent is to get the config in userspace as soon as possible. This article covers VM slices at Rackspace using Ubuntu 11.10.

First: Install and update:

  • allocate the OS
  • select the OS and wait for it to complete.  You’re going to receive an email with the root password
  • login, change the root password
  • create an “admin” privileged user (usually my name or “builder”)
  • add this user to the sudo
  • change it’s password
  • edit /etc/ssh/sshd_config and disable root login
  • update the package definitions (apt-get update)
  • upgrade the packages (apt-get upgrade)
  • reboot

Second: Install the required roo packages

  • postfix – when prompted select the default values
    • apt-get -y install postfix
  • apt-get -y install python-setuptools daemontools daemontools-run python-dev mailutils mutt build-essential uuid-dev python-nose vim htop sysstat dstat ifstat screen locate apache2-utils unzip siege python-virtualenv bwm-ng libcairo2-dev libglib2.0-dev libpango1.0-dev libxml2-dev fail2ban openssl libssl-doc openvpn libssl-dev libgcrypt11-dev lighttpd lighttpd-dev libevent-dev libcurl4-openssl-dev  libreadline6-dev beanstalkd tree
  • apt-get install postgresql-9.1 postgresql-client-9.1 postgresql-doc-9.1 postgresql-plperl-9.1 postgresql-plpython-9.1 postgresql-server-dev-9.1
  • easy_install pip
  • easy_install mercurial
  • easy_install pycurl
  • pip install virtualenvwrapper

That’s it, essentially, for the second layer, however, here’s an explanation of the modules from a macro perspective:

  • python-setuptools – make the installer, easy_install, available
  • daemontools daemontools-run – there are so many ways to implement a ‘daemon’ this tools make it simple to make daemon deployment simple
  • python-dev python-nose python-virtualenv – basic prereqs for python development. virtualenv is needed so that packages can be installed in userspace
  • mailutils mutt – generate emails
  • build-essential uuid-dev  - basic developer tools
  • vim screen – editor and console tool
  • htop sysstat dstat ifstat locate unzip bwm-ng – debug /monitoring tools
  • libcairo2-dev libglib2.0-dev libpango1.0-dev libxml2-dev – libs used when rendering usage graphics
  • fail2ban – detect login attempts and put the IP in time-out
  • openssl libssl-doc openvpn libssl-dev libgcrypt11-dev libcurl4-openssl-dev - crypto
  • lighttpd lighttpd-dev – web server that should be in front of the framework
  • libevent-dev – kevent, kpoll libs
  • apache2-utils siege – performance simulation tools
  • beanstalkd – message queue

And finally the third layer, the userspace framework layer. But before you start installing packages you need to create the virtual environment:

  • cd ${HOME}
  • mkdir -p src
  • cd ${HOME}/src
  • virtualenv currentenv
  • . ./currentenv/bin/activate
Now install the third layer.
  • pip install tornado
  • pip install flask
  • pip install flask-rest
  • easy_install pip
  • pip install pycurl
  • pip install simplejson
  • pip install tornado
  • pip install Fabric
  • pip install PasteDeploy
  • pip install PasteScript
  • pip install modern-package-template
  • pip install requests
  • pip install gevent
  • pip install pystache
  • pip install nose
  • pip install redis-py
  • pip install pymongo
  • pip install hoover
  • pip install pyzmq
  • pip install pyyaml
  • pip install beanstalkc
  • pip install django
  • pip install django-redis-cache
  • pip install clint
  • pip install djangorestframework
  • pip install pyparsing
  • pip install flup

I’m hoping that there is a practical use-case for embedding Lua in Python. There are an few interesting projects like lunatic-python and lupa. Normally I would not consider Lua for anything beyond “hello world”, however, the redis team is embedding Lua, it seems like a very lightweight codebase, it can be embedded in just about any language (do a google search).

  • cd ${HOME}
  • mkdir -p tmp
  • cd tmp
  • wget http://www.lua.org/ftp/lua-5.2.0.tar.gz
  • tar zxvf lua-5.2.0.tar.gz
  • cd lua-5.2.0
  • make linux
  • sudo make install

NOTE: the lunatic project does not compile under Lua 5.2. So this thread is postponed for now.

  • pip install lunatic-python

Alternatively I tried [lupa] but that requires LuaJIT 2.0 which is currently in beta (version 9)

  • cd ${HOME}
  • mkdir -p tmp
  • cd tmp
  • wget http://luajit.org/download/LuaJIT-2.0.0-beta9.tar.gz
  • tar zxvf LuaJIT-2.0.0-beta9.tar.gz
  • cd LuaJIT-2.0.0-beta9
  • make
  • sudo make install
  • sudo ldconfig

Then install lupa.

  • pip install lupa
NOTE: hoover is a client library for loggly.com.  You’ll need an account if you want to use this service.

In closing, I would like to include a few more libraries, however, the current version in apt-get is too old. I’d prefer installing them from scratch. They are necessary packages so for the time-being I’m just going to list them. They should be installed when installing the first layer and by the root user (or sudo)

  • ZeroMQ - trivial to build and deploy if you follow the instructions
    • cd /tmp
    • wget http://download.zeromq.org/zeromq-2.1.11.tar.gz
    • tar zxvf zeromq-2.1.11.tar.gz
    • ./configure
    • make
    • make install
    • ldconfig
  • MongoDB – (can actually be installed in userspace)
    • cd /tmp
    • wget http://fastdl.mongodb.org/osx/mongodb-linux-x86_64-2.0.2.tgz
    • mkdir -p ${HOME}/bin
    • cd ${HOME}/bin
    • tar zxvf mongodb-linux-x86_64-2.0.2.tgz
    • sudo mkdir -p /data/db
    • sudo chown `id -u` /data/db
    • ./mongodb-linux-x86_64-2.0.2/bin/mongod
    • … or …
    • cd ${HOME}/bin
    • find ./mongodb-linux-x86_64-2.0.2/bin/ -type f -exec ln -s {} \;
    • ./mongod
  • Redis – trivial to build and deploy if you follow the instructions
    • cd /tmp
    • wget http://redis.googlecode.com/files/redis-2.4.6.tar.gz
    • tar zxvf redis-2.4.6.tar.gz
    • cd redis-2.4.6
    • make
    • make install
  • SQLite – a simple SQL DB
    • cd /tmp
    • wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
    • tar zxvf sqlite-autoconf-3070900.tar.gz
    • cd sqlite-autoconf-3070900
    • ./configure
    • make
    • make install
    • ldconfig
  • ISO8583 – ISO8583 lib

Good luck!

PS: You should consider scripting this installation so that the deploy can be automated.  Specially via Fabris, chef, or puppet.

 
1 Comment

Posted by on 2011/12/30 in architecture, beta

 

Tags: , , , , , , , , , , , ,

“Mojolicious” has lost it’s Mojo

I’ve recently encountered my second issue with Mojolicious; since the Mojo team had recently added some core developers and reinstated their ticket system via GitHub I decided to open a ticket.

The first issue I presented to the team was their use of “daemon” as a command line param to launch your webapp, however, it unexpectedly ran the app in the foreground. My understanding of “daemon” and the behavior of any number of apps is that “-d” or daemon-mode meant background execution.

The issue I am currently working on is the new 2.37 version. It’s the first build from the new core team and that was a good thing, however, it would not build on my system (OpenBSD 5.0). So I reported it. The response that I received directed me to the CPAN team who verified that it worked.

Less obvious was the notion that I needed to check my dependencies. So I suggested exactly that… to which I received a reply that a) we were off topic and b) that there are no dependencies.

Well, ok… we were a little off topic… but there is such a thing as customer service. And while the cpan install file may not actually set the dependencies… they are listed on the CPAN page. So why not add that to the install?

So I’m up to my eyeballs in this. I’ve spent the last few months (calendar time) trying to wrap my head around this thing called Mojolicious. I happen to like perl and the CPAN. But I’m also frustrated with my two encounters with the Mojolicious team. They are neither smart enough or pretty enough to warrant this sort of snarkey-ness,

In the last 24-hours I’ve spent some time looking at flask, Werkzeug, Cyclone, and of course I already use Django and TornadoWeb. I also like python. The dependencies are easier here too.

 
1 Comment

Posted by on 2011/12/11 in web

 

Tags: , , , ,

Django-App-Engine is not Django

I’m not going to give these guys any more press than they deserve.  I tweeted that “django-app-engine development halted”. As I tweeted the message I thought they were referring to the DjangoProject, however, I was wrong! Seems the Django project is still going strong, I don’t know who these other guys are or what their endgame is…

Anyway, Django is a strong platform. I do not use it much these days because I’m focusing on TornadoWeb and Mojolicious but it is rock solid. It’s admin tools can bootstrap just about app you might consider building.

 
Leave a comment

Posted by on 2011/11/24 in web

 

Tags: , ,

In response to your interest – in case you want to hire me.

Hi Richard,

Thank you for considering this position. I have been going over your CV and it looks interesting enough to take it to the next stage.  As for helping us better understand where your strengths are as far as your current software engineering capabilities I would like you to answer the following questionnaire.

Cheers,
Ofer

 

Question: Write a simple sorting algorithm (array of numbers) in python and explain it.
Answer:

my_numbers_that_need_sorting = [4,3,4,6,3,6,9]
my_numbers_that_need_sorting.sort()
## there are plenty of APIs out there that do sorting. 
## There is absolutely no reason for me to open my 
## Knuth books and read anything on merge sorts, hash sorts, 
## btree sorts, insert sorts etc. People smarter than me 
## are getting their Phd(s) on the subject.

 

Question: What parts of Python don’t you like and why?
Answer:

I hate the indenting.

 

Question: What is Bitcoin and what do you think about it?

Answer:

 I’m not an economist so I don’t know what the long term ramifications are. As a skeptical systems person I hope there are no bugs.

 

Question: What other software projects have you been involved with? Do you have a github account/website with code you wrote?
Answer:

My code is proprietary. I do give back from time to time. Recently I patched a bug for MongoDB… for fun. Their data “import” utility supports importing JSON, CSV and TSV.  When loading TSV and CSV files the leading and trailing whitespace is removed from each cell, however, the TAB character is considered whitespace in the TSV file import code. Therefore, if the first field were an empty field then the data would skew(shift by one cell) and the load would fail. So I identified the offending line of code, wrote a patch, tested it and submitted a patch to the dev team.

 

Question: What’s your favorite programming language (besides Python)?

Answer: 

I do not have a specific favorite… but if I had to choose it would be one that does that job. And as a manager I want to make sure that there are resources that pick up the standard when the time comes. (business continuity see http://github.com/languages)

ASM – when performance is absolutely necessary and I don’t need floating point. I hate floating point in assembler)

C – when performance is absolutely necessary and I need floating point or integration with other APIs like libcurl or the gtk.

C++ – when I have to bugfix someone else’s code.

perl – nice for reporting, ETL and other batch operations. (parrot and perl 6 have me concerned about compatibility)

python – same as perl. many of the APIs make things easier than perl. I also like tornado/cyclone and Django for webapp frameworks. (I like easy_install!!)

Java – java is the new cobol. there are APIs and frameworks for just about everything. There was a time when java had a manageable library but now it’s too big and it has fractured. Not to mention that the JDK is semi open source and then there is the Oracle factor.  J2EE is also a well known framework but it is the 1200lb gorilla in the room.

Scala and Clojure – interesting functional languages. If they were real languages instead of using the JDK. During initial development it is interesting that the languages can interop with traditional JDK libs, however, in the end apps like “lift” are simply calling Jetty. That makes a functional call stack not to functional.

erlang – interesting but not all ‘that’. While it works well for long running process and it’s lightweight processes make for some interesting parallelization it’s better for longer running tasks like phone switches and audio codecs. It’s not well suited for messaging. There are so many other better solutions. Mnesia is useful. It’s nice that it’s integrated into the language, however, there are plenty of warts there and there are so many other DBs that make more sense.

haskell – bloated and disorganized package manager.

prolog – In 20 years I have not found it useful… or in production. Erlang does a better job and Turbo Prolog is long since gone.

R – I would like to use this language, however, I have not found a use-case for it yet. It generates nice graphs and charts… but it requires Intel Fortran to build it. So I’m not sure I want this many dependencies.

LUA – another interesting idea.  Nice that the language is small enough to compile quickly and there is a jit. It’s also interesting that it integrates with C instead of the JDK.

.NET – I’m not a fan of anything that creates a lock-in and Mono while it runs on *nix is not a real viable solution in the long term. Mono is loosely glued together.

Thank you. I hope to hear from you shortly.

/r

 
Leave a comment

Posted by on 2011/07/01 in for hire, ProgLang

 

Tags: , , , , , , , , , , , , , , ,

 
One Page Docs

Creating a library one page at a time.

One Page Bugs

Reducing the friction of writing and fixing bugs or features.

Follow

Get every new post delivered to your Inbox.

Join 223 other followers