Sunday, November 1, 2015

(Java) Development Stack 2015

So, I switched company last year. My current company is a e-commerce B2B which also built it's offering based on Java and Open Source technologies. Here my technology stack per Oct 2018:

Presentation Layer
Depending on the nature of the project (urgency). My default stack is still to use JSF 2.x with Primefaces for rapid development. I also still working with Spring MVC, Angular.JS and Twitter Bootstrap. Lately, I also start to work with SpringBoot. I found it kinda tricky sometimes (maybe I'm too conservatives)

Business Layer
Still using Spring Framework and Spring Security. Similar like in the web arena (presentation layer), I also start to use SpringBoot for several independent tasks, especially batch jobs.

Data Access Layer
I'm using Hibernate - JPA combo! For my latest webservice project, I'm using Spring JDBC (JdbcTemplate).

Build
Start to use Maven 3.x.x. Currently evaluating Graddle, but I'll give it a pass.

Testing
Using JUnit with some mocking library (JMockit and/or Mockito). To test REST webservice, I'm using Rest Assured.

Continuous Integration and Code Quality
Now I'm becomes a fan of Continuous Integration. We are using Jenkins for CI. Sonarqube for code quality is a must!

Application Server
I'm still using Tomcat 7.0.x for development and production.

Database Server
My company using Oracle DB. For my own side projects, I'm move away from MySQL and using PostgreSQL.

Source Control
Pretty much I'm using both Mercurial (bitbucket) and Git (bitbucket & github).

Linux?
Currently I'm move away from Ubuntu to CentOS.

What do you think compared to this?

I'm sure you also notice that lately I've been posting about Python and pyramid framework. Yes, Python is my 2nd programming language now (I mean for back-end). And I pretty much love SQLAlchemy. Maybe in the future I'll touch Django, who knows...

Sunday, August 16, 2015

Compiling Python extensions on Windows

source: https://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/

Using Windows is difficult...

Extensions usually need to be built with the same compiler version as the interpreter. This is because each compiler version uses a different and incompatible CRT, until VS 2015 that is.

If you're missing the required compiler you usually get a vague error: Unable to find vcvarsall.bat.


For Python 3.4

This is the python version I currently use.

In order to get it to work you need to jump through these hoops:

1. Install Visual C++ 2010 Express

2. Before installing the Windows SDK v7.1 (WARNING!):
  • Do not install Microsoft Visual Studio 2010 Service Pack 1 yet. If you did then you have to reinstall everything. Uninstalling the Service Pack removes components so you have to reinstall Visual C++ 2010 Express again.
  • Remove all the Microsoft Visual C++ 2010 Redistributable packages from Control Panel\Programs and Features.

If you don't do those then the install is going to fail with an obscure "Fatal error during installation" error.


3. Install Windows SDK for Visual Studio 2010 (v7.1). This is required for 64bit extensions.

⚠ On Windows 10 the web installer gets confused:
Some Windows SDK components require the RTM .NET Framework 4. Setup detected a pre-release version of the .NET Framework 4.
You certainly don't need any of the .NET stuff so you can work around by getting the offline version of the SDK (ISO).

  • Make sure you download GRMSDKX_EN_DVD.iso (X means 64bit).
  • Windows has builtin mounting for ISOs. Just mount the ISO and run Setup\SDKSetup.exe instead of setup.exe.

4. Create a vcvars64.bat file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 that contains:

CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64


5. Now everything should work, go and try py -3 setup.py clean --all build_ext --force.

6. Install Microsoft Visual Studio 2010 Service Pack 1. This is optional, however, if you do this you also have to do the following too:


8. Remove all those SQL Server packages that you don't need from Control Panel\Programs and Features.


For Python 3.5

Get the Visual C++ 2015 Build Tools. It doesn't come with Visual Studio and all the useless cruft but make sure you select the Windows 8.1 SDK during the install.

Thank you so much, Ionel.

Sunday, March 8, 2015

From 2 to 3 - Part 2

Repeating problem (task) that I encounter during migration from Python 2 to Python 3 (Part-2):

* iteritems in Python
Based on this stackoverflow question:

In Python 2.x - .items() returned a list of (key, value) pairs.
In Python 3.x, .items() is now an itemview object, which behaves different - so it has to be iterated over, or materialised... So, list(dict.items()) is required for what was dict.items() in Python 2.x. 

In Python 2.7:
common_keys = list(dict_a.viewkeys() & dict_b.viewkeys())
Will give you a list of the common keys, but again, in Python 3.x - just use .keys() instead.
common_keys = list(dict_a.keys() & dict_b.keys())
Python 3.x has generally been made to be more "lazy" - i.e. map is now effectively itertools.imap, zip is itertools.izip, etc.

* 'module' object has no attribute 'urlencode'
It's about urllib. In Python 3.x Do
import urllib.parse
instead. urlencode is part of urllib.parse

* ImportError: cannot import name 'quote'
Again about urllib. Similar like problem above you can do
from urllib.parse import quote
For direct import

* dictionary changed size during iteration
It's a problem in Python 3, in short; use list...

as explained:
In Python 2.x calling keys makes a copy of the key that you can iterate over while modifying the dict:
for i in d.keys():
Note that this doesn't work in Python 3.x because keys returns an iterator instead of a list. Another way is to use list to force a copy of the keys to be made. This one also works in Python 3.x:
for i in list(d):