Posts

Showing posts with the label Tutorial

MotherNature: A Framework-Agnostic Python Environment Variables Manager

In today's fast-paced tech startup environment you need to ship things fast. This makes way to the blossoming continuous integration and code promotion system. Continuous integration and code promotion have several requirements. One of it is environment variables management. This will enable your code promotion easier. Change your environments and you still get the correct values.  In python world there are tools for this but most of it are tailored to certain frameworks. Take Flask-Environments and Django-Environ. These solutions does not always work everywhere. About 4 months ago, the app I worked on requires me to use Apache Thrift. The public facing API is using Flask. I can use Flask-Environments. But, the micro-services are build using standard Thrift Servers. These babies do not have any environment variables manager. This was when I decided that I should write my own. Enter MotherNature, a framework agnostic python environment variables manager. It c...

Android TDD Using JUnit, Robolectric and Mockito

Image
Android now supports unit testing. Android unit testing runs on devices or emulators that adds extra time during development. I'm a big fan of TDD and the way android testing is done does not help me much. However... Thanks to Robolectric, headless testing is now possible by leveraging gradle. I wrote this post as a result of trying out several different approaches that confused me. Hopefully this one will help you set it up better. How? First, current common Android development projects are tightly coupled. Most stuffs are done in the Activity or Fragment, blame the tutorials. This makes it hard for us to actually do unit testing since a unit test should be isolated. The tight coupling makes unit testing impossible. Then, come this approach called Model - View - Presenter (MVP). MVP aims at separating concerns. The three components involved handles different concerns: Model This component groups all data related concerns. This component handles data que...

Form and JSON Post Request Value to Model Mapper Functions For Flask

One of the iritating part that you have to deal with when you're handling POST requests in Flask is how you map the values into the model. It could be in JSON or in common form format. Usually this is what you do # say this is your model # using SQLAlchemy class User(db.Model): username = db.Column(db.String(50)) password = db.Column(db.String(50))         email = db.Column(db.String(50)) first_name = db.Column(db.String(50)) last_name = db.Column(db.String(50)) # this handles the common form request app.route('/process_form',methods=['POST']) def data_process(): new_user = User(                                  username = request.values.get('username')                                  password = request.values.get('password')                   ...

Creating Python Virtual Environment Without Installing To The System

When you develop projects in python, you often met the situation where you will need to install various packages that will clutter the general python installation in your system. Usually people will use the famous virtualenv. However, it often brings trouble when you have to run 2 or more python environments simultaneously. I'm about to share a simple trick that you can use to separate those environment, still using virtualenv but we're using it differently. The examples are in unix/linux, but the usage is quite similar in windows. First, download virtualenv.py from  https://raw.github.com/pypa/virtualenv/master/virtualenv.py . That should be done in seconds. Next up, create any folder where ever you want to create the virtual environment and copy the downloaded virtualenv.py  file inside the folder. Now, run the following command: python virtualenv.py env That will create a folder called env inside your current folder and the folder will contain your newly created...

EmeraldBox: My New Boilerplate Python Framework And A Mini Tutorial

I believe that developing web apps should be done in the easiest and most efficient ways. Python offers that. However, most of the available frameworks required a deep learning curve for new users and most users have problems deploying the web app. After using several python web frameworks as well as using other languages' frameworks like Rails, Django, CodeIgniter and Zend over the years, I came to a conclusion that python is the easiest and most efficient language. However, it will require tools that may speed up development. It that sense, Rails has a very good approach and will be implemented for the helper tools. Integration with 3rd party packages should also comes easily without having the need to interfere with the main OS, hence comes virtualenv. Thus, comes EmeraldBox, an easy-to-use, light-weight, and easy-to-deploy framework. EmeraldBox comes in a localized environment and includes standard packages that are commonly used in web development. The tool includes f...