Posts

Showing posts from November, 2018

resolving vscode thenable

vscode Thenable is a promise, we just need to return a promised of a type, as illustrated in code below :- class CodeCompletionItemProvider implements CompletionItemProvider { public provideCompletionItems ( document : vscode . TextDocument , position : vscode . Position , token : vscode . CancellationToken ): Thenable < vscode . CompletionItem []> {              let linePrefix = document . lineAt ( position ). text . substr ( 0 , position . character );              if ( linePrefix . endsWith ( 'std.' )) {                  console . log ( 'great stuff!!!!' );                  // returning thenable //           ...

GitKraken throwing weird exception - unable determine remote when it comes to pull or push

Happen to be one of those weird things that's happening. Probably not GitKraken fault. Whenever i tried to pull or push, I had had error message like :- a) cannot determined remote b) fullname is undefined I suspect this is because I cloned my repo using Sourcetree and then try to push / pull using GitKraken. To resolve this I abandon my repo and reclone using GitKraken. After that I don't faced any issues.

Vscode : Extension is not compatible with Code 1.17.0

Image
Bump into this issue the other day and i wasn't able to fire up my 'Hello world' extension after running "Yo Code". By going to "Help->Update and Restart" resolve it for me. Hope this helps.

Docker - environment variable during build

Yes it is quite possible to set environment variable during build , Example snippet from Dockerfile, RUN cd c:\app; .\some.install --version $($env:CLIVERSION) If you notice code above, you can immediately tell that , $($env:VERSION)  is the variable.  So when we  run it we do something like :- docker build -t  netcorebuilder --build-arg VERSION=1.0.19

hadoop on docker as a single cluster

Image
Start your instance by running the following command :- docker run -it sequenceiq/hadoop-docker:2.7.0 /etc/bootstrap.sh -bash or docker run -it -p 50070:50070 sequenceiq/hadoop-docker:2.7.0 /etc/bootstrap.sh -bash You can browse using the following url http://192.168.99.100:50070/explorer.html#/ Next, run the following commands :- >docker run -it -p 50070:50070 -v c:/tmp/hive:/hive sequenceiq/hadoop-docker:2.7.0 /etc/bootstrap.sh -bash For docker toolbox you might need to run the following command :- docker run -it -p 50070:50070 -v /hive:/hive sequenceiq/hadoop-docker:2.7.0 /etc/bootstrap.sh -bash To submit jobs $HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.0.jar grep input output 'dfs[a-z.]+' $HADOOP_HOME/bin/hdfs dfs -cat output/* Turning on Hive (this step is optional) To enable Hive,  Please download and install Hive (basically extract it - :) to c:/tmp/hive (the comm...

docker push - server gave HTTP response to HTTPS client

Image
If  you're getting this when trying to push a docker image, most likely you need to enable insecure registry (in my case) or register a docker registry. Goto Docker -> Settings and then under the Daemon tab, enter your insecure registry. In my case it is 192.168.55.93 And then you should be able to work your magic.
https://github.com/kripken/lzma.js To build, run doit.sh. ~/Dev/emscripten/emcc -O2 lzip/lzip-full.bc -o lzma-full.raw.js ~/Dev/emscripten/emcc -O2 lzip/lzip-decoder.bc -o lzma-decoder.raw.js

getting started with enscripten

Please make sure you have python 2.7 above installed in your computer. And git too. git clone https : // github . com / juj / emsdk . git Next, type python to make sure you have it your path.  cd emsdk e msdk.bat install latest emsdk activate latest If you type emcc on your command prompt you should be able see some program running asking for file input. This file is located inside the following path :- emsdk\emscripten\1.38.20 Save the following into a file called test.c /* * Copyright 2011 The Emscripten Authors . All rights reserved . * Emscripten is available under two separate licenses , the MIT license and the * University of Illinois / NCSA Open Source License . Both these licenses can be * found in the LICENSE file . */ #include int main () { printf ( "hello, world! \n " ); return 0 ; } Next compile it using the following command :- emcc test.c -o test\hello.html Si...

setting up local docker registry

Normally i thought this is going to be difficult process. But turns out to be easy as, docker run -d -p 5000:5000 --restart = always --name registry registry:2 From this point onward, your registry is already setup. So it is just working with docker images by pulling, tagging and pushing it. docker tag ubuntu:16.04 localhost:5000/my-ubuntu the only part you have to get it right is tagging with localhost:5000/ docker push localhost:5000/my-ubuntu That's it, we're done. (your can try to browse your docker repo with a browser example, :- http://localhost:5000/v2/_catalog) Testing it out  Remove all our local images $ docker image remove ubuntu:16.04 $ docker image remove localhost:5000/my-ubuntu Lets try pulling it from our registry. docker pull localhost:5000/my-ubuntu That's ways easy.

c# 8 - new constructs

Nullable reference type  String and other reference type can be assigned null value. string ? s = null; // Ok New Switch statement  I really like the switch statement. This is more compact var area = figure switch { Line _ => 0 , Rectangle r => r.Width * r.Height, Circle c => Math.PI * c.Radius * c.Radius, _ => throw new UnknownFigureException(figure) }; Async streams Working with streams of data used to be like this :- async Task< int > GetBigResultAsync() { var result = await GetResultAsync(); if (result > 20 ) return result; else return -1 ; } Now, it supports full async async IAsyncEnumerable< int > GetBigResultsAsync() { await foreach (var result in GetResultsAsync() ) { if (result > 20 ) yield return result; } } Range (..) and from end operator ^ Now we can write int [] a = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }; i1 = 3 //...

Building infernojs

Infernojs is mostly written in typescript. To get started building infernojs, close the repo using the following command git clone https://github.com/infernojs/inferno.git Then npm instal l and finally (this will build all the artifacts) npm run-script build Then if you look under infernojs\packages\inferno\dist, this is where your inferno.js is located after build

Using rakt on docker

Image
This is a bit confusing but i am running on windows, so this is me trying to try out rocketd contianer. You can run docker images using rocket but that's another story. Anyways to get started, you need to use docker to install fedora (and some other Linux distribution - ubuntu is not one of them) and install rocketd container. dnf install rkt 76 M - that's not too bad. To experiment it, try running a redis docker image on rocketd container. rkt --insecure-options=image run docker://redis Some useful command are : rkt image list rkt list --full - list currently running pods rkt status   rkt enter (allows me to enter into the pods shell for exploration activities - kinda list this) rkt fly (nobody know what this does - LOL )

git updated last commit message

If you're trying to modify git messages, then the following command comes in handy :- git commit --amend -m "new comment message" Forces a push to  remote branch git push --force

netcore - specifying specific assembly version to use

In Netcore you typically use  PackageReference    order to force a specific version of dll to be used by your project. It might look like configuration below :-        

Roslyn analyzer - Getting Could not load file or assembly … An attempt was made to load a program with an incorrect format

Bump into this issue while trying to deploy my analyzer to Visual Studio projects and i was wondering what is going on. I guess this is a problem happens across all project. My Visual Studio is running x86 while my build target x64. D'oh... i know right. :) The solution? Right click on your project -> Build -> Platform Target ->  Any CPU That's it! :)

vs2017 - getting code coverage analysis

Image
You can get lost in a 'sea of code' when it comes to writing unit test. You can be effective, if you know which code gets covered. To get this statistic, goto Test -> Analyze Code Coverage -> All Test You should get a Code Coverage Results tab that lets you choose which code to target, drill down and write up your test cases.

js :- replacing require() with es6 import

Been working on this for quite some time, finally was able to pen this down. How do you replace 'require(some-library-file)' construct with import. Say you have older javascript module that looks like this :- // test.js function Hello ( name ) { console . log ( 'hello' + name ) } module . exports = Hello ; Then we can import this as shown in code below :- // main.js import * as MyHello from './test' ; import * as m from 'mongodb' ; var greeting = MyHello ( 'test' ); The output you will be getting is : hellotest

Getting started with storybook

Imagine codepen.io, jsfiddle and now imagine you have that in your local development machine. Yeap that's pretty much what's storybook is all about. It gives you a playground to work with React, Vue, Html and etc and its pretty cool. Get started with html, npx - p @storybook/cli sb init --type html If you need to get stared with React, you can follow this guide here .  I think the add-on gallery is pretty cool. Some add-on ideas. - Preview for mobile and responsive component. Not forgetting React Native support. - See component loading and profiling loads - Convert to actual react component -> Typescript, JS  and also with smart / dumb component features.

.netcore - (for all .net version i suppose) getting 'TestMethodAttribute' could not be found

After i create my ms test unit project, i am getting this error. I think this happens whenever you have new package references. "'TestMethodAttribute' could not be found" Ms Unit test project, just fail to build. So i found out that even "dotnet restore" is not working. This is due to my nuget configuration which errored and is not valid locally. So i remove it and i was able to build successfully.

sourcetree - squashing commits.

Image
First up, you gotta be 'connected/tracked/commited' intial changes to your git repo before starting. To do squashing using sourceree, try right clicking your commit graph and then select ' rebase interactively '. Then drag a commit over to another commit, as shown in diagram below :- Once you're done, change your commit message accordingly and then you're good to push those changes remotely.

ms build target file - what is the purpose again?

Suppose you wanna introduce a environment build variable, you need to go through all your csproj to make modifications. With targets, you can define in a single file and it gets 'recognized' by all other csproj files.

Compilation issue "SkipNonExistentTargets"

After installing .net 2.1.0 core framework, I have this issue. All you need to do is right click your project -> Properties -> Uncheck generate package. Or update your VS 2017's update to the latest version.

cool nuget install cli - quick and fast way to get data

One of the cool way  to use nuget cli is "nuget get" -how many get you going to type. :) Anyways, it gives a quick way to get some assemblies into your current folder. Not packages but current. For example, if you  run :- nuget install System.Collections.Immutable -Version 1.3.1 You get a "System.Collections.Immutable -Version 1.3.1" folder created for you. 

Msbuid : CSC : warning CS8032: An instance of analyzer be created. Could not load file or assembly 'Microsoft.CodeAnalysis, Version

I was creating analyzer for .net core project and bump into this error when i tried to use MSBuild to do my builds. No problem when i do "dotnet build". Anyways, a workaround for this issue is to install this package into your target project. I am using 2.6.1 but other version might work for you. This also resolve messages coming from VStudio. Install-Package Microsoft.Net.Compilers -Version 2.6.1 

Roslyn - Packaging your analyzer

Update : If you find yourself doing this, you are probably not using Extensibility template (Analyzer + VSix solution). In that case, please take some time before you go down this "rabbit hole". There are 2 ways you can package your anaylzer as nuget package. I am assuming you are trying to deploy this as .Net standard. I specifically target Net 1.3 standard. Analyzers are packaged differently, as we are required to place it under, \analyzer\dotnet\cs folder.  1. csproj - you need to add this in your solution file. (Notice i change my packagePath="" = empty string, if you deploy to .netcore project, it is all good. If you try to deploy to .net framework, you might not be able to install it.       And not forgetting - this basically omit generation of dll. If you don't do this, your analyzer will be installed as any dll package instead of anaylzer. 2. nuget (will cover this later, till then try reading it from https://roslyn-analyze...

Kubernetes - setting up simple nginx service

Image
This tutorial shows you how to deploy nginx and then expose the service (making it accessible) in minikube. Your image will display "welcome to nginx" if you hit the main page as shown below :- Here is an example of a deployment yaml. Let's say we call this app.yaml.  First we run the following command :- kubectl create -f app.yaml Next, kubectl expose deployment nginx --type = LoadBalancer To find out more info about  your service :- kubectl get services or  kubectl describe service nginx-service You will see that external ip status is . In Minikube, you can access this service by using the following command :-  minikube service nginx https://kubernetes.io/docs/tutorials/hello-minikube/

Getting error - "Failed to start the virtual machine 'MobyLinuxVM' because one of the Hyper-V components is not running"

Despite having my hypervisor installed and running, i am still getting this error. Tried installing with the latest version of docker for windows. Then i found this powershell cmd from stackoverflow which help me get my docker up and running. Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -Verbose Enable-WindowsOptionalFeature -Online -FeatureName Containers -All -Verbose Very important, please right click on your docker and restart it.

Working with roslyn to parse the statement correctly.

Image
One of the indispensable tool that helps in constructing / parsing statement using Rosyln is Syntax Tree's Syntax Graph. THE HARD WAY Lets's say you have the following codes :- var myDate2 = new DateTime(); This is easy to write but to do it from Rosyln, there's quite abit of work. To help you understand what to do is using Syntax Tree's Syntax Graph and SyntaxFactory. From here, you get an idea of what to do .... .To build this using roslyn, use this piece of code. THE FAST WAY  Goto http://roslynquoter.azurewebsites.net/ and paste your code and then click "Get Roslyn API to generate this code.

Roslyn : - SyntaxFactory.InitializerExpression

If you're getting exception using SyntaxFactory.InitializerExpression, that's because you need to pair it with one and only one 'Kind' .... SyntaxFactory.InitializerExpression(SyntaxKind.ObjectInitializerExpression);