Blog

  • SQL-Task-1

    SQLBolt:

    SQL exercises from sqlbolt.com.:

    Index:

    1. SELECT Queries 101:

    1.Find the title of each film.
    SELECT title
    FROM movies;
    2.Find the director of each film.
    SELECT director
    FROM movies;
    3.Find the title and director of each film.
    SELECT title, director
    FROM movies;
    4.Find the title and year of each film.
    SELECT title, year
    FROM movies;
    5Find all the information about each film.
    SELECT *
    FROM movies;

    1. Queries With Constraints (Pt. 1):

    1.Find the movie with a row id of 6.
    SELECT title
    FROM movies
    WHERE id = 6;
    2.Find the movies released in the years between 2000 and 2010.
    SELECT title
    FROM movies
    WHERE year BETWEEN 2000 AND 2010;
    3.Find the movies not released in the years between 2000 and 2010.
    SELECT title
    FROM movie
    WHERE year NOT BETWEEN 2000 and 2010;
    4.Find the first 5 Pixar movies and their release year.
    SELECT title, year
    FROM movies
    WHERE year <= 2003;

    1. Queries With Constraints (Pt. 2):

    1.Find all the Toy Story movies.
    SELECT title
    FROM movies
    WHERE title LIKE ‘Toy Story%’;
    2.Find all the movies directed by John Lasseter.
    SELECT title
    FROM movies
    WHERE director = ‘John Lasseter’;
    3.Find all the movies (and director) not directed by John Lasseter.
    SELECT title
    FROM movies
    WHERE director != ‘John Lasseter’;
    4.Find all the WALL-* movies.
    SELECT title
    FROM movies
    WHERE title LIKE ‘WALL-%’;

    1. Filtering and Sorting Query Results:

    1.List all directors of Pixar movies (alphabetically), without duplicates.
    SELECT DISTINCT director
    FROM movies
    ORDER BY director;
    2.List the last four Pixar movies released (ordered from most recent to least).
    SELECT title
    FROM movies
    ORDER BY year DESC
    LIMIT 4;
    3.List the first five Pixar movies sorted alphabetically.
    SELECT title
    FROM movies
    ORDER BY title
    LIMIT 5;
    4.List the next five Pixar movies sorted alphabetically.
    SELECT title
    FROM movies
    ORDER BY title
    LIMIT 5 OFFSET 5;

    1. Simple SELECT Queries:

    1.List all the Canadian cities and their populations.
    SELECT city, population
    FROM north_american_cities
    WHERE country = ‘Canada’;
    2.Order all the cities in the United States by their latitude from north to south.
    SELECT city
    FROM north_american_cities
    WHERE country = ‘United States’
    ORDER BY latitude DESC;
    3.List all the cities west of Chicago, ordered from west to east.
    SELECT city
    FROM north_american_cities
    WHERE longitude < -87.629798
    ORDER BY longitude;
    4.List the two largest cities in Mexico (by population).
    SELECT city
    FROM north_american_cities
    WHERE country = ‘Mexico’
    ORDER BY population DESC
    LIMIT 2;
    5.List the third and fourth largest cities (by population) in the United States and their population.
    SELECT city, population
    FROM north_american_cities
    WHERE country = ‘United States’
    ORDER BY population DESC
    LIMIT 2 OFFSET 2;

    1. Multi-table Queries With JOINs:

    1.Find the domestic and international sales for each movie.
    SELECT title, domestic_sales, international_sales
    FROM boxoffice
    JOIN movies ON movie_id = movies.id;
    2.Show the sales numbers for each movie that did better internationally rather than domestically.
    SELECT title, domestic_sales, international_sales
    FROM boxoffice
    JOIN movies ON movie_id = movies.id
    WHERE international_sales > domestic_sales;
    3.List all the movies by their ratings in descending order.
    SELECT title, rating
    FROM movies
    JOIN boxoffice ON movies.id = movie_id
    ORDER BY rating DESC;

    1. OUTER JOINs:

    1.Find the list of all buildings that have employees.
    SELECT DISTINCT building
    FROM employees
    LEFT JOIN buildings ON building = building_name;
    2.Find the list of all buildings and their capacity.
    SELECT building_name, capacity
    FROM buildings;
    3.List all buildings and the distinct employee roles in each building (including empty buildings).
    SELECT DISTINCT building_name, role
    FROM buildings
    LEFT JOIN employees ON building = building_name;

    1. A Short Note on NULLs:

    1.Find the name and role of all employees who have not been assigned to a building.
    SELECT name, role
    FROM employees
    WHERE building IS NULL;
    2.Find the names of the buildings that hold no employees.
    SELECT DISTINCT building_name
    FROM buildings
    LEFT JOIN employees ON building_name = building
    WHERE name IS NULL;

    1. Queries With Expressions:

    1.List all movies and their combined sales in millions of dollars.
    SELECT title,
    (domestic_sales + international_sales) / 1000000 AS gross_sales
    FROM movies
    JOIN boxoffice ON movies.id = boxoffice.movie_id;
    2.List all movies and their ratings in percent.
    SELECT title,
    rating * 10 AS rating_percent
    FROM movies
    JOIN boxoffice ON movies.id = boxoffice.movie_id;
    3.List all movies that were released on even number years.
    SELECT title
    FROM movies
    WHERE year % 2 = 0;

    1. Queries With Aggregates (Pt. 1):

    1.Find the longest time that an employee has been at the studio.
    SELECT MAX(years_employed) AS maximum_years_employed
    FROM employees;
    2.For each role, find the average number of years employed by employees in that role.
    SELECT role,
    AVG(years_employed) AS average_number_of_years
    FROM employees
    GROUP BY role;
    3.Find the total number of employee years worked in each building.
    SELECT building,
    SUM(years_employed) AS total_years
    FROM employees
    GROUP BY building;

    1. Queries With Aggregates (Pt. 2):

    1.Find the number of Artists in the studio (without a HAVING clause).
    SELECT COUNT(name) AS number_of_artists
    FROM employees
    WHERE role = ‘Artist’;
    2.Find the number of Employees of each role in the studio.
    SELECT role,
    COUNT(name) AS employees
    FROM employees
    GROUP by role;
    3.Find the total number of years employed by all Engineers.
    SELECT role,
    SUM(years_employed) AS total_years_employed
    FROM employees
    GROUP BY role
    HAVING role = ‘Engineer’;

    1. Order of Execution of a Query:

    1. FROM and JOINs

    2. WHERE

    3. GROUP BY

    4. HAVING

    5. SELECT

    6. DISTINCT

    7. ORDER BY

    8. LIMIT / OFFSET
      ->Find the number of movies each director has directed.
      SELECT director,
      COUNT(title) AS number_of_movies
      FROM movies
      GROUP BY director;
      ->Find the total domestic and international sales that can be attributed to each director.
      SELECT director,
      SUM(domestic_sales + international_sales) AS total_sales
      FROM movies
      JOIN boxoffice ON movies.id = boxoffice.movie_id
      GROUP BY director;

    9. Inserting Rows:


    ->Add the studio’s new production, Toy Story 4 to the list of movies (you can use any director).
    INSERT INTO movies
    VALUES (4, ‘Toy Story 4’, ‘John Lasseter’, 2017, 90);
    ->Toy Story 4 has been released to critical acclaim! It had a rating of 8.7, and made 340 million domestically and 270 million internationally. Add the record to the BoxOffice table.
    INSERT INTO boxoffice
    VALUES (4, 8.7, 340000000, 270000000);

    1. Updating Rows:

    ->The director for A Bug’s Life is incorrect, it was actually directed by John Lasseter.
    UPDATE movies
    SET director = ‘John Lasseter’
    WHERE id = 2;
    ->The year that Toy Story 2 was released is incorrect, it was actually released in 1999.
    UPDATE movies
    SET year = 1999
    WHERE title = ‘Toy Story 2’;
    ->Both the title and director for Toy Story 8 is incorrect! The title should be “Toy Story 3” and it was directed by Lee Unkrich.
    UPDATE movies
    SET title = ‘Toy Story 3’,
    director = ‘Lee Unkrich’
    WHERE title = ‘Toy Story 8’
    AND director = ‘El Directore’;

    1. Deleting Rows

    ->This database is getting too big, lets remove all movies that were released before 2005.
    DELETE FROM movies
    WHERE year < 2005;
    ->Andrew Stanton has also left the studio, so please remove all movies directed by him.
    DELETE FROM movies
    WHERE director = ‘Andrew Stanton’;

    1. Creating Tables:

    ->Create a new table named Database with the following columns:
    Name A string (text) describing the name of the database
    Version A number (floating point) of the latest version of this database
    Download_count An integer count of the number of times this database was downloaded
    CREATE TABLE IF NOT EXISTS database (
    name STRING,
    version FLOAT,
    download_count INTEGER);

    1. Altering Tables:

    ->Add a column named Aspect_ratio with a FLOAT data type to store the aspect-ratio each movie was released in..
    ALTER TABLE movies
    ADD aspect_ratio FLOAT;
    ->Add another column named Language with a TEXT data type to store the language that the movie was released in. Ensure that the default for this language is English.
    ALTER TABLE movies
    ADD language TEXT DEFAULT ‘English’;

    1. Dropping Tables:

    ->We’ve sadly reached the end of our lessons, lets clean up by removing the Movies table.
    DROP TABLE IF EXISTS movies;
    ->And drop the BoxOffice table as well.
    DROP TABLE IF EXISTS boxoffice;

    Visit original content creator repository
    https://github.com/SanthoshKumar211299/SQL-Task-1

  • mapbox-gl-arcgis-tiled-map-service

    Mapbox GL Custom Source for ArcGIS Tiled Map Services

    2020 UPDATE

    This is no longer needed, most tiles services on AGOL, and newer versions of Server for ArcGIS are creating using compatible Web Mercator projections and zoom levels.

    Here is an update to the usage sample below using only the mapbox-gl-js built-in raster source:

    var map = new mapboxgl.Map({
      /* ... */
    });
    
    map.addSource('amazon-human-footprint', {
        "type": "raster",
        "url": "https://tiles.arcgis.com/tiles/RTK5Unh1Z71JKIiR/arcgis/rest/services/HumanFootprint/MapServer/tile/{z}/{y}/{x}",
        "tileSize": 256
    });
    
    map.addLayer({
      "id": "amazon-human-footprint",
      "type": "raster",
      "source": "amazon-human-footprint",
      "minzoom": 0,
      "maxzoom": 18,
      "paint": {
        "raster-opacity": 75
      });

    This may still be useful if you need to support older servers, or tile services not using the standard LOD.

    Original Readme

    This is an unofficial plugin, and is not affliated with Mapbox or Esri. 😇

    ⚠️🚧 Custom sources are still under development and have not yet been publicly documented. This custom source also depends on code above and beyond the API. This may break with future versions of mapbox-gl. 🚧⚠️

    • version 0.1.2 = tested with mapbox-gl-js v0.36.0
    • version 0.2.0 = tested with mapbox-gl-js v0.43.0
    • version 0.4.0 = tested with mapbox-gl-js v1.1.0
    • version 0.5.0 = tested with mapbox-gl-js v1.4.0

    🚦Limitations🚦

    Installation

    npm install mapbox-gl-arcgis-tiled-map-service

    or

    yarn add mapbox-gl-arcgis-tiled-map-service

    Usage

    var ArcGISRasterTileSource = require('mapbox-gl-arcgis-tiled-map-service');
    var map = new mapboxgl.Map({
      /* ... */
    });
    map.addSourceType('arcgisraster', ArcGISRasterTileSource, function(err) {
      if(err){
        /*do something*/
      }
    });
    
    map.addSource('amazon-human-footprint', {
        "type": "arcgisraster",
        "url": "https://tiles.arcgis.com/tiles/RTK5Unh1Z71JKIiR/arcgis/rest/services/HumanFootprint/MapServer?f=json",
        "tileSize": 256
    });
    
    map.addLayer({
      "id": "amazon-human-footprint",
      "type": "raster",
      "source": "amazon-human-footprint",
      "minzoom": 0,
      "maxzoom": 18,
      "paint": {
        "raster-opacity": 75
      });

    Development

    Build: npm run build-dev

    License

    MIT

    Attributions

    Some code was adapted from https://github.com/Leaflet/Leaflet and https://github.com/Esri/esri-leaflet

    Visit original content creator repository
    https://github.com/maphubs/mapbox-gl-arcgis-tiled-map-service

  • ScholarlyRecommender

    DeepSource
    DeepSource

    Logo

    Scholarly Recommender

    End-to-end product that sources recent academic publications and prepares a feed of recommended readings in seconds.
    Try it now »
    Explore the Docs · Report Bug · Request Feature

    Table of Contents
    1. About The Project
    2. Getting Started
    3. Usage
    4. Roadmap
    5. Contributing
    6. License
    7. Contact
    8. Methods
    9. Acknowledgements

    About The Project

    As an upcoming data scientist with a strong passion for deep learning, I am always looking for new technologies and methodologies. Naturally, I spend a considerable amount of time researching and reading new publications to accomplish this. However, over 14,000 academic papers are published every day on average, making it extremely tedious to continuously source papers relevant to my interests. My primary motivation for creating ScholarlyRecommender is to address this, creating a fully automated and personalized system that prepares a feed of academic papers relevant to me. This feed is prepared on demand, through a completely abstracted streamlit web interface, or sent directly to my email on a timed basis. This project was designed to be scalable and adaptable, and can be very easily adapted not only to your own interests, but become a fully automated, self improving newsletter. Details on how to use this system, the methods used for retrieval and ranking, along with future plans and features planned or in development currently are listed below.

    (back to top)

    Built With

    Python Streamlit Pandas NumPy Arxiv.arxiv

    (back to top)

    Getting Started

    To try ScholarlyRecommender, you can use the streamlit web application found Here. This will allow you to use the system in its entirety without needing to install anything. If you want to modify the system internally or add functionality, you can follow the directions below to install it locally.

    Prerequisites

    In order to install this app locally you need to have following:

    • git
    • python3.9 or greater (earlier versions may work)
    • pip3

    Installation

    To install ScholarlyRecommender, run the following in your command line shell

    1. Clone the repository from github and cd into it
      git clone https://github.com/iansnyder333/ScholarlyRecommender.git
      cd ScholarlyRecommender
    2. Set up the enviroment and install dependencies
      make build

    All done, ScholarlyRecommender is now installed. You can now run the app with

    make run

    (back to top)

    Usage

    Once installed, you want to calibrate the system to your own interests. The easiest way to do this is using the webapp.py file. Alternativley, you can use calibrate.py, which runs on the console.

    Make sure you are cd into the parent folder of the cloned repo.

    Run this in your terminal as follows:

    make run

    This is the same as running:

    streamlit run webapp.py

    Navigate to the configure tab and complete the steps. You can now navigate back to the get recommendations tab and generate results! The web app offers full functionality and serves as an api to the system, while using the webapp, updates made to the configuration will be applied and refreshed in a continuous manner.

    Note: If you are using ScholarlyRecommender locally, certain features such as direct email will not work as the original applications database will not be available. If you want to configure the email feature for yourself, you can follow the instructions provided in mail.py. This will require some proficiency/familiarity with SMPT. If you are having issues please feel free to check the docs, or make a discussion post here and someone will help you out.

    (back to top)

    Roadmap

    • ✅ Adding email support on the web app ✅
    • OS support, specifically for windows.
    • shell scripts to make installs, updates, and usage easier.
    • Database to store user configurations, currently zero user data is saved. Also would like to improve data locality and cache to improve user experience.
    • Making it easier to give feedback to suggested papers to improve the system
    • Improving the overall labeling experience, specifically the pooling process and labeling setup to be more integrated.
    • Improve modularity in the webapp and try to improve caching for faster performance.
    • Many visual and user experience improvements, a complete overhaul of the UX is likely.
    • Allowing users to navigate between pages without using the Navbar, streamlit does not currently support this directly.

    See the open issues for a full list of proposed features (and known issues).

    (back to top)

    Contributing

    Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

    If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!

    1. Fork the Project
    2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
    3. Commit your Changes (git commit -m 'Add some AmazingFeature')
    4. Push to the Branch (git push origin feature/AmazingFeature)
    5. Open a Pull Request

    (back to top)

    License

    Distributed under the apache license 2.0. See LICENSE for more information.

    (back to top)

    Contact

    Ian Snyder – @iansnydesidsnyder136@gmail.com

    Project Email – scholarlyrecommender@gmail.com

    My Website: iansnyder333.github.io/frontend/

    Linkedin: www.linkedin.com/in/iandsnyder

    (back to top)

    Methods

    Once candidates are sourced in the context of the configuration, they are ranked. The ranking process involves using the normalized compression distance combined with an inverse weighted top-k mean rating from the candidates to the labeled papers. This is a modified version of the algorithm described in the paper ““Low-Resource” Text Classification- A Parameter-Free Classification Method with Compressors” (1). The algorithm gets the top k most similar papers to each paper in the context that the user rated and calculates a weighted mean rating of those papers as its prediction. The results are then sorted by the papers with the highest predicting rating and are returned in accordance with the desired amount.

    While using a large language model such as BERT might yield a higher accuracy, this approach is considerably more lightweight, can run on basically any computer, and requires virtually no labeled data to source relevant content. If this project scales to the capacity of a self improving newsletter, implementing a sophisticated deep learning model such as a transformer could be a worthwhile addition.

    (back to top)

    Acknowledgements

    1“Low-Resource” Text Classification: A Parameter-Free Classification Method with Compressors (Jiang et al., Findings 2023)

    README TemplateBest-README-Template by (othneildrew)

    (back to top)

    Visit original content creator repository https://github.com/iansnyder333/ScholarlyRecommender
  • LLM-SysAdmin


    Logo

    Can LLMs Understand Computer Networks?

    Towards a Virtual System Administrator

    Preprint Available »

    Denis Donadel
    ·
    Francesco Marchiori
    ·
    Luca Pajola
    ·
    Mauro Conti

    Table of Contents
    1. Abstract
    2. Usage

    🧩 Abstract

    Recent advancements in Artificial Intelligence, and particularly Large Language Models (LLMs), offer promising prospects for aiding system administrators in managing the complexity of modern networks. However, despite this potential, a significant gap exists in the literature regarding the extent to which LLMs can understand computer networks. Without empirical evidence, system administrators might rely on these models without assurance of their efficacy in performing network-related tasks accurately. In this paper, we are the first to conduct an exhaustive study on LLMs’ comprehension of computer networks. We formulate several research questions to determine whether LLMs can provide correct answers when provided with a network topology and questions on it. To assess them, we developed a thorough framework for evaluating LLMs’ capabilities in various network-related tasks. We evaluate our framework on multiple computer networks employing private (e.g., GPT4) and open-source (e.g., Llama2) models. Our findings demonstrate promising results, with the best model achieving an average accuracy of 79.3%. Private LLMs achieve noteworthy results in small and medium networks, while challenges persist in comprehending complex network topologies, particularly for open-source models. Moreover, we provide insight into how prompt engineering can enhance the accuracy of some tasks.

    (back to top)

    ⚙️ Usage

    To access the NetJSONs and the prompts we use in our study, clone the repository using the following command.

    git clone https://github.com/spritz-group/LLM-SysAdmin.git
    cd LLM-SysAdmin

    (back to top)

    Visit original content creator repository
    https://github.com/spritz-group/LLM-SysAdmin

  • ptopi

    PToPI – A Research Compedium of

    A submitted article (title will be available after review)

    Last-changedate License: AGPL v3 ORCiD

    This platform is a research compedium of our academic publication submitted (the information will be available after reviews).

    The platform provides the following materials:

    • PToPI.xlsx: Periodic Table of (Binary-Classification) Performance (Evaluation) Instruments (open with Microsoft Excel™)
    • PToPI.dot, PToPI_NonRedundantMetricsOnly.dot, and PToPI.pdf: Dependency graph codes and outputs for 57 performance measures and metrics (Graphviz file). You can try dot files online at (https://edotor.net)

    An exploratory table (PToPI) presents the novel concepts introduced from multi-perspective analysis of 57 binary-classification performance instruments (29 measures and 28 metrics with 12 variant and parametric instruments). It is like a “periodic table of elements” in chemisstry.

    Please, refer to online data (will be available after review) providing comprehensive findings

    Note: Please, cite our article if you would like to use and/or adapt the code, datasets, methodology, and other materials provided and let us know. Thank you for your interest. Be aware that the exploratory table/tool PToPI by Gürol Canbek is licensed under CC BY-NC-ND 4.0. You can use PToPI for personal purposes or academical studies by giving a citation to the article above. See the “license for use” in the spreadsheet file.

    Visit original content creator repository https://github.com/gurol/ptopi
  • ViViT

    ViViT: A Video Vision Transformer

    1. How to Use

    from vivit import (
        SpatTempoAttnViViT, # Model 1: 'Spatio-temporal attention'
        FactorEncViViT, # Model 2: 'Factorised encoder'
        FactorSelfAttnViViT, # Model 3: 'Factorised self-attention'
    )
    
    # e.g.,
    num_frames = 16
    img_size = 224
    video = torch.randn((4, 3, num_frames, img_size, img_size))
    
    vit = timm.create_model("vit_base_patch16_224", pretrained=True)
    tempo_patch_size = 4
    spat_patch_size = 16
    num_classes = 1000
    pooling_mode="cls"
    model = FactorEncViViT(
        vit=vit,
        num_frames=num_frames,
        img_size=img_size,
        tempo_patch_size=tempo_patch_size,
        spat_patch_size=spat_patch_size,
        num_classes=num_classes,
        pooling_mode=pooling_mode,
    )
    
    device = torch.device("cuda")
    model = model.to(device)
    video = video.to(device)
    
    out = model(video) # (B, `num_classes`)

    2. Citation

    @misc{arnab2021vivit,
        title={ViViT: A Video Vision Transformer}, 
        author={Anurag Arnab and Mostafa Dehghani and Georg Heigold and Chen Sun and Mario Lučić and Cordelia Schmid},
        year={2021},
        eprint={2103.15691},
        archivePrefix={arXiv},
        primaryClass={cs.CV}
    }
    

    Visit original content creator repository
    https://github.com/KimRass/ViViT

  • bike-heatmap

    Heatmap Visualisation Tool For Multiple Bike Rides

    Create and customise a heatmap of your bike rides.

    Contents

    Examples

    My heatmap of 4 years of Deliveroo cycling with no background layer.

     

    My heatmap of 4 years of Deliveroo cycling with building and water layer behind.

     

    The resulting getagged .tif file can be imported into ArcGIS or QGIS for further analysis or rendering opportunities.

     

    Other scales are also possible. Below is the heatmap of my recreational rides in the vicinity of Bristol.

    Requirements

    The python packages can be installed using pip install -r requirements.txt.

    User Guide

    GPX Files

    The GPX files should be placed in one folder. Each GPX file should contain only one GPS track. The frequency of samples in the files should be constant. For best results the sampling frequency should be 1Hz (one sample per second).

    Command Line Arguments

    The example folder is an example folder with a few GPX files to demonstrate the command line arguments of the script.

    The required argument -folder or --f sets the folder which contains the GPX files. It searches all subfolders for GPX files in a recursive fashion too.

    The script can be run by simply writing:

    python3 draw.py -f example
    

    The extent of the map can be defined by the --area or -a argument. It expects a formatted string in the form “xmin,ymin,xmax,ymax” where xmin is the minimal longitude, ymin is the minimal latitude, xmax is the maximal longitude, ymax is the maximal latitude. If any of the four number is not given, it is inferred from the data itself. For example if we want to crop only the bottom we should run the following command:

    python3 draw.py -f example -a ,51.464753,,
    

    If we want to crop all four sides then run:

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004"
    

    We need the surrounding quotation signs and the extra space because the starting coordinate is negative.

    The algorithm divides the geographical area into a grid, and places all coordinate samples into the grid cells and counts the number of points in each cell. We can change the resolution of the underlying grid by the argument --bins or -b (default = 1200). We want to be sure that we get this parameter right because both too large or too small resolution might be unsatisfactory. An example use:

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004" -b 300
    

    The next argument is --limit or -l (default = 30). When a place is visited way too often than other places it makes all other places dark/invisible. By setting --limit lower we can add more colour to less visited places, by increasing it we can emphasise the most visited places. For example:

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004" -b 300 -l 150
    

    The argument --colormap or -c (default = inferno) can define the color-coding of the heatmap. We use matplotlib colourmaps. These colormaps can be used in the argument: https://matplotlib.org/stable/tutorials/colors/colormaps.html. For example another coloring:

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004" -b 300 -l 150 -c turbo
    

    Places visited very few times can seem to disappear from the image. By the --add_min or -m (default = 0) argument we can add more emphasis to these places, which means we compress the colours a little.

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004" -b 300 -l 150 -m 50
    

    There is an opportunity to smoothen the image. This can be achieved by the -smoothing or -s (default = 7) argument. It expects a non-negative number. 0 means that it does not perform smoothening. In the argument, the number n means that it will perform smoothening with a kernel of size 2n+1.

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004" -b 300 -l 150 -s 0
    

    Places where we stopped during our activities can be emphasised by the argument --emph_stops or -e (default = 1) argument. It expects a postive number, and the bigger this number is the more radical the effect will become.

    python3 draw.py -f example -a " -2.602665,51.444753,-2.592001,51.453004" -b 300 -l 150 -e 8
    

    Background Layers

    From the website https://download.geofabrik.de/europe/great-britain/england.html and other websites we can download shapefiles. Put them in the XML file and render it. Make sure the heatmap .tif file is interpolated either in bilinear or bicubic manner for best results.

    Visit original content creator repository https://github.com/csekri/bike-heatmap
  • php-bignumber

    php-bignumber

    release phpdownloads

    About

    中文文档

    The integer size in PHP is platform-dependent. The maximum size is usually 2 billion, and the maximum size on 64-bit platforms is usually 9E18.

    Floating-point Numbers have limited precision and depend on the system, so never trust floating-point Numbers to be accurate to the last bit, and never compare two floating-point Numbers to be equal.

    When the business scenario needs to deal with a large range of values or needs to accurately deal with floating point values, arbitrary precision mathematical functions should be used, such as: trading system, e-commerce system, etc.

    The current project encapsulates arbitrary precision mathematical functions to make it easier to solve large number and floating point precision problems in PHP.


    Installation

    First please make sure your PHP has been installed and the BC Math extension, if not support, specific installation reference website: http://php.net/manual/en/bc.installation.php

    See the way:

    php -info | grep bcmath
    

    If you can see the output

    bcmath
    bcmath.scale => 0 => 0
    

    BC Math is available

    Start the installation:

    1. Way 1: By composer

    composer require chawuciren/bignumber
    

    2. Way 2: Directly download and include

    Download the source code directly, introducing src/bignumber.php


    Begin to use

    Initialization of the incoming numeric string should be used, such as a out of numerical and later returned to the front interface, the type of stored in the database as a DECIMAL, should first initialize the value of the BigNumber will be removed, and then used in the code BigNumber calculated, after the return to use on interface: value () method for numerical output string

    1. Way 1: use new statements

    use \chawuciren\BigNumber;
    
    $number = new BigNumber('0.002', 3);
    

    2. Way 2: use the static method build

    use \chawuciren\BigNumber;
    
    $number = BigNumber::build('0.002', 3);
    

    3. Way 3: assign values using the valueOf method

    use \chawuciren\BigNumber;
    
    $number = new BigNumber();
    $number->valueOf('0.002', 3);
    

    Sample

    use \chawuciren\BigNumber;
    
    $number = new BigNumber('1.0001', 4);
    $number->add('0.0004')->sub('1')->mul('4')->div('5');
    var_dump($number->value()); //string(5) "0.0002"
    
    $number2 = new BigNumber('0.0002');
    var_dump($number->eq($number2)) //bool true
    

    Methods list

    1.valueOf

    Set a value to the BigNumber instance

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber A string or number of type BigNumber
    scale Int Precision of number
    Return value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber();
    $number->valueOf('0.002', 3);
    var_dump($number); //object(chawuciren\BigNumber)
    

    2.toString

    Returns a value as a string

    Parameters:

    No parameters

    Reture value: String(Current value)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $str = $number->toString();
    var_dump($str); //string(5) "0.002"
    

    3.value

    Returns a value of type string, currently an alias of the toString method

    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $str = $number->value();
    var_dump($str); //string(5) "0.002"
    

    4.add

    Adds the current value plus the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The value used to add
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->add('0.003');
    var_dump($number->value()); //string(5) "0.005"
    

    5.sub

    Subtracts the current value from the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The value used to subtract
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->sub('0.001');
    var_dump($number->value()); //string(5) "0.001"
    

    6.mul

    Multiply the current value by the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The number used to multiply
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->sub('0.001');
    var_dump($number->value()); //string(5) "0.001"
    

    7.div

    Divide the current value by the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber Divide the current value by the number value passed in
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->div('2');
    var_dump($number->value()); //string(5) "0.001"
    

    8.mod

    Modulates the current value with the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The value used to take a modulus
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('108');
    $number->mod('10');
    var_dump($number->value()); //string(1) "8"
    

    9.pow

    Take the current value to the number power

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The number of powers
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('2');
    $number->pow('2');
    var_dump($number->value()); //string(1) "4"
    

    10.sqrt

    Take the square root of the current value

    Parameters:

    No parameters

    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('16');
    $number->sqrt();
    var_dump($number->value()); //string(1) "4"
    

    11.eq

    Determine whether the current value equals the value of number

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: equal; False: no equal)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->eq($number2)); //bool(true)
    

    12.gt

    Determine whether the current value is greater than the number value

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: greater than; False: no more than)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->gt($number2)); //bool(true)
    

    13.egt

    Determine whether the current value is greater than or equal to the number value

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: greater than or equal to; False: not greater than and not equal to)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->egt($number2)); //bool(true)
    

    14.lt

    Determine whether the current value is less than the number value

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: less than; False: no less than)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->lt($number2)); //bool(false)
    

    15.elt

    Determine whether the current value is less than or equal to the value of number

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: less than or equal to; False: not less than and not equal to)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->lt($number2)); //bool(false)
    

    Visit original content creator repository https://github.com/chawuciren/php-bignumber
  • php-bignumber

    php-bignumber

    release phpdownloads

    About

    中文文档

    The integer size in PHP is platform-dependent. The maximum size is usually 2 billion, and the maximum size on 64-bit platforms is usually 9E18.

    Floating-point Numbers have limited precision and depend on the system, so never trust floating-point Numbers to be accurate to the last bit, and never compare two floating-point Numbers to be equal.

    When the business scenario needs to deal with a large range of values or needs to accurately deal with floating point values, arbitrary precision mathematical functions should be used, such as: trading system, e-commerce system, etc.

    The current project encapsulates arbitrary precision mathematical functions to make it easier to solve large number and floating point precision problems in PHP.


    Installation

    First please make sure your PHP has been installed and the BC Math extension, if not support, specific installation reference website: http://php.net/manual/en/bc.installation.php

    See the way:

    php -info | grep bcmath
    

    If you can see the output

    bcmath
    bcmath.scale => 0 => 0
    

    BC Math is available

    Start the installation:

    1. Way 1: By composer

    composer require chawuciren/bignumber
    

    2. Way 2: Directly download and include

    Download the source code directly, introducing src/bignumber.php


    Begin to use

    Initialization of the incoming numeric string should be used, such as a out of numerical and later returned to the front interface, the type of stored in the database as a DECIMAL, should first initialize the value of the BigNumber will be removed, and then used in the code BigNumber calculated, after the return to use on interface: value () method for numerical output string

    1. Way 1: use new statements

    use \chawuciren\BigNumber;
    
    $number = new BigNumber('0.002', 3);
    

    2. Way 2: use the static method build

    use \chawuciren\BigNumber;
    
    $number = BigNumber::build('0.002', 3);
    

    3. Way 3: assign values using the valueOf method

    use \chawuciren\BigNumber;
    
    $number = new BigNumber();
    $number->valueOf('0.002', 3);
    

    Sample

    use \chawuciren\BigNumber;
    
    $number = new BigNumber('1.0001', 4);
    $number->add('0.0004')->sub('1')->mul('4')->div('5');
    var_dump($number->value()); //string(5) "0.0002"
    
    $number2 = new BigNumber('0.0002');
    var_dump($number->eq($number2)) //bool true
    

    Methods list

    1.valueOf

    Set a value to the BigNumber instance

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber A string or number of type BigNumber
    scale Int Precision of number
    Return value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber();
    $number->valueOf('0.002', 3);
    var_dump($number); //object(chawuciren\BigNumber)
    

    2.toString

    Returns a value as a string

    Parameters:

    No parameters

    Reture value: String(Current value)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $str = $number->toString();
    var_dump($str); //string(5) "0.002"
    

    3.value

    Returns a value of type string, currently an alias of the toString method

    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $str = $number->value();
    var_dump($str); //string(5) "0.002"
    

    4.add

    Adds the current value plus the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The value used to add
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->add('0.003');
    var_dump($number->value()); //string(5) "0.005"
    

    5.sub

    Subtracts the current value from the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The value used to subtract
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->sub('0.001');
    var_dump($number->value()); //string(5) "0.001"
    

    6.mul

    Multiply the current value by the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The number used to multiply
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->sub('0.001');
    var_dump($number->value()); //string(5) "0.001"
    

    7.div

    Divide the current value by the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber Divide the current value by the number value passed in
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('0.002', 3);
    $number->div('2');
    var_dump($number->value()); //string(5) "0.001"
    

    8.mod

    Modulates the current value with the number value passed in

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The value used to take a modulus
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('108');
    $number->mod('10');
    var_dump($number->value()); //string(1) "8"
    

    9.pow

    Take the current value to the number power

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The number of powers
    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('2');
    $number->pow('2');
    var_dump($number->value()); //string(1) "4"
    

    10.sqrt

    Take the square root of the current value

    Parameters:

    No parameters

    Reture value: BigNumber(Current instance)
    Sample:
    $number = new \chawuciren\BigNumber('16');
    $number->sqrt();
    var_dump($number->value()); //string(1) "4"
    

    11.eq

    Determine whether the current value equals the value of number

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: equal; False: no equal)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->eq($number2)); //bool(true)
    

    12.gt

    Determine whether the current value is greater than the number value

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: greater than; False: no more than)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->gt($number2)); //bool(true)
    

    13.egt

    Determine whether the current value is greater than or equal to the number value

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: greater than or equal to; False: not greater than and not equal to)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->egt($number2)); //bool(true)
    

    14.lt

    Determine whether the current value is less than the number value

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: less than; False: no less than)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->lt($number2)); //bool(false)
    

    15.elt

    Determine whether the current value is less than or equal to the value of number

    Parameters:
    Parameter names Type Instructions
    number String/BigNumber The rvalue participating in the judgment
    Reture value: Bool (True: less than or equal to; False: not less than and not equal to)
    Sample:
    $number = new \chawuciren\BigNumber('0.00000000000000000002', 20);
    $number2 = new \chawuciren\BigNumber('0.00000000000000000001', 20);
    var_dump($number->lt($number2)); //bool(false)
    

    Visit original content creator repository https://github.com/chawuciren/php-bignumber
  • ADW

    Visit original content creator repository
    https://github.com/brave3d/ADW