Sunday, June 18, 2017

Angular 4.2.3 getting started

https://angular.io/guide/quickstart

How to install and use CLI : https://github.com/angular/angular-cli/blob/master/README.md

#make sure you have latest version of node and npm
node -v
npm -v

#clean up previous angular-cli installations
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm uninstall -g @angular/cli
npm cache clean

#install latest angular-cli
npm install -g @angular/cli@latest
ng new my-app
cd my-app
ng serve --open



Tour of Heroes https://angular.io/tutorial



Friday, June 16, 2017

funny /etc/hosts behaviour

Someone entered 2 lines in /etc/hosts, specifying the same host and 2 different IPs

cat /etc/hosts | grep myvp.pippo.net

116.8.194.82   myvp.pippo.net 
119.57.52.83   myvp.pippo.net



the funny thing is that:

nslookup myvp.pippo.net 
Name: myvp.pippo.net
Address: 119.57.52.83


but

telnet myvp.pippo.net 443
Trying 116.8.194.82...



so nslookup and telnet don't follow the same strategy to pick up the IP...

At least on Linux 2.6.18-417.el5 RHAT 5.11 Tikanga

Weird that Linux doesn't report the issue...

Thursday, June 15, 2017

byte buddy getting started


I use this pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.pierre</groupId>
  <artifactId>bytebuddytest</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
   <dependency>
    <groupId>net.bytebuddy</groupId>
    <artifactId>byte-buddy</artifactId>
    <version>1.7.0</version>
   </dependency>
  </dependencies>
</project>



and I run this Java code, as from the homepage http://bytebuddy.net/#/

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;
import net.bytebuddy.matcher.ElementMatchers;

public class HelloWorld {
 public static void main(String[] args) throws InstantiationException, IllegalAccessException {
  HelloWorld helloWorld = new HelloWorld();
  helloWorld.testHello();

 }

 public void testHello() throws InstantiationException, IllegalAccessException {
  Class dynamicType = new ByteBuddy().subclass(Object.class).method(ElementMatchers.named("toString"))
    .intercept(FixedValue.value("Hello World!")).make().load(getClass().getClassLoader()).getLoaded();

  System.out.println(dynamicType.newInstance().toString());
 }
}



It works! Exciting!