Author: wfhyoma5fmgi

  • simple-stringify

    simple-stringify

    Build Status Coverage Status npm Github Releases

    Simple way stringify json for log.

    Installation

    $ npm install simple-stringify

    API

    const stringify = require('simple-stringify');
    const data = {
      no: 123,
      mobile: null,
      addresss: undefined,
      disabled: false,
      name: 'tree.xie',
      keywords: [
        'koa',
        'framework',
        'albi',
      ],
      infos: {
        url : 'https://github.com/vicanso/albi/issues',
        email: 'vicansocanbico@gmail.com'
      },
    };
    // no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[] infos={}
    stringify.json(data);

    divider

    The divider for stringify, default is ‘ ‘.

    const stringify = require('simple-stringify');
    stringify.divider = ',';

    isSecret

    Determine if it is confidential by key. If return true, the value will be ***.

    const stringify = require('simple-stringify');
    stringify.isSecret = key => key === 'password';
    // account="tree.xie" password="***"
    stringify.json({
      password: '123456',
    });

    json

    Stringify json data

    • level format level, default is stringify.maxLevel
    const stringify = require('simple-stringify');
    const data = {
      no: 123,
      mobile: null,
      addresss: undefined,
      disabled: false,
      name: 'tree.xie',
      keywords: [
        'koa',
        'framework',
        'albi',
      ],
      infos: {
        url : 'https://github.com/vicanso/albi/issues',
        email: 'vicansocanbico@gmail.com'
      },
    };
    // no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[] infos={}
    stringify.json(data);
    
    // no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[0="koa" 1="framework" 2="albi"] infos={url="https://github.com/vicanso/albi/issues" email="vicansocanbico@gmail.com"}
    stringify.json(data, 2);

    maxLevel

    Set stringify max level, default is 1

    const stringify = require('simple-stringify');
    stringify.maxLevel = 2;
    const data = {
      no: 123,
      mobile: null,
      addresss: undefined,
      disabled: false,
      name: 'tree.xie',
      keywords: [
        'koa',
        'framework',
        'albi',
      ],
      infos: {
        url : 'https://github.com/vicanso/albi/issues',
        email: 'vicansocanbico@gmail.com'
      },
    };
    // no=123 mobile=null addresss=undefined disabled=false name="tree.xie" keywords=[0="koa" 1="framework" 2="albi"] infos={url="https://github.com/vicanso/albi/issues" email="vicansocanbico@gmail.com"}
    stringify.json(data);

    Benchmarks

    JSON.stringify 1000000 times, use:2438ms
    simple-stringify json 1000000 times, use:1684ms
    

    License

    MIT

    Visit original content creator repository https://github.com/vicanso/simple-stringify
  • miner

    miner

    R-CMD-check

    Following the python module py3minepi, this is an R package that allows connection to the Minecraft API using RaspberryJuice and either Spigot or Minecraft:Pi.

    The miner package provides a few simple functions to manipulate the Minecraft world from R. The intent of this package is to encourage new R users to learn R by writing scripts to do fun things in Minecraft.

    See the online book, R Programming with Minecraft, for details on setting up a Minecraft server and using this package, and for a variety of detailed examples. The package also contains a short vignette on its basic use.

    Here are a few of the things you can do with miner:

    Write words on a hillside:

    Render a photograph as a wall of blocks:

    Or the R logo:

    Generate a random maze in R, and create it in the world for players to explore:

    This player is operated by a bot trying to find its way out of the maze via a rule-based algorithm:

    Give the player the powers of Elsa:

    Freeze water as you run over it

    or create towers of ice with a gesture:

    Write a bot to play a game with players over chat:

    .

    And, of course, make ggplot plots in Minecraft:

    Extending

    The craft package includes additional functions that illustrate and extend the use of miner. Contributors who want to extend the functionality of miner should submit a pull request to the craft package.

    Documentation

    R Programming with Minecraft is a bookdown book about R and Minecraft, and particularly about using Minecraft with the miner package. Contributors who want to add documentation should submit a pull request to the miner_book repository on Github.

    About this package

    This package was created as part of the ROpenSci unconference in May, 2017 by:

    License

    Licensed under the MIT license. (More information here.)

    Visit original content creator repository https://github.com/kbroman/miner
  • C-INI-Parser

    C-INI-Parser

    Build Status GitHub license

    An simple INI parser based on inih in OOP style C99.

    Preserve parsed INI data in hashtable and provide a key-value access interface.

    // C API

    // constructor
    IniParserPtr_T IniParser_Create ( const char* const ini_filename );
    
    // destructor
    void IniParser_Destroy ( IniParserPtr_T P );
    
    // check error
    int16_t IniParser_CheckInstanceError ( IniParserPtr_T P );
    
    // get string via key string
    const char* const IniParser_GetString ( IniParserPtr_T P, const char* const section, const char* const name, const char* const default_value );
    
    // get integer via key string
    int32_t IniParser_GetInteger ( IniParserPtr_T P, const char* const section, const char* const name, long default_value );
    
    // get real(double) via key string
    double IniParser_GetDouble ( IniParserPtr_T P, const char* const section, const char* const name, double default_value );
    
    // get boolean via key string
    bool IniParser_GetBoolean ( IniParserPtr_T P, const char* const section, const char* const name, bool default_value );

    // Example

    Build from example folder via gcc (link iniparser.c and ini.c)

    gcc -std=c99 -Wall -o test test.c ../src/iniparser.c ../src/internal/ini.c -I../src

    Build via CMake

    • DENABLE_EXAMPLE: build examples flag, default is TRUE.
    • DENABLE_SHAREDLIB: share or static library flag, default is TRUE (shared).
    mkdir build && cd build
    cmake .. [-DENABLE_EXAMPLE=TRUE -DENABLE_SHAREDLIB=FALSE]
    make
    make install

    Sample INI taken from inih repo

    ; Just comments
    ; Another comments
    
    [protocol]             ; Protocol configuration, this is section
    version=6              ; IPv6, this is name
    
    
    [user]
    name = Bob Smith       ; Spaces around '=' are stripped
    email = bob@smith.com  ; And comments (like this) ignored
    active = true          ; Test a boolean
    pi = 3.14159           ; Test a floating point number

    Sample Code

    #include <stdio.h>
    #include "iniparser.h"
    
    int main(void)
    {
        IniParserPtr_T p = IniParser_Create ("test.ini");
        printf ("Is error: %" PRId16 "\n", IniParser_CheckInstanceError(p));
    
        const char * v1 = IniParser_GetString (p, "user", "name", "taka");
        printf ("user-name: %s\n", v1);
    
        int32_t v2 = IniParser_GetInteger (p, "protocol", "version", 4);
        printf ("protocol-version: %" PRId32 "\n", v2);
    
        double v3 = IniParser_GetDouble (p, "user", "pi", 10.2);
        printf ("user-pi: %f\n", v3);
    
        bool v4 = IniParser_GetBoolean (p, "user", "active", false);
        printf ("user-active: %s\n", v4 ? "true" : "false");
    
        IniParser_Destroy(p);
    
        return 0;
    }

    // Dependency

    • inih: Simple .INI file parser in C
    • uthash: C macros for hash tables

    // License

    BSD

    // Acknowledgments

    The design of this library was inspired by inih, libzdb and How to C in 2016.

    Visit original content creator repository https://github.com/taka-wang/c-ini-parser