Blog

  • WinChatTCP

    WinChatTCP

    WinChatTCP

    Aplicativo de chat usando Sockets TCP

    Este é um aplicativo de chat simples para sistemas operacionais Windows, baseado no conceito de cliente-servidor, que permite que vários usuários se conectem a um servidor de chat e troquem mensagens em tempo real.

    Funcionalidades

    • Definir um host como servidor de chat
    • Definir uma porta de sua preferência
    • Conectar-se ao servidor do chat usando o IP e a porta especificada
    • Enviar mensagens de texto para todos os usuários conectados
    • Visualize hosts conectados e desconectados no servidor de chat

    Desenvolvimento

    A aplicação foi construída na linguagem de programação C e compilada com o TDM-GCC da IDE Dev-C++, utilizando a API Win32 e a biblioteca Winsock.

    Uso

    1. Compilar os arquivos server.c e client.c, de preferência usar as mesmas ferramentas que utilizei em Desenvolvimento.

    2. Após a compilação, inicie o executável Server.exe e insira uma porta de sua preferência. Feito isso, o servidor do chat estará pronto.

    3. Agora que o servidor está pronto, inicie o executável Client.exe em qualquer host Windows da mesma rede, insira o IP do servidor e a porta que foi especificada nele (do host que está rodando o Server.exe) nos campos correspondentes e clique em “Connect” para conectar-se ao servidor.

    4. Quando conectado ao servidor, os campos “Username” e “Message” serão liberados, sendo possível inserir um nome de usuário e o envio de mensagens de texto.

    5. Todas as mensagens enviadas e recebidas aparecerão na caixa de “Chat” para todos que estão conectados na mesma rede do servidor do chat.

    Observação: todos os hosts devem estar na mesma rede local para que funcione.

    Visit original content creator repository https://github.com/fgomesx/WinChatTCP
  • Javascript_clock_and_date

    #JavaScript Clock and Date

    #Synopsis —

    this is a simple JS clock and Calander project i put togethor to keep time on on my website Yusifelawawdeh.com
    its two javascript functions in date.js that outputs the date to the div id (dateDisplay) and the current clock
    time to another div id (timeDisplay). so that the date and time can be put on different parts of my portfolio site.
    The code runs in the page when you include the { onload=”updateTime();” } attribute in the body tag. it is also important to specify
    which divs with the proper ID attribute in order for the time and date to render in place. I’ve included some CSS so as to show
    that the clock and calander can be influenced stylisticly with css nothing else, its not required it just looks nice.

    to reiterate this simple clock and “calander” is all javascript so it can be copied and put as an inline script or be called from the date.js
    file, no need for anything special from css. on requirements are that you specify onload and ID attribute.

    #Code Example —

    function updateTime(){

    //Date year – month – day
    var myDate = new Date();
    var year = myDate.getFullYear();
    var month = myDate.getMonth();
    var day = myDate.getDay();
    var daym = myDate.getDate();
    var dayarray = new Array (‘Sunday’, ‘Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’);
    var montharray = new Array (‘January’,’Febuary’,’March’,’April’,’May’,’June’,’July’,’August’,’September’,’October’,’November’,’December’);
    //Date year – month – day

    // Hour – Minute – Second
    var myTime = new Date();
    var hour = myTime.getHours();
    var minute = myTime.getMinutes();
    var second = myTime.getSeconds();
    hour = checkTime(hour);
    minute = checkTime(minute);
    second = checkTime(second);
    // now is 24 hour clock

    // current spliced togethor
    var currentDate = ” + dayarray[day] + ‘ ‘ + daym + ‘ ‘ + montharray[month] + ‘ ‘ + year;
    // current 24hr spliced togethor
    var currentTime = setTimeout(updateTime, 500);

    //get date div
    var myClock = document.getElementById(‘dateDisplay’);
    //get time div
    var myWatch = document.getElementById(‘timeDisplay’).innerHTML = hour + ‘:’ + minute + ‘:’ + second;

    //write current date as string to div
    myClock.innerHTML = currentDate;

    }
    function checkTime(i){
    if (i < 10) {i = “0” + i}; // adds a 0 infront of numbers less than 10
    return i;
    }

    #Motivation —

    I had a need to impliment The Date and the time seperatly on my portfolio, so i made this Javascript “snippet” if you will, to solve
    that problem. Its available on git hub because, i know its not the prettiest or best coded solution to my problem. However since
    i’m learning and applying things as i go, i figuered i’d let other developers or folks take a look at this code and set me straight
    if ive made any mistakes or if i could have done this project better.

    #Installation —

    Steps listed below

    Step 1 : download / clone the Repo to desktop

    Step 2 : Extract zip or rar

    Step 3 : copy date.js to your js folder in your project

    Step 4 : open your index.html or other associated html file

    Step 5 : copy and paste the script tag below the end or top of your html doc

         <script type="text/Javascript" src="https://github.com/Yusifelawawdeh/js/date.js"></script> 
    

    Step 6 : copy and paste the attribute below into your body tag

        onLoad="updateTime();"
    

    Step 7 : copy and paste the ID below into the tag you want to display date

        id="dateDisplay"
    

    Step 8: copy and paste the ID below into the tage you want to display time

        id="timeDisplay"
    

    Step 9: Save Documents, (pray to the overseer it works) and open the html doc in a browser to see if it works

    Step 10: if Script works (thank the overseer) and do a little dance for luck so that nothing in code will be depricated.

    ————– WARNING ————-

    if steps 1 – 10 not make the clock work its likley either that you missed a step or wrote something incorrect or that
    something is depricated or you did not worship the overseer.

    its likely the first thing so take a deep breath and
    check your code.

    #API REFERENCE —

    N/A none here its to basic for a full blown API

    #Tests —

    Simply follow the aformentioned steps under installation and you should be fine.

    #License —

    MIT

    Copyright 2017 Yusif El-awawdeh

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Visit original content creator repository
    https://github.com/Yusifelawawdeh/Javascript_clock_and_date

  • HackerNews.jl

    License: MIT Build Status codecov.io GitHub contributors GitHub issues GitHub version

    ForTheBadge built-by-developers

    HackerNews.jl

    The unofficial Julia API for Hackernews 🔥

    See Hacker News API

    Installation

    Since HackerNews is registered in official Julia Registry, you can directly install it.

    julia> ]
    (v1.0) pkg> add HackerNews

    How it works?

    The API is fairly simple to use and there isn’t much required to get up and running.

    Getting all the routes available to be used

    The package provides a HackerNews.HNApiRoute which represents all the routes that the Hackernews API can handle. You can get a list of all available routes by typing,

    julia> subtypes(HackerNews.HNApiRoute)
    8-element Array{Union{DataType, UnionAll},1}:
     HackerNews.AskStories 
     HackerNews.BestStories
     HackerNews.JobStories 
     HackerNews.MaxItem    
     HackerNews.NewStories 
     HackerNews.ShowStories
     HackerNews.TopStories 
     HackerNews.Updates 

    Getting maxitem

    julia> using HackerNews
    
    julia> maxitem = HackerNews.HN(HackerNews.MaxItem)
    
    julia> HackerNews.getinfo(maxitem)
    INFO: fetching maxitem..
    INFO: generating post data...
    1-element Array{HackerNews.HNPost,1}:
     HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ...)
    

    Getting topstories, newstories, beststories, askstories, showstories and jobstories

    julia> topstories = HackerNews.HN(HackerNews.TopStories, 2)
    HackerNews.HN(HackerNews.TopStories, 2, false)
    
    julia> result = HackerNews.getinfo(topstories)
    INFO: fetching HackerNews.TopStories...
    INFO: generating post data...
    2-element Array{HackerNews.HNPost,1}:
     HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ....)
     HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ...)
    
    # getting the type of result 
    julia> typeof(result)
    Array{HackerNews.HNPost,1}
    
    # data field respresnt the raw Hackernews API response
    julia> result[1].data
    Dict{String,Any} with 8 entries:
      "by"          => "KKKKkkkk1"
      "descendants" => 0
      "score"       => 7
      "time"        => 1520836426
      "id"          => 16566536
      "title"       => "Intel Fights for Its Future"
      "type"        => "story"
      "url"         => "https://mondaynote.com/intel-fights-for-its-future-6498f886992b"
    
    # accessing data using fields, AWESOME!
    julia> result[1].id
    16566536
    
    julia> result[1].by
    "KKKKkkkk1"
    
    julia> result[1].title
    "Intel Fights for Its Future"

    Getting updates

    Updates can be related to profiles as well as posts,

    • for User updates, set user_related=true while instantiating the HN type object
    • for Item updates, HN follows default settings which is user_related=false
    # posts related updates
    julia> item_updates = HackerNews.HN(HackerNews.Updates, 1, false)
    HackerNews.HN(HackerNews.Updates, 1, false)
    
    julia> HackerNews.getinfo(item_updates)
    INFO: fetching updates..
    INFO: generating post data...
    1-element Array{HackerNews.HNPost,1}:
     HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ...) 
    
    
    # user related updates
    julia> user_updates = HackerNews.HN(HackerNews.Updates, 1, true)
    HackerNews.HN(HackerNews.Updates, 1, true)
    
    julia> HackerNews.getinfo(user_updates)
    INFO: fetching updates..
    INFO: generating user data...
    1-element Array{HackerNews.HNUser,1}:
     HackerNews.HNUser(Dict{String,Any}(Pair{String,Any}("submitted", Any[...])

    Getting user information

    julia> HackerNews.getuser("pg")
    HackerNews.HNUser(Dict{String,Any}(Pair{String,Any}("submitted", ...)
    
    # get the raw Hackernews api result inside data field
    julia> HackerNews.getuser("pg").data
    Dict{String,Any} with 5 entries:
      "submitted" => Any[10484520, 10071788, 10071052, 10071018, 10070939, 10070787, 10070703, 10070527, 10070299, 10070175    36, 34, 31, 22, 
      "karma"     => 155111
      "about"     => "Bug fixer."
      "id"        => "pg"
      "created"   => 1160418092
    
    # Again, awesome!
    julia> HackerNews.getuser("pg").id
    "pg"
    
    julia> HackerNews.getuser("pg").karma
    155111

    Facing issues? 😱

    • Open a PR with the detailed expaination of the issue.
    • Reach me out here
    Visit original content creator repository https://github.com/rahulkp220/HackerNews.jl
  • openssl

    Visit original content creator repository
    https://github.com/dondyabla/openssl

  • Hey

    Hey

    这是我的毕业设计。
    刚开始确定这个课题的时候是因为以前有稍微研究过一些XMPP协议,在这个基础上做起来应该不难。然后开始选技术的时候还有半年,我想为什么不从更底层做起呢!那就不用XMPP,当时接触过相关的即时通讯技术还有WebSocket,那为什么直接从更底层的Socket开始封装呢
    服务端就用Go语言吧,用来做IM服务器和HTTP服务器都很好。

    技术选型

    既然是基于Socket,iOS端我并不准备中C语言的Socket开发封装起,而是使用一个第三方库CocoaAsyncSocket。XMPP的iOS framework也是从这个库开始封装。而Go语言的IM服务端则直接使用原生开发即可,无论是UDP还是TCP都已经封装的很好。

    HTTP服务器使用的框架是Gin,已经相当成熟,可以用于大型服务端的开发了。

    关于传输的数据格式,XMPP使用的是XML,但是体积太大,冗余过多不必要的数据,考虑了很久好像也没必要自己封装二进制的数据格式,我用的是Google的protocol buffer。HTTP服务器还是使用JSON。

    我还需要存储客户端的IP地址,由于需要快速读写,我使用的是Redis

    AccessToken验证方式使用的是JSON Web Token(JWT)

    实现思路

    我的想法是使用UDP Socket来传输数据,至于为什么使用UDP呢,一开始的想法是UDP比TCP快,虽然可能会丢包但是可以试着优化。关于使用UDP来做IM这个想法也被一些大神喷过,但是这都是我自己的想法,就这样做着先。

    使用UDP会丢包,所以我想需要一个回执机制,接收端收到了消息后就给发送端发送一个回执,这个回执包括这条消息的ID,如果发送方过一段时间还没有接受到回执的时候则重新发送。而且这个回执还不能丢,所以我使用TCP来发送回执。

    UDP是无连接性的,还是要使用TCP来连接服务端,表明登录状态。所以TCP的作用是连接和发送回执。

    具体思路是当客户端登录和重新连接的时候,客户端使用UDP Socket绑定端口,然后使用TCP Socket来发送UDP 地址给服务端,服务端把用户的ID和UDP地址存进Redis,等发送方发送的消息包含接收端的用户ID,服务端再从Redis取出接收方的UDP地址进行转发。

    发送图片我是这样实现的,我会把图片上传到七牛云,发图片的URL来发送,接收端只需要使用URL来加载图片即可

    架构

    关于整个APP的流程如下

    关于iOS端,使用了MVVM设计模式结合RAC,在Controller里面只需要组合一下视图和布局,绑定数据即可,把处理数据和大部分逻辑都放在了ViewModel里面,结构还算清晰。

    关于数据管理,我使用了一个Redux思想的全局数据调度中心,实现了单向数据流,数据的持久化等。数据持久化用到了FMDB。但是大部分代码是一个大神写的,很屌。

    效果和下一步

    目前实现传输文字和图片,好友添加还是在后台添加(前端还没做),动态模块等。

    登录

    通讯录

    详细资料

    个人资料

    聊天界面

    感谢一下开源技术

    • SDAutoLayout
    • YYWebImage
    • ReactiveObjC
    • AFNetworking
    • Protobuf
    • CocoaAsyncSocket
    • Qiniu
    • UICKeyChainStore
    • TZImagePickerController
    • SVProgressHUD
    • DateTools
    • MLEmojiLabel
    • MJRefresh
    • Mantle
    • FMDB
    • FMDBMigrationManager
    • MTLFMDBAdapter

    Visit original content creator repository
    https://github.com/ascenx/Hey

  • logApiServer

    logApiServer Framework For PHP


    phalcon框架封装日志服务接口,上报日志数据,
    记录日志数据,后期可以介入ELK服务。
    

    环境要求

    • Linux,FreeBSD,MacOS
    • PHP-7.0及以上版本
    • beanstalkd(队列)
    • phalcon(PHP框架)
    • SeasLog(日志扩展)

    安装篇

    扩展安装参考我的doc项目安装步骤
    

    代码下载

    git clone https://github.com/hormoneGroup/logApiServer
    

    虚拟域名配置

    server {
        listen      80;
        server_name dev.logApiServer.com;
        set         $root_path '/data/web/logApiServer';
        root        $root_path;
    
        index index.php index.html index.htm;
    
        try_files $uri $uri/ @rewrite;
    
        location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/$1;
        }
    
        location ~ \.php {
            # try_files    $uri =404;
    
            fastcgi_index  /index.php;
            fastcgi_pass   127.0.0.1:9000;
    
            include fastcgi_params;
            fastcgi_split_path_info       ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    
        location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
            root $root_path;
        }
    
        location ~ /\.ht {
            deny all;
        }
    }
    

    日志级别说明

    debug (信息、细粒度信息事件)
    
    info ( 重要事件、强调应用程序的运行过程)
    
    warning (出现了非错误性的异常信息、潜在异常信息、需要关注并且需要修复)
    
    error (运行时出现的错误、不必要立即进行修复、不影响整个逻辑的运行、需要记录并做检测)
    
    critical (紧急情况、需要立刻进行修复、程序组件不可用)
    

    日志上报

    上报接口地址:http://dev.logApiServer.com/log/save
    

    1. 接口描述

    日志上报

    1.1.1. 请求说明

    URL 请求方式
    http://dev.logApiServer.com/log/save POST

    1.1.2. 参数说明

    参数名称 是否必填 描述
    log_level 日志级别(参考日志级别说明)
    log_type 日志数据类型
    log_data 日志数据JSON

    1.1.3. 请求示例

    POST /log/save HTTP/1.1
    Host: dev.logApiServer.com
    ...
    Content-Length: 83
    
    log_level=debug&log_type=app_dubug&log_data={"name":"xxx"}
    

    1.1.5. 返回参数说明

    正确的json返回结果示例:

    {
        "code": 0,
        "msg": "ok",
        "body": {
        }
    }
    
    

    错误的json返回结果示例:

    {
        "code": "1000",
        "msg": "error",
        "body": {
        }
    }
    

    字段说明:

    {
      "code": 返回码,取值0成功,其它表示失败,
      "msg": 描述信息,
      "body": {
      }
    }
    

    启动命令行日志队列

    /usr/local/php/bin/php /data/web/logApiServer/app/tasks/cli.php backend.log asyncAppLog
    

    Visit original content creator repository
    https://github.com/hormoneGroup/logApiServer

  • thesis

    Multilevel Models and Missing Data Models for Crowdsourced Bicycle Route Ratings

    May 2016

    This is my undergraduate thesis, which I completed my senior year at Reed College. Andrew Bray advised this thesis. This project was done in collaborate with Knock Software, creators of the Ride Report app.

    My aim in this project was to improve way the Ride Report stress map is created. The Ride Report app collects commuting bicyclists’ routes and their ratings of those routes. From this crowdsourced data set of bicycle route ratings, they create a map of Portland, OR that shows each road segment colored according to the average ratings of the ride that goes through it. They call it the stress map. Though the averaging method gives results that are acceptable, we suspected that we could do better by building a probabilistic model for the effect of route on ride rating.

    It turns out there are three majors hurdles in building this model: First, to develop a model that accounts for covariates other than route; second, to implement an algorithm for mapping GPS traces of routes into sequences of road segments with output suitable for modelling; and third, to develop a model that can estimate a parameter for each road segments’ contribution to the ride rating. Because I was short on time, I had to focus on the first piece.

    We identified three predictors besides route that the model should account for: time of day, weather and road conditions, and the variation in cyclists’ tendency to give a negative rating. We propose using a logistic regression model with weather and road conditions as normal predictors, time of day fit with a cyclic cubic spline, and cyclist variation modelled with varying intercepts.

    In the course of exploring this data, we also did several other analyses. We explored correcting for a non-ignorable bias in which rides were giving rates, suspecting that rides with negative experiences were more likely to be rated than those that were uneventful. Though we implemented the methods described in Ibrahim’s 1996 paper, the results were not useful because we know many of the rides missing ratings are car or transit rides that were incorrectly classified as bike rides. As that classification improves, we suspect this method may produce more useful insight into the model.

    File Structure

    We have attempted to make this analysis reproducible, though we are not able to share the data we worked with. It contains confidential information of riders, such as their exact commutes between their home and workplace.

    The repository is organized as follows:

    • analysis: contains exploratory analysis from original work on data manipulation and cleaning.
    • data: contains some data. For privacy and license reasons, most of the data is not availible in the repository.
    • model_iterations: contains the scripts that ran the actual models in this analysis. Most of the figures in the thesis come from these R markdown files.
    • logs: contains weekly logs reporting work done for the past week.
    • R: contains R functions written as part of the package to manipulate data
    • thesis: All of the writing for the thesis document. It is written entirely in R Markdown, created from an R markdown thesis template, which can be found at https://github.com/Reedies/reedtemplates)

    Outline

    Chapter 1: Data sources details the collection methods of the data sources used, including the Ride Report data as well as weather data.

    Chapter 2: Methods outlines the main modeling methods used, including logistic regression, multilevel models, and additive models, to keep the analysis accessible for most readers.

    Chapter 3: Modeling Rides and Riders compares six iteratively built statistical models, importantly demonstrating that the differences in average ride rating throughout the day can be account better by differences in the base rate at which riders give negative ratings rather than an universal daily pattern.

    Chapter 4: Classifying Riders attempts to map out the distinction between different kinds of rider and then uses these classifications to improve models developed in the previous chapter.

    Chapter 5: Modeling Missing Response reports the results of using expectation maximization to use ride observations that are missing a rating to reduce the potential bias in estimates in previous models and, at the same time, model the missing data mechanism.

    Chapter 6: Unfinished Work: Modeling Routes outlines the data transformation challenges we faced and puts forward some suggestions for models that incorporate route information.

    Visit original content creator repository https://github.com/wjones127/thesis
  • OpENer

    Quality Gate Status Join the chat at https://gitter.im/EIPStackGroupOpENer/Lobby

    OpENer Version 2.3.0

    Welcome to OpENer!

    OpENer is an EtherNet/IP™ stack for I/O adapter devices; supports multiple I/O and explicit connections; includes objects and services to make EtherNet/IP™- compliant products defined in THE ETHERNET/IP SPECIFICATION and published by ODVA (http://www.odva.org).

    Participate!

    Users and developers of OpENer can join the respective Google Groups in order to exchange experience, discuss the usage of OpENer, and to suggest new features and CIP objects, which would be useful for the community.

    Developers mailing list: https://groups.google.com/forum/#!forum/eip-stack-group-opener-developers

    Users mailing list: https://groups.google.com/forum/#!forum/eip-stack-group-opener-users

    Requirements:

    OpENer has been developed to be highly portable. The default version targets PCs with a POSIX operating system and a BSD-socket network interface. To test this version we recommend a Linux PC or Windows with Cygwin (http://www.cygwin.com) installed. You will need to have the following installed:

    • CMake
    • gcc
    • make
    • binutils
    • the development library of libcap (libcap-dev or equivalient)

    for normal building. These should be installed on most Linux installations and are part of the development packages of Cygwin.

    If you want to run the unit tests you will also have to download CppUTest via https://github.com/cpputest/cpputest

    For configuring the project we recommend the use of a CMake GUI (e.g., the cmake-gui package on Linux, or the Installer for Windows available at CMake)

    Compile for Linux/POSIX:

    1. Make sure all the needed tools are available (CMake, make, gcc, binutils)
    2. Change to the /bin/posix
    3. For a standard configuration invoke setup_posix.sh
      1. Invoke the make command

      2. Invoking OpENer:

        ./src/ports/POSIX/OpENer <interface_name>

        e.g. ./src/ports/POSIX/OpENer eth1

    OpENer also now has a real-time capable POSIX startup via the OpENer_RT option, which requires that the used kernel has the full preemptive RT patches applied and activated. If you want to use OpENer_RT, prior to step 2, execute sudo setcap cap_ipc_lock,cap_sys_nice+ep ./src/ports/POSIX/OpENer to grant OpENEr CAP_SYS_NICE, and the CAP_IPC_LOCK capabilities, which are needed for the RT mode

    OpENer can also be built and installed as a library by setting the CMake flag -DOPENER_INSTALL_AS_LIB. To build a shared library, the global option -DBUILD_SHARED_LIBS=ON should also be set. It has only been tested under Linux/POSIX platform.

    Compile for Windows XP/7/8 via Visual Studio:

    1. Invoke setup_windows.bat or configure via CMake
    2. Open Visual Studio solution OpENer.sln in bin/win32
    3. Compile OpENer by chosing Build All in Visual Studio
    4. For invoking OpENer type from the command line:
      1. Change to \bin\win32\src\ports\WIN32\

      2. Depending if you chose the Debug or Release configuration in Visual Studio, your executable will either show up in the subfolder Debug or Release

      3. Invoke OpENer via

        OpENer <interface_index>

        e.g. OpENer 3

    In order to get the correct interface index enter the command route print in a command promt and search for the MAC address of your chosen network interface at the beginning of the output. The leftmost number is the corresponding interface index.

    Compile for Windows XP/7/8/10 via Cygwin:

    The POSIX setup file can be reused for Cygwin. Please note, that you cannot use RT mode and you will have to remove the code responsible for checking and getting the needed capabilities, as libcap is not available in Cygwin. The easier and more supported way to build OpENer for Windows is to either use MinGW or Visual Studio.

    Compile for MinGW on Windows XP/7/8/10

    1. Make sure 64 bit mingw is installed. (Test with gcc –version, should show x86_64-posix-seh-rev1)
    2. Make sure CMake is installed. (Test with cmake –version, should be version 3.xx)
    3. Change to /bin/mingw
    4. Run the command setup_mingw.bat in a dos command line. (Not a bash shell). If tracing is desired, use the following (where the cmake parameter must be enclosed in quotes) or change the ./source/CMakeList.txt file.
      setup_mingw.bat "-DOpENer_TRACES:BOOL=TRUE"
      
    5. Run the command “make” from the same directory (./bin/mingw)
    6. The opener.exe is now found in \bin\mingw\src\ports\MINGW
    7. Start it like this: “opener 192.168.250.22”, where the ip address is the local computer’s address on the nettwork you want to use.

    Directory structure:

    • bin … The resulting binaries and make files for different ports
    • doc … Doxygen generated documentation (has to be generated for the SVN version) and Coding rules
    • data … EDS file for the default application
    • source
      • src … the production source code
        • cip … the CIP layer of the stack
        • cip_objects … additional CIP objects
        • enet_encap … the Ethernet encapsulation layer
        • ports … the platform specific code
        • utils … utility functions
      • tests … the test source code
        • enet_encap … tests for Ethernet encapsulation layer
        • utils … tests for utility functions

    Documentation:

    The documentation of the functions of OpENer is part of the source code. The source packages contain the generated documentation in the directory doc/api_doc. If you use the GIT version you will need the program Doxygen for generating the HTML documentation. You can generate the documentation by invoking doxygen from the command line in the opener main directory.

    Fuzzing

    Intro

    Fuzzing is an automated testing method that directs varying input data to a program in order to monitor output. It is a way to test for overall reliability as well as identify potential security bugs.

    The fuzzer we are using is AFL, a fuzzer that uses runtime guided techniques to create input for the tested program. From a high-level prespective AFL works as follows:

    • Forks the fuzzed process
    • Genereates a new test case based on a predefined input
    • Feeds the fuzzed process with the test case through STDIN
    • Monitors the execution and registers which paths are reachable

    Alt text

    Compile

    To start fuzzing this project with AFL you’ll need to compile it with AFL. First make sure you have AFL installed:

    sudo apt install build-essential
    wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
    tar xzf afl-latest.tgz
    cd afl*
    make && sudo make install
    echo "AFL is ready at: $(which afl-fuzz)"
    
    

    Then, compile OpENer with AFL:

    1. Change to the OpENer/bin/posix directory
    2. Compile OpENer with AFL ./setup_posix_fuzz_afl.sh
    3. Run make

    Fuzz

    Finally, generate some test cases and start AFL:

    # Generate inputs
    mkdir inputs
    echo 630000000000000000000000000000000000000000000000 | xxd -r -p > ./inputs/enip_req_list_identity
    # You can also use the inputs we prepared from OpENer/fuzz/inputs
    # Finally, let's fuzz!
    afl-fuzz -i inputs -o findings ./src/ports/POSIX/OpENer <interface_name>
    

    Reproduce a crash

    Usually to reproduce a crash it’s enough to retransmit the testcase using cat testcase | nc IP_ADDR 44818 However, since CIP runs over the EtherNet/IP layer, it must first register a valid session. Therefore, we need to use a dedicated script: python fuzz/scripts/send_testcase.py IP testcase_path

    Running an OpENer “swarm”:

    1. Create a macvlan network for this purpose and tie it to the desired eth port. Specify the IP range and use aux address to exclude the addresses used by other devices in the subnet such as the IP of the EIP scanner PC, network bridge, etc.: docker network create -d macvlan –subnet=192.168.135.253/24 –ip-range=192.168.135.100/24 –aux-address=”PC1=192.168.135.250″ –aux-address=”VM=192.168.135.252″ –aux-address=”BR=192.168.135.253″ -o parent=eth2 mac_vlan_network

    Check the network you created with: docker network inspect mac_vlan_network

    The network will assign IP’s to the docker containers and an external scanner will be able to communicate with them. To access the containers from inside the docker host, you will have to create a bridge.

    1. Create a Dockerfile. This uses Ubuntu as the base image. It will copy OpENer to the image root and install the required packages. Lastly run OpENer on eth0 of the image: #Filename: Dockerfile FROM ubuntu:20.04 ADD ./bin/posix/src/ports/POSIX/OpENer / RUN apt-get update && apt-get install -y –no-install-recommends libcap-dev nmap ENTRYPOINT [“./OpENer”, “eth0”]

    2. Create a docker-compose.yml that will let you connect the macvlan network to the containers and easily build them and tear them down: version: “3.3” services: dockerimagename: network_mode: mac_vlan_network image: dockeruser/dockerimagename

    Note that to login to a running container, you have to expose a port in the dockerfile and dockercompose files and set up a network bridge.

    Docker commands to start and stop multiple instances of the OpENer containers: Start up 128 docker image instances: docker-compose up –scale dockerimagename=128 -d Shut down all the instances: docker-compose down

    Porting OpENer:

    For porting OpENer to new platforms please see the porting section in the Doxygen documentation.

    Contributing to OpENer:

    The easiest way is to fork the repository, then create a feature/bugfix branch. After finishing your feature/bugfix create a pull request and explain your changes. Also, please update and/or add doxygen comments to the provided code sections. Please stick to the coding conventions, as defined in source/doc/coding_rules The easiest way to conform to the indenting convertion is to set uncrustify as git filter in the OpENer repository, which can be done with the following to commands:

    git config filter.uncrustify.clean "/path/to/uncrustify/uncrustify -c uncrustify.cfg --mtime --no-backup"
    
    git config filter.uncrustify.smudge "cat"
    
    Visit original content creator repository https://github.com/EIPStackGroup/OpENer
  • JAXBD2K-ShortCourse

    Big Genomics Data Skills Training for Professors

    From 2016 to 2018, a 5-day training program has been developed in the Jackson laboratory. The purpose of the course is to offer training to professors from small colleges, regional universities, HBCU and INBRE institutions in big data-computational biology. The goal of the program is to enable professors to launch Big Data or Computational Biology courses at their home institutions. Professors will be trained, receive a curricular model and be offered the ongoing technical support required to teach undergraduate courses in Biomedical Big Data science. This program is funded by the NIH Big Data to Knowledge (BD2K) Initiative.

    The training program included seminars, extensive hands-on data analyses, evening activities and collaborative curriculum development work. Instruction covered data analysis of RNA-Seq, Exome-Seq, Whole Genome and ChiP-Seq data types. Hands on data analysis was done in Galaxy and terminal.

    In the past three years, our short-course has been proven to be a desirable program. We have developed adaptable bioinformatics modules to be implemented appropriately into an undergraduate curriculum. To benefit broader audience, we decide to release our lastest couse materials here. We hope that our sharing with the community will inform colleagues, encourage collaborations and discussions, and most beneficially inspire new approaches to enhance bioinformatics education for our field.

    NOTE:

    Visit original content creator repository
    https://github.com/TheJacksonLaboratory/JAXBD2K-ShortCourse

  • pure-lang

    The Pure Programming Language

    Pure is a modern-style functional programming language based on term
    rewriting. It offers equational definitions with pattern matching, full
    symbolic rewriting capabilities, dynamic typing, eager and lazy evaluation,
    lexical closures, built-in list and matrix support and an easy-to-use C
    interface. The interpreter uses LLVM as a backend to JIT-compile Pure
    programs to fast native code.

    Please check our Github website for more information. The Pure Language
    and Library Documentation is available in html and pdf format. A
    very complete and up-to-date collection of packages for Arch Linux are
    available from the Arch User Repositories, please also check
    our Pure on Arch Linux wiki page for details. We also offer a reasonably
    complete set of Ubuntu packages at Launchpad. Instructions for installing
    Pure on the Mac and Windows can be found on the Pure on Mac OS X
    and Pure on Windows wiki pages. Source packages can be found on
    the Download page. Please also have a look at our mailing list /
    Google group and IRC chat (#pure-lang on freenode) if you need any help
    or if you want to discuss Pure.

    Please also check my personal Github site for some fun side projects
    that I’ve written in or for Pure (mostly about computer music and multimedia).

    Albert Gräf aggraef@gmail.com

    Enjoy. 🙂

    Visit original content creator repository
    https://github.com/agraef/pure-lang