Posts

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 */functionMortal() { owner = msg.sender; } /* Function to recover the funds on the contract */functionkill() { 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 */functionGreeter(string _greeting) public{ greeting = _greeting; } /* Main function */functiongreet() constantreturns (string) { return greeting; } }


To run it, you fire up your geth console.

Then type the followings :-

loadScript("greetcontract.js")      // case sensitive

if you get an error saying  invalid account try…

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 StringHelpera.ToUpper()// 2nd b := new(StringHelper) b.ToUpper()// 3rdc := 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 :-

helming

Image
First of all download your helm version.

To serve your chart locally

helm serve
Normally, your local repository will be here C:\Users\Jeremy\.helm\repository\local on Windows.




You can see that we have a folder call vistio.

To install this chart, simply run :-

helm install local/vistio

Why local? If you type  helm repo list , you can see that the "local" refers to a local repository.

NAME    URL
stable  https://kubernetes-charts.storage.googleapis.com
local   http://127.0.0.1:8879/charts

Please note :- 
helm list repo is not the same as helm repo list , please make sure you type it correctly.