Posts

Showing posts from April, 2018

First go-lang at moby client's

Docker has transition their engine API to msoby and i have the opportunity to play with it. https://github.com/moby/moby/tree/master/client Using the code, I stumble into the following error.  " " Error response from daemon: client version 1.37 is too new. Maximum supported API version is 1.35 " Still trying to figure out how i can get around this. You need to have a command prompt / terminal that is setup to run docker command, as describe here .

asset project.asset.json not found after installing AWS nuget package

"asset project.asset.json not found" -  go to command prompt and change directory into your project folder. Then run "dotnet restore". That should fix it.

aws .net nuget packages

Nuget packages for working with AWS specific services :- a) AWS DynamoDB - b) AWS SNS - Install-Package AWSSDK.SimpleNotificationService -Version 3.3.0.28 c) AWS RDS - d) S3 - Install-Package AWSSDK.S3 -Version 3.3.18.1 e) AWS SNQ - Install-Package AWSSDK.SQS -Version 3.3.3.6

reactjs quick project setup with local server

I have been going around searching for some cli to setup and start development on react app, which can be time consuming. It is not as complete as angular but hey reactjs is really fast. You can just get started with this project here . It support ES6 (via Babel) not typescript. Remember to get your project started, quickly clone https://github.com/facebook/create-react-app Run npm install  (please make sure you have latest npm install npm install npm@latest -g (basically gives you npx which is required) To start the local server, run ' npm start ' That's it! Reactjs ready to worked on.

Entity framework core entity - self referential table

Image
Say you have a self referencing table, that looks something like this (Root nodes points to null which signifies end of hierarchical organization. We defined our Process model using code below :- Next we need to tell EF our relationship In the OnModelCreating method, use the following code to define relationship modelBuilder.Entity ().HasMany(p => p.SubNodes).WithOne(p => p.ParentNode).HasForeignKey(p => p.ParentId); It basically says that we can have many SubNodes, one Parent node - which make sense right. We can have many parent. Full code can be found here. This code retrieve all the Process and its child (subnodes) var result = p.Process.Include(a => a.SubNodes).Include(c => c.ProcessViewingHistory).AsNoTracking().ToList();             The code to pull out all, is show below :-

working with alexa skills - right places to get info

First up, if you're developing from Alexa Blueprint Skill you can change much. Pretty much use it out of the box. For example, Q&A skillset :- User : How to apply leave? Alexa : Go to this page, then navigate to ....etc. That's it. If you need to call a custom endpoint, you need to create custom skillset which can be found in the Alexa Console .  The right place to get info is from here . This will give you an understanding of AWS Built in intents etc.

Ethereum : Create a greeter

In the ethereum's greeter sample, if you following it here ,  it requires user to save the following code into a file, say greetcontract.js contract Mortal { /* Define variable owner of the type address */ address owner; /* This function is executed at initialization and sets the owner of the contract */ function Mortal ( ) { owner = msg.sender; } /* Function to recover the funds on the contract */ function kill ( ) { if (msg.sender == owner) selfdestruct(owner); } } contract Greeter is Mortal { /* Define variable greeting of the type string */ string greeting; /* This runs when the contract is executed */ function Greeter ( string _greeting ) public { greeting = _greeting; } /* Main function */ function greet ( ) constant returns ( string ) { return greeting; } } To run it, you fire up your geth console. Then type the followings :- loadScript("greetcontract.js")     

golang - different ways of initializing your struct /class

Different ways of initializing your struct // Util.go package main type StringHelper struct { } func (sh StringHelper ) ToUpper() string{ return "TOUPPER" } Different ways of initializing : // 1st var a StringHelper a.ToUpper() // 2nd b := new(StringHelper) b.ToUpper() // 3rd c := StringHelper{} c.ToUpper() I kinda prefer 3rd way of doing it.

golang - getting top libraries used in the community

Click on the following link to get all this info . 

building kubernetes on your local machine - docker

Image
In case you would like to build kubernetes on your docker machine, please do the following :- a) Download and run the following Dockerfile. b) Next, run the following comand - "docker run -it /bin/bash c) apt-get update d) apt-get install rsync e)  go get -d k8s.io/kubernetes f)  cd $GOPATH/src/k8s.io/kubernetes g) make  And if all things goes well, you will get the following screen :- That's it! :)

first golang package

I created my first golang package (library - not an executable). My code which i ripped off the internet can be found here. https://github.com/appcoreopc/gomath Then i do a "go get github.com/appcoreopc/gomath" - (without the https) and it gets build and move to a folder called package in Golang environment. You can try to rebuild it by trying "go install".

using nsubstitute to mock dbset

I thought this is going to be a one off thing until i realized that i have to do this quite often. Using nsubtitute to mock my database layer. So here are the codes that i wanna share, as i know it is going to be the same (most of the time)

javascript slice vs splice

In English, slice is used to get portion of a string without modifying the original array, for example :- It takes 2 parameter, start and end. Very different from splice. Say we have the following array :- Slice  a = [1,2,3,4,5] a.slice(0,1) [1] // return a.slice(0,2) (2) [1, 2]  a.slice(1,2) (2) [2, 3] a => values stay intact (5) [1, 2, 3, 4, 5] Splice  This function takes portion of the string and change original value of your array. Splice accepts index - which position to start howmany optional item to be added into the list You will also notice that value of a is changed. a.splice(1,2) (2) [2, 3] a (3) [1, 4, 5] It is quite different function.

angular2 http delete with body

To answer your question, angular2 above do not support http.delete with "body". The Http specs didn't agree or disagree. HEre is normally how you do it If you need to send the body, then you need to use http.request method as shown in code below :-