Web Services : Data flow between the UI view and the backend APIs

These two articles helped me a lot in understanding how to handle data passing between the UI view and the backend APIs.

References:

  1. https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_and_retrieving_form_data
  2. http://www.asp.net/web-api/overview/advanced/sending-html-form-data-part-1
  3. http://carehart.org/blog/client/index.cfm/2007/1/2/form_self_post

 

Git : Steps to take after getting a sign off in code review branch

Steps to take after getting a sign off in code review branch.  feature/masquerading (say)

— Go back to master

  • [feature/masquerading]> git checkout master

— get latest code from master

  • [master]> git pull origin master
  • [master]> git checkout feature/masquerading

— rebase with master

  • [feature/masquerading]> git rebase master
  • [feature/masquerading]> git add readconfigapp2/Program.cs
  • [feature/masquerading]> git rebase –continue
  • [feature/masquerading]> git checkout master

— merge and push master

  • [master]> git merge feature/masquerading
  • [master]> git push origin master

— delete CR branch

  • [master]> git branch -d feature/masquerading
  • [master]> git push origin –delete feature/masquerading

Azure Machine Learning : Model Retraining

References:

  1. https://azure.microsoft.com/en-us/documentation/articles/machine-learning-retrain-models-programmatically/
  2. https://azure.microsoft.com/en-us/blog/retraining-and-updating-azure-machine-learning-models-with-azure-data-factory/
  3. https://gallery.cortanaanalytics.com/Tutorial/No-code-Batch-Scoring-and-Retraining-1
  4. https://azure.microsoft.com/en-us/documentation/articles/machine-learning-consume-web-services/

Visual Studio : Project Structure

Have always been a bit curious to understand about VS’s project structure. Also, the use of config files and stuff. So here goes :

  • I create a solution ‘vsprojstructure’
    • I eventually wan to create a git repo out of it.
  • class library ‘configlib’
    • It has an app.config file
  • class library ‘algolib’
    • when algolib is independent, it doesn’t know anything about ‘configlib’
    • when i add ‘configlib’ as a reference, 2 things happen:
      • VS automatically updates the ‘Project Dependencies’ for ‘algolib’ project. It marks that ‘algolib’ depends on ‘configlib’
      • when i build the project, it copies ‘configlib’s dll and pdb files inside ‘algolibs’ bin\Debug folder
      • Note : it does not copy the .config file. This is worrisome
  • Now add a console app called ‘demo’
    • ‘demo’ has ‘algolib’
    • when i build the project, it copies ‘algolib’ and ‘configlib’s dll and pdb files inside ‘demos’  bin\Debug folder. However compilation fails (see code why)
    • So i also add ‘configlib’ as a reference. Compilation succeeds now.
    • However, it shows ‘AppSettings is empty’. This makes sense because as we noted before, the .config was never copied
  • It seems the only way to solve this problem is via post build events.
    • See reference.
    • Using build events.
    • This explains why in many cases we see projects having post build events writing to a common folder
  • Also, note by default the ‘demo’ exe will try to read its own exe. The .config file in the configlib directory needs to be crafted to ensure it reads its own .config file

 

Examples:

1.

robocopy $(SolutionDir)configlib\bin\Debug\ $(TargetDir) configlib.dll.config /xo /xn
IF %ERRORLEVEL% GEQ 8 exit 1
exit 0

2.

robocopy $(ProjectDir)dependencies $(SolutionDir)bin\$(Configuration) /xo /xn
IF %ERRORLEVEL% GEQ 8 exit 1
exit 0

Pro Tip:

  • A critical aspect is to understand the OutputPath parameter in the .config file
  • For each project, this is what controls where the output is going to.

Code:

Github

References:

 

 

Git : Pull Requests, Branches

Tips:

 

 

References:

  1. http://www.gitguys.com/topics/switching-branches-without-committing/
  2. https://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to-understand-git/  
    • Super useful!!

Threading. Singletons. Generics. Locking Bug!

I recently came across this very interesting bug.  Note: the problem requires understanding of threads, generics, inheritance and locks.

In particular look at the Locking Bug code. Specifically, notice how the locking behaviour changes based on the types used for the generic base class.

  • When the types are same, the base class object used for locking is the same.
    • So locking can be enforced by doing something like
      • private static readonly object Padlock = new object();
      • lock (Padlock)
  • However, when the types are different, the compiler creates two completely different memory objects, hence the locking does not come into play
    • A possible solution is to create a separate internal class and enforce locking using the typeof that class
      • internal class ForLocking {}
      • lock (typeof(ForLocking))
    • If you dont prefer using typeof, another option is to create a separate class and have a static lockObject in it.
      • See code.
    • http://stackoverflow.com/questions/8185004/lockx-vs-locktypeofx

Code:

References: