Category: Blog

  • time-slime

    Time Slime

    Time Slime - Scooby Doo Villain

    Time Slime is a C library for implementation of a basic time sheet program.

    It uses an SQLITE database to store logs, and allows you to clock in/out as well as add a set number of hours.

    There is also a shell interface for using only the library from the terminal.

     

    Getting Started

    To use this as a library in another program, you need the timeslime.h and timeslime.c files.

    If your project already includes SQLITE, then replace this line, in timeslime.h:

    #include "third_party/sqlite3/sqlite3.h"

    With:

    #include "path/to/sqlite3.h"

    Pointing to your sqlite3.h file.

    If your project is NOT using SQLITE, then you need to take third_party/sqlite3/sqlite3.h and third_party/sqlite3/sqlite3.c as well, and change the path to sqlite3.h in timeslime.h based on where you place the files.

    Building

    To build the command line utility, you can just run:

    make

    on Windows or Linux.

     

    Library Documentation

    The Time Slime library has the following functions available for use:

    TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[]);
    
    TIMESLIME_STATUS_t TimeSlime_Close(void);
    
    TIMESLIME_STATUS_t TimeSlime_AddHours(float hours, TIMESLIME_DATE_t date);
    
    TIMESLIME_STATUS_t TimeSlime_ClockIn(TIMESLIME_DATETIME_t time);
    
    TIMESLIME_STATUS_t TimeSlime_ClockOut(TIMESLIME_DATETIME_t time);
    
    TIMESLIME_STATUS_t TimeSlime_GetReport(TIMESLIME_DATE_t start, TIMESLIME_DATE_t end, TIMESLIME_REPORT_t **out);
    
    void TimeSlime_FreeReport(TIMESLIME_REPORT_t **report);
    
    char*  TimeSlime_StatusCode(TIMESLIME_STATUS_t status);

    Time Slime Status

    TIMESLIME_STATUS_t is a type alias for int, and can be one of the following (defined in timeslime.h):

    Value Description
    TIMESLIME_OK No problems or errors
    TIMESLIME_UNKOWN_ERROR Unkown error prevented function from finishing
    TIMESLIME_SQLITE_ERROR Problem executing SQLITE actions
    TIMESLIME_INVALID_YEAR Invalid year in parameter object
    TIMESLIME_INVALID_MONTH Invalid month in parameter object
    TIMESLIME_INVALID_DAY Invalid day in parameter object
    TIMESLIME_INVALID_HOUR Invalid hour in parameter object
    TIMESLIME_INVALID_MINUTE Invalid minute in parameter object
    TIMESLIME_ALREADY_CLOCKED_IN Unable to clock in since a clock out action has not been performed
    TIMESLIME_NOT_CLOCKED_IN Unable to clock out since a clock in action has not been performed
    TIMESLIME_NO_ENTIRES No time sheet entries were found for a given date range
    TIMESLIME_NOT_INITIALIZED TimeSlime_Initialize(char[]) has not been called yet

    If you want to get a string key that represents a status code, use the TimeSlime_StatusCode(TIMESLIME_STATUS_t) method, and pass in the status code. A string will be returned.

    Inititialization

    The TimeSlime_Initialize(char[]) function needs to be called before any other Time Slime methods. This is responsible for creating the SQLITE database if it does not exist.

    The parameter passed to this should be the directory to place the the timeslime.db file (WITHOUT a trailing slash).

    Closing

    The TimeSlime_Close() function needs to be called before exiting your program, it is responsible for safely disposing of allocated memory.

    Adding Hours

    It might be desired to add a set number of hours to a time sheet for a specific date (rather than clocking in and out).

    This is where the TimeSlime_AddHours(float, TIMESLIME_DATE_t) functions comes in.

    The function accepts a float, which is the number of hours worked. Then a TIMESLIME_DATE_t struct, which is the date to add the hours to.

    See more about TIMESLIME_DATE_t.

    Clocking In and Out

    To clock in and out of the time sheet, use the TimeSlime_ClockIn(TIMESLIME_DATETIME_t) and TimeSlime_ClockOut(TIMESLIME_DATETIME_t) functions.

    Each function accepts a TIMESLIME_DATETIME_t struct, which represents the date and time that the clock in, clock out should be performed on.

    See more about TIMESLIME_DATETIME_t.

    Reports

    Generating a report will show you how many hours have been worked per day for a certain date range.

    TimeSlime_GetReport(TIMESLIME_DATE_t start, TIMESLIME_DATE_t end, TIMESLIME_REPORT_t **out) will generate a report between the start and end dates.

    The result will be placed in the TIMESLIME_REPORT_t pointer, and this needs to be passed a pointer to that pointer.

    When you are done, use TimeSlime_FreeReport(TIMESLIME_REPORT_t**) to clear allocated memory.

    See more about TIMESLIME_DATE_t and TIMESLIME_REPORT_t.

     

    Library Datatypes

    To avoid conflicts with other libraries, Time Slime defines custom datatypes for use with the library.

    Date and DateTime

    The Date and DateTime structs are passed to several Time Slime functions.

    struct TIMESLIME_DATE_STRUCT
    {
        int year;
        int month;
        int day;
    };
    typedef struct TIMESLIME_DATE_STRUCT TIMESLIME_DATE_t;
    
    struct TIMESLIME_DATETIME_STRUCT
    {
        int year;
        int month;
        int day;
        int hour;
        int minute;
    };
    typedef struct TIMESLIME_DATETIME_STRUCT TIMESLIME_DATETIME_t;

    Time Slime also defines some helpful directives to easily create these for the current time.

    #define TIMESLIME_DATE_NOW         (TIMESLIME_DATE_t){ 0, 0, 0}
    #define TIMESLIME_TIME_NOW         (TIMESLIME_DATETIME_t){ 0, 0, 0, -1, -1 }

    Report

    The TIMESLIME_STATUS_REPORT_t struct looks like:

    // Report Entry
    struct TIMESLIME_REPORT_ENTRY_STRUCT
    {
        float Hours;
        char Date[];
    };
    typedef struct TIMESLIME_REPORT_ENTRY_STRUCT TIMESLIME_REPORT_ENTRY_t;
    
    // Time Sheet Report
    struct TIMESLIME_REPORT_STRUCT
    {
        int NumberOfEntries;
        TIMESLIME_REPORT_ENTRY_t Entries[];
    };
    typedef struct TIMESLIME_REPORT_STRUCT TIMESLIME_REPORT_t;

     

    Terminal Usage

    Once build, if you add the executable (in the build folder) to your system PATH, you can run it with the following commands:

    # Show information and command help
    > timeslime help
    
    # Add an amount of time to the current date
    > timeslime add [hours]
    
    # Add an amount of time to a specific date
    > timeslime add [hours] [date]
    
    # Clock in
    > timeslime clock in
    
    # Clock out
    > timeslime clock out
    
    # Run a report
    > timeslime report [start-date] [end-date]

    IMPORTANT: All dates must be formatted as either YYYY-MM-DD or YYYY/MM/DD

     

    Todo

    • Better report formatting (done?)
    • Allow second parameter of a report to be “today”
    • Shell program to prompt user for choices if no parameters (or not all parameters) are given (but works on all systems)
    • Imrpove logging

     

     

    Font used in logo is Liquidism

    Visit original content creator repository
  • matio

    MATIO

    MATLAB MAT file I/O library

    Status

    pre-commit.ci Status Autotools Build Status CMake Build Status Coverity Scan Build Status Coverage Status Build Status FreeBSD Build Status CodeQL Packaging status Fuzzing Status Open Hub Conan Center Vcpkg Version

    Table of Contents

    1. Introduction
    1. Building
    1. License

    1.0 Introduction

    Matio is an open-source C library for reading and writing binary MATLAB MAT files. This library is designed for use by programs/libraries that do not have access or do not want to rely on MATLAB’s shared libraries.

    1.1 Contact

    You can contact the maintainer through email at t-beu@users.sourceforge.net.

    1.2 Acknowledgements

    The following people/organizations have helped in the development of matio through patches, bug reports, and/or testing:

    1.3 Contributing

    If you are interested in collaborations, contact the maintainer via email (see section 1.1).

    1.4 Questions and Reporting Bugs

    Questions can be asked using the forums on the sourceforge site hosting matio.

    Bugs, enhancements, etc. should be submitted using one of the trackers on the sourceforge page.

    2.0 Building

    This section describes how to build matio. Section 2.1 describes the dependencies, section 2.2 how to build/test matio, and section 2.3 documents the platforms matio has been tested on.

    2.1 Dependencies

    Matio has two optional dependencies. These are not required for the software to work, but without them some files may be unreadable. Zlib is required to read/write level 5 MAT files that use compression. HDF5 is required to work with newer MAT files that use the HDF5-format files.

    2.1.1 zlib

    To support compressed MAT files, zlib version ≥ 1.2.3 is required. The zlib software can be downloaded from http://zlib.net/.

    2.1.2 HDF5

    Support for MAT file version 7.3 requires the HDF5 library of version ≥ 1.8.x. This library can be downloaded from https://github.com/HDFGroup/hdf5/releases. Neither deprecated HDF5 1.6.x API functions nor HDF5 higher-level functions are called.

    • Building matio with HDF5 1.8.x requires configuration of HDF5 with default API v18.
    • Building matio with HDF5 1.10.x requires configuration of HDF5 with either default API v110 or with deprecated API v18.
    • Building matio with HDF5 1.12.x requires configuration of HDF5 with either default API v112, or with deprecated APIs v110 or v18.
    • Building matio with HDF5 1.14.x requires configuration of HDF5 with either default API v114, or with deprecated APIs v112, v110 or v18.
    • Building matio with HDF5 2.0.0 requires configuration of HDF5 with either default API v200, or with deprecated APIs v114, v112, v110 or v18.

    For Ubuntu, sudo apt install libhdf5-dev should work fine.

    2.2 Building matio

    2.2.1 Quick Build Guide

    The primary method for building the software is with GNU autotools using configure followed by make. After building, the testsuite can be executed to test the software using make check. The software can be installed using make install. For example,

    git clone git://git.code.sf.net/p/matio/matio
    cd matio
    git submodule update --init  # for datasets used in unit tests
    ./autogen.sh
    ./configure
    make
    make check
    make install

    If any of the tests in the testsuite fail, you should report the failure using the tracker (see section 1.4). You should attach the generated testsuite.log file to the bug report.

    2.2.2 Configure Options

    The configure script used to build the software takes a number of options. This section describes the key options.

    • --enable-mat73=yes This flag enables the support for version 7.3 MAT files. The option only makes sense if built with HDF5 as support for version 7.3 files. It will be disabled if HDF5 is not available.
    • --enable-extended-sparse=yes This option enables extended sparse matrix data types not supported in MATLAB. MATLAB only supports double-precision sparse data. With this flag, matio will read sparse data with other types (i.e. single-precision and integer types).
    • --with-matlab=DIR This option specifies the directory (DIR) with the ‘matlab’ program. With this option, the testsuite will check that the MAT files written by matio can be read into MATLAB. Without this, the test will only check that matio can read the file written and if successful the test will be skipped. If matio can not read the file, the test will fail.
    • --with-zlib=DIR This option specifies the prefix where zlib is installed (see section 2.1.1 for information about zlib).
    • --with-hdf5=DIR This option specifies the prefix where the HDF5 software is installed (see section 2.1.2 for information about HDF5).
    • --with-default-file-ver=version This option sets the default MAT file version (4,5,7.3) that will be used when writing. The default file version is used by the Mat_Create macro and the Mat_CreateVer function when MAT_FT_DEFAULT is used for the version argument.
    • --with-libdir-suffix=suffix This option specifies a suffix to apply to library directories when installing and looking for dependent libraries (i.e. HDF5 and zlib). For example, some multi-arch Linux distributions install 64-bit libraries into lib64 and 32-bit libraries into lib.

    2.2.3 CMake build system

    The CMake build system is supported as an alternative build system, which usually consists of three steps for configuration, build and installation. By default, the CMake project is also configured for testing with CTest. For example,

    git clone git://git.code.sf.net/p/matio/matio
    cd matio
    git submodule update --init  # for datasets used in unit tests
    cmake .
    cmake --build .
    ctest --test-dir .
    cmake --install .

    The following matio specific options for building with CMake are available.

    • MATIO_DEFAULT_FILE_VERSION:STRING=5 This option sets the default MAT file version (4,5,7.3) that will be used when writing.
    • MATIO_EXTENDED_SPARSE:BOOL=ON This option enables extended sparse matrix data types not supported in MATLAB.
    • MATIO_MAT73:BOOL=ON This flag enables the support for version 7.3 MAT files.
    • MATIO_PIC:BOOL=ON This option enables position-independent code (PIC), i.e., compilation with the -fPIC flag. It is ignored for Visual Studio builds.
    • MATIO_SHARED:BOOL=ON This option builds the matio library as shared object (i.e., a dynamic link library on Windows).
    • MATIO_WITH_HDF5:BOOL=ON This option enables CMake to check for availability of the HDF5 library (see section 2.1.2 for information about HDF5).
    • MATIO_WITH_ZLIB:BOOL=ON This option enables CMake to check for availability of the zlib library (see section 2.1.1 for information about zlib).
    • MATIO_BUILD_TESTING:BOOL=ON This option enables the matio testsuite for CTest.
    • MATIO_ENABLE_CPPCHECK:BOOL=OFF This option enables CMake ≥ 3.10 to perform static analysis with Cppcheck.
    • MATIO_USE_CONAN:BOOL=OFF This deprecated option enables the Conan 1.X package manager to resolve the library dependencies.

    To help CMake find the HDF5 libraries, set environment variable HDF5_DIR to the cmake/hdf5 directory (containing hdf5-config.cmake) inside the HDF5 build or installation directory, or call CMake with -DHDF5_DIR="dir/to/hdf5/cmake/hdf5". Alternatively call CMake with -DCMAKE_PREFIX_PATH="dir/to/hdf5/cmake". See the HDF5 documentation for more information. Using hdf5-config is recommended over using CMake’s built-in FindHDF5, especially for static builds. CMake 3.10 or later is recommended.

    For Conan 2.X as dependency provider call CMake with -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider. CMake 3.24 or later is required.

    2.2.4 Visual Studio

    Visual Studio solutions are provided as matio_vs2008.sln for VS2008 and as matio.sln for VS2010 (and newer). The Debug and Release configurations of both solutions are set up to build a DLL of the matio library (libmatio.dll) and the matdump tool and assume HDF5 is available in the directory specified by the HDF5_DIR environment variable. It is assumed that the shared libraries of HDF5 (and zlib) are available. If the static libraries of HDF5 (and zlib) are installed/built the macro H5_BUILT_AS_STATIC_LIB needs to be defined (instead of H5_BUILT_AS_DYNAMIC_LIB). Furthermore, the Release Lib configuration of the VS2010 solution is set up to build a static LIB of the matio library (libmatio.lib) and assumes that the static libraries of HDF5 (and zlib) are installed/built.

    2.2.5 Testsuite

    A testsuite is available when building with the GNU autotools. To run the testsuite, first configure and build matio. After building run make check to run the testsuite. If matio was built without zlib, the compressed variable tests will be skipped. If built without HDF5, the tests for version 7.3 MAT files will be skipped. If the path to the MATLAB application was not specified (--with-matlab), the write tests will fail if matio cannot read the file and skip if matio can read the file. The write tests will pass if MATLAB is available and can also read the file.

    To report matio testsuite failures, compress the testsuite.log file in the test sub-directory of the build directory. Upload the compressed log file along with a bug report (see section 1.4 for information on reporting bugs).

    2.3 Platforms

    The library has been tested/used on Linux, Windows, and OS X including both little-endian and big-endian architecture.

    3.0 License

    This software is provided under a Simplified BSD license. See the COPYING file for details on the license.

    MATLAB is a registered trademark of The MathWorks, Inc.

    Visit original content creator repository
  • Vigilant

    Vigilant


    ℹ️ This project is not currently in development and has no current plans for development. A successor to this project is sentinel.

    Vigilant is a free software Roblox game. It combines the gameplay features of MOBA and RTS games like Dota 2, or Warcraft III with the character mechanics of hero/class shooters such as Overwatch and Team Fortress 2 along with twin stick style controls similar to games like Alien Swarm, HELLDIVERS, or Magicka. This creates a unique gameplay experience where players cooperate using their heroes’ unique abilities to survive against relentless hordes of enemies.

    Vigilant is a free to play cooperative game on Roblox designed to feel wholly unique among other games of the platform. It builds systems from the ground up to provide a striking experience that feels different than ‘just another Roblox game’. It achieves this through custom frameworks for controls, asset definition, replication, particle systems, game events/effects, and more. Overall, it aims to push the bar of what a Roblox game is percieved to be.

    Usage

    You can play the game on Roblox. There’s no need to install Vigilant to play, simply click play on the game page and Roblox will handle its own installation and get you into the game as quickly as possible.

    Vigilant uses Rojo as a bridge between the filesystem and Roblox Studio. If you want to contribute or use Vigilant for development, install both to get started. The project contains a default.project.json that can be used by Rojo to generate or sync with a Roblox save file.

    Documentation

    The only documentation is currently in the source. This will be changing soon.

    Contributing

    Contributions are welcome, please make a pull request!

    Be sure to set up Rojo to get started. Check out our contribution guide for further information.

    Please read our code of conduct when getting involved.

    License

    Vigilant is free software available under the MIT license. See the license for details.

    Everything you see here is free software, but not all game assets you see while playing are.

    Visit original content creator repository
  • progressr

    CRAN check status R CMD check status Top reverse-dependency checks status Coverage Status Life cycle: maturing

    progressr: An Inclusive, Unifying API for Progress Updates

    The progressr package provides a minimal API for reporting progress updates in R. The design is to separate the representation of progress updates from how they are presented. What type of progress to signal is controlled by the developer. How these progress updates are rendered is controlled by the end user. For instance, some users may prefer visual feedback such as a horizontal progress bar in the terminal, whereas others may prefer auditory feedback. The progressr framework is designed to work out-of-the-box also with parallel and distributed processing, especially with the futureverse ecosystem.

    Three strokes writing three in Chinese

    Design motto:

    The developer is responsible for providing progress updates but it’s only the end user who decides if, when, and how progress should be presented. No exceptions will be allowed.

    Two Minimal APIs – One For Developers and One For End-Users

    Developer’s API

    1. Set up a progressor with a certain number of steps:

    p <- progressor(nsteps)
    p <- progressor(along = x)
    

    2. Signal progress:

    p()               # one-step progress
    p(amount = 0)     # "still alive"
    p("loading ...")  # pass on a message
    
        
    End-user’s API

    1a. Subscribe to progress updates from everywhere:

    handlers(global = TRUE)
    
    y <- slow_sum(1:5)
    y <- slow_sum(6:10)
    

    1b. Subscribe to a specific expression:

    with_progress({
      y <- slow_sum(1:5)
      y <- slow_sum(6:10)
    })
    

    2. Configure how progress is presented:

    handlers("progress")
    handlers("txtprogressbar", "beepr")
    handlers(handler_pbcol(enable_after = 3.0))
    handlers(handler_progress(complete = "#"))
    

    A simple example

    Assume that we have a function slow_sum() for adding up the values in a vector. It is so slow, that we like to provide progress updates to whoever might be interested in it. With the progressr package, this can be done as:

    slow_sum <- function(x) {
      p <- progressr::progressor(along = x)
      sum <- 0
      for (kk in seq_along(x)) {
        Sys.sleep(0.1)
        sum <- sum + x[kk]
        p(message = sprintf("Adding %g", x[kk]))
      }
      sum
    }

    Note how there are no arguments (e.g. .progress = TRUE) in the code that specify how progress is presented. This is by design and because the only task for the developer is to decide on where in the code it makes sense to signal that progress has been made. As we will see next, it should be up to the end user, and end user only, of this code to decide whether they want to receive progress updates or not, and, if so, in what format. Asking them to specify a special “progress” argument adds a lot of friction, it clutters up the code, and, importantly, might not even be possible for end users to do (e.g. they call a package function that in turn calls the progress reporting function of interest).

    Now, if we call this function, without further settings:

    > y <- slow_sum(1:10)
    > y
    [1] 55
    >

    the default is that there will be no progress updates. To get progress updates, we need to request them to be “handled”, which we do by:

    > progressr::handlers(global = TRUE)

    After this, progress will be reported;

    > y <- slow_sum(1:10)
      |====================                               |  40%
    > y <- slow_sum(10:1)
      |========================================           |  80%

    To disable reporting again, do:

    > handlers(global = FALSE)

    Customizing how progress is reported

    By default, progressr presents progress via the built-in utils::txtProgressBar(). It presents itself as a rudimentary ASCII-based horizontal progress bar in the R terminal. See help("handler_txtprogressbar") for how to customize the look of “txtprogressbar”, e.g. colorization and Unicode. There are many other ways to report on progress, including visually, auditory, and via notification systems. You can also use a mix of these, e.g.

    handlers(c("cli", "beepr", "ntfy"))

    See the ‘Customizing How Progress is Reported’ vignette for for examples.

    Additional Features

    Support for progressr elsewhere

    Note that progression updates by progressr is designed to work out of the box for any iterator framework in R. See the different package vignettes for details. Prominent examples are:

    • lapply() etc. of base R
    • map() etc. by the purrr package
    • llply() etc. by the plyr package
    • foreach() iterations by the foreach package

    and near-live progress reporting in parallel and distributed processing via the future framework:

    Other uses of progressr are:

    • make packages that report progress via the cli package (e.g. purrr) report progress via progressr
    • make knit() of the knitr package report via progressr

    Use regular output as usual alongside progress updates

    In contrast to other progress-bar frameworks, output from message(), cat(), print() and so on, will not interfere with progress reported via progressr. For example, say we have:

    slow_sqrt <- function(xs) {
      p <- progressor(along = xs)
      lapply(xs, function(x) {
        message("Calculating the square root of ", x)
        Sys.sleep(2)
        p(sprintf("x=%g", x))
        sqrt(x)
      })
    }

    we will get:

    > library(progressr)
    > handlers(global = TRUE)
    > handlers("progress")
    > y <- slow_sqrt(1:8)
    Calculating the square root of 1
    Calculating the square root of 2
    - [===========>-----------------------------------]  25% x=2

    This works because progressr will briefly buffer any output internally and only release it when the next progress update is received just before the progress is re-rendered in the terminal. This is why you see a two second delay when running the above example. Note that, if we use progress handlers that do not output to the terminal, such as handlers("beepr"), then output does not have to be buffered and will appear immediately.

    Comment: When signaling a warning using warning(msg, immediate. = TRUE) the message is immediately outputted to the standard-error stream. However, this is not possible to emulate when warnings are intercepted using calling handlers. This is a limitation of R that cannot be worked around. Because of this, the above call will behave the same as warning(msg) – that is, all warnings will be buffered by R internally and released only when all computations are done.

    Sticky messages

    As seen above, some progress handlers present the progress message as part of its output, e.g. the “progress” handler will display the message as part of the progress bar. It is also possible to “push” the message up together with other terminal output. This can be done by adding class attribute "sticky" to the progression signaled. This works for several progress handlers that output to the terminal. For example, with:

    slow_sum <- function(x) {
      p <- progressr::progressor(along = x)
      sum <- 0
      for (kk in seq_along(x)) {
        Sys.sleep(0.1)
        sum <- sum + x[kk]
        p(sprintf("Step %d", kk), class = if (kk %% 5 == 0) "sticky", amount = 0)
        p(message = sprintf("Adding %g", x[kk]))
      }
      sum
    }

    we get

    > handlers("txtprogressbar")
    > y <- slow_sum(1:30)
    Step 5
    Step 10
      |====================                               |  43%

    and

    > handlers("progress")
    > y <- slow_sum(1:30)
    Step 5
    Step 10
    / [===============>-------------------------]  43% Adding 13

    Installation

    R package progressr is available on CRAN and can be installed in R as:

    install.packages("progressr")

    Pre-release version

    To install the pre-release version that is available in Git branch develop on GitHub, use:

    remotes::install_github("futureverse/progressr", ref="develop")

    This will install the package from source.

    Contributing

    To contribute to this package, please see CONTRIBUTING.md.

    Visit original content creator repository