Blog

  • discord-games-beta

    This package will no longer be maintained, see https://github.com/biologyscience/discord-games-beta/blob/main/deprecated.md for more info

    Discord Games BETA

    NOTE:

    This is my first npm package, used for testing with my friends. Feel free to continue reading if you want to use it for yourself.


    If you have any errors or issues, please update the package by doing npm i discord-games-beta and read the contents in the usage section to make sure you have coded it correctly
    If that doesn’t solve your error, have a look at the Known Issues section.

    What is this ?

    This is a package used to enable an game event inside a Discord Voice Channel, like YouTube Watch Togther, Chess, Word Tile, and much more.

    How does this work ?

    This works by creating an invite to a voice channel of your will in such a way that is makes game playable in that specific voice channel.

    Installation

    npm i discord-games-beta
    

    Usage

    • Constructor:
    const DiscordGame = require('discord-games-beta');
    const game = new DiscordGame(params);
    • Params:
    /**
     * (YourDiscordBotToken, NameOfTheGame, MaximumDuration, {Options})
     */
    
    const game = new DiscordGame('Token', 'chess', 2, {neverExpire: false});
    
    /**
     * "Token" is the Discord Client which you are using in your code
     * "chess" is the name of the game which you wanted to play
     * "2" is the Maximum Duration of the game event in hours
     * 
     * "neverExpire" is an optional parameter by which you can choose wheater you want your invite link to get expired or not
     * Normally it will get expired after the "MaximumDuration" but by setting the parameter to true, the link will not expire on its own
     */

    NOTE: The Maximum Duration can only be more than 0


    • Function:
    game.play(vc).then(result => console.log(result));
    
    // "vc" is the Discord Voice channel which you want to play the game in.
    • Result:
    {
        code : String // Code of the invite link
        inviteLink : String // The invite link itself
        createdAt : Date // The time when the invite was created
        validTill : Date | String // The time at which the invite gets expired, if 'neverExpire' is set as 'true' you will get a string
    
        guild :
        {
            ID : String // ID of the server in which the invite has been made
            name : String // Name of the server in which the invite has been made
        },
    
        channel :
        {
            ID : String // ID of the channel to which the invite has been made
            name : String // Name of the channel to which the invite has been made
        },
    
        inviter : 
        {
            ID : String // ID of the user who made the invite (i.e, The Bot's ID which has been used to do the task)
            name : String // Name of the user who made the invite (i.e, The Bot's Name which has been used to do the task)
        },
    
        app :
        {
            ID : String // ID of the game
            name : String // Name of the game
            description : String // A short description of the game
            summary : String // A summary of the game
            maxMembers : String // Maximum number of members the game allows
        }
    }

    Example Code (for one game)

    const Discord = require('discord.js');
    const DiscordGame = require('discord-games-beta');
    
    const client = new Discord.Client();
    const YouTube = new DiscordGame('Token', 'youtube', 2);
    
    client.on('messageCreate', (message) =>
    {
        if (message.content === 'play')
        {    
            const VoiceChannel = message.member.voice.channel;  // The voice channel in which the event is gonna occur
    
            YouTube.play(VoiceChannel).then(result => message.channel.send(result.inviteLink));
        }
    });
    
    client.login('Token');

    Example Code (for one game)

    What should I do if I want to play other games ?

    Just replace name of the game which is the second parameter of constructor (i.e, new DiscordGame()) with any of the available games

    To get the list of the available games you can do

    const DiscordGame = require('discord-games-beta');
    const game = new DiscordGame();
    
    console.log(game.gameNames()); // This will print all the available games in your console !

    Output:

    youtube
    poker
    betrayal
    fishing
    chess
    letterLeague
    wordSnack
    awkword
    doodleCrew
    spellCast
    checkers
    sketchHeads
    blazing8s
    landIO
    puttParty
    bobbleLeague
    askAway
    kwim    // Game name for "Know What I Meme"
    

    Example code (for more than one games)

    const Discord = require('discord.js');
    const DiscordGame = require('discord-games-beta');
    
    const client = new Discord.Client();
    
    const YouTube = new DiscordGame('Token', 'youtube', 10);
    const Chess = new DiscordGame('Token', 'chess', 1);
    const LetterTile = new DiscordGame('Token', 'lettertile', 5);
    const WordSnack = new DiscordGame('Token', 'wordsnack', 3);
    const DoodleCrew = new DiscordGame('Token', 'doodlecrew', 2);
    
    client.on('messageCreate', (message) =>
    {
        if (message.content === 'play')
        {
            const games =
            [
                "🇦 - YouTube Watch Together",
                "🇧 - Chess",
                "🇨 - Letter Tile",
                "🇩 - Word Snack",
                "🇪 - Doodle Crew"
            ];
    
            const ReactionEmbed = new Discord.MessageEmbed()
            .setColor('#2F3136')
            .setDescription(`React to the appropriate emoji to start a game !\n\n${games.join('\n')}`);
    
            message.channel.send({embeds: [ReactionEmbed]}).then((msg) =>
            {
                msg.react('🇦');
                msg.react('🇧');
                msg.react('🇨');
                msg.react('🇩');
                msg.react('🇪');
    
                const collector = new Discord.ReactionCollector(msg);
        
                collector.on('collect', (reaction) =>
                {
                    collector.stop();
    
                    const VoiceChannel = message.member.voice.channel;  // The voice channel in which the event is gonna occur
    
                    const data =
                    {
                        "🇦" : YouTube,
                        "🇧" : Chess,
                        "🇨" : LetterTile,
                        "🇩" : WordSnack,
                        "🇪" : DoodleCrew
                    };
    
                    data[reaction.emoji.name].play(VoiceChannel).then((result) => message.channel.send(result.inviteLink));
                });
            });
        }
    });
    
    client.login('Token');

    Example code (for more than one games)


    Known Issue:

    Most common error. Caused due to version mismatch of node-fetch

    Error:

    \node_modules\discord-games-beta\index.js:1
    const fetch = require('node-fetch');
                  ^
    
    Error [ERR_REQUIRE_ESM]: require() of ES Module ... 
    

    Fix:

    • Open up your terminal
    • Do npm rm node-fecth
    • Then do npm i node-fetch@2.x

    If you face any other issue, feel free to create an issue on the issues page in the github repository

    Have Fun 🥳


    F.A.Q:

    Do you work for Discord ?

    No, I do not work for or related to Discord in any means, I am just a normal person who uses it.

    Did you make this package ?

    Yes, I am only person who made this package.

    Did you make these games ?

    No, I did not make these games. All these games were made by a group of people in Discord Games Lab.

    Do not expect frequent changes to this package (unless there is a new game release or changes in a game) as this package is only used to test with my friends, but it works fine with everyone.
    If you have any questions, you may add me in Discord: BIOLOGY SCIENCE#1756

    Visit original content creator repository https://github.com/biologyscience/discord-games-beta
  • helloworld

    Readme

    Hello World! – For C++

    A C++ edition of the classic “Hello World” program, enhanced with integer addition. This project is designed to test Visual Studio Code (VSCode) with MSYS2 UCRT64 but should compile on most modern C++ environments.

    Features

    • Prints “Hello C++ World!” with version information
    • Adds two integers (via CLI arguments or interactive input)
    • Well-documented with Doxygen support
    • Released into the public domain under the Unlicense

    Requirements

    • MSYS2 UCRT64 (recommended for Windows):
      • Install required packages:
        pacman -S –needed base-devel mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-autotools
      • Add to PATH:
        C:\msys64\ucrt64\bin
        C:\msys64\usr\bin
      • Verified g++ version: 14.2.0
    • VSCode with the “C/C++” extension by Microsoft
    • Doxygen (optional, for generating documentation)

    Setup

    1. Clone or download the project to a directory named helloworld.
    2. Open the helloworld folder in VSCode.
    3. Ensure MSYS2 paths are in your system PATH as listed above.

    Build

    • Command Line:
      make all
    • VSCode:
      • Press Ctrl+Shift+B to run the default “Build” task (make clean all)
    • Output: Generates bin/helloworld.exe

    Run

    • Command Line:
      bin/helloworld.exe # Interactive mode
      bin/helloworld.exe 5 10 # CLI mode
    • VSCode:
      • Use the “Run” task (add to tasks.json if desired)

    Debug

    • VSCode:
      • Press F5 to launch with GDB in an external console
      • Supports both interactive and CLI modes (edit launch.json for arguments)

    Documentation

    • Generate Doxygen Docs:
      make docs
    • Output: Documentation in docs/ directory

    Test Case: Overflow Checking

    To verify the MSYS2 g++ and VSCode setup, the project includes overflow detection in function(int a, int b):

    • Returns std::numeric_limits<int>::max() with a warning if a + b exceeds INT_MAX
    • Test it:
      bin/helloworld.exe 2147483647 1
      This demonstrates standard library support, compilation, and debugging capabilities.

    License

    This is free and unencumbered software released into the public domain under the Unlicense. See LICENSE.md for details.

    Warranty Disclaimer

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

    Author

    David Lee McDanel (smokepid@gmail.com, pidsynccontrol@gmail.com)

    Visit original content creator repository
    https://github.com/davemcdanel/helloworld

  • ArtofReentry

    Art of Reentry KSP version License
    Curseforge GitHub SpaceDock CKAN
    Pages

    Art Of Reentry (AoR)

    Stylish and slightly functional heat shields to protect your kerbals or more important science devices, For Kerbal Space Program.

    By zer0Kerbal, originally by Rareden

    adopted with express permission and brought to you by Moho HVAC

    ArtofReentry Hero


    See More

    • Discussions and news on this mod: See Discussions or KSP Forums
    • Changelog Summary for more details of changes: See ChangeLog
    • Known Issues for more details of feature requests and known issues : See Known Issues
    • GitHub Pages : See Pages

    Hero Image

    Help Wanted

    • Promo video / review video(s)
    • Compatibility patches
    • Variant Textures and code to make it work always welcome!
    • Model updates to Unity 2019
    • Have a request? Glad to have them, kindly submit through GitHub.

    Localization

    • English English
    • your translation here

    HELP WANTED – See the README in the Localization folder or the Quickstart Guide for instructions for adding or improving translations. GitHub push is the best way to contribute. Additions and corrections welcome!


    Installation Directions 1

    Use CurseForge/OverWolf App (currently does not install dependencies)

    CurseForge/OverWolf App

    or CKAN

    Dependencies

    Supports

    red box below is a link to forum post on how to get support

    How to get support

    Be Kind: Lithobrake, not jakebrake! Keep your Module Manager up to date

    Credits and Special Thanks

    Legal Mumbo Jumbo (License provenance)

    Current (1) – zer0Kerbal

    Forum: Thread – Source: GitHub
    License: License License

    Disclaimer(s)

    All bundled mods are distributed under their own licenses
    All art assets (textures, models, animations, sounds) are distributed under their own licenses

    see Notices.md for more legal mumbo jumbo

    Original (0) – Author: Rareden

    Forum: Thread – Download: CurseForge – Source: CurseForge
    License: License


    How to support this and other great mods by zer0Kerbal

    Support Github Sponsor Patreon Buy zer0Kerbal a snack


    Connect with me

    Track progress: issues here and projects here along with The Short List

    zer0Kerbal | kerbalspaceprogram.com zer0Kerbal | CurseForge zer0Kerbal | reddit zer0Kerbal | Patreon zer0Kerbal | YouTube zer0Kerbal | Twitch zer0Kerbal | PayPal zer0Kerbal | Buy Me a Coffee zer0Kerbal | Twitter

    Footnotes

    1. this isn’t a mod. ;P

    2. may work on other versions (YMMV)

    3. Be Kind: Lithobrake, not jakebrake! Keep your Module Manager up to date!

    Visit original content creator repository https://github.com/zer0Kerbal/ArtofReentry
  • ArtofReentry

    Art of Reentry KSP version License
    Curseforge GitHub SpaceDock CKAN
    Pages

    Art Of Reentry (AoR)

    Stylish and slightly functional heat shields to protect your kerbals or more important science devices, For Kerbal Space Program.

    By zer0Kerbal, originally by Rareden

    adopted with express permission and brought to you by Moho HVAC

    ArtofReentry Hero


    See More

    • Discussions and news on this mod: See Discussions or KSP Forums
    • Changelog Summary for more details of changes: See ChangeLog
    • Known Issues for more details of feature requests and known issues : See Known Issues
    • GitHub Pages : See Pages

    Hero Image

    Help Wanted

    • Promo video / review video(s)
    • Compatibility patches
    • Variant Textures and code to make it work always welcome!
    • Model updates to Unity 2019
    • Have a request? Glad to have them, kindly submit through GitHub.

    Localization

    • English English
    • your translation here

    HELP WANTED – See the README in the Localization folder or the Quickstart Guide for instructions for adding or improving translations. GitHub push is the best way to contribute. Additions and corrections welcome!


    Installation Directions 1

    Use CurseForge/OverWolf App (currently does not install dependencies)

    CurseForge/OverWolf App

    or CKAN

    Dependencies

    Supports

    red box below is a link to forum post on how to get support

    How to get support

    Be Kind: Lithobrake, not jakebrake! Keep your Module Manager up to date

    Credits and Special Thanks

    Legal Mumbo Jumbo (License provenance)

    Current (1) – zer0Kerbal

    Forum: Thread – Source: GitHub
    License: License License

    Disclaimer(s)

    All bundled mods are distributed under their own licenses
    All art assets (textures, models, animations, sounds) are distributed under their own licenses

    see Notices.md for more legal mumbo jumbo

    Original (0) – Author: Rareden

    Forum: Thread – Download: CurseForge – Source: CurseForge
    License: License


    How to support this and other great mods by zer0Kerbal

    Support Github Sponsor Patreon Buy zer0Kerbal a snack


    Connect with me

    Track progress: issues here and projects here along with The Short List

    zer0Kerbal | kerbalspaceprogram.com zer0Kerbal | CurseForge zer0Kerbal | reddit zer0Kerbal | Patreon zer0Kerbal | YouTube zer0Kerbal | Twitch zer0Kerbal | PayPal zer0Kerbal | Buy Me a Coffee zer0Kerbal | Twitter

    Footnotes

    1. this isn’t a mod. ;P

    2. may work on other versions (YMMV)

    3. Be Kind: Lithobrake, not jakebrake! Keep your Module Manager up to date!

    Visit original content creator repository https://github.com/zer0Kerbal/ArtofReentry
  • TwinCAT-Dynamic-String-Kit

    TwinCAT Dynamic String Kit

    A library that provides tools for working with dynamic strings in TwinCAT. It includes a comprehensive string builder with string enumeration and a read-only string builder adapter. Additionally, there are several C-style string functions, such as isdigit(...), strstr(...), strlcpy(...), isspace(...), and more. There are also functions for converting ANY to STRING and STRING to ANY.

    Examples

    Working with the string builder.

    Declarations:

    VAR
    	bStart 			: BOOL;
    	nLn1, nLn2 		: T_Size;
    	sValue1, sValue2	: STRING(255);
    	pString			: POINTER TO STRING;
    	fbStringBuilder1,
    	fbStringBuilder2	: FB_StringBuilder;
    END_VAR

    Implementation:

    IF bStart THEN
    	bStart := FALSE;
    	fbStringBuilder2
    		.Append(' I hate cats.')
    		.GetBuffer(pString);
    	
    	fbStringBuilder1
    		.Clear()
    		.Append(' I love cats.')
    		.Append(' I love dogs.')
    		.AppendBuffer(pString)
    		.BTrim()
    		.GetLength(Length => nLn1)
    		.Replace('cats','dogs',TRUE)
    		.Insert(nLn1, ' Anaconda! ')
    		.Split(nLn1,100, fbStringBuilder2.Append(' Tigers are cats.'))
    		.GetLength(Length => nLn1);
    	
    	sValue1 := fbStringBuilder1.ToUppercase().GetString();
    	sValue2 := fbStringBuilder2
    		.ToLowercase()
    		.BTrim()
    		.GetString();
    	
    	nLn2 := Tc2_Standard.LEN(sValue1);
    	__DELETE(pString);
    	END_IF

    Output:

    string builder


    Working with the read-only adapter.

    Declarations:

    VAR
    	bStart			: BOOL;
    	sValue 			: STRING(255);
    	nPos			: T_Size;
    	tTime 			: TIME :=  TIME();
    	tTime2			: TIME;
    	fbStringBuilder 	: FB_StringBuilder;
    	fbReadOnlySB 		: FB_ReadOnlyStringBuilderAdapter;
    	ipReadOnlySB 		: I_ReadOnlyStringBuilderAdapter;
    END_VAR

    Implementation:

    fbReadOnlySB(ipStringBuilder := fbStringBuilder);
    ipReadOnlySB := fbReadOnlySB;
    
    IF bStart THEN
    	bStart := FALSE;
    	fbStringBuilder
    		.Clear()
    		.Append('   I love cats.')
    		.Append('The time is: ').AppendAny(tTime).Append('.')
    		.Append('   ')
    		.BTrim();
    	END_IF
    
    sValue := ipReadOnlySB
    	.Search('T#', 0, Position => nPos)
    	.CopySubstringTo(nPos, tc2_Standard.LEN(TO_STRING(tTime)), tTime2)
    	.GetString();

    Output:

    string builder using an adapter


    Working with the enumerator.

    Declarations:

    VAR
    	bStart			: BOOL;
    	sValue			: STRING(255);
    	dtTime			: DT :=  DT#2023-5-8-12:55:23;
    	fbStringBuilder1,
    	fbStringBuilder2	: FB_StringBuilder;
    	ipEnumerator		: I_Enumerator;
    END_VAR

    Implementation:

    IF bStart THEN
    	bStart := FALSE;
    	
    	fbStringBuilder1
    		.Clear()
    		.Append('   I love cats.')
    		.Append('The time is: ').AppendAny(dtTime).Append('.')
    		.BTrim();
    	
    	ipEnumerator := fbStringBuilder1.GetEnumerator();
    	WHILE ipEnumerator.Next() DO
    		fbStringBuilder2.Append(ipEnumerator.Current);
    		END_WHILE
    		
    	sValue := fbStringBuilder2.GetString();
    	END_IF

    Output:

    string builder enumerator

    ⚠ Important ⚠

    This project is still in development. There’s a lot of work and testing ahead. Changes to functionality may occur in the future.

    Visit original content creator repository https://github.com/fisothemes/TwinCAT-Dynamic-String-Kit
  • bikelert

    Bikelert

    The code located in this repository contains Bikealert project’s codebase.
    https://www.youtube.com/watch?v=j1RYXIv0pps

    Limitations

    API has not been secured yet with any secure protocol (HTTPS) and/or with usage limitations or authentication/authorization.

    How to use it

    Before running or testing application, do not forget to install all
    app required libraries by running the following command at the command
    line interface.

    npm install
    

    Running

    Check environment variables section before running this.

    npm run start
    

    Testing

    Check environment variables section before running this.

    npm run test
    

    Environment variables

    Service can be ran including a file named service.env at the root folder or even setting
    console/terminal environment variables before starting the application.

    In case console/terminal environment variables want to be used
    there is a variable named from_env that must have any value.

    service.env variables must follow the format below:

    <variable_name>=<value>
    <variable_name>=<value>
    ...
    

    V1 Environment variables – Server

    watson_visual_recognition_version=
    watson_visual_recognition_apikey=
    watson_visual_recognition_classifier_id=
    watson_visual_recognition_positive_class_name=
    mongo_connection_string=
    test_mongo_connection_string=
    test_device_id=
    test_device_cred1=
    test_device_cred2=
    PORT=
    

    V1 Environment variables – Client

    time_between_photo=
    distance=
    speed=
    IP=
    PORT=
    photoPath=
    signalPath=
    device_cred1=
    device_cred2=
    

    Testing

    Remember adding to devices collection a mock device in order to be able to run tests:

    use <db-name>;
    db.devices.insert({cred1: 'cred1', cred2: 'cred2', location: {type: 'Point', coordinates: [-2.939020,43.270128]}});
    

    Visit original content creator repository
    https://github.com/asier-gutierrez/bikelert

  • wamu-rs

    Wamu

    A collection of modular Rust libraries for implementing the Wamu protocol for computation of threshold signatures by multiple decentralized identities.

    ⚠️ Security Warning

    All crates in this repository are pre-alpha software developed as PoCs (Proofs of Concept) of the Wamu protocol.
    They have NOT been independently audited and/or rigorously tested yet!
    They SHOULD NOT BE USED IN PRODUCTION!

    NOTE: 🚧 This project is still work in progress, check back over the next few weeks for regular updates.

    Architecture

    This repository contains 2 main crates:

    This crate implements the core sub-protocols (i.e. share splitting and reconstruction, identity authenticated request initiation and verification, identity challenge, quorum approved request initiation and verification and encrypted backup-based share recovery) as well as types, abstractions and utilities for augmentations (e.g. utilities for initializing and verifying identity rotation, quorum-based share recovery and other decentralized identity authenticated requests) as described by the Wamu protocol.

    This crate implements CGGMP20 with augmentations as described by the Wamu protocol.

    It uses the Wamu Core (wamu-core) crate for Wamu‘s core sub-protocols and augmentations, and Webb tool’s cggmp-threshold-ecdsa crate for the CGGMP20 implementation that it wraps and augments.

    Installation and Usage

    Check the readme of each crate for installation and usage instructions and links to documentation.

    Documentation

    Or you can access documentation locally by running the following command from the project root

    cargo doc --no-deps --open

    To open crate specific docs, see instructions in the readme in each crate’s directory.

    Testing

    You can run unit tests for all the core functionality by running the following command from the project root

    cargo test

    NOTE: To run only tests for a single crate, add a -p <crate_name> argument to the above command e.g.

    cargo test -p wamu-core

    Examples

    See the /crates/cggmp/examples directory.

    License

    Crate License
    Wamu Core (wamu-core) Licensed under either MIT or Apache-2.0 license at your option.
    Wamu CGGMP (wamu-cggmp Licensed under GPL-3.0.

    Contribution

    Crate Guidelines
    Wamu Core (wamu-core) Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
    Wamu CGGMP (wamu-cggmp) Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the GPL-3.0 license, shall be licensed as above, without any additional terms or conditions.

    Acknowledgements

    🌱 Funded by: the Ethereum Foundation.

    Visit original content creator repository
    https://github.com/wamutech/wamu-rs

  • fastrq

    Fastrq – Queue, Stack and Priority Queue built on Redis

    Build Status

    Wiki

    Fastrq for PHP

    Features

    • Abstract Queue, Deque, Capped Queue/Deque, and Overflow-able Capped Queue/Deque
    • Abstract Stack, Capped Stack
    • Abstract Priority Queue, Capped Priority Queue and Overflow-able Capped Priority Queue
    • Push and Pop support batch operation
    • Using Lua scripts to save RTT (Round Trip Time)
    • Support getting indexes of members
    • Support pushing only if a member not already inside the queue
    • Support pushing only if the queue already exists/not already exist
    • All operations are atomic

    Requirements

    • Redis >=3.0.2
    • Python 2.7 or >=3.4

    Installation

    via pip

    pip install fastrq
    

    or from source

    python setup.py install
    

    Usage

    from fastrq.queue import Queue, CappedQueue
    from fastrq.deque import Deque
    from fastrq.stack import Stack
    from fastrq.priorityqueue import PriorityQueue
    
    # queue
    q = Queue("fastrq_queue")
    q.push(1)
    q.push([2, 3])
    q.push_ni(1) # got [3, False]. `ni` stands for `not inside`
    q.push_ae(1) # got 4. `ae` stands for `already exists`
    q.push_ne(1) # got False. `ne` stands for `not already exist`
    q.ttl(10)   # set the lifetime in seconds
    q.range(0, -1)  # got ['1', '2', '3']
    q.range(0, 1)  # got ['1', '2']
    q.indexof_one(1); # got 0
    q.indexof_one(2); # got 1
    q.indexof_one(4); # got None
    q.indexof_many([1, 2, 4]); # got {1: 0, 2: 1, 4: None}
    # push only if the member not inside the queue
    q.push_ni(4) # got [4, True]
    q.pop()
    q.pop(2)
    q.destruct() # destruct the queue
    cq = CappedQueue("fastrq_capped_queue", 3)
    cq.push(1)
    cq.push(2)
    cq.push([3, 4]) # got "err_qof"
    cq.push(3)
    cq.push(4) # got "err_qf"
    of_cq = OfCappedQueue("fastrq_of_capped_queue", 3)
    of_cq.push(1)
    of_cq.push([2, 3, 4])  # "1" would be forced out
    
    
    # deque
    dq = Deque("fastrq_deque")
    dq.push_front([1, 2])
    dq.push_back([3, 4])
    dq.pop_front()
    dq.pop_back()
    dq.push_front_ni(3)
    dq.push_back_ni(5)
    
    # priority queue
    pq = PriorityQueue("fastrq_priority_queue")
    pq.push({'alibaba': 1})
    pq.push({'google': 0, 'microsoft': 2})
    pq.indexof_one('google'); # got 0
    pq.indexof_one('alibaba'); # got 1
    pq.indexof_one('baidu'); # got None
    pq.pop()
    pq.pop(2)
    pq.push_ni('ibm', 4)
    pq.push_ni('amazon', 5)
    
    # stack
    s = Stack("fastrq_stack")
    s.push([1,2,3])
    s.indexof_one(1); # got 2
    s.indexof_one(2); # got 1
    s.indexof_one(3); # got 0
    s.pop()
    s.push_ni(4)

    Data types

    Queue

    • first in and first out
    • unlimited capacity
    • support batch push and batch pop

    Deque

    Derive from queue with more features

    • support push front and push back
    • support pop front and pop back

    Capped Queue/Deque

    Derive from queue/deque with more features

    • Have fixed capacity
    • Push to a full one would fail
    • Push to one whose positions are not enough would fail

    Overflow-able Capped Queue/Deque

    Derive from capped queue/deque with more features

    • The queue length would never exceed its capacity
    • Push to an end would force out from the other end if one is full

    Stack

    • Last in and First out
    • Unlimited capacity
    • Support batch push and batch pop

    Capped Stack

    Derive from Stack with more features

    • Have fixed capacity
    • Push to a full capped stack would fail
    • Push to a capped stack whose positions are not enough would fail

    Priority Queue

    • The lower the score, the higher the priority
    • Unlimited capacity
    • Support batch push and batch pop

    Capped Priority Queue

    Derive from Priority Queue with more features

    • Have fixed capacity
    • Push to a full one would fail
    • Push to a capped one whose positions are not enough would fail

    Overflow-able Capped Priority Queue

    Derive from Capped Priority Queue with more features

    • The queue length would never exceed its capacity
    • Push to would force out the lowest priority if queue is full
    Visit original content creator repository https://github.com/limen/fastrq
  • boot_from_usb

    bootFromUSB

    Boot NVIDIA Jetson Nano Developer Kit from a mass storage USB device. This includes Jetson Nano 2GB, and may also work with the TX1. This setup is done from the Jetson Development Kit itself.

    WARNING: This is a low level system change. You may have issues which are not easily solved. You should do this working on a freshly flashed micro SD card, and certainly do not attempt this with valuable data on the card itself. A serial debug console is useful if things go wrong.

    A new feature of JetPack 4.5 (L4T 32.5) is the ability to boot from a USB device with mass storage class and bulk only protocol. This includes devices such as a USB HDD, USB SSD and flash drives.

    In order to setup a Jetson to boot from a USB device, there are several steps.

    Step 1: Setup and Boot the Jetson

    You will need to do an initial setup of the Jetson with JetPack 4.5+ in order to load updated firmware into the Jetson Module QSPI-NOR flash memory. Follow the ‘Getting Started’ instructions on the JetPack site: https://developer.nvidia.com/embedded/jetpack

    The JetPack archives are located here: https://developer.nvidia.com/embedded/jetpack-archive

    During the initial setup of L4T 32.5+, the firmware for the Jetson Nano developer kits relocates the boot firmware from the micro SD card to the Jetson module integrated QSPI-NOR flash memory. This also changes the layout of the SD card. This layout is now analagous to the BIOS in a PC.

    Step 2: Prepare the USB Drive

    Plug in the USB drive.

    Prepare the USB drive (USB 3.0+, SSD, HDD, or flash drive) by formatting the disk as GPT with an Ext4 partition. Formatting the disk will erase any data that is on that disk. When finished, the disk should show as /dev/sda1 or similar. Note: Make sure that the partition is Ext4, as other formats will appear to copy correctly but cause issues later on. You may set the volume label during this process.

    You can prepare the USB drive by using the Disks app. Formatting the disk using Format and creating a partition are two different tasks. Format the disk as GPT, then add a partition formatted as Ext4. Name the newly created partition APP so that Jetson system apps recognize it correctly.

    Once the disk is ready, mount the disk. If you are using a desktop, you can do this by clicking on the USB disk icon and opening a file browser on its contents.

    Formatting the USB Drive using Linux Command

    To simplify the steps for formatting the USB drive using command line, make sure that you only have one USB drive being connected to the Jetson Nano. Firstly, we need to search for the device path of the USB drive by entering the command in the terminal:

    $ sudo parted -l
    

    We have to obtain the optimal IO size and physical block size of the USB drive by entering the 2 commands below (you have to change the term “sda” into the device path as obtained from the previous step):

    $ cat /sys/block/sda/queue/optimal_io_size
    $ cat /sys/block/sda/queue/physical_block_size
    

    After obtaining the number of sector, it’s time to format the USB drive. Make sure that there are no important files inside before proceeding to the next step!

    $ sudo parted /dev/sda
    $ mklabel gpt
    

    You might be prompted to confirm the formatting, just enter “y” for confirmation. After formatting, we need to create the partition in the USB drive. Replace the  variable with the number of sector which we calculated earlier.

    $ mkpart primary ext4 s 100%
    

    Press ctrl + D to exit the parted command line. Then, we have to properly format the partition we created earlier to ext4 file system. Make sure that you change the term “sda” into the device path being obtained previously.

    $ mkfs.ext4 /dev/sda1
    $ sudo parted -l
    

    Look for the device path of the USB drive, in this case it is “/dev/sda”. Search for the USB drive again. If all of the steps are taken correctly, you will see that the Partition Table is set to “gpt” and the file system for the partition is “ext4” as shown in the image above.

    ajeetraina@ajeetraina-desktop:~$ sudo mkdir /mnt/usbboot
    ajeetraina@ajeetraina-desktop:~$ sudo mount /dev/sda1 /mnt/usbboot
    [sudo] password for ajeetraina:
    ajeetraina@ajeetraina-desktop:~$ sudo df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/mmcblk0p1   15G   12G  2.6G  82% /
    none            947M     0  947M   0% /dev
    tmpfs           986M  4.0K  986M   1% /dev/shm
    tmpfs           986M   27M  960M   3% /run
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs           986M     0  986M   0% /sys/fs/cgroup
    tmpfs           198M  4.0K  198M   1% /run/user/121
    tmpfs           198M     0  198M   0% /run/user/1000
    /dev/sda1        29G   12G   16G  43% /mnt/usbboot
    

    Cloning the repository

    git clone https://github.com/PHONGANSCENTER/boot_from_usb.git
    

    ajeetraina@ajeetraina-desktop:~/boot_from_usb$ ./copyRootToUSB.sh -p /dev/sda1
    Device Path: /dev/sda1
    Target: /mnt/usbboot
    ..
    Setting up rsync (3.1.2-2.1ubuntu1.2) ...
    Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
    Processing triggers for systemd (237-3ubuntu10.50) ...
     11,511,169,692  95%   17.93MB/s    0:10:12 (xfr#142716, to-chk=0/205797)
    ajeetraina@ajeetraina-desktop:~/bootFromUSB$
    

    Copy the below content and put it in extlinux.conf file as shown below:

    ajeetraina@ajeetraina-desktop:/mnt/usbboot/boot/extlinux$ cat extlinux.conf
    TIMEOUT 30
    DEFAULT sdcard
    
    MENU TITLE L4T boot options
    # Sample extlinux.conf file for booting from USB
    # You will need to set the root environment variable to match your system
    #
    # You can set the root to various levels of specificity
    # If you have multiple USB storage devices, the PARTUUID approach is very useful
    # PARTUUID is the PARTUUID of the USB device; most exact - recommended
    # LABELNAME is a little more specific; root=LABEL=jetson_drive
    # /dev/sda1 is the most general; root=/dev/sda1
    # Note: The UUID options seems to have some issues on the Jetson
    LABEL primary
          MENU LABEL primary kernel
          LINUX /boot/Image
          INITRD /boot/initrd
          APPEND ${cbootargs} quiet root=PARTUUID=32a76e0a-9aa7-4744-9954-dfe6f353c6a7 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
    
    # When testing a custom kernel, it is recommended that you create a backup of
    # the original kernel and add a new entry to this file so that the device can
    # fallback to the original kernel. To do this:
    #
    # 1, Make a backup of the original kernel
    #      sudo cp /boot/Image /boot/Image.backup
    #
    # 2, Copy your custom kernel into /boot/Image
    #
    # 3, Uncomment below menu setting lines for the original kernel
    #
    # 4, Reboot
    
    LABEL sdcard
          MENU LABEL primary kernel
          LINUX /boot/Image
          INITRD /boot/initrd
          APPEND ${cbootargs} quiet root=/dev/sda1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
    

    That’s it. Now remove the SD card and let your Jetson nano boot from USB drive

    ajeetraina@ajeetraina-desktop:~$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda1        29G   12G   16G  43% /
    none            947M     0  947M   0% /dev
    tmpfs           986M   40K  986M   1% /dev/shm
    tmpfs           986M   27M  960M   3% /run
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs           986M     0  986M   0% /sys/fs/cgroup
    tmpfs           198M  8.0K  198M   1% /run/user/1000
    ajeetraina@ajeetraina-desktop:~$
    

    Step 5 Try It Out!

    Remove the micro SD card, and boot the system.

    Release Notes

    March, 2021

    • JetPack 4.5.1
    • L4T 32.5.1
    • Remove payload updater, the JetPack update addresses this issue
    • Slightly more generous readme
    • Tested on Jetson Nano

    February, 2021

    • JetPack 4.5
    • L4T 32.5
    • Initial Release
    • Tested on Jetson Nano

    Visit original content creator repository
    https://github.com/PHONGANSCENTER/boot_from_usb

  • Quine-McCluskey-Boolean-Minimizer

    Quine-McCluskey Introduction

    The Quine McCluskey algorithm is a systematic way used for minimizing Boolean expressions. It is more suitable for handling complex Boolean functions with more than 4 variables, where methods like Karnaugh maps become difficult.

    Expression Parser (Minterms Extractor Module)

    The definition of the minterm is the term that makes boolean function output become true and we can represent any boolean function as the summation of its minterms.

    1. In the following module we need to first give the script a correct boolean expression then we parse this expression to the formal form using the following function with aid of basic functions like NOT(a), AND(a,b) and OR(a,b) :
    • parse_boolean_expression()

    from expression_parser import parse_boolean_expression
    
    print(parse_boolean_expression('(!A&B) | (A&!B)'))
    # output will be --> OR(AND(NOT(a), B), AND(A, NOT(B)))
    1. The second step will be to extract variables and try to substitute by their correspondent values according to the truth table and evaluate the expression and check if result is true then this combination is a minters for the function if not neglect it:
    • get_minterms(expression)

    from expression_parser import get_minterms
    
    print(get_minterms("(!A&B) | (A&!B)"))
    # output will be --> [(1, 0), (0, 1)]

    McCluskey Minimizer (Expression Minimization Module)

    The main idea of this module is to divide the minterms to groups based on the number of 1’s in each minterm and start the comparison between minterms that differs in only one bit to see if a literal can be removed and turn them prime implicants (the prime implicant is an implicant that cannot be further reduced or combined with other implicants).

    1. The core part of the Quine-McCluskey algorithm to find the prime implicants for a given set of Boolean minterms. The function takes a list of binary tuples representing the minterms and returns a list of prime implicants in binary tuple form.
    • find_prime_implicants(minterms)

    from expression_parser import get_minterms
    
    expression = 'A|B'
    prime_implicants = find_prime_implicants(get_minterms(expression))
    print(prime_implicants)
    # 'x' represent a don't care
    # output will be --> [('x', 1), (1, 'x')]
    1. This function converts any set of prime implicants into a human-readable Sum of Products form using the provided variable names.
    • prime_implicants_to_sop(prime_implicants, variables)

    from expression_parser import get_minterms, extract_vars
    
    expression = 'A|B'
    vars = extract_vars(expression)
    prime_implicants = find_prime_implicants(get_minterms(expression))
    sop = prime_implicants_to_sop(prime_implicants, vars)
    print(sop)
    # output will be --> B + A

    Overall Running Script

    $python3 maccluskey_minimization.py '(A&B&C)|(!A&B&C)|(A&!B&C)|(A&B&!C)'
    # output will be --> The minimized (SOP) expression: BC + AC + AB

    Time Complexity Issues

    The overall time complexity is dominated by the prime implicant extraction step which is O(N^2) but the worst case complexity for Boolean minimization problems (in general) is exponential O(2^M). This makes Quine-McCluskey less efficient for large numbers of variables which is why heuristic algorithms like Espresso (I am going to implement it soon) are often used in practice for larger problems.

    Visit original content creator repository
    https://github.com/ahmd-kamel/Quine-McCluskey-Boolean-Minimizer