Author: n6rloxhpftd7

  • SoundRecorder

    SoundRecorder

    Some web applications require an MP3 recorder to record sound directly from the user. The sound is converted to mono MP3 format with an adjustable sample rate and bit rate to reduce the output file size.

    A page can contain several MP3 recorders that can be used interchangeably. The recording process can be paused and can be resumed to continue the recording process.

    Reqirement

    1. Lame
    2. jQuery 1.11.1

    Example

    <html>
    <head>
        <title>MP3 Recorder</title>
        <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link rel="stylesheet" type="text/css" href="css/css.css">
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script type="text/javascript" src="js/lame.js"></script>
    	<script type="text/javascript" src="js/js.js"></script>
    </head>
    
    <body>
    <style type="text/css">
    .audio-tool-wrapper {
    	display:flex;
    	justify-content:center;
    }
    
    .audio-tool-wrapper > span {
    	width:100px;
    	margin:8px;
    	text-align:center;
    	position:relative;
    	display:block;
    }
    </style>
    
    <h1>MP3 Recorder</h1>
    	<div class="audio-recorder" data-question-id="12" data-audio-index="1">
        	<div class="audio-tool-wrapper">
            	<span><a class="audio-tool tool-browse" title="Pilih File Suara"><span></span></a></span>
            	<span><a class="audio-tool tool-record" title="Rekam Langsung"><span></span></a></span>
            	<span><a class="audio-tool tool-play" title="Dengarkan"><span></span></a></span>
            	<span><a class="audio-tool tool-stop" title="Hentikan"><span></span></a></span>
            	<span><a class="audio-tool tool-upload" title="Unggah Suara"><span></span></a></span>
            	<span><a class="audio-tool tool-download" title="Unduh Suara"><span></span></a></span>
            	<span><a class="audio-tool tool-delete" title="Hapus Suara"><span></span></a></span>
                <span><span class="tool-timer"><i></i></span></span>
            </div>
        </div>
    	<div class="audio-recorder" data-question-id="12" data-audio-index="2">
        	<div class="audio-tool-wrapper">
            	<span><a class="audio-tool tool-browse"><span></span></a></span>
            	<span><a class="audio-tool tool-record"><span></span></a></span>
            	<span><a class="audio-tool tool-play"><span></span></a></span>
            	<span><a class="audio-tool tool-stop"><span></span></a></span>
            	<span><a class="audio-tool tool-upload"><span></span></a></span>
            	<span><a class="audio-tool tool-download"><span></span></a></span>
            	<span><a class="audio-tool tool-delete"><span></span></a></span>
                <span><span class="tool-timer"><i></i></span></span>
            </div>
        </div>
    <script type="text/javascript">
    
    var audioRecorder = {
    	initialized:false,
    	recorder:[]
    };
    var params = {
    	bitrate:32,
    	sampleRate:44100,
    	timeLimit:1800,
    	uploadSound:function(audio, duration, index, questionID, audioIndex){
    		console.log(audio.src);
    		audioRecorder.recorder[index].beforeUpload();
    		setTimeout(function(){
    			audioRecorder.recorder[index].afterUpload();
    		}, 2000);
    		var url = audio.src;
    		$.ajax({
    			url:'upload-sound.php',
    			type:'POST',
    			dataType:"json",
    			data:{
    				sound_data:url,
    				question_id:questionID,
    				audio_index:audioIndex
    			},
    			success: function(data)
    			{
    				console.log('Uploaded');
    			}
    		});     
    	},
    	downloadSound:function(audio, duration, index, questionID, audioIndex)
    	{
    		console.log(audio.src);
    
    		//Create a URL to the blob.
    		/*
    		var url = window.URL.createObjectURL(blob);
    		window.open(url);
    		*/
    
    	},
    	nullAudio:function()
    	{
    		alert('Belum ada audio cuyy! Selesaikan rekaman dulu...');
    	},
    	stillRecording:function()
    	{
    		alert('Masih merekam cuyy! Selesaikan dulu yach...');
    	},
    	stillPlaying:function()
    	{
    		alert('Masih memutar cuyy! Ga boleh merekam dulu... Pause dulu kek, atau tunggu selesai...');
    	},
    	overLimit:function()
    	{
    		alert('Melebihi batas');
    	},
    	log:function(text)
    	{
    		console.log(text);
    	}
    };
    
    $(document).ready(function(e) {
    
    	$(document).on('click', '.audio-recorder .tool-browse', function(e)
    	{
    		var audioController = $(this).closest('.audio-recorder');
    		var idx = audioController.attr("data-index") || "";
    		if(idx == "")
    		{
    			var index = audioRecorder.recorder.length;
    			audioRecorder.recorder.push(new MP3Recorder(audioController, index, 'browse', params));
    		}
    		
    	});
    	
    	$(document).on('click', '.audio-recorder .tool-record', function(e)
    	{		
    		var audioController = $(this).closest('.audio-recorder');
    		var idx = audioController.attr("data-index") || "";
    		if(idx == "")
    		{
    			var index = audioRecorder.recorder.length;
    			audioRecorder.recorder.push(new MP3Recorder(audioController, index, 'record', params));
    		}
    	})	
    });
    
    </script>
    </body>
    </html>
    

    Visit original content creator repository

  • ESP32FileuploadServer

    ESP32 Local Webserver

    with SPIFFS Upload & MCP4725 Digital to Analog Transmission Routine

    Overview

    This repository contains a web application for ESP32 that enables users to upload, delete, download, and format files. Additionally, it includes a routine to transmit data from a medical dataset uploaded on the SPIFFS using an MCP4725 DAC peripheral.

    Screenshots

    Screenshot1 Screenshot2

    Structure

    1. The final deployed application can be found under V3/.
    2. Web application files (HTML/CSS/JS) are stored as a .h file under include/.
    3. The webserver and DAC routine application are located in src/.
    4. The maximum possible partition table for a 6MB ESP32 V2 is provided in no_ota_2_2.csv.
    5. PlatformIO configuration files for featheresp32 and adafruit_feather_esp32_v2 are available in platformio.ini.

    Tips if forking for your project

    1. There seems to be a limit to the amount of CSS that can be rendered at runtime when supplied using inline <style>. If your application requires elaborate CSS and/or frameworks, it’s recommended to load the files onto SPIFFS and reference them in your HTML.
    2. Since this project necessitated SPIFFS formatting capability, the HTML, CSS, and JS files are stored in app storage as header files. If this isn’t an issue for your project, it’s better to have separate .html, .css, and .js files in SPIFFS.
    3. The app will be served at http://"your-hostname". By default –> retia_cp200. Refer V3/retia.ino for complete wifi config details.
    4. The app also has an API through which you can access the app via serial. You can test it using Docklight etc.
    5. V5/ is a “serial” version of the app, without the web app capabilites. Think of it as a glorified DAC system hooked onto your PC. It has an API that can be used to transmit files directly via serial. Using com_script.py, you can trasmit your local file. The script allows you to change your COM port, file location etc. The idea behind this implementation is that now you have no limit on file that has to be trasmitted, as the file will be on your PC and not SPIFFS. Note: The script is configured to scale down DAC’s reference voltage of 3.3V to 3.0V. (See V5/retia.ino)

    Acknowledgement

    Parts of the SPIFFS upload mechanism are based on this repository.

    Visit original content creator repository
  • 21sh

    21sh

    Project from UNIX branch in school 42

    Project 21sh is the continuation of the project minishell

    New in 21sh project

    Mandatory implementations

    [✓] Pipes ‘|

    [✓] The 4 following redirections ‘<‘, ‘>‘, ‘<<‘ and ‘>>

    [✓] File descriptor aggregation ‘<&‘ and ‘>&

    [✓] Basic line editing features using termcap library

    Bonuses

    [✓] Implementation of Hash Table for binary files, also the hash builtin command

    [✓] Advanced auto completion using tab

    [✓] Search through history using ctrl+R

    [✓] Some other line editing features (see below)

    Hotkey list for line editing:

    Key Details
    Left move cursor backward by one character
    Right move cursor forward by one character
    Up List term history up
    Down List term history down
    Ctrl + Left ⌃← move cursor backward by one word
    Ctrl + Right ⌃→ move cursor forward by one word
    Ctrl + Up ⌃↑ move cursor backward by one row
    Ctrl + Down ⌃↓ move cursor forward by one row
    Ctrl + Shift + Left ⌃⇧← delete the word in front of the cursor
    Ctrl + Shift + Right ⌃⇧→ delete the word after the cursor
    Ctrl + Shift + Up ⌃⇧↑ delete the row in front of the cursor
    Ctrl + Shift + Down ⌃⇧↓ delete the row after the cursor
    Return Confirm line entry
    Backspace delete one previous character from current position of cursor
    Delete delete one character from current position of cursor
    Home move cursor to the beginning of the line
    End move cursor to the end of the line
    Tab Auto compilation
    Ctrl + R ⌃R Search history
    Ctrl + A ⌃A work same as Home
    Ctrl + E ⌃E work same as End
    Ctrl + U ⌃U clear all characters in front the cursor
    Ctrl + K ⌃K clear all characters after the cursor
    Ctrl + G ⌃G clear all characters in line
    Ctrl + H ⌃H Undo the last change
    Ctrl + L ⌃L clear screen

    Preview

    Preview output

    ➜  21sh git:(master) ./21sh
    ✓ (21sh) cd /tmp/test_dir/
    ✓ (test_dir) pwd
    /tmp/test_dir
    ✓ (test_dir) env
    TERM_SESSION_ID=w0t0p0:D3D7901C-F606-4245-89ED-C2B1F3E713F3
    SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.ldiuufG508/Listeners
    LC_TERMINAL_VERSION=3.3.6
    Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.lcd6sflWma/Render
    COLORFGBG=7;0
    ITERM_PROFILE=Default
    XPC_FLAGS=0x0
    PWD=/tmp/test_dir
    SHELL=21sh
    LC_CTYPE=UTF-8
    TERM_PROGRAM_VERSION=3.3.6
    TERM_PROGRAM=iTerm.app
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin
    LC_TERMINAL=iTerm2
    COLORTERM=truecolor
    TERM=xterm-256color
    HOME=/Users/prippa
    TMPDIR=/var/folders/nc/lc4x38yx18sgjmwh0qyy9prw0000gn/T/
    USER=prippa
    XPC_SERVICE_NAME=0
    LOGNAME=prippa
    ITERM_SESSION_ID=w0t0p0:D3D7901C-F606-4245-89ED-C2B1F3E713F3
    __CF_USER_TEXT_ENCODING=0x0:7:49
    SHLVL=2
    OLDPWD=/Users/prippa/Desktop/21sh
    LC_ALL=en_US.UTF-8
    LANG=en_US.UTF-8
    ZSH=/Users/prippa/.oh-my-zsh
    PAGER=less
    LESS=-R
    LSCOLORS=Gxfxcxdxbxegedabagacad
    _=env
    ✓ (test_dir) touch riri
    ✓ (test_dir) ls
    riri
    ✓ (test_dir) rm riri ;cat riri 2>&-
    ✕ (test_dir) cat riri
    cat: riri: No such file or directory
    ✕ (test_dir) mkdir test; cd test; ls -a; ls | cat | wc -c > fifi; cat fifi
    .	..
           5
    ✓ (test) pwd
    /tmp/test_dir/test
    ✓ (test) echo '
    quote> Hello
    quote> World
    quote> !
    quote> '; echo "awesome $SHELL";\
    > exit
    
    Hello
    World
    !
    
    awesome 21sh
    exit
    ➜  21sh git:(master)
    

    more info

    Visit original content creator repository

  • MameRomCheck

    [ updated 1st of March 2020 ]

    MameRomCheck

    yet another tool to manage Mame Roms – ui and api

    it has a gui (tkinter or gtk) and an api. This is very early release, but non destructive,
    since it only get informations and dont touch anything (for now..)

    Goal is to Provide a ‘simple’ user interface and a python api to get efficient romset listing inside Mame
    without weeks of self-education about how Mame work :

    • check wether a rom is really playable (not only marked as working)
    • check several romsets against several releases of Mame
    • remove duplicates, move roms in the right place
    • integrate into existing mame tools eco-system
    • click on a romset and run the compatible Mame release.

    Goal is not to compete with very powerful analysis tools like clrMamePro or romCenter.
    But both needs a lot of self eductation about how Mame work, and so far I was not able to automatically check wether a romset
    is really playable or not / to only keep the playable romsets in my roms directories.

    environment(s) :

    • Windows 10 for now

    for GTK interface :

    • python3.8.2 from mingw64
    • the GTK library

    for TKinter interface :

    • python3.7+ for windows from python.org
    • PIL (pip install pillow)

    this should work in other context, provided you use a Python 3.7+ release, but didn’t get the chance to test yet.

    installation :

    • unzip master and open a cmd shell.
    • it needs 3 files from the 7-zip project to run : these can be found in the 7zip 19.00 64-bit x64 version, on the 7-zip.org website :
      https://www.7-zip.org/download.html. direct download link
    • the 7z1900-x64.exe can be open as an archive with 7zip to get the files
    • If you didnt have 7-zip then you should :). Install it (and uninstall winrar, winzip etc once confident).
    • copy 7z.exe, 7z.dll and License.txt from in the ./bin directory
    • cd to the top level of the directory then :
    python bin
    

    The GTK user interface will open

    python bin/tk.py
    

    The tkinter user interface will open. Please note I work first on the GTK ui for now, (2020/03/01)
    so everything wont work as it should with tkinter.

    add Mame installations

    • click the add button under the Mame releases area and browse to your Mame64.exe runtime,
    • the guess release button should populate the name and version field (Version field is important you should let it as is)
    • click ok : the Mame release is added. in the Romset folders view, the roms folder(s) defined in mame.ini should appear.
    • the ‘M’ icon means the corresponding folder is used by the currently selected Mame release. Try to add another Mame release to get it.
    • one can add additional romset folders which are not used by any Mame installation
    • name and/or path MUST be different for Mame and folders, no duplicates.

    list romsets

    • click on a romset folder to see what it contains
    • in the romsets view, click on a romset to populate some information. This makes use of the 7z.exe and dll files.
    • the update button refresh the romset list if needed.
    • the verify button test the romset with the currently selected Mame release.
    • the verify all button test all the romsets of the current folder with the currently selected Mame release. this is multithreaded but this is uncompiled python code : is takes around 25 seconds for 800 romsets on a i7.
    • use the save button to save the informations gathered.

    run

    • a romset will be ok if the driver is reported as ‘good’ in the romset view/driver column (but this need a couple more tests to be sure [bios tests, split romset etc…])
    • try the ‘Run with Mame xxx’ button

    API

    Actually the core code is apart from the interface so on could script operations or integrate in another python project.

    to run and play from a python console :

    python -i bin/mameromcheck.py
    

    the ui’s make use of the methods listed below, so can you.

    Mame.list()         # list your Mame Releases (ordered as in the conf.default.tab file and the ui)
    Romdir.list()       # list your romset folders (ordered as in the conf.default.tab file and the ui)
    m = Mame.get(0)     # get the first Mame installation you defined. Mame.get(name) also work.
    m2 = Mame("C:\\ ... \\mame64.exe")  # create a new mame installation
    m2.name = 'my Mame'                 # add a name if you want to save it later
    
    m.run()             # run Mame
    rd = Romdir.get(1)  # get the second romset folder you defined. with name also.
    rd.romset.keys()    # romsets names in this folder
    rd.populate()       # update the romset of this folder
    rd.verify(0)        # silently run a -listxml Mame command on 
    r = rd.romset['romsetname']  # get a romset
    r.verify(0)         # verify it with the first Mame installation
    m.activate()        # romsets will return verification results of the first Mame release ( since m = Mame.get(0) )
    r.driver            # if 'good' is returned, then this should be ok for this release
    
    r.verify(1)            # verify it with the second Mame installation
    Mame.get(1).activate() # romsets will return verification results of the second installation
    r.driver               # so this could be a different result than previously
    r.run(0)               # run the romset with the first Mame release
    r.description
    r.roms              # dictionnary with rom information (crc)
    ...
    
    task.info()     # infos about parrallel threads and current tasks
    task.maxtasks   # max number of parrallel threads. used by ROmdir.verify(), default 5, use with caution (10 means 40% cpu on a i7 8gen. and is ok for me)
    task.verbose    # True|False
    ...
    
    cfg.save()      # save everything in conf/default.tab. file is human readable
    
    [! WIP WIP WIP !]

    Visit original content creator repository

  • chrono

    Project CHRONO

    pipeline status BSD License

    Distributed under a permissive BSD license, Chrono is an open-source multi-physics package used to model and simulate:

    • dynamics of large systems of connected rigid bodies governed by differential-algebraic equations (DAE)
    • dynamics of deformable bodies governed by partial differential equations (PDE)
    • granular dynamics using either a non-smooth contact formulation resulting in differential variational inequality (DVI) problems or a smooth contact formulation resulting in DAEs
    • fluid-solid interaction problems whose dynamics is governed by coupled DAEs and PDEs
    • first-order dynamic systems governed by ordinary differential equations (ODE)
    • sensors (camera, LiDAR, GPS, IMU, SPAD) to support simulation in robotics and autonomous agents via a ROS2 interface

    Chrono provides a mature and stable code base that continues to be augmented with new features and modules. The core functionality of Chrono provides support for the modeling, simulation, and visualization of rigid and flexible multibody systems with additional capabilities offered through optional modules. These modules provide support for additional classes of problems (e.g., granular dynamics and fluid-solid interaction), modeling and simulation of specialized systems (such as ground vehicles and robots), co-simulation, run-time visualization, post-processing, interfaces to external linear solvers, or specialized parallel computing algorithms (multi-core, GPU, and distributed) for large-scale simulations.

    Used in many different scientific and engineering problems by researchers from academia, industry, and federal government, Chrono has mature support for multibody dynamics, finite element analysis, granular dynamics, fluid-solid interaction, ground vehicle simulation, robotics, embodied AI, and terramechanics.

    Implemented almost entirely in C++, Chrono also provides Python and C# APIs. The build system is based on CMake. Chrono is platform-independent and is actively tested on Linux, Windows, and MacOS using a variety of compilers.

    Documentation

    Support

    Note on Chrono repository structure

    The structure of the Chrono git repository was changed as follows:

    • The main development branch is now called main (previously develop)
    • The master branch, now obsolete, was deleted
    • Releases are located in branches named release/*.* and have tags of the form *.*.*
    Visit original content creator repository
  • mediator.dart

    Mediator.dart

    Dart pub package codecov

    Description

    A Mediator implementation for Dart inspired by MediatR.

    This package provides a simple yet configurable solution.

    Features

    • Request/Response
    • Commands
    • Request/Command Pipelines
    • Events
    • Event Observers

    Sending events

    An event can have multiple handlers. All handlers will be executed in parallel (by default).

    import 'package:dart_mediator/mediator.dart';
    
    /// Strongly typed event class containing the event data.
    /// All events must implement the [DomainEvent] interface.
    class MyEvent implements DomainEvent {}
    
    Future<void> main() async {
      final mediator = Mediator.create();
    
      // Subscribe to the event.
      mediator.events.on<MyEvent>()
        .subscribeFunction(
          (event) => print('event received'),
        );
    
      // Sends the event to all handlers.
      // This will print 'event received'.
      await mediator.events.dispatch(MyEvent());
    }

    Sending Commands

    A command can only have one handler and doesn’t return a value.

    /// This command will not return a value.
    class MyCommand implements Command {}
    
    class MyCommandHandler implements CommandHandler<MyCommand> {
      @override
      FutureOr<void> handle(MyCommand request) {
        // Do something
      }
    }
    
    Future<void> main() async {
      final mediator = Mediator.create();
    
      mediator.requests.register(MyCommandHandler());
    
      /// Sends the command request. Return value is [void].
      await mediator.requests.send(MyCommand());
    }

    Sending Requests

    A request can only have one handler and returns a value.

    import 'package:dart_mediator/mediator.dart';
    
    class Something {}
    
    /// This query will return a [Something] object.
    class MyQuery implements Query<Something> {}
    
    class MyQueryHandler implements QueryHandler<Something, MyQuery> {
      @override
      FutureOr<Something> handle(MyQuery request) {
        // do something
        return Something();
      }
    }
    
    Future<void> main() async {
      final mediator = Mediator.create();
    
      mediator.requests.register(MyQueryHandler());
    
      // Sends the query request and returns the response.
      final Something response = await mediator.requests.send(MyQuery());
    
      print(response);
    }

    Event Observers

    An observer can be used to observe events being dispatched, handled or when an error occurs. For example logging events.

    class LoggingEventObserver implements EventObserver {
    
      /// Called when an event is dispatched but before any handlers have
      /// been called.
      @override
      void onDispatch<TEvent>(
        TEvent event,
        Set<EventHandler> handlers,
      ) {
        print(
          '[LoggingEventObserver] onDispatch "$event" with ${handlers.length} handlers',
        );
      }
    
      /// Called when an event returned an error for a given handler.
      @override
      void onError<TEvent>(
        TEvent event,
        EventHandler handler,
        Object error,
        StackTrace stackTrace,
      ) {
        print('[LoggingEventObserver] onError $event -> $handler ($error)');
      }
    
      /// Called when an event has been handled by a handler.
      @override
      void onHandled<TEvent>(
        TEvent event,
        EventHandler handler,
      ) {
        print('[LoggingEventObserver] onHandled $event -> $handler');
      }
    }
    
    void main() {
      final mediator = Mediator.create(
        // Adds the logging event observer.
        observers: [LoggingEventObserver()],
      );
    
      // Dispatch an event.
    }
    

    Request/Command Pipeline Behavior

    A pipeline behavior can be used to add cross cutting concerns to requests/commands. For example logging.

    class LoggingBehavior implements PipelineBehavior {
      @override
      Future handle(dynamic request, RequestHandlerDelegate next) async {
        try {
          print('[LoggingBehavior] [${request.runtimeType}] Before');
          return await next();
        } finally {
          print('[LoggingBehavior] [${request.runtimeType}] After');
        }
      }
    }
    
    void main() {
        final mediator = Mediator.create();
    
        // add logging behavior
        mediator.requests.pipeline.registerGeneric(LoggingBehavior());
    }

    Credits

    Visit original content creator repository
  • imgur-download

    Imgur Image Downloader

    Python version License Code Style: Black

    This project is a Python script that enables you to download tagged images from Imgur.

    Download Modes

    This script supports two download modes: sequential and threaded.

    • Sequential: In this mode, images are downloaded one after another using only the main thread of the process.

    • Threaded: This mode creates multiple threads to download images concurrently.

    The script measures and logs the time taken to download the images in both modes. This enables you to see the effect of using the different modes and different numbers of threads on the script’s performance.

    Requirements

    The project’s only dependency is the requests module, which can be installed using pip:

    pip install requests

    The script also requires an Imgur client ID which should be set in your environment variables as imgur_client_id. To obtain an Imgur client ID, create an account on Imgur and follow the instructions on registering an application.

    How to Run

    To run the script, you need to use the command line. Navigate to the directory containing the script, then run the command with the following format:

    python download.py --tag <tag> --mode <mode> [--threads <threads>]

    Where:

    • <script name> is the name of the python file.
    • <tag> is the tag of the images you want to download. For example, astronomy or cats.
    • <mode> is the download mode which can be either threaded or sequential.
    • <threads> (optional) is the number of threads to use in threaded mode. Default is 10. Only valid when --mode=threaded.

    An example command to download images tagged with astronomy using 10 threads is:

    python download.py --tag astronomy --mode threaded --threads 12

    Imgur Tags

    Examples of Imgur tags you can use include: astronomy, cats, cars, nature, earth.

    Notes

    The downloaded images will be saved in an images directory in the same location as the script. Each run will save its images in a new directory with the current time stamp. For tags with multiple images, each image will be saved in a separate directory within this top-level directory.

    Visit original content creator repository
  • sequence_generator

    Sequence Generator

    By Clayton Boneli

    Number or letter sequences are easy to obtain when you are only interested in sequence of numbers (ascending or descending) that follow
    a predefined order, for example decimal numbers 0,1,2,3,4,5,6,7,8,9 always follow that order, the number 1 will follow the number 0, the number 3 will follow the number 2.

    Other numbers of larger quantities also follow the same order of formation, all are composed of digits between 0 and 9. This same feature for sequential letters can be applied to vowels, all of which correspond to characters sequences that follow a predefined order.

    But, what if you need to create a sequence that has a completely different formation order? A string or number that does not follow the rule natural of decimal numbers or the alphabet? For example, if you need to create sequences like the following:

    AA-0001
    AA-0002
    AA-0003
    
    AA-9999
    AB-0001
    AB-0002
    AB-0003
    
    AB-9999
    AC-0001
    AC-0002
    AC-0003
    
    AC-9999
    AD-0001
    AD-0002
    AD-0003
    
    
    Other sequence
    
    A-2019-01
    A-2019-02
    A-2019-03
    
    A-2019-99
    B-2019-01
    B-2019-02
    
    B-2019-99
    C-2019-01
    C-2019-02

    How to create growing sequences but made up of characters made up of letters, numbers, punctuation marks, etc.? For this kind of need it is that the “sequence” package was created which contains classes and the means that allow the definition of a sequence of alphanumeric values and the generation these values in ascending / descending sequential order.

    You can define any sequence of numeric or alphanumeric characters, which can be letters, numbers, decimals, hexadecimals, DNA sequence, etc. Using the sequence generator you can create sequences that will be generated in ascending or descending order.

    You can create your own sequences or use the predefined ones.

    Example:

    seq = factory("WM [0-9][0-9]")
    for x in range(100):
        print(seq.next().get())
        
    seq = factory("WM [0-9]{2}")
    for x in range(100):
        print(seq.next().get())
        
    seq = factory("WM [0-9]{2}", order=[0, 1])
    for x in range(100):
        print(seq.next().get())
        

    Dependencies:

    • exrex

    Visit original content creator repository