Blog

  • An-Application-based-on-Probability-Prediction-using-Randomization-Algorithms

    An Application based on Probability Prediction using Randomization Algorithms.

    An Application based on Probability Prediction using Randomization Algorithms. Where winning probability of player and banker is calculated simultaneously with the simulation of game Baccarat.

    Monte Carlo Algorithm:

    Monte Carlo is that class of algorithm which may return the correct result or the incorrect result
    with some probability. The algorithm resources used in this are often bounded and thus it has a deterministic
    or fixed run time. It gives better probability results when it is run for a larger number of iterations.

    Las Vegas Algorithm:

    A Las Vegas algorithm returns the correct or optimum result always, and informs when it fails.
    Its run time differs at each run since it depends on a random value, even for the same input.

    Pthread Library:

    POSIX threads or Pthreads are the thread implementations which adhere to this standard. Implementation of pthread is available with GCC compiler and has been used for multithreading. We have implemented all the algorithms in C language with a GCC
    compiler only.

    Baccarat

    Baccarat is a game of cards which contains 8 decks. There are 416415414*413 possible cases in first hand
    which makes it almost impossible to be followed for patterns/predictions. To be able to even calculate the
    probabilities with a great deal of accuracy, it takes a large amount of time. Hence, it served as a suitable
    problem statement that could be solved by our algorithms

    The following algorithms are implemented in these ways:

    1). Las Vegas

    2). Las Vegas with Threading (416 POSIX Threads)

    3). Monte Carlo

    4). Monte Carlo with array of linked lists

    Visit original content creator repository
    https://github.com/namanadlakha3/An-Application-based-on-Probability-Prediction-using-Randomization-Algorithms

  • whatsapp-to-html

    whatsapp-to-html · Build Status npm

    The problem

    Currently, WhatsApp lets you export chats only in the plain .txt format, which is difficult to read. It’d be nice to have those chats nicely formatted.

    The solution

    $ npm install -g whatsapp-to-html

    It comes with a command line program and a user-facing API.

    Usage

    CLI

    whatsapp-to-html expects a date pattern and an exported WhatsApp chat. You can also optionally pass it a path to a JSON file, which should be a map of the interlocutors in the provided WhatsApp chat to strings, which will be used as aliases. See an example below.

    Thus, the flags are:

    -d              A date pattern
    -a              A path to a JSON file containing aliases for the participants in the provided chat
    

    The last argument should a the path to an exported WhatsApp chat.

    The resulting HTML will be written to stdout.

    Examples

    Let’s say we have the following chat exported from WhatsApp in a _chat.txt file:

    [12/05/2019, 3:32:47 PM] Daniel: Who are you?
    [12/05/2019, 3:33:14 PM] Mysterion: I’m an angel keeping watch over the city at night
    [12/05/2019, 3:43:46 PM] Daniel: Are you Craig?
    [12/05/2019, 3:48:09 PM] Mysterion: I might be Craig, and then again, I might not be. My identity must remain a secret. You cannot know.
    [12/05/2019, 3:48:41 PM] Daniel: What are you doing here?
    [12/05/2019, 3:49:32 PM] Mysterion: The city needs my help. It cries for protection, and I will answer the call to save her.
    [13/05/2019, 8:00:43 AM] Mysterion: Today you crossed paths with the wrong immortal fourth grader
    [13/05/2019, 2:53:14 PM] Daniel: Right. This conversation is over.
    

    According to this table, the date pattern in this file is DD/MM/YYYY. Running this

    $ whatsapp-to-html -d DD/MM/YYYY -- _chat.txt > out.html

    will produce the following out.html

    <h2>Sunday, May 12, 2019</h2>
    
    <p>
      <span style="color:#ed6f42">Daniel</span> @
      <span style="color:grey;font-size:10px">3:32:47 PM</span>: Who are you?
    </p>
    <p>
      <span style="color:#c4e559">Mysterion</span> @
      <span style="color:grey;font-size:10px">3:33:14 PM</span>: I’m an angel
      keeping watch over the city at night
    </p>
    <p>
      <span style="color:#ed6f42">Daniel</span> @
      <span style="color:grey;font-size:10px">3:43:46 PM</span>: Are you Craig?
    </p>
    <p>
      <span style="color:#c4e559">Mysterion</span> @
      <span style="color:grey;font-size:10px">3:48:09 PM</span>: I might be Craig,
      and then again, I might not be. My identity must remain a secret. You cannot
      know.
    </p>
    <p>
      <span style="color:#ed6f42">Daniel</span> @
      <span style="color:grey;font-size:10px">3:48:41 PM</span>: What are you doing
      here?
    </p>
    <p>
      <span style="color:#c4e559">Mysterion</span> @
      <span style="color:grey;font-size:10px">3:49:32 PM</span>: The city needs my
      help. It cries for protection, and I will answer the call to save her.
    </p>
    
    <h2>Monday, May 13, 2019</h2>
    
    <p>
      <span style="color:#c4e559">Mysterion</span> @
      <span style="color:grey;font-size:10px">8:09:43 PM</span>: Today you crossed
      paths with the wrong immortal fourth grader
    </p>
    <p>
      <span style="color:#ed6f42">Daniel</span> @
      <span style="color:grey;font-size:10px">2:30:14 PM</span>: Right. This
      conversation is over.
    </p>

    It will look like this, which is much more readable.

    Optionally, you can create a JSON file (let’s call it _chat.json):

    {
      "Mysterion": "Kenny"
    }

    If you passed it to the program, you’d get this:

    $ whatsapp-to-html -d DD/MM/YYYY -a _chat.json -- _chat.txt > out.html

    out.html:

    <h2>Sunday, May 12, 2019</h2>
    
    <p>
      <span style="color:#48e2dd">Daniel</span> @
      <span style="color:grey;font-size:10px">3:32:47 PM</span>: Who are you?
    </p>
    <p>
      <span style="color:#e28f85">Kenny</span> @
      <span style="color:grey;font-size:10px">3:33:14 PM</span>: I’m an angel
      keeping watch over the city at night
    </p>
    <p>
      <span style="color:#48e2dd">Daniel</span> @
      <span style="color:grey;font-size:10px">3:43:46 PM</span>: Are you Craig?
    </p>
    <p>
      <span style="color:#e28f85">Kenny</span> @
      <span style="color:grey;font-size:10px">3:48:09 PM</span>: I might be Craig,
      and then again, I might not be. My identity must remain a secret. You cannot
      know.
    </p>
    <p>
      <span style="color:#48e2dd">Daniel</span> @
      <span style="color:grey;font-size:10px">3:48:41 PM</span>: What are you doing
      here?
    </p>
    <p>
      <span style="color:#e28f85">Kenny</span> @
      <span style="color:grey;font-size:10px">3:49:32 PM</span>: The city needs my
      help. It cries for protection, and I will answer the call to save her.
    </p>
    
    <h2>Monday, May 13, 2019</h2>
    
    <p>
      <span style="color:#e28f85">Kenny</span> @
      <span style="color:grey;font-size:10px">8:09:43 PM</span>: Today you crossed
      paths with the wrong immortal fourth grader
    </p>
    <p>
      <span style="color:#48e2dd">Daniel</span> @
      <span style="color:grey;font-size:10px">2:30:14 PM</span>: Right. This
      conversation is over.
    </p>

    Mysterion is now displayed as Kenny, which is just as well.

    API

    After installing the library, import it:

    import { whatsappToHtml } from "whatsapp-to-html";

    or require it:

    const whatsappToHtml = require("whatsapp-to-html").whatsappToHtml;

    whatsappToHtml(filePath, datePattern, senderAliases?)

    • @param {string} filePath
    • @param {string} datePattern
    • @param {{ readonly [s: string]: string }} [senderAliases]
    const html = whatsappToHtml("./_chat.txt", "DD/MM/YYYY", {
      Mysterion: "Kenny",
    });

    This will return the same html as we saw before.

    Notes

    • The colors are assigned to chat participants at random. If you don’t like the result, run the program again
    • If there are chat participants identified by their phone numbers, use the following rule to properly map them to names (or whatever you’d like to map them to. Maybe different numbers. Who knows):
      • Remove all the dashes and parentheses, if there are any, from the number, but keep the spaces. For instance, if the number is (+451 12-34-5678), use "+451 12345678" as a key in your JSON file / object
    Visit original content creator repository https://github.com/danplisetsky/whatsapp-to-html
  • prosafe-vlan-manager

    ProSAFE VLAN Manager

    This is a utility & library to manage VLANs on Netgear ProSAFE series switches.

    Currently implemented and tested devices, and their firmware versions:

    • GS108Ev3
      • V2.06.10EN
      • V2.06.24EN
    • GS116Ev2
      • V2.6.0.48

    Intro

    This utility/library gives you the ability to manage your VLANs in a declarative way, that is, write your configuration, and the program will validate and apply it all in once.

    The web interface is convenient when you only have one switch to configure. But the web interface requires every modification to meet internal constraints. That will make changing pvids, adding/deleting VLANs a complex work to do, and you have to jump back and forth to adjust the settings.

    With “ProSAFE VLAN Manager”, you can automate every modification, and focus only on the network structure, released from the burden of manually configuring the switches.

    You can apply your configuration with the following command:

    # Note: you have to setup the environment before running this command
    # e.g. run `uv sync && source .venv/bin/activate` once
    python -m prosafe apply -c path/to/your/config.toml
    # if you have uv installed:
    uv run -m prosafe -- apply -c path/to/your/config.toml

    The format for configuration is in section Example configuration.

    About more information on how to use this tool in command line, print the help message with the commands below.

    python -m prosafe --help
    python -m prosafe apply --help

    How does this work?

    This program is basically a “spider” that mimic user actions on the web interface. I guess this answer is clear enough.

    Netgear has their own configuration utility and protocol, called “ProSAFE Plus Utility” and “NSDP”(Netgear Switch Discovery Protocol). But they are proprietary and obsolete/EOL. Using the program or analysing the protocol doesn’t improve the situation.

    So, I just write my own program to automate all the actions I need to perform.

    Supported actions

    All 802.1Q VLAN operations, including:

    • Add/delete VLAN
    • Change port pvid
    • Change ports membership in a VLAN
      • Including Tagged, Untagged, Ignored(internal state)

    And extra functions like:

    • Read switch information
    • Export statistics TBD

    Note the tool itself won’t turn on the advanced 802.1Q VLAN function for you. You have to manually enable it, as it may break your current network configuration.

    Example configuration

    The configuration file is written in TOML.

    [base]
    anykey = "won't be parsed, everything important are under 'switches'"
    
    [switches.switch1]
    # switch1 is the switch's nickname, only useful in logs and config backups
    # multiple switches can be defined, so long as they have different names
    address = "192.168.0.101"
    password = "password1"
    model = "gs108ev3"
    
    [switches.switch1.ports]
    # vlans: port vlan membership, defaults to 'not participate'/IGNORED,
    # format: vlan id + port status
    # U: Untagged
    # T: Tagged
    #
    # Any port omitted will be allocated to VLAN{original pvid}.
    # This behavior is model dependent.
    1 = { pvid = 1,     vlans = ['1T', '2T', '23T']}
    2 = { pvid = 2,     vlans = ['2U']}
    3 = { pvid = 1,     vlans = ['1T', '23T']}
    4 = { pvid = 1,     vlans = ['1U']}
    5 = { pvid = 1,     vlans = ['1U']}
    6 = { pvid = 1,     vlans = ['1U']}
    7 = { pvid = 99,    vlans = ['99U']}
    
    # this is also a valid configuration format for toml
    # just a reminder
    [switches.switch1.ports.8]
    pvid = 1
    vlans = ['1U']
    
    [switches.switch2]
    address = "192.168.0.239"
    password = "password2"
    model = "gs116ev2"
    
    [switches.switch2.ports]
    # Any port omitted will be disabled.
    # This behavior is model dependent.
    1 = { pvid = 1,     vlans = ['1T']}
    2 = { pvid = 2,     vlans = ['2U']}
    3 = { pvid = 1,     vlans = ['1U']}

    This project is licensed under AGPL 3.0.

    Visit original content creator repository
    https://github.com/PotatoMania/prosafe-vlan-manager

  • Помощник Логиста

    Помощник Логиста

    Android-приложение “Помощник логиста”.
    Приложение должно помочь логистам выполнять свои задачи более эффективно и удобно.

    Описание

    • Авторизация: Вход осуществляется по номеру телефона и паролю, выданному работодателем
    • Отслеживание заказов: Приложение позволяет логистам отслеживать статус заказов
    • Планирование маршрутов доставки: Приложение позволяет логистам планировать маршруты доставки для заказов
    • Управление рабочим графиком: Приложение позволяет логистам строить свой график работы, где они могут запросить больничный, выходной или обозначить свою готовность к подработке
    • Быстрая обратная связь: Приложение позволяет быстро решить вопросы связи с работодателем с помощью чата

    Запуск и Авторизация

    При запуске приложения появляется Splash Screen

    splash

    Перед пользователем страница ввода номера телефона

    phone

    Появляется страница ввода пароля

    password

    • *1 – Кнопка для отмены действия, возвращает на предыдущую страницу
    • На примере выше указан неверный пароль. При вводе верного – 123456 – пользователь отправляется на основной экран приложения

    Основной экран

    Перед пользователем появляется раздел “Задания”

    tasks

    Раздел “Графики” (прототип)

    graphs

    Раздел “Чат”

    chat

    • *1 – При открытии страницы “Чат” остается одно уведомление – новое сообщение, написанное нам работодателем. При отправке сообщения в ответ, либо при переходе в любой другой раздел – уведомления пропадут

    Раздел “Профиль”

    profile

    • *1 – Отображается номер телефона, который пользователь ввёл при Авторизации

    Архитектура

    Приложение “Помощник логиста” построено на основе MVVM-архитектуры. MVVM-архитектура позволяет разделить приложение на три слоя:

    • View: Слой представления отвечает за отображение пользовательского интерфейса
    • ViewModel: Слой ViewModel отвечает за привязку данных к представлению и обработку пользовательских событий
    • Model: Слой модели отвечает за хранение данных

    Зависимости

    • Использование Android платформы
    • Номер телефона – любой
    • Пароль – 123456

    Установка

    • Вы можете установить APK-файл приложения по ссылке

    Автор

    Евгений Федин
    @GitHub
    @HeadHunter
    @Telegram
    @LinkedIn

    Visit original content creator repository https://github.com/DivisionCom/logistics-assistant