Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Sunday, August 27, 2017

Swagger and Flask Tutorial

Swagger and Flask Tutorial


Introduction

  • API documentation is important.
  • Coding to Interfaces and Separation of Concerns remain fundamental design patterns
    • Any project involving a great deal of source code and multiple developers will likely fail without proper attention to this design
  • Exposing Functionality is important
    • This conveys and demonstrates progress 
    • In a proper SOA design, functionality is exposed as a series of internal business processes
  • Business Processes are APIs
    • By using Swagger to document the APIs we get an auto-generated user interface that both documents and helps a (somewhat technical) user explore the dialog functionality
    • Any Tester or Business Analyst role should have the skill to navigate a Swagger-generated API, view the documentation, and explore a variety of I/O possibilities



API Documentation in Swagger

You can download swagger locally, but I find it just as easy to use the remote site.
http://editor.swagger.io

Once there, you can create your markup.  There are some useful tutorials in the references section.

Once youve defined your markup, then use the Generate Server option:
Generate a Python Flask app from the YAML markup
This generates a Python Flask application from the YAML markup.


Fixing the Generated Code

There were a few manual fixes I had to make consistently each time I regenerated the flask app.


  1. Each method was generated into a separate python file (<name>_controller.py).  There was a casing issue that I had to correct. 

    The swagger.yaml file had this
    operationId:
    "controllers.Occurences_controller.ups_global_get"

    and I had to change that to this:
    operationId:
    "controllers.occurences_controller.ups_global_get"

    in order to correspond to the actual casing of the python file.
  2. Likewise, the generated code was initially configured to run the swagger UI on port 80 and the operations on port 8080. 

    This caused some trouble, as the endpoint operation couldnt figure out which port to use when.

    It became a lot easier when I changed this line from
    host:
    "localhost"
    to
    host:
    "localhost:5000"
    and alter app.py to run on 5000 as well:
    app.run(port=5000)
  3. The generated code needs some changing:

 Im using Python 2.7.12 :: Anaconda 4.1.1 (x86_64) on OS X 10.11.6 (15G1108).



    Running the App

    By going to this URL
    http://localhost:5000/dialog/ui/

    I saw this screen


    I could then expand operations, find the single operation I had documented:



    and execute a simple test.


    References

    1. Swagger Tutorial
    2. Online Swagger Editor

    download file now

    Read more »

    Friday, August 11, 2017

    Summary of “A Tutorial Survey on Vehicular Ad Hoc Networks”

    Summary of “A Tutorial Survey on Vehicular Ad Hoc Networks”


    The concept of using wireless communication to provide safety and comfort in vehicles has appeared since 1980s. In the last few years, the research in this field shows a large increase because of these reasons:

    1. Adaptation and decreasing cost of IEEE 802.11 technologies
    2. The embrace of vehicle manufactures of information technology to provide safety and comfort
    3. The commitment of large government to allocate wireless spectrum for VANET communication

    The main goals of VANET summarized as follow:
    1. Road safety
    2. Transportation efficiency
    3. Reduce the impact of transportation on the environment

    One-hop broadcast communication plays an important role to provide information for safety-related applications. For this reason, two different messages are used as follow:
    1. Event-driven (DEN)
    are sent when an hazardous event happens.
    1. Periodic (CAM)
    are sent periodically to inform the surrounding cars about the cars knowledge such as: geographical position, speed, acceleration and so on. It is suggested that these messages send 10 times per second with maximum latency of 100ms and minimum range of 150 m.

    Unfortunately, using broadcast communication causes that we can not use the predefined schemes in IEEE 802.11 to alleviate the collision among the contending nodes. In this case, schemes like RTS/CTS and ACK packets cause more collisions. As a result, IEEE 802.11 converts to a simple CSMA scheme for broadcast communication. Therefore, well-known problem of hidden and exposed terminals is problematic and must be revised. Because the periodic messages overloaded the control channel, adaptive transmit power and rate control are required.

    1. The main challenges of VANET is as follow:
    2. No central communication coordinator or handshaking protocol
    3. The necessity of on shared control channel to broadcast each cars knowledge to the surroundings
    4. Dynamic network topology
    5. Diversity of network traffic density

    download file now

    Read more »

    Monday, April 13, 2015

    Tutorial Trocando a roupa das sims grávidas com o Master Controller no The Sims 3

     
    DESCRIÇÃO:
    Muitos jogadores não gostam e se incomodam com as roupas das grávidas no The Sims 3, realmente as roupas das sims são feias e você não consegue trocar enquanto elas estão grávidas, aqui vamos ensinar à vocês como trocar a roupa das sims grávidas com o mod Master Controller, é muito fácil!



     
    Primeiramente, deixaremos claro que é possível planejar a roupa das grávidas antes da barriga aparecer. Quando a sim ainda estiver com os sintomas de enjoo desconhecido você pode ir no armário e planejar a roupa dela.
    OBS: Todas as roupas femininas da expansão Gerações são compatíveis com a gravidez das sims, mas mesmo assim depois que a barriga aparecer não será possível trocar sem usar mod.


     
    Se sua sim já está grávida e você não planejou antes a roupa, será necessário baixar esse mod: Master Controller 
    (link direto para patch 1.55, acesse aqui para baixar da sua atual versão, requer somente o Base-Mod)
    Instale o mod como um package normal (clique aqui se não souber instalar arquivos packages).

     
    1° Passo: Clique na sua sim e em seguida em NRaas.

     
    2º Passo: Depois clique na opção Master Controller.

     
    3° Passo: Em seguida irá aparecer uma janela com várias opção, entre elas escolha a opção "Básico".

     
    4° Passo: Novamente irá aparecer uma outra janela e nela clique na opção "Roupa".
    5° Passo: Em seguida uma janela com todas as suas roupas planejadas (anteriormente) irão aparecer, (todas as suas roupas normais de antes), é só clicar e escolher a roupa que deseja usar no momento.

     
    6° Passo: Note que algumas roupas irão fazer a barriga da sim não aparecer, por isso recomendamos que baixe roupas que são compatíveis com a gravidez.

     
    OBS: Roupas de banho personalizadas - em sua maioria - funcionam, mesmo quando não são ditas como compatíveis com a gravidez.

    Divirta-se!

    Créditos: Downs Sims 3
    Mod: NRaas Industries
    Read more »