Posts

Showing posts from November, 2017

Modularizing your flask app

For complex and larger flask project, you probably want to structure you application well. for example, ROOT- ---> app.py ---> /tour --->/tour/controllers.py --->/tour/__init__.py ---> /user --->/user/controllers.py --->/user/__init__.py For me, i rather put my starter code into app.py instead of __init__.py so clearly my intention are clearly shown. Sample of my app.py looks like this. This is where i reference my other controllers and hooked up into flask blueprint. Flask blueprint allow us to modularize our app. Sample of my app.py looks as follow :- From line 10 and 11, you can see that i am importing my controllers and modularizing it. My controllers typically looks like this :- Now you can go and browse http://localhost:port/tour

python wheel quick guide

To create a wheel python setup . py bdist_wheel To create your requirements.txt file pip wheel - r requirements . txt To install a wheel pip install some - package . whl

importing python custom library

Trying out custom library in python. I think the better way to write is basically to have different object into a specific file. For example, paymentMethod in a file instead of nested paymentMethod, payee, account into a single py file. Let's say we are creating a custom library called payment and placed it under a folder called payment. First we need to create a "payment" folder. Create a file called __init__.py. a) __init__.py file b) payment.py c) then import it using the following code

Getting windows docker directory mount on your container image

Image
Let's say you want to use docker image as your development machine. So you would like to build a docker container and you like to mount a windows path so your changes can be persisted and directly reflected in your container. Also if you see bloggers are saying you can run something like "docker exec it -v /app:/app" - well there are additional steps require, discussed below :- So you have Windows -->  Docker (Virtualbox) Your VM -> Container Dev_Folder -> Map to VM Box as shared folder -> Mount it using docker -v command Let's map your windows folder first (a shared folder in virtual box) In your virtual box goto Settings -> Shared Folders -> Please note :- this mapping is case sensitive, perhaps i should use all lowercase as a demo. Next, if you open your docker default virtual machine, you should see "miacucinaCms" folder. All this happening before you run your container. Setting up your container To mount thi

Conda environment cheat sheet

Creating environment in conda conda create --name myAppName Listing all your python environment conda env list Activating your environment activate myAppName Enabling pip in this environment conda install -n myenv pip Working with flask command in Windows Start off flask with port 3000 flask run -h localhost -p 3000

Using command prompt to connecting to docker toolbox running on a Window Host

I am trying to automate my container images using script. The GoLang SDK (Docker Engine API) helps but only if i can get into docker shell. So how do I do it? Create a docker machine and then gain access to docker ssh. From there, we can execute any scripts we wants. a) Create a docker machine called " default " - If you already have one, please use this one. :)   docker-machine create --driver virtualbox autodocker b) Executing docker command from Dos Command via docker-machine. docker-machine ssh default "docker run hello-world" This will execute docker command to download an image called 'hello-world'. Longer way to do it. First you run 1. docker-machine.exe env --shell cmd default 2. It gives me alot of info as shown below :- SET DOCKER_TLS_VERIFY=1 SET DOCKER_HOST=tcp://192.168.99.100:2376 SET DOCKER_CERT_PATH=C:\Users\User\.docker\machine\machines\default SET DOCKER_MACHINE_NAME=default SET COMPOSE_CONVERT_WINDOWS_PATHS=tru

AWS Light Sail - connecting using Putty or PuttyGen

How you can use Putty to access Light Sail Linux machine? Go and read up this link. https://lightsail.aws.amazon.com/ls/docs/how-to/article/lightsail-how-to-set-up-putty-to-connect-using-ssh

Registering more developer finger printing for your android development

Image
Let's say you have more than one developer working on your android app. Good news is your can easily set this up using firebase console as shown below. Just thought you want want to know.

android error 12500 - trying to setup google single sign on

If you're hitting this messages and getting error code 12500 then please ensure your emulator supports google play. You emulator would generally ask you to login to gmail account ...blah blah blah.. if you don't get that, it is almost certain you need to install it. :) The funny thing is I have emulator with Android 4.4, SDK 19 ad that doesn't work. So I created another emulator with Android 6.0 (Google API) and SDK 23. Most people don't run into this issue. But if you do, you're sorted now.

facebook single sign on using android sdk

This the best place to get started :- https://developers.facebook.com/quickstarts/124695344865811/?platform=android#

Getting started with Docker Engine API on Windows with Go (Golang)

Make sure you installed 1. Docker ToolBox 2. Go language from Google. 3. Create the following script and call it "listimage.go" 4. Fire up "Docker command prompt". And then run "go run listimage.go". This will list all the image in your current container.

Cloud design pattern

These are pretty common design pattern for cloud pattern. Availability  - End point Availabity - Throttling - Queue resource leveling Database  - CQRS - Event Sourcing - Index Table - Sharding - Cache Aside -

Excel File 0xC020801c issue

I encountered a couple of issue with :- a) DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER - Excel Source Failed validation and return error code  0xC020801c. b) Microsoft.Jet.OLEDB.4.0 is not registered. If the driver is not installed, run package in 32bit mode. An OLEDB Service componet :- 0x80040154 description - Class not registered. This really points to 32 bit vs 64 bit incompatibility issues. Solution: Install 64 bit driver or redeploy your SSIS package in 32 bit.

What is the difference between .net core, .net standard and .net framework

Check out this site here and it gives a detail list of comparison :- https://github.com/dotnet/standard/tree/master/docs/comparisons

SSIS - "Microsoft JET Database Engine" error - Hresult: 0x80004005 Description: "Unexpected error from external database driver (1)

Bump into this error a couple of days ago. The root causes - Windows Update. To way to resolve this is look at your windows update and check against Microsoft website to see what is the patch about. For example, KB4041693 provides a list of components affected and possible resolution. If you cannot quickly repair your connection string from Jet to ACE,. then you might try uninstalling windows updates and restart your machine.  This could be different on your machine, there could be additional updates you need to un-installed compare to the list below :- KB4041681 - Windows 7 Update  KB4041693 (Window 8 and Window Server 2012 ) /  KB4041678 (Windows 7 and Win 2008 Server)   - Both stated it will affect Microsoft.Jet driver  SQL-Management studio -> SSIS package -> The specific package -> Report -> All Execution and try to see what other error messages you're getting. Do not focus on the DRIVERS. Re-installing the database driver is the last option. You

android - great resource for working with material design

Should definitely check out this site here to get more information and tips on working with different android components. https://materialdoc.com/components/autocomplete/

Docker - How to configure IIS (Web server) feature in docker image

The following scripts gives an example of how we can configure our windows server to add web server feature into our docker image.

use powershell.exe to run a script with space in its path

If you run into a situation whereby you need to execute a powershell script that has a space in it using powershell.exe. just add a -File parameter in there. Otherwise you will get error message and putting quotes in between the "xxx.ps1" script won't work. Example is shown below :- %SYSTEMROOT%\system32\WindowsPowerShell\v1.0\powershell.exe  -File "%APP%deployControlService.ps1" -projectPath "%~dp0"

Android facebook integration

Getting Android app integrated with facebook application is pretty straight forward. If you follow the guide here, it will guide to from start until end. https://developers.facebook.com/docs/facebook-login/android/ The only point that i would like to emphasis here is, this line of code in "onActivityResult". You will get resultCode = -1 even though you have signed in successfully. That is why, forwarding result to callbackManager is important as it will be able to tell for sure if your user did signed in, signed out or cancel. protected void onActivityResult( int requestCode, int resultCode, Intent data) { super .onActivityResult(requestCode, resultCode, data); callbackManager .onActivityResult(requestCode, resultCode, data); }

Android using theme for your UI development

We're gonna define theme to use in our app. This means we do not have to manually 'write up' a bunch of "style=" attribute and assigned a custom value to it. The only major code change we need to do is in our manifest.xml as shown below :- Declaring theme in manifest  Here we are assigning a theme called AppTheme/NoActionBar (ok maybe its not a good name) Default Styling of UI Component in style.xml Here we have two customer style which we would like to apply to our controls. These are call Widget.TextView.Custom and Widget.Spinner.Customer respectively.    

Trying to run powershell from command and you get - “execution of scripts is disabled on this system.”

First off, you can enable powershell execution script for good. The only problem is powershell comes in 32bit and 64bit. This probably cuz Windows itself allow this. In order to ensure you're able to run powershell in both environment without problem, you need to do the following :- For 32 bit machine Open  C:\Windows\SysWOW64\cmd.exe Execute this line   powershell Set-ExecutionPolicy RemoteSigned For 64 bit machine  Open  C:\Windows\system32\cmd.exe Execute this line   powershell Set-ExecutionPolicy RemoteSigned