Category: Blog

  • LovelyPlots

    LovelyPlots

    PyPI Version PyPI Downloads doi tests

    Warning

    As of version 1.0.0, you need to add import lovelyplots before setting the style (plt.style.use('ipynb')).

    LovelyPlots is a repository containing matplotlib style sheets to nicely format figures for scientific papers, thesis and presentations while keeping them fully editable in Adobe Illustrator. Additonaly, .svg exports options allows figures to automatically adapt their font to your document’s font. For example, .svg figures imported in a .tex file will automatically be generated with the text font used in your .tex file.

    Installation

    # to install latest PyPI release
    pip install LovelyPlots
    
    # to install latest GitHub commit
    pip install --upgrade git+https://github.com/killiansheriff/LovelyPlots.git

    The pip installation will move all of the matplotlib style files *.mplstyle into the appropriate matplotlib directory.

    Usage

    LovelyPlots main style is called ipynb. To use it, add the following lines to the begining of your python scripts:

    import lovelyplots
    import matplotlib.pyplot as plt
    plt.style.use('ipynb')

    Styles can be combined:

    import lovelyplots
    import matplotlib.pyplot as plt
    plt.style.use(['ipynb','colorsblind34'])

    In the above case, the ipynb default color cycle will be overwritten by a 34 colors colorblind safe color cycle called colorsblind34.

    If you only wish to apply a style on a specific plot, this can be achieved using:

    import lovelyplots
    import matplotlib.pyplot as plt
    
    with plt.style.context('ipynb'):
      fig, ax = plt.subplots()
      ax.plot(x, y)

    Examples

    A few styles are presented here, please see Styles for a list of all implemented styles. The script used to generate these plots can be found here.

    ⚠️ If you use the use_mathtext style, Adobe Illustrator might fail to nicely detect text objects. Please see here for work arounds.

    The ['ipynb', 'use_mathtext'] style:

    The ['ipynb', 'use_mathtext','colors10-markers'] style:

    The ['ipynb', 'use_mathtext','colors5-light'] style:

    The ['ipynb', 'use_mathtext', 'colors10-ls'] style:

    The ['ipynb'] style:

    The ['paper', 'use_mathtext'] style:

    Styles

    LovelyPlots main style is called ipynb. The latter by default sets the figure size to (4.5, 3.46) inches, uses the default matplotlib font, activate scientific notation and makes sure your matplotlib exports will be editable in Adobe Illustrator. Its default color cycle was set to colors10.

    Color cycles

    A multitude of color cycles were implemented:

    colors5-light

    colors5

    colors10

    colorsblind10

    colorsblind34

    Can be seen here.

    Lines styles, markers and combinations styles

    Line styles, markers styles and combinations can be set using the following styles: ls5, marker7, colors10-ls, colors10-markers.

    Color maps

    Default matplotlib colormaps were implemented and can be used by adding the following styles: cmap-viridis, cmap-inferno, cmap-cividis, cmap-magma, cmap-plasma.

    Utils

    Specific matplotlibrc parameters can be turned on/off using the following utilities styles: svg_no_fonttype, use_mathtex, use_tex.

    Fonts

    By default the ipynb style uses the default matplotlib font. However, one can set its favorite font from a TIFF file:

    import lovelyplots as lp
    import matplotlib.pyplot as plt
    
    plt.style.use('ipynb')
    lp.utils.set_font('my_font.tiff')

    Tips and Tricks

    Adobe Illustrator

    Unfortunately, mathtext (and thus nicely formated scientific notation) will mess up Adobe illustrator ability to detect text objects, and is thus not activated by default. If you wish to use it, please add the style use_mathtext.

    Latex and SVG files

    By default, the ipynb style sets svg.fonttype: none. This allows for plots saved as .svg not to carry font information. Consequently, when opened in another environement, the plot will be generated with the default system font.

    For example, this allows .svg plots imported inside a Latex file to directly be generated with the proper document font, without you having to manually edit the fonts to match your document’s font. Additonally, you can open the .svg file as text file, find the ugly 1e10 scientific notation and replace it with $10^10$ so that it is nicely formated when included in your .tex file.

    An example of how to show an svg in a .tex file:

    \usepackage{svg}
    
    \begin{figure}[htbp]
      \centering
      \includesvg{myfig.svg}
    \end{figure}

    Retina displays

    For those using IPython notebooks, you can set retina display support by adding the following lines to the begining on your python script:

    import lovelyplots as lp
    lp.utils.set_retina()

    Useth in Google Colab

    To use on Google Colab, you will need to run the following code:

    !pip install lovelyplots
    import lovelyplots
    plt.style.reload_library()
    plt.style.use('ipynb')

    Acknowledgements

    This reprository was inspired by SciencePlots, but adds different styles and crucial functionalities for useth in .tex files and Adobe Illustrator.

    Citing

    If you use LovelyPlots, please cite:

    @software{sheriff_lovelyplots_2022,
      author       = {Killian Sheriff},
      title        = {{LovelyPlots, a collection of matplotlib 
                       stylesheets for scientific figures}},
      month        = jul,
      year         = 2022,
      publisher    = {Zenodo},
      doi          = {10.5281/zenodo.6903936},
    }
    
    Visit original content creator repository https://github.com/killiansheriff/LovelyPlots
  • LovelyPlots

    LovelyPlots

    PyPI Version PyPI Downloads doi tests

    Warning

    As of version 1.0.0, you need to add import lovelyplots before setting the style (plt.style.use('ipynb')).

    LovelyPlots is a repository containing matplotlib style sheets to nicely format figures for scientific papers, thesis and presentations while keeping them fully editable in Adobe Illustrator. Additonaly, .svg exports options allows figures to automatically adapt their font to your document’s font. For example, .svg figures imported in a .tex file will automatically be generated with the text font used in your .tex file.

    Installation

    # to install latest PyPI release
    pip install LovelyPlots
    
    # to install latest GitHub commit
    pip install --upgrade git+https://github.com/killiansheriff/LovelyPlots.git

    The pip installation will move all of the matplotlib style files *.mplstyle into the appropriate matplotlib directory.

    Usage

    LovelyPlots main style is called ipynb. To use it, add the following lines to the begining of your python scripts:

    import lovelyplots
    import matplotlib.pyplot as plt
    plt.style.use('ipynb')

    Styles can be combined:

    import lovelyplots
    import matplotlib.pyplot as plt
    plt.style.use(['ipynb','colorsblind34'])

    In the above case, the ipynb default color cycle will be overwritten by a 34 colors colorblind safe color cycle called colorsblind34.

    If you only wish to apply a style on a specific plot, this can be achieved using:

    import lovelyplots
    import matplotlib.pyplot as plt
    
    with plt.style.context('ipynb'):
      fig, ax = plt.subplots()
      ax.plot(x, y)

    Examples

    A few styles are presented here, please see Styles for a list of all implemented styles. The script used to generate these plots can be found here.

    ⚠️ If you use the use_mathtext style, Adobe Illustrator might fail to nicely detect text objects. Please see here for work arounds.

    The ['ipynb', 'use_mathtext'] style:

    The ['ipynb', 'use_mathtext','colors10-markers'] style:

    The ['ipynb', 'use_mathtext','colors5-light'] style:

    The ['ipynb', 'use_mathtext', 'colors10-ls'] style:

    The ['ipynb'] style:

    The ['paper', 'use_mathtext'] style:

    Styles

    LovelyPlots main style is called ipynb. The latter by default sets the figure size to (4.5, 3.46) inches, uses the default matplotlib font, activate scientific notation and makes sure your matplotlib exports will be editable in Adobe Illustrator. Its default color cycle was set to colors10.

    Color cycles

    A multitude of color cycles were implemented:

    colors5-light

    colors5

    colors10

    colorsblind10

    colorsblind34

    Can be seen here.

    Lines styles, markers and combinations styles

    Line styles, markers styles and combinations can be set using the following styles: ls5, marker7, colors10-ls, colors10-markers.

    Color maps

    Default matplotlib colormaps were implemented and can be used by adding the following styles: cmap-viridis, cmap-inferno, cmap-cividis, cmap-magma, cmap-plasma.

    Utils

    Specific matplotlibrc parameters can be turned on/off using the following utilities styles: svg_no_fonttype, use_mathtex, use_tex.

    Fonts

    By default the ipynb style uses the default matplotlib font. However, one can set its favorite font from a TIFF file:

    import lovelyplots as lp
    import matplotlib.pyplot as plt
    
    plt.style.use('ipynb')
    lp.utils.set_font('my_font.tiff')

    Tips and Tricks

    Adobe Illustrator

    Unfortunately, mathtext (and thus nicely formated scientific notation) will mess up Adobe illustrator ability to detect text objects, and is thus not activated by default. If you wish to use it, please add the style use_mathtext.

    Latex and SVG files

    By default, the ipynb style sets svg.fonttype: none. This allows for plots saved as .svg not to carry font information. Consequently, when opened in another environement, the plot will be generated with the default system font.

    For example, this allows .svg plots imported inside a Latex file to directly be generated with the proper document font, without you having to manually edit the fonts to match your document’s font. Additonally, you can open the .svg file as text file, find the ugly 1e10 scientific notation and replace it with $10^10$ so that it is nicely formated when included in your .tex file.

    An example of how to show an svg in a .tex file:

    \usepackage{svg}
    
    \begin{figure}[htbp]
      \centering
      \includesvg{myfig.svg}
    \end{figure}

    Retina displays

    For those using IPython notebooks, you can set retina display support by adding the following lines to the begining on your python script:

    import lovelyplots as lp
    lp.utils.set_retina()

    Useth in Google Colab

    To use on Google Colab, you will need to run the following code:

    !pip install lovelyplots
    import lovelyplots
    plt.style.reload_library()
    plt.style.use('ipynb')

    Acknowledgements

    This reprository was inspired by SciencePlots, but adds different styles and crucial functionalities for useth in .tex files and Adobe Illustrator.

    Citing

    If you use LovelyPlots, please cite:

    @software{sheriff_lovelyplots_2022,
      author       = {Killian Sheriff},
      title        = {{LovelyPlots, a collection of matplotlib 
                       stylesheets for scientific figures}},
      month        = jul,
      year         = 2022,
      publisher    = {Zenodo},
      doi          = {10.5281/zenodo.6903936},
    }
    
    Visit original content creator repository https://github.com/killiansheriff/LovelyPlots
  • k2hdkc_dbaas

    K2HDKC DBaaS

    License GitHub forks GitHub stars GitHub issues

    About K2HDKC DBaaS

    K2HDKC DBaaS

    K2HDKC DBaaS Overview

    K2HDKC DBaaS (DataBase as a Service of K2HDKC) is a basic system that provides K2HDKC(K2Hash based Distributed Kvs Cluster) as a service.
    K2HDKC DBaaS (Database as a Service for K2HDKC) is a Database as a Service that uses K2HR3 and works with OpenStack and kubernetes to build a K2HDKC(K2Hash based Distributed Kvs Cluster) Cluster for distributed KVS.
    Users can easily launch, scale, back up, and restore K2HDKC clusters as K2HDKC DBaaS.

    Detailed documentation for K2HDKC DBaaS can be found here.

    Background

    Yahoo! JAPAN publishes some products as AntPickax as Open Source Software(OSS).
    We planned to provide one of them, K2HDKC(K2Hash based Distributed Kvs Cluster) as DBaaS(Database as a Service) so that anyone can easily use it.
    And the publicly available K2HR3(K2Hdkc based Resource and Roles and policy Rules) offers enough features to make this happen.
    We have built DBaaS(Database as a Service) in conjunction with OpenStack and kubernetes, centering on this K2HR3(K2Hdkc based Resource and Roles and policy Rules).

    Components for K2HKDC DBaaS system

    K2HDKC DBaaS (Database as a Service for K2HDKC) is configured using the following products which is provided by AntPickax.

    • K2HDKC – K2Hash based Distributed Kvs Cluster
      This product is distributed KVS(Key Value Store) clustering system and the core product of K2HDKC DBaaS.
    • CHMPX – Consistent Hashing Mq inProcess data eXchange
      This product is communication middleware over the network for sending binary data and an important component responsible for K2HDKC communication.
    • K2HR3 – K2Hdkc based Resource and Roles and policy Rules
      This is extended RBAC (Role Based Access Control) system, and this system manages the configuration of the K2HDKC cluster as a backend for K2HDKC DBaaS.

    K2HKDC DBaaS types

    There are four types of DBaaS (Database as a Service) provided by K2HDKC DBaaS (Database as a Service for K2HDKC) as shown below.
    We provide two K2HDKC DBaaS types that cooperate with OpenStack and two types that cooperate with kubernetes.

    With Trove(Trove is Database as a Service for OpenStack)

    This is DBaaS(Database as a Service) using Trove which is a product of OpenStack.
    It incorporates K2HDKC (Distributed KVS) as one of Trove’s databases to realize DBaaS(Database as a Service).
    The source code is k2hdkc_dbaas_trove.

    K2HDKC DBaaS CLI(Command Line Interface) for OpenStack

    If you have an existing OpenStack environment, this K2HDKC DBaaS CLI(Command Line Interface) allows you to implement DBaaS(Database as a Service) without any changes.
    The source code is k2hdkc_dbaas_cli.

    K2HDKC DBaaS on kubernetes CLI(Command Line Interface)

    If you are using kubernetes cluster or trial environment such as minikube, this K2HDKC DBaaS on kubernetes CLI(Command Line Interface) allows you to implement DBaaS(Database as a Service) without any changes.
    The source code is k2hdkc_dbaas_k8s_cli.

    K2HDKC Helm Chart

    If you are using kubernetes cluster or trial environment such as minikube, you can install(build) DBaaS(Database as a Service) by using Helm(The package manager for Kubernetes) with K2HDKC Helm Chart.
    The source code is k2hdkc_helm_chart.

    Documents

    K2HDKC DBaaS Document
    Github wiki page

    About k2hdkc Document
    About chmpx Document
    About k2hr3 Document

    About AntPickax

    Repositories

    k2hdkc_dbaas_trove
    k2hdkc_dbaas_cli
    k2hdkc_dbaas_k8s_cli
    k2hdkc_dbaas_override_conf

    k2hdkc
    chmpx

    k2hr3
    k2hr3_app
    k2hr3_api
    k2hr3_cli
    k2hr3_get_resource

    Packages

    k2hdkc-trove(Docker image)
    k2hdkc-trove-backup(Docker image)
    k2hdkc-dbaas-cli(packagecloud.io)
    k2hdkc-dbaas-k8s-cli(packagecloud.io)
    k2hdkc-dbaas-override-conf(packagecloud.io)

    k2hdkc(packagecloud.io)
    chmpx(packagecloud.io)

    k2hr3-app(npm packages)
    k2hr3-api(npm packages)
    k2hr3-cli(packagecloud.io)
    k2hr3-get-resource(packagecloud.io)

    License

    This software is released under the 2.0 version of the Apache License, see the license file.

    AntPickax

    K2HDKC DBaaS is one of AntPickax products.

    Copyright(C) 2020 Yahoo Japan Corporation.

    Visit original content creator repository https://github.com/yahoojapan/k2hdkc_dbaas
  • samurai-way

    Social network

    Deployed on gh-pages.


    Social Network is an rather complex online platform, with many sections, redirection and state managing. This app was written in react class components.


    Goals

    The goal of this project was to explore React starting with class components, higher order components such as connect, component lifecycle, routing, and classic redux.


    Web Stack

    The main focus of the project was to study the react library and state management, so the web stack itself turned out to be pretty small. In addition to the react and redux libraries, the redux-thunk middleware was added, as well as formik for the login form, and axios for REST API requests.


    Problems and process

    The main problem of the whole project is the legacy code and outdated libraries, so in its current state it will be easier to rewrite the application again than to update it. Many other complexities follow from this, managing the life cycle of a class component is more difficult than a functional component using hooks, container components introduce additional layers, classic redux has a lot of boilerplate code, and so on.


    Lesson learned

    However, dealing with these problems helps develop programmer skills, clearly abstract entities, isolate code and shorten interfaces.

    Visit original content creator repository
    https://github.com/dspopravko/samurai-way

  • Chinese-Poetry-Bilingual

    Chinese-Poetry-Bilingual

    LIVE RESTFUL API: https://api.playgameoflife.live/v1/tang.json
    Welcome to adopt!

    What is the definition of this repository?

    A database of Chinese Poetry in json format
    with both Chinese and English versions.

    Why do I want to maintain this database?

    Mainly inspired by the highly-stared repository
    chinese-poetry, the author of which aims
    to provide chinese users a quick way to get
    exposed to traditional Chinese culture.
    Then, it occurs to me why not maintain a similar
    database, but in English? According to my experience, I notice that
    a lot of native English speakers like to pick some Chinese culture sentences
    during their conversation. To enrich their understanding of Chinese culture,
    this repository is born.
    The repository focuses
    on offering developers who are native English speakers and
    interested in traditional Chinese culture an original database
    which can be used in their projects, forming an mysterious beauty from
    ancient China.

    How does this repository work?

    The repository is written in json format, and organized the
    document tree as dynasties-works.

    Id format: *-****
    eg. 1-0001
    The first number: 1->Tang dynasty, 2->Song dynasty, 3->Qing dynasty)

    Directories

    .
    ├── index
    ├── English
        ├── title
        ├── dynasty
        ├── author
        └── content
    ├── Chinese
        ├── title
        ├── dynasty
        ├── author
        └── content
    └── tag
    

    By the way,the repository is still constructing.

    A concrete example:

    [
        {
        "index": "1-0001",
        
        "English":{
          "title":"Home-Coming",
          "dynasty":"Tang",
          "author": "He Zhizhang",
          "content":[
          "Oh, I return to the homeland I left while young,",
          "Thinner has grown my hair, though I speak the same tongue.",
          "My children, whom I meet, do not know who am I,",
          "Where are you from, dear sir?\" they ask with beaming eyes."
          ]
          },
          
          
        "Chinese":{
          "title":"回乡偶书",
          "dynasty":"",
          "author":"贺知章",
          "content":[
          "少小离家老大回,",
          "乡音无改鬓毛衰。",
          "儿童相见不相识,",
          "笑问客从何处来。"
          ]
          },
          
         "tags": [
         "homesick"
         ]
        }
         
        
     ]
    
    

    Tag Classification

    • Age
    • Ambition
    • Autumn
    • Border
    • Class
    • Dream
    • Farewell
    • Friendship
    • Frustration
    • History
    • Homesick
    • Honor
    • Landscape
    • Love
    • Longing
    • Military
    • Mountain
    • Music
    • Night
    • Optimism
    • Reunion
    • Sadness
    • Season
    • Silence
    • Solitude
    • Spring
    • Summer
    • Voyage
    • Windy
    • Wine
    • Winter

    License

    Chinese_Poetry_Bilingual is published under the
    Apache License, Version 2.0.

    Thanks for your support.

    Visit original content creator repository
    https://github.com/Leslie-Wong-H/Chinese-Poetry-Bilingual

  • tws

    tws

    Simple and quick one-off file sharing over HTTP

    Note that a recent version of Perl is required (definitely works with 5.18)

    This is (hopefully) an evolution (perhaps suffering from creeping featurism) of the excellent wwwshare (thanks pgas), which itself is based on Vidar’s one (which gets the credit for the original idea). This is a simple throwaway web server (tws) – or better said, something that pretends to be one to a client -, which can be useful when we need to quickly transfer some file or data to a friend or remote party. The program prints a list of URLs, and the remote end can then download the file by pointing a normal HTTP client (browser, curl, whatever) to one of these URLs. As the original author says, “when the file is downloaded, it exits. No setup or cleanup required”.

    The new features are:

    • Written in Perl
    • MIME support (to help the client know the file type)
    • Progress bar!
    • Streaming mode, using chunked transfer encoding (introduced by HTTP 1.1)

    Usage

    Run the program with -h to see a summary:

    $ tws.pl -h

    Usage:
    tws.pl [ -a ] [ -u ] [ -n ] [ -b bufsize ] [ -p port ] [ -m mimetype ] [ -U url ] [ -f filename ] name
    
    -a          : consider all addresses for URLs (including loopback and link-local addresses)
    -u          : flush output buffer as soon as it's written
    -n          : do not resolve IPs to names
    -b bufsize  : read/write up to bufsize bytes for cycle (default: 16384)
    -p port     : listen on this port (default: random)
    -m mimetype : force MIME type (default: autodetect if possible, otherwise application/octet-stream)
    -U url      : include this URL among the listed alternative URLs
    -f filename : use 'filename' to build the request part of the URL (default: dynamically computed)
    
    'name' (mandatory argument) must exist in normal mode; in streaming mode it's only used to build the URL
    
    Examples:
    $ tws.pl -p 1025 /path/to/file.zip
    Listen for connections on port 1025; send file.zip upon client connection. The specified path must exist.
    
    $ tws.pl -p 4444 -U 'publicname.example.com:5555' -f archive.zip '/path/to/funny file.zip'
    Listen on port 4444, suggest http://publicname.example.com:5555/archive.zip as download URL (presumably a port forwarding exists)
    
    $ tar -cjf - file1 file2 file3 | tws.pl -m application/x-bzip2 result.tbz2
    Listen on random port; upon connection, send the data coming from the pipe with the specified MIME type.
    result.tbz2 need not exist; it's only used to build the URL
    

    In the simplest case, one just does

    $ tws.pl /path/to/some/file.iso
    Listening on port 8052, MIME type is application/x-iso9660-image
    
    Possible URLs that should work to retrieve the file:
    
    http://scooter.example.com:8052/file.iso
    http://10.4.133.1:8052/file.iso
    http://[2001:db8:1::2]:8052/file.iso
    

    Hopefully at least one of the printed URLs is valid and can be communicated to the other party, which then connects to download the file:

    Client connected: 10.112.1.18 (colleague.example.com) from port 51066
     100% [=======================================================>]   3,224,686,592 (29s) 104.8M/s
    

    The listening port is random; it is possible to force a specific value if needed (see the help). The part after the / in the URL is determined based on the supplied filename, to give some hint to the client or browser that downloads the file. Here too it is possible to force a specific string.

    If the program detects that its standard input is connected to a pipe, it automatically operates in streaming mode, which is a fancy name to mean that it reads from standard input rather than a given file. A filename should still be specified, though, so the download URL can be “correctly” built (to be more helpful to the client). Streaming mode means that one can do something like this, for instance:

    $ tar -cjf - file1 file2 file3 | tws.pl -m application/x-bzip2 result.tbz2
    Listening on port 8787 (streaming mode), MIME type is application/x-bzip2
    
    Possible URLs that should work to retrieve the file:
    
    http://scooter.example.com:8787/result.tbz2
    http://10.4.133.1:8787/result.tbz2
    http://[2001:db8:1::2]:8787/result.tbz2
    

    In streaming mode, the content length is of course not known, so the program sends the data using chunked transfer encoding; since this is an HTTP 1.1 feature, HTTP 1.0-only clients will not understand it (notably wget versions prior to 1.13 have this limitation, so don’t use it to download when in streaming mode). Another issue with streaming mode is that the MIME type is also not known; it’s possible to give hints on the command line (see the above example and the help); in any case, the program defaults to application/octet-stream which should always work (though not extremely helpful to the client).

    The program can also operate in unbuffered mode (-u), which means that data sent to the client is flushed as it is written, so the client receives it immediately. This feature, coupled with streaming mode, can be used as a rudimentary tool to send live streaming data to an HTTP client, for example like this:

    $ tail -f /var/log/messages | tws.pl -u -m text/plain log.txt
    

    or actual output from a pipeline, eg

    $ bigprocessing.sh hugefile.csv | tee results.txt | tws.pl -u -m text/plain results.txt
    

    Connecting with a browser or another HTTP client should show the data in (near) real time. This doesn’t seem terribly useful, but perhaps someone can come up with a valid use case. Keep in mind that for this to work you need to make sure that whatever program is writing to the pipe is not buffering the output (many programs do buffering if they detect that stdout is not a terminal). Tools like stdbuf or unbuffer help in this case. On the client side, curl has a –no-buffer/-N option that tells it to show data as it arrives without buffering. Also, it seems some browsers do a bit of initial buffering of the data they receive, after which they start showing new data in realtime (more info welcome).

    Notes

    If the address or name in the URL that the other party should use to download is not local, the program cannot know it. In principle, it could be done (somewhat unreliably) by querying some external IP address check service like dyndns and friends, but in practice it’s easier to leave this to the user, who surely knows better. Thus, it’s possible to supply an URL that the user knows is leading to the local machine (see help for an example). And of course, this is only so it can be copied/pasted; it doesn’t really change what the program does.

    The way the program works is: once a connection is received, it reads the client’s HTTP request and discards it (the only check that is performed is that it is a GET method, but even that could probably be avoided); after that, a minimal set of HTTP reply headers are sent, followed by the actual data. This means the code is simple, but it also means that picky clients that only accept certain encodings, expect specific headers, do some sort of prefetching or other special features will probably not work. If more sophisticated behavior is desired, use a real web server (of which there are many).

    The code makes a number of assumptions and uses some tools that practically make it very Linux-specific; it has not been tested under other platforms. Also it relies on some external programs to get some information (local IPs, terminal size, MIME types etc); none of these external programs is critical, so the absence of some or all of them will not cause failure.

    URL encoding is done using the URI::Escape module, if available; otherwise, no URL encoding is performed at all. With “normal” filenames this is not a problem, however in cases where weird URLs would result, it is possible to explicitly supply a name (see help).

    To handle IPv4 and IPv6 clients with a single IPv6 socket, IPv4-mapped addresses are used. The program disables the socket option IPV6_V6ONLY, so both IPv4 and IPv6 clients can be accepted regardless of the setting in /proc/sys/net/ipv6/bindv6only. However, people should be using IPv6 already!

    If the terminal is resized while the program is sending data, the progress bar will NOT be resized accordingly. However, since the terminal width is not checked until after a client has connected, it is possible to resize the terminal while the program is still waiting for a client to connect.

    And btw, only one client is handled. As said, for anything more complex use a real webserver.

    Visit original content creator repository
    https://github.com/waldner/tws

  • ppTag

    pptag

    Plex Photo Tagger

    As the plex server is not compatible with xmp metadata inside photos, this python based app uses plex rest api to implement an update of all related metadata within plex with tags and rating of the xmp

    dependencies

    • python 3
    • watchdog
    • plexapi
    • xmltodict

    what you need to change

    change values to fit your installation in config.py

        ####################### Change HERE #######################
        #if you do not have a token you have to supply your credentials
        PLEX_LOGIN = ''
        PLEX_PASS = ''
    
        # if you already have a token pass it here
        PLEX_TOKEN = ''
    
        # the plex server url
        PLEX_URL = 'http://192.168.0.200:32400' # including http(s) (local url is best)
    
        # provide the usernames for which the rating should be updated
        # when users have a pin we need this, otherwise set it to ''
        USERDATA = { 'user': '1234' }
    
        # for the access tokens we need the exact server name
        SERVERNAME = 'plexserver'
    
        # Photo section name in plex to focus on (empty will process the first photo section found)
        PLEX_SECTION = ''
    
        # path of the photo library in plex (absolute path)
        PHOTOS_LIBRARY_PATH_PLEX = '/<some path>/'
    
        # for the correct path creation we need the path to the
        # photo library from the view of the script (absolute path)
        # Linux/Mac: "/<some path>/"
        # Windows: "C:\\some folder\\some folder" # (paths need escaping)
        PHOTOS_LIBRARY_PATH = "/<some path>/"
    
        # start an update at the start of the script
        FORCE_RUN_AT_START = True # False
    
        # set logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
        LOG_LEVEL = 'ERROR'
        ###########################################################

    For getting a valid token you can enter you login credentials and run the script.
    It will then output this:

    use this token
    xxxxxxxxxxxxxxxxxxxxxxx
    and put it into the file config.py after PLEX_TOKEN:
    

    how it works

    pptag needs local access to the images that are part of the plex library. An observer is started to look for changes in the path of the library. If so, all changes are processed. For this the Plex server needs to be set to automatically update all libraries, “Scan my library automatically”. In addition you may select “Run a partial scan when changes are detected”.

    pptag fetches all users and tries to get an access token for the user. This is needed as the rating of images is user based.

    Currently only one photo library is supported.

    Images are scanned for adobe lightroom tags and rating written to the XMP data in the images.

    Docker Container

    You can use the provided docker file to build the image yourself or use the dockerhub versions arehbein/pptag.
    The container needs one volumes for the photos:

    <path to photolibrary>:/Photos
    

    The config file should be mounted as readonly:

    <path to config>/config.py:/app/pptag/config.py:ro
    

    Run the image

    docker run -v <path to photolibrary>:/Photos -v <path to config>/config.py:/app/pptag/config.py:ro -d arehbein/pptag

    Use the provided docker-compose:

    docker-compose up -d

    Visit original content creator repository
    https://github.com/arehbein-git/ppTag

  • rust-psp-prxencrypter

    Rust Prx Encrypter

    Port of C PSP PrxEncrypter tools into pure rust its to create SIGNED binary for PSP Eboot
    or Sign a PRX Module.

    Build Requirement

    Build and Compile

    cargo build --release
    

    Usage

    Refer to help and version this program compiled by using -V or -h

    rsprxencrypter -h
    

    or to check the version

    rsprxencrypter -V
    

    All Available CLI interface

    Usage: rsprxencrypter --source <SOURCE>
    
    Options:
      -s, --source <SOURCE>  Pass `-s ` <source Eboot or Prx file path> 
      -h, --help             Print help
      -V, --version          Print version
    

    Signing

    rsprxencrypter -s <prxfile>
    

    or

    rsprxencrypter --source <prxfile>
    

    it should output data.psp in the same directory

    Todo List

    • []Implement full hashing standard FIPS PUB 180-1 published April 17, 1995 optimized in rust the rijndael (aes) and sha1 used in signing , even its legacy and insecure . our goals is to easily sign homebrew here, and remove some caveats and portability issues on non 32bits processor , maybe through emulating some or align and padding accordingly see rspspkirk/crypto.rs for more insight.
    • []optional create PrxDecrypter in pure rust

    Goals

    • [] write it in pure rust.
    • [] Sign PSP Homebrew to run on Official Playstation Portable Firmware easily.
    • [] Make sign EBOOT.PBP files to run on unmodified PSPs checkmark in rust-psp crates
    • [] easily build , and compile, mantain this tools for the homebrew development project using rust programing lang targeting Playstation Portable mipsel-sony-psp

    Thanks

    Credits to alls big shoulder who had been in PSP Scenes that share info online , either Hacking , Developing , Create the SDK or share document the hardware, ~ You’re Cools

    - pspdev wiki
    - bbtgp from the code from wololo forum
    - kirk_engine from google svn
    - the team that write emulator in C++
    - all reverse engineer gods in PSP scene that on homebrew scene
    - ~PSP that create the closed box 
    

    Visit original content creator repository
    https://github.com/gmnprada/rust-psp-prxencrypter

  • react-form-material-ui

    material-ui Inputs for React Form Base

    material-ui input bindings for react-form-base.

    build status npm version

    Installation

    npm install --save react-form-material-ui
    

    Usage

    For a more detailed information on core functionality of react-form-base, take a look at react-form-base demo. To see a sample usage of this package components, you may want to look at react-form-material-ui components demo.

    Example

    import Form, {
      TextField,
      DatePicker,
      SelectField,
      Checkbox,
      Toggle,
      Slider,
      RadioButtonGroup,
      RadioButton
    } from 'react-form-material-ui';
    
    const colors = [
      'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Purple', 'Black', 'White'
    ];
    
    export default class MyForm extends Form {
      render() {
        return (
          <div>
            <TextField {...this.$('fullName')} floatingLabelText="Full Name" />
            <DatePicker {...this.$('birthDate')} hintText="Birth Date" />
            <SelectField {...this.$('hairColor')} options={colors} floatingLabelText="Hair Color" />
            <AutoComplete
              hintText="Eye Color"
              dataSource={colors}
              filter={(value, key) => (key.indexOf(value) !== -1)}
              openOnFocus
            />
            <RadioButtonGroup {...this.$('sex')}>
              <RadioButton value="male" label="Male" />
              <RadioButton value="female" label="Female" />
            </RadioButtonGroup>
            <Slider {...this.$('tanLevel')} />
            <Checkbox {...this.$('admin')} label="Admin" />
            <Toggle {...this.$('extraFeatures')} label="Extra Features" />
          </div>
        );
      }
    }

    DialogForm Example

    import Form, { Dialog, TextField } from 'react-form-material-ui';
    import FlatButton from 'material-ui/FlatButton';
    
    export default class MyDialogForm extends Dialog(Form) {
      // title may be passed in props, or can be rendered dynamically (based on
      // form's attrs, for example) via getTitle method:
      getTitle() {
        return this.get('id') ? this.get('name') : 'New Item';
      }
    
      // actions may be passed in props, or they can be set dynamically. Bellow is
      // what DialogForm uses for actions by default if they are not passed in props.
      // You don't need to overload it if 2 buttons is what your DialogForm needs to have.
      getActions() {
        return [
          <FlatButton label={closeLabel} onTouchTap={this.props.onRequestClose} />,
          <FlatButton label={saveLabel} primary onTouchTap={() => this.save()} />
        ];
      }
    
      // NOTE: in DialogForm you have to use form's $render helper method for rendering
      // form content. Generally, this is optional (yet recommended) way of rendering,
      // but is mandatory in case of DialogForm.
      $render($) {
        <div>
          <div><TextField {...$('email')} floatingLabelText="Email" /></div>
          <div><TextField {...$('firstName')} floatingLabelText="First Name" /></div>
          <div><TextField {...$('lastName')} floatingLabelText="Last Name" /></div>
        </div>
      }
    }

    Dialog function

    Note that in the example above MyDialogForm is extended from a class generated by a Dialog(Form) function call. The reason of such implementation is that you most likely will have base form class in your application, where all your validations and custom behavior will be defined. And to be able to reuse all this functionality, any dialog form has to be inherited from this base form of yours. Thus, in real-life situations you probably will have something like that:

    import { Dialog } from 'react-form-material-ui';
    import Form from 'your-base-form';
    
    export default class ItemForm extends Dialog(Form) {
      // form definitions...
    }

    NOTE: the full signature of Dialog function is following:

    function Dialog(Form, { Component = MaterialDialog } = {})

    where MaterialDialog stands for material-ui‘s Dialog component. This means that in special cases you can use your own dialog containers to render form’s body.

    Component Props

    Dialog Form

    Dialog form component renders it’s content within material-ui‘s Dialog component (by default). In addition to react-form-base‘s Form API methods there are 2 additional methods available for Dialog forms:

    • getTitle(): overload it to set form’s dialog title on rendering, if you don’t want to pass it in props.

    • getActions(): overload it if you want your dialog form to have something different from ‘Cancel’-‘Save’ actions. Or you can pass actions in props without overloading this method.

    Prop Name Spec Description
    saveLabel PropTypes.string. Defaults to 'Save' label for ‘save’ primary action button that is one of 2 buttons that DialogForm generates by default.
    cancelLabel PropTypes.string. Defaults to 'Cancel' label for ‘cancel’ action button that is one of 2 buttons that DialogForm generates by default.
    ...rest the rest of props are delegated to internal Dialog component.

    Input Components

    All input components receive value, onChange, error and name properties from react-form-base API (this props generated via form’s $ method).

    Bellow are the specs for other properties that components work with.

    TextField

    This component is a simple wrapper around material-ui‘s TextField component.

    Prop Name Spec Description
    ...rest the rest of props are delegated to internal TextField component.

    DatePicker

    Prop Name Spec Description
    wrapperClassName PropTypes.string className for the root component element (div), which wraps DatePicker component and error’s div, which is rendered if input has validation errors.
    errorClassName PropTypes.string. Defaults to 'error' className for internal error element (div), which is rendered if error is present.
    ...rest the rest of props are delegated to internal DatePicker component.

    SelectField

    Prop Name Spec Description
    options
    PropTypes.arrayOf(
      PropTypes.oneOfType([
        PropTypes.number,
        PropTypes.string,
        PropTypes.shape({
          value: PropTypes.oneOfType([
            PropTypes.string,
            PropTypes.number
          ]),
          text: PropTypes.string
        })
      ])
    )
    options to be rendered (as MenuItems) within internal SelectField component. If array of strings or integers is passed, it’s values are used as options’ texts and values. If array of objects is passed, each object should have value and text properties.
    children PropTypes.node Can be used to render options manually. Overrides options prop.
    includeBlank PropTypes.oneOf([ 'floatingLabelText', 'hintText' ]) When this property is set and input has non-empty value, additional option will be rendered within the input. It will have a blank value and text that corresponds to the value of prop itself. This behavior can be used to “drop” the value of input after some option has been selected.
    ...rest the rest of props are delegated to the internal SelectField component.

    AutoComplete

    This component is a simple wrapper around material-ui‘s AutoComplete component. It’s main purpose is to map form’s props into AutoComplete’s analogs: value is passed as searchText, error as errorText, and appropriate onUpdateInput prop is generated to match form’s onChange API requirements (new value should be passed as first argument).

    Prop Name Spec Description
    ...rest the rest of props are delegated to internal AutoComplete component.

    RadioButtonGroup

    Prop Name Spec Description
    options
    PropTypes.arrayOf(
      PropTypes.oneOfType([
        PropTypes.number,
        PropTypes.string,
        PropTypes.bool,
        PropTypes.shape({
          value: PropTypes.oneOfType([
            PropTypes.string,
            PropTypes.number,
            PropTypes.bool
          ]),
          label: PropTypes.string
        })
      ])
    )
    options to be rendered (as RadioButtons) within internal RadioButton component. If array of strings or integers is passed, it’s values are used as options’ values and labels. If array of objects is passed, each object should have value and label properties.
    children PropTypes.node Can be used to render options manually. Overrides options prop.
    wrapperClassName PropTypes.string className for the root component element (div), which wraps RadioButtonGroup component and error’s div, which is rendered if input has validation errors.
    errorClassName PropTypes.string. Defaults to 'error' className for internal error element (div), which is rendered if error is present.
    ...rest the rest of props are delegated to the internal RadioButtonGroup component.

    Checkbox

    Prop Name Spec Description
    wrapperClassName PropTypes.string className for the root component element (div), which wraps Checkbox component and error’s div, which is rendered if input has validation errors.
    errorClassName PropTypes.string. Defaults to 'error' className for internal error element (div), which is rendered if error is present.
    ...rest the rest of props are delegated to internal Checkbox component.

    Toggle

    Prop Name Spec Description
    wrapperClassName PropTypes.string className for the root component element (div), which wraps Toggle component and error’s div, which is rendered if input has validation errors.
    errorClassName PropTypes.string. Defaults to 'error' className for internal error element (div), which is rendered if error is present.
    ...rest the rest of props are delegated to internal Toggle component.

    Slider

    Prop Name Spec Description
    wrapperClassName PropTypes.string className for the root component element (div), which wraps Slider component and error’s div, which is rendered if input has validation errors.
    errorClassName PropTypes.string. Defaults to 'error' className for internal error element (div), which is rendered if error is present.
    ...rest the rest of props are delegated to internal Slider component.

    Credits

    Hugs and thanks to ogrechishkina for her support and building all of the CSS for demo application.

    License

    MIT

    Visit original content creator repository https://github.com/akuzko/react-form-material-ui
  • OrganicVisu

    OrganicVisu

    Visualisation of organic compounds by name.

    Usage

    User opens index.html, draws compound name into the text field and clicks Draw.

    Supported structures

    Currently supported chemical structures are:

    • Base string (metan, etan, propan, …, oktan)
    • Alkyls (metyl, etyl, propyl, …, oktyl)
    • Alcohols (metan-1-ol, etan-1-ol…)

    These structures can be arbitrarly combined.
    Implicit positioning (works metyletan as well as metyl-1-etan) is available only for alkyls.

    File structure

    .
    ├── p5.js – p5 library
    ├── sketch.js – main script
    ├── constants.js – conversion between string and number encoding
    ├── carbon.js – contains Yl and Carbon classes
    ├── compound.js – contains Compound class
    └── addons – currently not in use

    Internal structure

    Scripts are called in following order: p5.js -> constants.js -> carbon.js -> compound.js -> sketch.js.
    Algorithm starts with function drawCompound()@sketch.js, which is called after user presses button. New Compound object is created.

    Compound class

    Represents whole compound. Compound parses input string using the function Compound.parse(). Compound stores array of Carbon objects in Compound.base. It also stores an array of Yl objects.

    Carbon class

    Represents one unit (for ex. CH3, OH…). Contains exact xy position where to be rendered.

    Yl class

    Represents an addition to base string (alkyls and alcohols). It contains an array or Carbon objects – Yl.base.

    Rendering

    Every class contains render function. Compound.render() calls Carbon.render(), which renders base carbons and calls Yl.render().

    Visit original content creator repository
    https://github.com/samostanek/OrganicVisu