Blog

  • ft-gt-demo

    CI Tests

    ft-gt-demo

    This repository demonstrates how to use a decorator approach to build a FastHTML app integrated with Great Tables.

    By decorating a function that returns a GT instance with gt2fasthtml, you can treat the function’s result as a FastHTML div component. Additional div parameters can be set in the decorator, like @gt2fasthtml(id="gt").

    Example

    from functools import cache
    
    import polars as pl
    from fasthtml.common import (H1, H2, Card, Div, Form, Grid, Input, Main, Title,
                                 fast_app)
    from great_tables import GT, html
    from great_tables.data import sza
    
    from ft_gt import gt2fasthtml
    
    app, rt = fast_app()
    
    
    @cache
    def get_sza_pivot():
        return (
            pl.from_pandas(sza)
            .filter((pl.col("latitude") == "20") & (pl.col("tst") <= "1200"))
            .select(pl.col("*").exclude("latitude"))
            .drop_nulls()
            .pivot(values="sza", index="month", on="tst", sort_columns=True)
        )
    
    
    @gt2fasthtml(id="gt")
    def get_gtbl(color1: str = "#663399", color2: str = "#FFA500"):
        return (
            GT(get_sza_pivot(), rowname_col="month")
            .data_color(
                domain=[90, 0],
                palette=[color1, "white", color2],
                na_color="white",
            )
            .tab_header(
                title="Solar Zenith Angles from 05:30 to 12:00",
                subtitle=html("Average monthly values at latitude of 20&deg;N."),
            )
            .sub_missing(missing_text="")
        )
    
    
    @app.post("/submit")
    def post(d: dict):
        return get_gtbl(**d)
    
    
    @app.get("https://github.com/")
    def homepage():
        return (
            Title("FastHTML-GT Website"),
            H1("Great Tables shown in FastHTML", style="text-align:center"),
            Main(
                Form(
                    hx_post="/submit",
                    hx_target="#gt",
                    hx_trigger="input",
                    hx_swap="outerHTML",
                )(
                    Grid(
                        Div(),
                        Card(
                            H2("Color1"),
                            Input(type="color", id="color1", value="#663399"),
                        ),
                        Card(
                            H2("Color2"),
                            Input(type="color", id="color2", value="#FFA500"),
                        ),
                        Div(),
                    )
                ),
                get_gtbl(),
                cls="container",
            ),
        )

    Live demo

    https://gallery.fastht.ml/vizualizations/great_tables_tables/display

    Visit original content creator repository https://github.com/jrycw/ft-gt-demo
  • kube-prompt

    kube-prompt

    Software License Go Report Card

    An interactive kubernetes client featuring auto-complete using go-prompt.

    demo

    kube-prompt accepts the same commands as the kubectl, except you don’t need to provide the kubectl prefix. So it doesn’t require the additional cost to use this cli.

    And you can integrate other commands via pipe (|).

    >>> get pod | grep web
    web-1144924021-2spbr        1/1     Running     4       25d
    web-1144924021-5r1fg        1/1     Running     4       25d
    web-1144924021-pqmfq        1/1     Running     4       25d
    

    Installation

    Downloading standalone binary

    Binaries are available from github release.

    macOS (darwin) – amd64
    wget https://github.com/c-bata/kube-prompt/releases/download/v1.0.11/kube-prompt_v1.0.11_darwin_amd64.zip
    unzip kube-prompt_v1.0.11_darwin_amd64.zip
    chmod +x kube-prompt
    sudo mv ./kube-prompt /usr/local/bin/kube-prompt
    
    Linux – amd64
    wget https://github.com/c-bata/kube-prompt/releases/download/v1.0.11/kube-prompt_v1.0.11_linux_amd64.zip
    unzip kube-prompt_v1.0.11_linux_amd64.zip
    chmod +x kube-prompt
    sudo mv ./kube-prompt /usr/local/bin/kube-prompt
    
    Linux – i386
    wget https://github.com/c-bata/kube-prompt/releases/download/v1.0.11/kube-prompt_v1.0.11_linux_386.zip
    unzip kube-prompt_v1.0.11_linux_386.zip
    chmod +x kube-prompt
    sudo mv ./kube-prompt /usr/local/bin/kube-prompt
    
    Linux – arm64
    wget https://github.com/c-bata/kube-prompt/releases/download/v1.0.11/kube-prompt_v1.0.11_linux_arm64.zip
    unzip kube-prompt_v1.0.11_linux_arm64.zip
    chmod +x kube-prompt
    sudo mv ./kube-prompt /usr/local/bin/kube-prompt
    

    Using Homebrew (macOS)

    $ brew install c-bata/kube-prompt/kube-prompt

    Arch Linux

    An unofficial AUR package kube-prompt is available. Install instructions can be found on the Arch wiki.

    Building from source

    $ GO111MODULE=on go build .

    To create a multi-platform binary, use the cross command via make:

    $ make cross

    Similar projects

    Goal

    Hopefully support following commands enough to operate kubernetes.

    • get Display one or many resources
    • describe Show details of a specific resource or group of resources
    • create Create a resource by filename or stdin
    • replace Replace a resource by filename or stdin.
    • patch Update field(s) of a resource using strategic merge patch.
    • delete Delete resources by filenames, stdin, resources and names, or by resources and label selector.
    • edit Edit a resource on the server
    • apply Apply a configuration to a resource by filename or stdin
    • namespace SUPERSEDED: Set and view the current Kubernetes namespace
    • logs Print the logs for a container in a pod.
    • rolling-update Perform a rolling update of the given ReplicationController.
    • scale Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.
    • cordon Mark node as unschedulable
    • drain Drain node in preparation for maintenance
    • uncordon Mark node as schedulable
    • attach Attach to a running container.
    • exec Execute a command in a container.
    • port-forward Forward one or more local ports to a pod.
    • proxy Run a proxy to the Kubernetes API server
    • run Run a particular image on the cluster.
    • expose Take a replication controller, service, or pod and expose it as a new Kubernetes Service
    • autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController
    • rollout rollout manages a deployment
    • label Update the labels on a resource
    • annotate Update the annotations on a resource
    • config config modifies kubeconfig files
    • cluster-info Display cluster info
    • api-versions Print the supported API versions on the server, in the form of “group/version”.
    • version Print the client and server version information.
    • explain Documentation of resources.
    • convert Convert config files between different API versions
    • top Display Resource (CPU/Memory/Storage) usage

    Author

    Masashi Shibata

    LICENSE

    This software is licensed under the MIT License (See LICENSE).

    Visit original content creator repository https://github.com/c-bata/kube-prompt