Free certificates / Godaddy SSL

Posted on Actualizado enn

1.-Create free certificates

2.-Download openssl https://code.google.com/archive/p/openssl-for-windows/downloads I downloaded the openssl-0.9.8k_X64.zip and copied openssl.exe / libeay32.dll / ssleay32.dll to my folder with ca_bundle.crt / certificate.crt / private.key the ran (like administrator) this:

I copied to a new folder these files: libeay32.dll, openssl.exe, ssleay32.dll and ca_bundle.crt, certificate.crt, private.key from the sslforfree.zip and next command will give me mysite.com.mx.pfx

  • c:\something>openssl pkcs12 -export -out aeinmobiliaria.com.mx.pfx -inkey private.key -in certificate.crt
  • And enter a password
  • and in Azure, custom domains http://www.aeinmobiliaria.com.mx and aeinmobiliaria.com.mx / CNAME>

 

3.-Then go to azure, in appservice/ssl certificates upload certificate (the pfx just created) and then add a binding to:

Captura

 

  • hostname: mysite.com.mx (with and without www)
  • certificate: mysite.com.mx (51……6E)
  • Ssl type: sni ssl

https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-ssl

  • so I had to include in godaddy
Edit
  • That is it

more useful links

ssl checker

https://www.sslshopper.com/ssl-checker.html#hostname=https://aeinmobiliaria.com.mx

tcp connection / pings

https://check-host.net/check-tcp?host=aeinmobiliaria.com.mx:443

Using cloudflare.com even in the free version you can use their ssl cert, some useful links…

https://www.troyhunt.com/how-to-get-your-ssl-for-free-on-shared/

http://wp.sjkp.dk/use-free-letsencrypt-ssl-certificate-with-azure-web-apps/

https://docs.microsoft.com/da-dk/azure/app-service-web/web-sites-custom-domain-name

Anuncios

Using Visual Studio 2015 and Deploying your first web app to your FREE Azure Subscription

Posted on

When you forget how to deploy to azure, a good link 🙂

https://blogs.msdn.microsoft.com/uk_faculty_connection/2015/07/20/using-visual-studio-2015-and-deploying-your-first-web-app-to-your-free-azure-subscription/

Design patterns

Posted on Actualizado enn

Design patterns are solutions to software design problems you find again and again in real-world application development. Patterns are about reusable designs and interactions of objects.

The 23 Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural, and Behavioral (for a complete list see below).

  • CREATIONAL PATTERNS
    • Abstract factory *
    • Builder
    • Factory Method *
    • Prototype
    • Singleton
  • STRUCTURAL PATTERNS
    • Adapter *
    • Bridge
    • Composite *
    • Decorator *
    • Facade
    • Flyweight
    • proxy
  • BEHAVIORAL PATTERS
    • Chain of responsibility
    • Command
    • Interpreter
    • Iterator
    • Mediator
    • Memento
    • Observer *
    • State
    • Strategy *
    • Template Method *
    • Visitor

*Commons and easiers patters

Singleton (just one instance):

using System;

public class Singleton
{
   private static Singleton instance;

   private Singleton() {}

   public static Singleton Instance
   {
      get
      {
         if (instance == null)
         {
            instance = new Singleton();
         }
         return instance;
      }
   }
}

Strategy

UML class diagram

using System;
 
namespace DoFactory.GangOfFour.Strategy.Structural
{
  /// 
  /// MainApp startup class for Structural
  /// Strategy Design Pattern.
  ///
  class MainApp
  {
    /// 
    /// Entry point into console application.
    ///
    static void Main()
    {
      Context context;
 
      // Three contexts following different strategies
      context = new Context(new ConcreteStrategyA());
      context.ContextInterface();
 
      context = new Context(new ConcreteStrategyB());
      context.ContextInterface();
 
      context = new Context(new ConcreteStrategyC());
      context.ContextInterface();
 
      // Wait for user
      Console.ReadKey();
    }
  }
 
  /// 
  /// The 'Strategy' abstract class
  ///
  abstract class Strategy
  {
    public abstract void AlgorithmInterface();
  }
 
  /// 
  /// A 'ConcreteStrategy' class
  ///
  class ConcreteStrategyA : Strategy
  {
    public override void AlgorithmInterface()
    {
      Console.WriteLine(
        "Called ConcreteStrategyA.AlgorithmInterface()");
    }
  }
 
  /// 
  /// A 'ConcreteStrategy' class
  ///
  class ConcreteStrategyB : Strategy
  {
    public override void AlgorithmInterface()
    {
      Console.WriteLine(
        "Called ConcreteStrategyB.AlgorithmInterface()");
    }
  }
 
  /// 
  /// A 'ConcreteStrategy' class
  ///
  class ConcreteStrategyC : Strategy
  {
    public override void AlgorithmInterface()
    {
      Console.WriteLine(
        "Called ConcreteStrategyC.AlgorithmInterface()");
    }
  }
 
  /// 
  /// The 'Context' class
  ///
  class Context
  {
    private Strategy _strategy;
 
    // Constructor
    public Context(Strategy strategy)
    {
      this._strategy = strategy;
    }
 
    public void ContextInterface()
    {
      _strategy.AlgorithmInterface();
    }
  }
}

Output

Called ConcreteStrategyA.AlgorithmInterface()
Called ConcreteStrategyB.AlgorithmInterface()
Called ConcreteStrategyC.AlgorithmInterface()
Real World

using System;
using System.Collections.Generic;

namespace DoFactory.GangOfFour.Strategy.RealWorld
{
  ///
  /// MainApp startup class for Real-World
  /// Strategy Design Pattern.
  ///

  class MainApp
  {
    ///
    /// Entry point into console application.
    ///

    static void Main()
    {
      // Two contexts following different strategies
      SortedList studentRecords = new SortedList();

      studentRecords.Add("Samual");
      studentRecords.Add("Jimmy");
      studentRecords.Add("Sandra");
      studentRecords.Add("Vivek");
      studentRecords.Add("Anna");

      studentRecords.SetSortStrategy(new QuickSort());
      studentRecords.Sort();

      studentRecords.SetSortStrategy(new ShellSort());
      studentRecords.Sort();

      studentRecords.SetSortStrategy(new MergeSort());
      studentRecords.Sort();

      // Wait for user
      Console.ReadKey();
    }
  }

  ///
  /// The 'Strategy' abstract class
  ///

  abstract class SortStrategy
  {
    public abstract void Sort(List<string> list);
  }

  ///
  /// A 'ConcreteStrategy' class
  ///

  class QuickSort : SortStrategy
  {
    public override void Sort(List<string> list)
    {
      list.Sort(); // Default is Quicksort
      Console.WriteLine("QuickSorted list ");
    }
  }

  ///
  /// A 'ConcreteStrategy' class
  ///

  class ShellSort : SortStrategy
  {
    public override void Sort(List<string> list)
    {
      //list.ShellSort(); not-implemented
      Console.WriteLine("ShellSorted list ");
    }
  }

  ///
  /// A 'ConcreteStrategy' class
  ///

  class MergeSort : SortStrategy
  {
    public override void Sort(List<string> list)
    {
      //list.MergeSort(); not-implemented
      Console.WriteLine("MergeSorted list ");
    }
  }

  ///
  /// The 'Context' class
  ///

  class SortedList
  {
    private List<string> _list = new List<string>();
    private SortStrategy _sortstrategy;

    public void SetSortStrategy(SortStrategy sortstrategy)
    {
      this._sortstrategy = sortstrategy;
    }

    public void Add(string name)
    {
      _list.Add(name);
    }

    public void Sort()
    {
      _sortstrategy.Sort(_list);

      // Iterate over list and display results
      foreach (string name in _list)
      {
        Console.WriteLine(" " + name);
      }
      Console.WriteLine();
    }
  }
}
Output
QuickSorted list
Anna
Jimmy
Samual
Sandra
VivekShellSorted list
Anna
Jimmy
Samual
Sandra
VivekMergeSorted list
Anna
Jimmy
Samual
Sandra
Vivek

AWS/azure (ubuntu) + Docker + Nodejs + Loadbalancer

Posted on Actualizado enn

  • Installing Docker in Ubuntu
    • In ec2(aws)/virtualmachine(azure) create a ubuntu server
    • Login to console using bitvise (ubuntu/publickey/global3[yourkey]), in Azure you can use a password too.
    • $ sudo apt-get update # Fetches the list of available updates
      $ sudo apt-get upgrade # Strictly upgrades the current packages
      $ sudo apt-get dist-upgrade # Installs updates (new ones)
    • $ sudo curl -fsSL https://get.docker.com/ | sh
    • $ sudo docker version
      • optional: down a hello image and run (copy to local)
      • $ sudo docker run hello-world
    • list image / containers
    • $ sudo docker images  / sudo docker ps -a
    • Create the image to upload to docker hub
  • NodeJS – server.js
var express=require('express')
var PORT=8080;
var app = express();
app.get('/', function(req,res){
	res.send('hi mother');
});
app.listen(PORT);
console.log('running on local '+PORT);
  • NodeJS – Package.json to configure needs
{
  "name": "hello",
  "version": "1.0.0",
  "main": "server.js",
  "author": "hemc",
  "description": "",
  "dependencies": {
    "express": "^4.15.2"
  }
}
  • Dockerfile (without extensión)
FROM node:6.9.4
EXPOSE 8080
WORKDIR /app
RUN npm install nodemon -g
COPY package.json /app/package.json
RUN npm install
COPY server.js /app
CMD ["nodejs", "/app/server.js"]
    all 3 in same folder, for example
  • Then we build the container image with a user to upload to dockerhub, local image name:
  • ~/nodeHello$ sudo docker build -t minode/test4 .  (point at the end)
  • Upload to docker hub
    • $sudo docker run -it minode/test4
      • new console
    • $sudo docker ps -a
      • containerid my user on dockerhub web image name
    • $sudo docker commit e1078f8d0cfb minode/onlinetest4
    • $sudo docker run -it minode/onlinetest4
      • uploading
    • $sudo docker login –username=minode
      • +password
    • $sudo docker push minode/onlinetest4

=============docker aws===============

  • Create cluser
    • t2 micro / instances 2 / key pairs (your keys) / port range 8080
  • Create task
    • default values
    • create container
      • default + minode/test4
  • Create service (back to cluster first tab)
    • numtask=4
  • Review EC2 / instances, verify inbound rules are port 8080 open
  • Verify ip:8080 of two instance
  • Loadbalancer
    • select vpc with access to zone where the instances are placed, security group with port 8080 open a follow loadbalancer classic tutorial
  • Delete cluster
    • Delete cluster in main page
    • Go inside task two times and desregister task
    • Delete load balancer and verify instances are deleted
  • To delete images
    • $ sudo docker rmi

Part 1


Part 2


Part 3


Part 4

(by the way, mute the videos, I was listening spain radio)

Reference

http://www.ybrikman.com/writing/2015/11/11/running-docker-aws-ground-up/

https://aws.amazon.com/es/getting-started/tutorials/deploy-docker-containers/

https://nodejs.org/en/docs/guides/nodejs-docker-webapp/

https://community.risingstack.com/deploying-node-js-microservices-to-aws-using-docker/

 

You can login into container with:

docker exec -it bash
and run:

apt-get update
apt-get install nano

Docker images are delivered trimmed to bare minimum – so no editor is installed with the shipped container. That’s why there’s a need to install it manually.

To show only running containers use:
docker ps
To show all containers use:
docker ps -a

docker nodejs

Posted on Actualizado enn

/////running nodejs like service////

sudo npm install forever -g
sudo ln -s "$(which nodejs)" /usr/local/bin/node

forever start server.js

forever stop server.js

http://stackoverflow.com/questions/12701259/how-to-make-a-node-js-application-run-permanently

http://stackoverflow.com/questions/4018154/node-js-as-a-background-service

http://stackoverflow.com/questions/30281057/node-forever-usr-bin-env-node-no-such-file-or-directory

http://www.slidequest.com/q/70ang

//////

graph android http://stackoverflow.com/questions/9741300/charts-for-android

http://mayankj00.blogspot.mx/2014/01/using-holograph-library-for-your.html

https://bitbucket.org/danielnadeau/holographlibrary/src/0b41d14f5724c8df3bdd2d64fa039dc531230d33/HoloGraphLibrarySample/res/values/dimens.xml?at=master&fileviewer=file-view-default

https://github.com/EddieRingle/HoloGraphLibrary/blob/master/sample/src/main/java/com/echo/holographlibrarysample/BarFragment.java

///

  • install docker
  • verify installation
    • $ sudo docker version
  • First container
    • $ sudo docker run hello-world
  • list containers
    • $ sudo docker ps -a
    • [containderid / ports / image / name / command / created / status]
  • Docker hub
  • Dockerfile
    • FROM node:6.9.4
      EXPOSE 8080
      WORKDIR /app
      RUN npm install nodemon -g
      COPY package.json /app/package.json
      RUN npm install
      COPY server.js /app
      CMD [“nodejs”, “/app/server.js”]
      #sudo docker build -t minode/node-web-app .
    • minode is your username in hub.docker.com
    • $ cd <your project directory>
      $ sudo docker build -t minode/node-web-app .
      #          ^    ^                     ^
      #        build  w/ tag            this directory
      
      # ... lots of output
  • Docker images
    • $ sudo docker images
    • $ sudo docker run -p 3000:8080 -d minode/node-web-app
    • [$ sudo docker run -it –rm –name myrunningapp minode/node-web-app 3000:8080]–rm remove container when exist
    • $ sudo docker ps
$ docker run -p 4500:4500 minode/node-web-app
#               ^^^^^^^^^
#          bind the exposed container port to host port (on the virtual machine)
  • Docker stop / start
    • $ sudo docker stop <CONTAINER ID>
    • $ sudo docker start <DOCKER NAME> –you can see that with sudo docker ps
  • deleting container, drop all info
    • $ sudo docker rm <drupal1>
  • publish
    • $sudo docker build -t “your_user_name/myapp” .
    • $ docker push <your_user_name/myapp>  / minode/node-web-app

 

 

sudo docke

 

/////////

$sudo docker run –name mynode -t -i node

Easy and simple hello world nodejs / express + pug

Posted on Actualizado enn

hello nodejs

file: server.js
var express=require('express')
var PORT=8080;

var app = express();
app.get('/', function(req,res){
res.send('hi mother');
});

app.listen(PORT);
console.log('running on local '+PORT);

//////////////////////////////////////////////

file: package.json

{
"name": "hello",
"version": "1.0.0",
"main": "server.js",

"author": "hemc",
"description": "desc",
"dependencies": {
}
}

/////////////////////////////////////////////
$npm install express
////////////////////////////////////////////
nodejs server.js
////////////////////////////////////////////
that’s it

open localhost:8080 or your ip:8080

//////////////////setting pug////////////////

package.json

{
"name": "restful-auth",
"main": "server.js",
"dependencies": {
"body-parser": "^1.9.3",
"express": "^4.9.8",
"jsonwebtoken": "^7.3.0",
"jwt-simple": "^0.3.1",
"mongoose": "^4.2.10",
"morgan": "^1.5.3",
"passport": "^0.3.0",
"passport-jwt": "^1.2.1",
"request": "^2.81.0",
"pug": "^2.0.0-beta.12",
"yelp": "^1.0.2"
}
}

server.js

var express 	= require('express');
var app         = express();
var port = process.env.PORT || 8080; // used to create, sign, and verify tokens
//
app.set('view engine','pug');

app.get('/signin',function(req,res){
res.render('template',{title:"Registro",message:"Página ejemplo de registro",id:"signin"});
});
app.get('/recoverypass',function(req,res){
res.render('template',{title:"Recupera contraseña",message:"Página ejemplo de recuperación contraseña",id:"recoverypass"});
});
//
app.listen(port);
console.log('Magic happens at http://localhost:' + port);

//views/template.pug

doctype html
html(lang="es")
  head
    title= Bienvenido
  body
    h1= message
    div
        ul
            li Por favor realice los pasos indicados
    label(for="ourname") Usuario
    br
    br
    input(name="ourname",type="text",id="ourid",placeholder="Usuario")
    br
    br
    if(id=="signin")
        label(for="ourname") Contraseña
        br
        br
        input(name="ourname2",type="password",id="ourname2",placeholder="Contraseña")
        br
        br
    input(value="Enviar",type="submit",id="submit")

complete