Posts

Installing 2.3.3 Ruby + Rails without tears

Image
To install Ruby 2.3.3, you have to install DevKit.

For 32-bit system follow instructions below :-
a) install Ruby 2.3.3 

b) download and unzip DevKit

c) Fire up your command prompt, make sure Ruby is in your PATH. Go to the folder that you unzip DevKit, Execute the following command : - ruby dk.rb init and ruby dk.rb install

d) From the command line, type gem install rails



You're done! :)



For 64-bit, please following instruction below:
a) Download Ruby from here.

b) Download and unzip DevKit.

c) Fire up your command prompt, make sure Ruby is in your PATH. Go to the folder that you unzip DevKit, Execute the following command : - ruby dk.rb init and ruby dk.rb install

d) From the command line, type gem install rails



Some typescript key takeaways

1. A module can only have a single default export. Yes only one. Please don't try to use multiple. There is no workaround.

2. You can export a class / interface like this :-

export = ZipCodeValidator;

3. And import it using 

import zip = require("./ZiCodeValidator");

4. Optional loading

Yes, you can define optional loading but Typescripts does this for you automatically. In nodejs, require.js or system.js, you might have to do it manually.

5. Working with other javascript libraries

This gotta sounds catchy...

6. Generator functions

You can have multiple yield statement like so.

function* generateIt()
{
   yield 1;

  yield 2;

  yield 3;

}

var myvar = generateIt()

To pass a value to your generator function.

let myfunc  = generateIt();
myfunc.next().value;   // return 1










docker remove all process

Best command of the day


docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)

Using R studio with TensorFlow

Check out this link if you're interested to learn more about tensorflow with R studio.

https://rstudio.github.io/tensorflow/

To install it, just type the following command

install.packages('tensorflow')

It also comes with a cool tutorial on MNIST (a tutorial for digit recognition)


Writing your WAMP Server and client in .net using WampSharp

Image
WAMP server basically allows you to use RPC and web socket to talk to your client. Yeap, you can use standard HTTP like GET/POST as long as you defined those on the server.

All rite just to keep things sweet and simple, let see how a simple server code looks like :-





Client code looks like this :-




Run both code on a separate C# console app, and you will get something like below :-



service designer guide for http status - check this out !!! :)

Image

Angular2 - No http post or get until you call subscribe.

Sometimes rxjs can be so lazy. Nothing happens until you call 'subscribe'.

When you are making a http request get or post, you might find out that there's no outgoing http request. Does the code below looks familiar, well..... you will get it if you call subscribe.  :/ This is a gotcha for many people.

Javascript / Typescript rest and spread operators

To make it easier, rest and spread operator basically helps to merge all your function parameter together. In the past, we use something like

myfunction.apply(null, myAgumentList)

With rest and spread we can easily

function log(...a) {
   console.log(a);
}

log(1,2,3,4,5); // outputs [1, 2, 3, 4, 5] array

Notice we're assigning myArguments at the back. 

let myArguments = ['x', 'y', 3]

log(1,2, myArguments); // outputs [1, 2, ['x', 'y', 3]] 2 different array 

log(1,2, ...myArguments); // outputs [1, 2, 'x', 'y', 3] 1 array


Notice we're assigning myArguments at the front. 

log(...myArguments,1,2 ); // outputs [ 'x', 'y', 3, 1, 2] essentially a single array.








Angular2 providers with useClass purpose

Might be wondering what is the purpose the useClass construct as shown here
[{ provide:Logger, useClass:Logger}This provides a way for Angular2 to find and use the proper class / providers. Think of it as a key / value matching approach. Some people uses mock logger service by specifying useClass : BetterLogger.