Category: Blog

  • lsp-phan

    lsp-phan (wip)

    THIS IS EXPERIMENTAL, the configuration will change

    PHP (Phan) support for lsp-mode using phan/phan.

    This is forked from emacs-lsp/lsp-php. (The way to determine the root Phan namespace is different)

    Features

    1. Enhanced error detection from Phan
    2. “Go To Definition” support.

    Installation

    Emacs

    Clone this repository, emacs-lsp/lsp-mode, and emacs-lsp/lsp-ui to suitable paths. Then add the following settings to your Emacs configuration.
    (TODO: If you also wish to install lsp-php for other features such as autocomplete, are multiple language servers for the same language supported?)

    (add-to-list 'load-path "/path/to/lsp-phan/")
    ;*******************************************************************************
    ; NOTE: This is incompatible with lsp-php
    ; lsp-mode does not support multiple clients per major mode, yet
    ; See https://github.com/emacs-lsp/lsp-mode/issues/105
    ;*******************************************************************************
    
    ; TODO: Make this more convenient. The below command should be fine
    ; "php" may need be replaced with a php 7.0 installation, preferably with php-ast installed.
    ; TODO: Document the individual settings that were added to lsp-phan with M-x customize
    (defvar lsp-phan-language-server-command
      (list
    	"php"
    	"/path/to/phan_stable/phan"
    	"--language-server-allow-missing-pcntl"
    	"--allow-polyfill-parser"
    	"--use-fallback-parser"
    	"--memory-limit" "1G"
    	"--language-server-enable-go-to-definition"
    	"--project-root-directory" "/path/to/analyzed_project"
    	"--language-server-on-stdin"))
    
    ; For php-language-server
    (require 'flycheck)
    
    ; Can't be used at the same time as (require 'lsp-php), see above
    (require 'lsp-phan)
    
    (require 'php-mode)
    (require 'lsp-mode)
    
    (require 'lsp-ui)
    (add-hook 'lsp-mode-hook 'lsp-ui-mode)
    (add-hook 'php-mode-hook 'flycheck-mode)
    (add-hook 'php-mode-hook 'lsp-mode)
    
    (add-hook 'php-mode-hook #'lsp-phan-enable)

    phan installation

    You will need to install phan/phan.

    You will also need to set up the project with a .phan/config.php if you have not done so already.

    Global installation

    Before installing php-language-server, make sure your ~/.config/composer/composer.json includes the lines below. The settings apply to all globally installed Composer packages, so proceed with caution. If you do not want to edit your global Composer configuration, see the section for local installation below.

    {
        "minimum-stability": "dev",
        "prefer-stable": true
    }
    

    After editing your composer.json, you can install phan/phan.

    composer global require phan/phan

    Keyboard shortcuts

    Configuration

    TODO: Make the configuration easier to work with and understand.
    See the VS Code extension’s configuration settings.

    License

    This package is licensed under the GPLv3 license. For more information, see LICENSE.

    Visit original content creator repository
    https://github.com/TysonAndre/lsp-phan

  • leetcode-rating-predictor

    LC Predictor

    Want to see your leetcode rating change right after the contest? Well, you are in the right place!


    About

    It takes about 4-5 days for leetcode to update the contest ratings of participants. So you have to wait for a long time to know your rating changes. This application predicts accurate leetcode rating changes for all the contestants within a few minutes of completion of the contest.

    Getting started

    This project consists of two types of user interfaces. You can either use browser extension or the website to get your rating changes.

    Chrome extension

    You can install the extension from Chrome Web Store. It adds the rating changes on leetcode ranking pages itself.

    extension preview

    Website

    You can also visit lcpredictor.onrender.com to get your rating changes.

    website preview

    How It Works

    This project is written in Node + MongoDB + Redis tech stack. We can divide it into three microservices.

    # Name Languages
    1. Background Js, Cpp
    2. Website Js, Ejs
    3. API Js

    Background

    It is the most important part of the project. It’s job is to fetch the data from leetcode and predict the contest ratings periodically.

    Rating prediction

    Rating prediction is a cpu intensive task. Therefore a nodejs C++ addon is implemented for this task so that we can utilize threading with better performance using C++. For performance measurement we got these results :

    No. of Threads Contest Time taken to make predictions(s)
    Js 1 Weekly contest 242 186.589
    C++ addon 1 Weekly contest 242 39.607
    C++ addon 2 Weekly contest 242 19.963
    C++ addon 4 Weekly contest 242 11.401
    C++ addon 8 Weekly contest 242 20.304

    Machine configuration :

    Property Value
    Processor Intel® Core™ i5-8250U CPU @ 1.60GHz × 8
    Memory 7.7 GB
    OS Ubuntu 21.04

    It implements leetcode’s latest rating prediction algorithm. Rating predictions are very close to the original rating but the accuracy may not be 100% due to changes in contest rankings after the completion of contest (leetcode rejudges some submissons).

    These are the results for the predictions of weekly-contest-242:

    Measure Value
    MSE 167.7947072739485
    R-squared 0.9988091420057561

    Job scheduling

    Job scheduling is required for processing jobs on desired time. Leetcode contests are weekly and biweekly. We can schedule them by scheduling a repeated job. But for making it more generic, job schedulers are implemented who schedules prediction and data update jobs. These job schedulers are scheduled as a repeated job. It is accomplished by using bull, a redis based queue for Node. A bull dashboard is also integrated using bull-board.

    bull dashboard bull dashboard

    Website

    It is built using express framework. Ejs is used for writing templates. It contains a table for contests and ranking pages with predicted rating changes for all the contests. Pagination is added to ranking pages for better user experience and performace.

    API

    It is also implemented using express framework. It contains an endpoint for fetching users’ predicted rating changes which is used in the browser extension.

    IP based rate limit is enforced for both the API and the website using express-rate-limit.

    Development

    Setup

    • Clone the repository

      git clone https://github.com/SysSn13/leetcode-rating-predictor
    • Install the dependencies

      npm install
    • Setup environment variables

      cp .env.example .env

      Fill in the required values in the .env file.

    • Build the predict-addon (if you are using different node version)

      npm run buildAddon
    • Start the project

      npm start
    • Or start the development server by:

      npm run dev

    Environment variables

    DATABASE_URL: Connection string for mongodb.
    
    # for web
    WEB: Whether to run the website or not. (0 or 1)
    
    RATE_LIMIT_WINDOW: Window size for rate limit in milliseconds (default: 10000).
    
    RATE_LIMIT: Number of requests allowed in the window (default: 50).
    
    
    # for api
    API_DISABLED: Whether to disable the API or not. (0 or 1)
    
    API_RATE_LIMIT_WINDOW: Window size for API rate limit in milliseconds (default: 10000).
    
    API_RATE_LIMIT: Number of API requests allowed in the window (default: 20).
    
    
    # for background
    BACKGROUND: Whether to run the background or not. (0 or 1)
    
    REDIS_URL: Connection string for redis.
    
    THREAD_CNT: Number of threads for prediction.(default: 4)
    
    # bull-board auth
    BULLBOARD_USERNAME: username for bull-board login
    
    BULLBOARD_PASS: password for bull-board login
    
    SESSION_SECRET: secret to hash the session
    
    

    Browser extension

    Current only chrome browser is supported. It uses manifest V3. See this for getting started with extension development. Source code for the extension is in ./chrome-extension.

    Contributing

    You can contribute by creating issues, feature/ pull requests. Any meaningful contributions you make are greatly appreciated.

    For contributing in the source code, please follow these steps:

    • Fork the Project
    • Create your new Branch
      git checkout -b feature/AmazingFeature
    • Commit your Changes
      git commit -m 'Add some AmazingFeature'
      
    • Push to the Branch
      git push origin feature/AmazingFeature
      
    • Open a Pull Request

    Contributors

    Stargazers

    Stargazers repo roster for @SysSn13/leetcode-rating-predictor

    License

    Distributed under the MIT License. See LICENSE for more information.


    Back to top

    Visit original content creator repository https://github.com/SysSn13/leetcode-rating-predictor
  • cvector.h

    cvector(1)

    MIT License Quality Grade example workflow

    Generic & Typesafe Vector/List implementation in C (~150 LOC).

    About

    Vector/List is fundamental data structure for just about anything. Almost all programming languages as a builtin or packaged into standard library except for C. Also, it includes Iterator for free which allows you to do pretty interesting stuff such as peek, next, done, etc.

    Go to cvector.h for complete list of APIs.

    Installation

    It has a single header file called cvector.h. You can simply copy/paste in your source directory to get started. You can also install via clib (package manager for C).

    With clib:

    clib install robusgauli/cvector

    Usage

    Simple example

    #include "cvector.h"
    
    int main() {
      // Define type that holds vector of int
      CVector(int) vector_int_t;
    
      // Declare variable of type `vector_int_t`
      vector_int_t vector_int;
    
      // Initialize
      cvector__init(&vector_int);
    
      // Push number to vector
      for (int i = 0; i < 100; i++) {
        cvector__add(&vector_int, i);
      }
    
      // Size of the vector
      size_t size = cvector__size(&vector_int);
    
      // Iterate over elements
      for (int i = 0; i < 100; i++) {
        int number = cvector__index(&vector_int, i);
        printf("Number is: %d\n", number);
      }
    }

    With Iterator

    #include "cvector.h"
    
    // Define zero type of int
    CVector(int) vector_int_t;
    
    
    // Define iterator type for iterator_int_t
    CVector_iterator(vector_int_t) iterator_int_t;
    
    int main() {
    
      // Declare variable of type `zero_int_t`
      vector_int_t vector_int;
    
      // Initialize
      cvector__init(&vector_int);
    
      // Push elements to vector
      for (int i = 0; i < 10; i++) {
        cvector__add(&vector_int, i*i);
      }
    
      // Declare varaible of type `iterator_int_t`
      iterator_int_t iterator_int;
    
      // Initialize iterator with vector of int
      cvector_iterator__init(&iterator_int, &vector_int);
    
      // Peek the current element
      int number = cvector_iterator__peek(&iterator_int);
      printf("The peeked number is: %d\n", number);
    
      // Iterate using iterator
      for (;;) {
        if (cvector_iterator__done(&iterator_int)) {
          break;
        }
    
        int number = cvector_iterator__next(&iterator_int);
        printf("Got number: %d\n", number);
      }
    }

    Using struct

    #include "cvector.h"
    
    typedef struct Node_t {
      int x;
      int y;
    } Node_t;
    
    int main() {
      // Define vector type of `Node_t`
      CVector(Node_t) vector_node_t;
    
      // Declare variable of type `vector_node_t`
      vector_node_t vector_node;
    
      // Initialize vector
      cvector__init(&vector_node);
    
      // Push to vector
      for (int i = 0; i < 100; i++) {
        Node_t node = ((Node_t){.x = i, .y = i*i});
        cvector__add(&vector_node, node);
      }
    
      // Define iterator of type `vector_node_t`
      CVector_iterator(vector_node_t) iterator_node_t;
    
      // Declare variable of type `iterator_node_t`
      iterator_node_t iterator_node;
    
      // Initialize iterator
      cvector_iterator__init(&iterator_node, &vector_node);
    
      // Iterate
      for(;;) {
        if (cvector_iterator__done(&iterator_node)) {
          break;
        }
    
        Node_t node = cvector_iterator__next(&iterator_node);
        printf("Node: x -> %d & y -> %d\n", node.x, node.y);
      }
    }

    More APIs (cvector.h)

    #include <cvector.h>
    
    int main() {
      CVector(int) vector_int_t;
      vector_int_t vector_int;
    
      cvector__init(&vector_int);
    
      cvector__add(&vector_int, 12);
      cvector__add(&vector_int, 13);
      cvector__add(&vector_int, 14);
      cvector__add(&vector_int, 15);
    
      // First
      {
        // Get the first element
        int number = cvector__first(&vector_int);
        printf("First element: %d\n", number);
      }
    
      // Last
      {
        // Get the last element by reference
        int* number = cvector__last_ref(&vector_int);
        printf("Last element: %d\n", *number);
      }
    
      // Pop
      {
        size_t size_before = cvector__size(&vector_int);
    
        printf("Size of vector before pop: %ld\n", size_before);
    
        // Pop element from the vector
        int number = cvector__pop(&vector_int);
    
        printf("Popped element: %d\n", number);
    
        size_t size_after = cvector__size(&vector_int);
        printf("Size of vector after pop: %ld\n", size_after);
      }
    
      // Set value at index
      {
        if(cvector__set_at_index(&vector_int, 0, 56) == -1) {
          fprintf(stderr, "Failed to set the value '56' at index '0'");
        }
      }
    }

    License

    Copyright © 2020-20121 Robus, LLC. This source code is licensed under the MIT license found in the [LICENSE.txt] The documentation to the project is licensed under the CC BY-SA 4.0 license.


    Made with ♥ by Robus Gauli ([@robusgauli]

    Visit original content creator repository https://github.com/RobusGauli/cvector.h
  • cvector.h

    cvector(1)

    MIT License Quality Grade example workflow

    Generic & Typesafe Vector/List implementation in C (~150 LOC).

    About

    Vector/List is fundamental data structure for just about anything. Almost all programming languages as a builtin or packaged into standard library except for C. Also, it includes Iterator for free which allows you to do pretty interesting stuff such as peek, next, done, etc.

    Go to cvector.h for complete list of APIs.

    Installation

    It has a single header file called cvector.h. You can simply copy/paste in your source directory to get started. You can also install via clib (package manager for C).

    With clib:

    clib install robusgauli/cvector

    Usage

    Simple example

    #include "cvector.h"
    
    int main() {
      // Define type that holds vector of int
      CVector(int) vector_int_t;
    
      // Declare variable of type `vector_int_t`
      vector_int_t vector_int;
    
      // Initialize
      cvector__init(&vector_int);
    
      // Push number to vector
      for (int i = 0; i < 100; i++) {
        cvector__add(&vector_int, i);
      }
    
      // Size of the vector
      size_t size = cvector__size(&vector_int);
    
      // Iterate over elements
      for (int i = 0; i < 100; i++) {
        int number = cvector__index(&vector_int, i);
        printf("Number is: %d\n", number);
      }
    }

    With Iterator

    #include "cvector.h"
    
    // Define zero type of int
    CVector(int) vector_int_t;
    
    
    // Define iterator type for iterator_int_t
    CVector_iterator(vector_int_t) iterator_int_t;
    
    int main() {
    
      // Declare variable of type `zero_int_t`
      vector_int_t vector_int;
    
      // Initialize
      cvector__init(&vector_int);
    
      // Push elements to vector
      for (int i = 0; i < 10; i++) {
        cvector__add(&vector_int, i*i);
      }
    
      // Declare varaible of type `iterator_int_t`
      iterator_int_t iterator_int;
    
      // Initialize iterator with vector of int
      cvector_iterator__init(&iterator_int, &vector_int);
    
      // Peek the current element
      int number = cvector_iterator__peek(&iterator_int);
      printf("The peeked number is: %d\n", number);
    
      // Iterate using iterator
      for (;;) {
        if (cvector_iterator__done(&iterator_int)) {
          break;
        }
    
        int number = cvector_iterator__next(&iterator_int);
        printf("Got number: %d\n", number);
      }
    }

    Using struct

    #include "cvector.h"
    
    typedef struct Node_t {
      int x;
      int y;
    } Node_t;
    
    int main() {
      // Define vector type of `Node_t`
      CVector(Node_t) vector_node_t;
    
      // Declare variable of type `vector_node_t`
      vector_node_t vector_node;
    
      // Initialize vector
      cvector__init(&vector_node);
    
      // Push to vector
      for (int i = 0; i < 100; i++) {
        Node_t node = ((Node_t){.x = i, .y = i*i});
        cvector__add(&vector_node, node);
      }
    
      // Define iterator of type `vector_node_t`
      CVector_iterator(vector_node_t) iterator_node_t;
    
      // Declare variable of type `iterator_node_t`
      iterator_node_t iterator_node;
    
      // Initialize iterator
      cvector_iterator__init(&iterator_node, &vector_node);
    
      // Iterate
      for(;;) {
        if (cvector_iterator__done(&iterator_node)) {
          break;
        }
    
        Node_t node = cvector_iterator__next(&iterator_node);
        printf("Node: x -> %d & y -> %d\n", node.x, node.y);
      }
    }

    More APIs (cvector.h)

    #include <cvector.h>
    
    int main() {
      CVector(int) vector_int_t;
      vector_int_t vector_int;
    
      cvector__init(&vector_int);
    
      cvector__add(&vector_int, 12);
      cvector__add(&vector_int, 13);
      cvector__add(&vector_int, 14);
      cvector__add(&vector_int, 15);
    
      // First
      {
        // Get the first element
        int number = cvector__first(&vector_int);
        printf("First element: %d\n", number);
      }
    
      // Last
      {
        // Get the last element by reference
        int* number = cvector__last_ref(&vector_int);
        printf("Last element: %d\n", *number);
      }
    
      // Pop
      {
        size_t size_before = cvector__size(&vector_int);
    
        printf("Size of vector before pop: %ld\n", size_before);
    
        // Pop element from the vector
        int number = cvector__pop(&vector_int);
    
        printf("Popped element: %d\n", number);
    
        size_t size_after = cvector__size(&vector_int);
        printf("Size of vector after pop: %ld\n", size_after);
      }
    
      // Set value at index
      {
        if(cvector__set_at_index(&vector_int, 0, 56) == -1) {
          fprintf(stderr, "Failed to set the value '56' at index '0'");
        }
      }
    }

    License

    Copyright © 2020-20121 Robus, LLC. This source code is licensed under the MIT license found in the [LICENSE.txt] The documentation to the project is licensed under the CC BY-SA 4.0 license.


    Made with ♥ by Robus Gauli ([@robusgauli]

    Visit original content creator repository https://github.com/RobusGauli/cvector.h
  • wishlists

    Wishlists Microservice

    Build Status codecov License

    The wishlists resource allows customers to create a collection of products that they wish they had the money to purchase. A customer might have multiple wishlists so they might want to name them for easy identification.

    LIVE URL

    (urls below do not currently work since we have revoked the ibm cloud membership)

    Prerequisite Installation using Vagrant VM

    The easiest way to use this lab is with Vagrant and VirtualBox. if you don’t have these software, then the first step is to download and install them.

    Download VirtualBox

    Download Vagrant

    Then all you have to do is to clone this repo and invoke vagrant:

    git clone https://github.com/wishlists/wishlists
    cd wishlists
    vagrant up
    vagrant ssh
    cd /vagrant
    

    You can run the code to test it out in your browser with the following command:

    honcho start
    

    When you are done, you can use Ctrl+C to stop the server and then exit and shut down the vm.

    Features supported

    GET /wishlists – Return all the wishlists

    GET /wishlists/{wishlist_id} – Return the wishlists with the given id

    POST /wishlists – Create a new wishlist record in the database

    PUT /wishlists/{wishlist_id} – Update a wishlist record in the database

    DELETE /wishlists/{wishlist_id} – Delete a wishlist record in the database

    GET /wishlists?name=wishlist_1 – Query the database by the name of the wishlist

    GET /wishlists?user_id=1 – Query the database by the user id of the wishlist

    PUT /wishlists/{wishlist_id}/disabled – It disables the target wishlist

    PUT /wishlists/{wishlist_id}/enabled – It enables the target wishlist

    POST /wishlists/{wishlist_id}/items – Add item into target wishlist

    GET /wishlists/{wishlist_id}/items/{item_id} – Get item by its id from target wishlist

    PUT /wishlists/{wishlist_id} – Updates an existing wishlist

    DELETE /wishlists/{wishlist_id}/items/{item_id} – Delete item by its id from target wishlist

    Manually running the Tests

    You can now run behave and nosetests to run the BDD and TDD tests respectively.

    Run the tests using nose

        $ nosetests

    Nose is configured via the included setup.cfg file to automatically include the flags --with-spec --spec-color so that red-green-refactor is meaningful. If you are in a command shell that supports colors, passing tests will be green while failing tests will be red.

    Nose is also configured to automatically run the coverage tool and you should see a percentage of coverage report at the end of your tests. If you want to see what lines of code were not tested use:

        $ coverage report -m

    This is particularly useful because it reports the line numbers for the code that is not covered so that you can write more test cases to get higher code coverage.

    You can also manually run nosetests with coverage (but setup.cfg does this already)

        $ nosetests --with-coverage --cover-package=service

    Run the tests using behave

        $ behave

    Behave is configured in features directory.

    Running Pylint to check PEP8

    vagrant up
    vagrant ssh
    cd /vagrant
    pylint --rcfile=pylint.conf service/*.py
    pylint --rcfile=pylint.conf tests/*.py
    
    Visit original content creator repository https://github.com/wishlists/wishlists
  • terraform-aws-ecs-task-execution-role

    Usage

    Creates an IAM role for use as an ECS task execution role.

    module "ecs_task_execution_role" {
      source = "dod-iac/ecs-task-execution-role/aws"
    
      allow_create_log_groups    = true
      cloudwatch_log_group_names = ["*"]
      name = format("app-%s-task-execution-role-%s", var.application, var.environment)
    
      tags  = {
        Application = var.application
        Environment = var.environment
        Automation  = "Terraform"
      }
    }

    Creates an IAM role for use as an ECS task execution role that writes to a specific list of encrypted CloudWatch log groups.

    module "cloudwatch_kms_key" {
      source = "dod-iac/cloudwatch-kms-key/aws"
    
      name = format("alias/app-%s-cloudwatch-logs-%s", var.application, var.environment)
    
      tags  = {
        Application = var.application
        Environment = var.environment
        Automation  = "Terraform"
      }
    }
    
    resource "aws_cloudwatch_log_group" "main" {
      name              = format("/aws/ecs/app-%s-%s", var.application, var.environment)
      retention_in_days = 1 # expire logs after 1 day
      kms_key_id        = module.cloudwatch_kms_key.aws_kms_key_arn
    
      tags  = {
        Application = var.application
        Environment = var.environment
        Automation  = "Terraform"
      }
    }
    
    module "ecs_task_execution_role" {
      source = "dod-iac/ecs-task-execution-role/aws"
    
      cloudwatch_log_group_names = [module.cloudwatch_log_group.name]
      name = format("app-%s-task-execution-role-%s", var.application, var.environment)
    
      tags  = {
        Application = var.application
        Environment = var.environment
        Automation  = "Terraform"
      }
    }

    Testing

    Run all terratest tests using the terratest script. If using aws-vault, you could use aws-vault exec $AWS_PROFILE -- terratest. The AWS_DEFAULT_REGION environment variable is required by the tests. Use TT_SKIP_DESTROY=1 to not destroy the infrastructure created during the tests. Use TT_VERBOSE=1 to log all tests as they are run. The go test command can be executed directly, too.

    Terraform Version

    Terraform 0.13. Pin module version to ~> 1.0.0 . Submit pull-requests to main branch.

    Terraform 0.11 and 0.12 are not supported.

    License

    This project constitutes a work of the United States Government and is not subject to domestic copyright protection under 17 USC § 105. However, because the project utilizes code licensed from contributors and other third parties, it therefore is licensed under the MIT License. See LICENSE file for more information.

    Requirements

    Name Version
    terraform >= 0.13
    aws >= 3.0, < 5.0

    Providers

    Name Version
    aws >= 3.0, < 5.0

    Modules

    No modules.

    Resources

    Name Type
    aws_iam_policy.main resource
    aws_iam_role.main resource
    aws_iam_role_policy_attachment.main resource
    aws_caller_identity.current data source
    aws_iam_policy_document.assume_role_policy data source
    aws_iam_policy_document.main data source
    aws_partition.current data source
    aws_region.current data source

    Inputs

    Name Description Type Default Required
    allow_create_log_groups Allow role to create CloudWatch log groups. bool false no
    allow_ecr Allow instance to pull a container image from an ECR repository. bool false no
    assume_role_policy The assume role policy for the AWS IAM role. If blank, allows ECS tasks in the account to assume the role. string "" no
    cloudwatch_log_group_names List of names of CloudWatch log groups that this task execution role can write to. Use [“*”] to allow all log groups. list(string) n/a yes
    name The name of the AWS IAM role. string n/a yes
    policy_description The description of the AWS IAM policy attached to the IAM task execution role. Defaults to “The policy for [NAME]”. string "" no
    policy_document The contents of the AWS IAM policy attached to the IAM task execution role. If not defined, then uses a generated policy. string "" no
    policy_name The name of the AWS IAM policy attached to the IAM task execution role. Defaults to “[NAME]-policy”. string "" no
    tags Tags applied to the AWS IAM role. map(string) {} no

    Outputs

    Name Description
    arn The Amazon Resource Name (ARN) of the AWS IAM Role.
    name The name of the AWS IAM Role.

    Visit original content creator repository
    https://github.com/dod-iac/terraform-aws-ecs-task-execution-role

  • dwlive

    dwlive

    Make a live CD Debian with dwagent (https://www.dwservice.net/)

    Make dwlive

    Install

    sudo apt install debootstrap xorriso live-build syslinux squashfs-tools isolinux grub-efi-amd64-bin
    
    cp config.dist config
    

    Change livework and os_version to your needs.

    Make

    sudo ./make_iso.sh
    

    If no error, you should get dwlive-debian-amd64.iso.
    Now, you can copy the iso on a usb stick.

    User dwlive

    «IT support» = the person helping
    «client» = the person who needs help

    IT support (person who helping)

    Sign up on https://www.dwservice.net/
    Go to Agents. Add new Agent.
    Send the code (like 123-456-789) and the dwlive’s iso to your client
    Wait your client enter the code.
    Afer that, you have access to his computer.

    Tips

    If you whant to fix de Gnu/Linux, you can run it with display.
    This is how to do.
    Mount the OS partition :

    mount /dev/sda1 /media/ # change sda1 to your conf
    

    or for lvm

    vgscan
    vgchange -ay ubuntu-vg # change ubuntu-vg to your conf
    mount /dev/ubuntu-vg/ubuntu-lv /media/
    

    Start X server :

    ./1_startx.sh
    

    Now on https://www.dwservice.net/, you can select a screen.
    Go to the screen tab, and

    2_run_os.sh
    

    After login, you can do :

    export DISPLAY=:1
    mate-session& # or cinamon-session or kde-session or...
    

    Client (person who needs help)

    Copy dwlive on a usb stick.
    Boot the computer on the usb stick.
    Valide questions about the key board. If you didn’t know the answer, just press enter.
    At the question «Please choose an operation», select 1.
    Then enter the code given by your IT support (like 123-456-789).

    Visit original content creator repository
    https://github.com/Oros42/dwlive

  • mongomove

    mongomove

    PkgGoDev

    mongomove is a utility tool that facilitates the migration of databases from one MongoDB server to another. It’s especially handy for transferring data between remote servers and local development environments.

    Installation

    As a Command-line Tool:

    go install github.com/bounoable/mongomove/cmd/mongomove@latest

    As a Library:

    go get github.com/bounoable/mongomove

    Usage

    Import All Databases

    Move databases from one server to another:

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018

    Filter Databases By Prefix

    Migrate databases that start with a specific prefix:

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018 -prefix my_

    Skip Confirmation

    To bypass the confirmation prompt:

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018 -confirm

    Insert Documents in Batches

    Specify the number of documents to process in a single batch (default is 100):

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018 -b 500

    Parallelize the Import Process

    Set the number of concurrent database imports. By default, mongomove uses the number of CPUs available:

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018 -p 2

    Disable Index Creation

    Prevent the creation of indexes during import:

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018 -indexes false

    Enable Verbose Output

    For a more detailed output:

    mongomove -source mongodb://127.0.0.1:27017 -target mongodb://127.0.0.1:27018 -v

    License

    MIT.

    Visit original content creator repository https://github.com/bounoable/mongomove
  • text-reuse-test

    Tracer

    System requirements

    • Any OS (Windows/OS X/Linux)
    • Java 8 — not higher!
    • Apache Ant (a build tool)

    NB! Only use ant command when compiling Tracer, any flags (like verbose) will later result in “Unable to access jarfile” error.

    Download & compilation

    git clone http://vcs.etrap.eu/tracer-framework/tracer.git

    cd tracer

    ant

    Running

    java -Xmx600m -Deu.etrap.medusa.config.ClassConfig=conf/tracer_config.xml -jar tracer.jar > FILENAME.OUT

    • Your data must be a single .txt file in tracer/data/corpora/*some-folder*
    • Check and update tracer/conf/tracer_config.xml before running

    Manual

    Passim

    Requirements

    • Java 8 — not higher!
    • Scala
    • Sbt ( a build tool for JVM languages)
    • Apache Spark
      • Comes with Java 11
      • Depends on Hadoop, which has native libraries that aren’t supported in OS X → won’t run on a Mac

    NB! Build Passim with sbt before installing Apache Spark. Spark comes with Java 11, which results in build conflicts when you are compiling Passim with sbt.

    Download & compilation

    git clone https://github.com/dasmiq/passim.git

    cd passim

    build/sbt package

    This should produce a runnable .jar in target/scala_*/passim*.jar.

    Running

    passim "{input.json,directory-of-json-files,some*.json.bz2}" output

    Docs

    GitHub repo

    Visit original content creator repository
    https://github.com/ancatmara/text-reuse-test

  • react-native-eslint-prettier-example

    How to set up ESLint and Prettier in a React Native app.

    This project was bootstrapped with React Native CLI.

    Available Scripts

    To see how you can run this app for iOS or Android please see the Running your React Native application section from the React Native Documentation. For this sample, we’ll ignore those details.

    Install and setup ESLint

    1. npm uninstall @react-native-community/eslint-config – React Native 0.63.4 (at the moment of this writing) comes with a predefined eslint config, but we’ll remove that package because we’ll create our own config.

    2. npm uninstall eslint – React Native 0.63.4 (at the moment of this writing) doesn’t come with the latest eslint version, so we’ll simply uninstall it and then install it again to pull the latest version.

    3. npm install eslint --save-dev – install the latest eslint package version.

    4. npx eslint --init – set up a configuration file for eslint. This command will ask you a few questions via CLI. Here’s a list of them, and the answers we’ll need to choose ( and symbols indicate the selected answers):

    # question 1:
    ? How would you like to use ESLint? …
      To check syntax only
      To check syntax and find problems
    ❯ To check syntax, find problems, and enforce code style
    
    # question 2:
    ? What type of modules does your project use? …
    ❯ JavaScript modules (import/export)
      CommonJS (require/exports)
      None of these
    
    # question 3:
    ? Which framework does your project use? …
    ❯ React
      Vue.js
      None of these
    
    # question 4 (select "No", because we won't add TypeScript support for this project):
    ? Does your project use TypeScript? › No / Yes
    
    # question 5:
    ? Where does your code run? …
      Browser
    ✔ Node
    
    # question 6:
    ? How would you like to define a style for your project? …
    ❯ Use a popular style guide
      Answer questions about your style
      Inspect your JavaScript file(s)
    
    # question 7 (we'll rely on Airbnb's JavaScript style guide here):
    ? Which style guide do you want to follow? …
    ❯ Airbnb: https://github.com/airbnb/javascript
      Standard: https://github.com/standard/standard
      Google: https://github.com/google/eslint-config-google
    
    # question 8:
    ? What format do you want your config file to be in? …
      JavaScript
      YAML
    ❯ JSON
    
    # the final prompt here is where eslint will ask you if you want to install all the necessary dependencies. Select "Yes" and hit enter:
    Checking peerDependencies of eslint-config-airbnb@latest
    The config that you have selected requires the following dependencies:
    
    eslint-plugin-react@^7.21.5 eslint-config-airbnb@latest eslint@^5.16.0 || ^6.8.0 || ^7.2.0 eslint-plugin-import@^2.22.1 eslint-plugin-jsx-a11y@^6.4.1 eslint-plugin-react-hooks@^4 || ^3 || ^2.3.0 || ^1.7.0
    
    ? Would you like to install them now with npm? › No / Yes

    As a result, you’ll end up having a .eslintrc.json file in the root of your project, which looks like so (we’ll modify it a little bit later on):

    {
        "env": {
            "es2021": true,
            "node": true,
        },
        "extends": [
            "plugin:react/recommended",
            "airbnb"
        ],
        "parserOptions": {
            "ecmaFeatures": {
                "jsx": true
            },
            "ecmaVersion": 12,
            "sourceType": "module"
        },
        "plugins": [
            "react"
        ],
        "rules": {
        }
    }

    NOTE: React Native comes (at the moment of this writing) with a .eslintrc.js config, and if that’s still the case for you, then simply remove it, since we’ll use the JSON format of that config.

    1. React Hooks are pretty popular at this point and most likely every new React Native project will make use of them, so let’s add the recommended ESLint rules for hooks. For that, update the extends section of your .eslintrc.json file like so:

    {
        //...
        "extends": [
            "plugin:react/recommended",
            "airbnb",
            "airbnb/hooks"
        ],
        //...
    }
    1. npm install --save-dev eslint-plugin-react-native – add support for React Native specific ESLint rules. After installing this package, update the plugins section of your .eslintrc.json file like so:

    {
        //...
        "plugins": [
            "react",
            "react-native"
        ],
        //...
    }
    1. Create a .eslintignore file in the root on your project to tell ESLint to ignore specific files and directories, and then add the following contents:
    node_modules/

    In our case, we simply want to ignore the node_modules folder from being linted.

    1. Last step here, is to configure your code editor to lint the code for you. If you’re a VS Code user, simply install the ESLint VS Code extension. The only ESLint configuration you need to add to your VS Code settings is the following:

    {
        "editor.codeActionsOnSave": {
            "source.fixAll.eslint": true
        }
    }

    NOTE: You may want to add these VS Code settings as Workspace settings instead of User settings, meaning that they will only apply to this specific project and not to any project you’ll open in VS Code. Read more on the VS Code Documentation page.

    Install and setup Prettier

    1. npm install --save-dev --save-exact prettier – add the prettier package as a dev dependency to your project. We’ll also install and use the Prettier VS Code extension later on, which already comes with Prettier package bundled in, but in general it’s a good practice to add the npm package to your project directly as well, just in case some people won’t use VS Code as their code editor of choice.

    2. npm install --save-dev eslint-config-prettier – we’ll use Prettier for code formatting concerns, and ESLint for code-quality concerns, so we need to turns off all ESLint rules that are unnecessary or might conflict with Prettier. Once the package has been installed, we need to update the extends section of your .eslintrc.json file like so:

    {
        //...
        "extends": [
            "plugin:react/recommended",
            "airbnb",
            "airbnb/hooks",
            "prettier",
            "prettier/react"
        ],
        //...
    }
    1. Create a .prettierrc.json configuration file in the root of your project with the following options:

    {
        "arrowParens": "always",
        "bracketSpacing": true,
        "jsxBracketSameLine": false,
        "jsxSingleQuote": false,
        "quoteProps": "as-needed",
        "singleQuote": true,
        "semi": true,
        "printWidth": 100,
        "useTabs": false,
        "tabWidth": 2,
        "trailingComma": "es5"
    }

    For more Prettier configuration options and an explanation of what each option does, see Prettier Documentation.

    NOTE: React Native comes (at the moment of this writing) with a .prettierrc config already, and if that’s still the case for you, then you can still use that config file instead of creating a new .prettierrc.json one. They both use the JSON format for specifying configuration options.

    1. Last step here, is to configure your code editor to format your code using Prettier. If you’re a VS Code user, simply install the Prettier VS Code extension. After the extension has been installed, add the following settings to your VS Code JSON config:

    {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.formatOnSave": true
    }

    Final step

    If you’re planning to have your React Native components written in .js files (which how this sample React Native project does), then you’ll need to update the react/jsx-filename-extension ESLint rule for React to allow JSX in .js files. The final version of your .eslintrc.json file should look like this.

    You can enable/disable/modify any ESLint rules within the rules section of your .eslintrc.json file.

    Visit original content creator repository
    https://github.com/vasilestefirta/react-native-eslint-prettier-example