Three underutilized python commands

By : Shabda Raaj

Today's post are three simple Python commands which should be known more widely, but are not.

Start a simple web server to serve files from current directory.

~$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

This is neither secure, nor scalable, but handy if you are in a directory and want to quickly test something.

Testing emails

~$ python -m smtpd -n -c DebuggingServer

Starts a fake SMTP server on port 1025. Useful if you are testing emails on a system which doesn't allow pluggable emails backends.

Pretty print JSON

echo '{"2legs":"Better", "4Legs": "Good ...

more info..
Topics : python tips Python

Two Scoops of Django: Review

By : Shabda Raaj

Django best practices

Two scoops of Django is the new book on Django best practices by Daniel Greenfeld and Audrey Roy. I just finished reading it and found it extremely useful.

The book is a collection of tips, their justification and code organized in logical areas. I have been using Django since 2008, but I still found a few tips which were new to me and many which served as good reminder. At about 200 pages, its comprehensive but not overwhelming. If you are an advanced Djangonaut, you can read it in a weekend (And you probably are using all its recommendations anyway ...

more info..

Easy client side form validations for Django: Django Parsley

By : Shabda Raaj

Parsleyjs is a JavaScript library to do client side data validations. It does this in a non-intrusive way via adding a data-* attributes to form fields. Check it out, it's really slick.

Django forms do a great job of server side data validations. By integrating Parsley with Django form, you get good client side data validations as well. Get the app here.

Some design considerations

When I started writing this app I wanted to make it really easy to use. My first thought was to make this a filter or a template tag which would have allowed you to ...

more info..
Topics : django

MoreApps - Android Library Project: Open Sourced

By : Shabda Raaj

If you have a portfolio of apps, you probably want to cross promote them.

We are open sourcing an Android Library Project to make this possible. Get the code. This provides an Activity which you can show with a Grid of your apps.

How to use it

Add this MoreAppsLibrary project(library) as a dependency in the Android Application project you are implementing.
Add the following code in your AndroidManifest.xml:

<activity android:name="com.agiliq.android.moreappslib.MoreAppsActivity"
          android:label="More Apps">
</activity>

Perform an Intent to start the MoreAppsActivity; make sure to putExtra("package", getPackageName());, this ensures that ...

more info..
Topics : android open-source

Password Generator App: Open Sourced

By : Shabda Raaj

Announcement:

We are open sourcing a few tools we developed recently. Here is the second one.

Password Generator Chrome Extension

Install it from chrome webstore
Here are the docs

Summary

A completely client side password generator.

What is it

Its a chrome app to generate unique passwords for each site. Depending upon the domain and a master password a unique password is generated. It doesn't need any server and everything happens on the client side.

Why?

I want to use a unique password for each website. However, I don't want to use lastpass/1password as I find their ...

more info..

Deploying Django apps on Heroku

By : Shabda Raaj

Deploying Django apps on Heroku:

Read this first: http://devcenter.heroku.com/articles/django.

This is a great article by the Heroku. I am just filling in some more details and making this step-by-step.

  1. Get your Django project code.
  2. Create a virtualenv with a no-site-packages command ::

    virtualenv vent --no-site-packages

  3. Install Django, psycopg2 (postgres connector), gunicorn and any other required Django libraries.

  4. Confirm that you have all the required libraries and you can run your code locally using manage.py runserver.
  5. Create a requirement.txt by using ::

    pip freeze > requirements.txt
    
  6. Make sure you have a requirements.txt at the root ...

more info..
Topics : django

Deploying Django apps on Heroku

By : Shabda Raaj

Read this first: http://devcenter.heroku.com/articles/django.

This is a great article by the Heroku. I am just filling in some more details and making this step-by-step.

  1. Get your Django project code.

  2. Create a virtualenv with a no-site-packages command

    virtualenv vent --no-site-packages
    
  3. Install Django, psycopg2 (postgres connector), gunicorn and any other required Django libraries.

  4. Confirm that you have all the required libraries and you can run your code locally using manage.py runserver.

  5. Create a requirement.txt by using
    pip freeze > requirements.txt
    
  6. Make sure you have a requirements.txt at the root of your repo. Heroku uses ...

more info..
Topics : django

Writing jQuery plugins using Coffeescript

By : Shabda Raaj

So you want to write a Jquery plugin. If you know jQuery and Coffeescript, this would be amazingly easy.

I will walk you through writing a jQuery plugin which will allow us to add alternating colors to alternating rows.

Here is the plugin in its entirety.

$ = jQuery
$.fn.zebraTable = (options) ->
    defaults = 
        evenColor: '#ccc'
        oddColor : '#eee'

    options = $.extend(defaults, options)
    @each ->
        $("tr:even", this).css('background-color', options.evenColor)
        $("tr:odd" , this).css('background-color', options.oddColor)

Lets look at what we did.

  1. We bound $ to jQuery object.
  2. We created an anonymous functions and added this to jQuery, by assigning it to $.fn ...

more info..
Topics : coffeescript

Haml for Django developers

By : Shabda Raaj

Haml is taking the Ruby(and Rails) world by storm. Its not used as heavily by Python(and Django) developers as the Python solutions aren't as mature. I finally gave Haml a try and was pleasantly surprised how easy it was.

The most mature Python implementation of Haml is hamlpy, which converts the hamlpy code to Django templates. Others are shpaml and GHRML

Lets look at some templates from Django tutorial

{% if latest_poll_list %}
    <ul>
    {% for poll in latest_poll_list %}
        <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>
    {% endfor %}
    </ul>
{% endif %}

Here is this template converted to Haml

-if ...

more info..
Topics : django

Coffeescript for Python programmers

By : Shabda Raaj

I just learnt Coffeescript, and as a Python programmer loved being able to write Javascript in a Python like language. Coffeescript is inspired by Python/Ruby and is very close to these languages. Writing Coffeescript and reading the compiled Javascript also improved my understanding of Javascript. Without much ado here is translation of some Python code to Coffeescript to get you started.

Defining a variable

Python
a = 10

Coffeescript
a = 10

Setting scope is done via whitespaces.

Python

if i == 10:
    foo()

Coffeescript

if i == 10
    foo()

No semicolons

List comprehensions

Python

languages = ["Python", "Coffeescript", "Java", "Ruby", "Haskell"]
languages = [lan ...

more info..
Topics : coffeescript
shabda
Comments
Reactions

Jobs

By : Shabda Raaj

We are a small software company building web facing applications for a number of clients. We work with Python, Django, Jquery, Mysql or Postgres. We “build amazing webapps”. You can learn more about us from:

What we are looking in you:

  • Are you a software engineer looking to work in a small team with smart people?
  • Do you know multiple programming languages, and have the ability to pick up new ones?
  • Can you prove why your IDE or editor is better than mine?
  • Do you know relational databases, when ...

more info..
Topics : jobs
shabda
Comments
Reactions

Comparison of mobile app frameworks: Iphone, Java, Phonegap and Titanium

By : Shabda Raaj

I recently built the same app with the common mobile technologies, Obj-C, Android:Java, Phonegap, and Titanium .

This is a quick comparison of the app frameworks.

Miscellaneous notes

  1. Phonegap and Titanium both amazed me. It feels very empowering to code in Html, css and JS, test it in Chrome, debug it with firebug, and deploy to a device without any changes. Titanium UI widgets are native, building it with JS was very cool.
  2. Phonegap and Titanium both underwhelmed me. I assumed Phonegap would have widgets which would be 95% of the way to looking like native widgets. It was easy ...

more info..
shabda
Comments
Reactions

Getting started with Titanium development for Android and Iphone

By : Shabda Raaj

This is the third post in our mobile app development series. ( You may want to read Phonegap and Android with Java.)

Like last time we will build an App which allows calculating the tax payable, per the rules here. We will use Titanium Mobile

Installing Titanium

Download and install the fairly small Titanium from their sites. Once you download and start it, it will download and install more components. You can then create a new project from their UI.

Layout the Layout

You can add UI widgets and lay them out using Javascript. You need to use Titanium's API ...

more info..
shabda
Comments
Reactions

Getting started with PhoneGap using Xcode for Mobile app development

By : Shabda Raaj

This is next in the series of apps I am building using various mobile technologies. It is the same app as build using Java for Android for calculating the Tax payable (in India). You can get the code for Objective-C, Java-Android, and PhoneGap.

First the impressions

Phonegap was the easiest to work with among the Objective-C, Java and PhoneGap, by far. I created the app as easily as

Step 1. Write the app and test it in Browser using the Chrome developer tools. Step 2. Start a project in Xcode. Step 3. Copy the HTML and CSS files to project ...

more info..
Topics : iphone android mobile
shabda
Comments
Reactions

Starting Android app developement: From zero to app

By : Shabda Raaj

We recently started with Mobile Application development. I am learning Android using the Commonsware book, and highly recommend it. This is a very short guide to getting you running your first Android app.

What will we build

We will build a simple tax calculator for India, per the rules given here for tax calculation. In this app, we need to gets users income and various tax deductible expenses. After that we need to update the UI to show the tax. You can see the final app and code on github here.

Setting up

  1. Install Java and Eclipse
  2. Install Android SDK ...

more info..
shabda
Comments
Reactions

Book Review: Pragmatic Guide to JavaScript

By : Shabda Raaj

Pragmatic Guide to JavaScript is the Pragprog's book by Christophe Porteneuve which I have wanted to read for a while.

I went into this book expecting to read actionable and task focussed book on modern JavaScript, and this book does not disappoint on that count. Using 35 tasks which you are going to need in your browser based JS development, this books teaches required JS techniques.

However I went into the book expecting a framework agnostic approach. This book however is very heavily focussed on Pototype. Initial chapters start as framework agnostic, but they soon turn into Prototype based ...

more info..
Topics : book reviews

Book review: The Principles of Successful Freelancing

By : Shabda Raaj

The Principles of Successful Freelancing is book I read after The Principles of Project Management.

My motivation from this book was to use freelancing advice and use that for our (larger) business. This book is razor focussed on Freelancing and even more on people who are starting with or considering starting freelancing. If you are in this group I consider this book very well written, and a must read, but if you are part of a larger group, the razor sharp focus makes this not worthwhile.

Chapter wise it is:

  1. Chapter 1: Considering Freelancing?
  2. Chapter 2: Prepare for the Transition ...

more info..
Topics : book reviews
shabda
Comments
Reactions

Book review: The Principles of Project Management

By : Shabda Raaj

The Principles of Project Management is the book I am reading after Outsourcing Web Projects.

I went into this book expecting lot of actionable steps I can use for our projects right away, however this book is heavier on theory. Guess I can not complain with the name being The Principles of Project Management.

In their own words the book has,

So What Is Project Management Anyway?

This chapter forms an introduction to the art and science of project management. Here, we talk about the key phases every project goes through and why project management skills are increasingly important today ...

more info..
Topics : book reviews
shabda
Comments
Reactions

Book Review: Outsourcing Web Projects.

By : Shabda Raaj

Sitepoint had a book sales running recently where they made all their books available for sale at 7$. Being a sucker for good books and deals, I bought more than I should have. Here is the review of the first I read, "Outsourcing web projects."

This books is written from the viewpoint of buyers, but as a vendor, I have some insights (IMO) from the other side.

It starts with these chapters.

  • How to Have Vendors Competing for your Job.
  • How to Find the Perfect Outsourcing Partner.
  • How to Get the Best Price for your Project.
  • How to Get it ...

more info..
Topics : book reviews
© Agiliq, 2009-2012