Skip to content

Instantly share code, notes, and snippets.

@bokwoon95
Last active July 1, 2024 12:45
Show Gist options
  • Save bokwoon95/9ac84beb08d5769e09b4e3b102e5f16c to your computer and use it in GitHub Desktop.
Save bokwoon95/9ac84beb08d5769e09b4e3b102e5f16c to your computer and use it in GitHub Desktop.

Revisions

  1. bokwoon95 revised this gist Jul 1, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/env bash
    sudo apt-get update -y
    sudo apt-get install -y git tmux libvips libvips-tools
    sudo apt-get install -y git tmux libvips libvips-tools sqlite3
    sudo apt-get upgrade -y
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-$(dpkg --print-architecture).tar.gz"
    sudo tar -xzf go.tgz --directory /usr/local
  2. bokwoon95 revised this gist Jul 1, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@ sudo apt-get upgrade -y
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-$(dpkg --print-architecture).tar.gz"
    sudo tar -xzf go.tgz --directory /usr/local
    rm go.tgz
    sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
    sudo ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    sudo ln -s "$HOME/go/bin/notebrew" /usr/local/bin/notebrew
    sudo ln -sf /usr/local/go/bin/go /usr/local/bin/go
    sudo ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    sudo ln -sf "$HOME/go/bin/notebrew" /usr/local/bin/notebrew
    if ! test -e "$HOME/nb10"; then
    pushd "$HOME"
    git clone https://github.com/bokwoon95/nb10
  3. bokwoon95 revised this gist Jul 1, 2024. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,9 @@ sudo apt-get upgrade -y
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-$(dpkg --print-architecture).tar.gz"
    sudo tar -xzf go.tgz --directory /usr/local
    rm go.tgz
    ln -s /usr/local/go/bin/go /usr/local/bin/go
    ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    ln -s "$HOME/go/bin/notebrew" /usr/local/bin/notebrew
    sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
    sudo ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    sudo ln -s "$HOME/go/bin/notebrew" /usr/local/bin/notebrew
    if ! test -e "$HOME/nb10"; then
    pushd "$HOME"
    git clone https://github.com/bokwoon95/nb10
    @@ -52,4 +52,5 @@ else
    vips resize "$INPUT_PATH" "$OUTPUT_PATH" "$scale_factor"
    echo "$INPUT_PATH: width = $width, old height = $height"
    echo "$OUTPUT_PATH: width = $(vipsheader "$OUTPUT_PATH" -f width), height = $(vipsheader "$OUTPUT_PATH" -f height)"
    fi'
    fi' | sudo tee /usr/local/bin/imgresize > /dev/null
    sudo chmod +x /usr/local/bin/imgresize
  4. bokwoon95 revised this gist Jul 1, 2024. 1 changed file with 37 additions and 1 deletion.
    38 changes: 37 additions & 1 deletion goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -16,4 +16,40 @@ else
    pushd "$HOME/nb10"
    git pull
    popd
    fi
    fi
    echo '#!/usr/bin/env bash
    set -e
    set -u
    set -o pipefail
    INPUT_PATH="$1"
    OUTPUT_PATH="$2"
    if test ! -f "$INPUT_PATH"; then
    echo "INPUT_PATH $INPUT_PATH does not exist"
    exit 1
    fi
    width="$(vipsheader "$INPUT_PATH" -f width)"
    height="$(vipsheader "$INPUT_PATH" -f height)"
    scale_factor="$(awk -v "width=$width" -v "height=$height" "BEGIN {
    aspect_ratio = width / height;
    is_tall_img = aspect_ratio < 9 / 16;
    if (is_tall_img || width > height) {
    if (width <= 1080) {
    print 1;
    } else {
    print 1080 / width;
    }
    } else {
    if (height <= 1080) {
    print 1;
    } else {
    print 1080 / height;
    }
    }
    }")"
    if test "$scale_factor" = "1"; then
    mv "$INPUT_PATH" "$OUTPUT_PATH"
    else
    vips resize "$INPUT_PATH" "$OUTPUT_PATH" "$scale_factor"
    echo "$INPUT_PATH: width = $width, old height = $height"
    echo "$OUTPUT_PATH: width = $(vipsheader "$OUTPUT_PATH" -f width), height = $(vipsheader "$OUTPUT_PATH" -f height)"
    fi'
  5. bokwoon95 revised this gist Jul 1, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    #!/usr/bin/env bash
    sudo apt-get update -y
    sudo apt-get install -y git tmux
    sudo apt-get install -y git tmux libvips libvips-tools
    sudo apt-get upgrade -y
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-$(dpkg --print-architecture).tar.gz"
    sudo tar -xzf go.tgz --directory /usr/local
  6. bokwoon95 revised this gist Jul 1, 2024. 1 changed file with 18 additions and 7 deletions.
    25 changes: 18 additions & 7 deletions goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,18 @@
    # Replace linux-amd64 with linux-arm64 if using an ARM server.
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-amd64.tar.gz"
    tar -xzf go.tgz --directory /usr/local
    ln -s /usr/local/go/bin/go /usr/local/bin/go
    ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    # TODO: untar go.tgz into $GOROOT (/usr/local/go)
    # TODO: symlink the go binaries in /usr/local/go/bin into /usr/local/bin
    sudo apt-get update -y
    sudo apt-get install -y git tmux
    sudo apt-get upgrade -y
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-$(dpkg --print-architecture).tar.gz"
    sudo tar -xzf go.tgz --directory /usr/local
    rm go.tgz
    ln -s /usr/local/go/bin/go /usr/local/bin/go
    ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    ln -s "$HOME/go/bin/notebrew" /usr/local/bin/notebrew
    if ! test -e "$HOME/nb10"; then
    pushd "$HOME"
    git clone https://github.com/bokwoon95/nb10
    popd
    else
    pushd "$HOME/nb10"
    git pull
    popd
    fi
  7. bokwoon95 revised this gist Jun 30, 2024. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    # Replace linux-amd64 with linux-arm64 if using an ARM server.
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-amd64.tar.gz"
    tar -xzf go.tgz --directory /usr/local
    ln -s /usr/local/go/bin/go /usr/local/bin/go
    ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
    # TODO: untar go.tgz into $GOROOT (/usr/local/go)
    # TODO: symlink the go binaries in /usr/local/go/bin into /usr/local/bin
  8. bokwoon95 created this gist May 8, 2024.
    4 changes: 4 additions & 0 deletions goinstall-linux.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # Replace linux-amd64 with linux-arm64 if using an ARM server.
    curl --location --output go.tgz "https://dl.google.com/go/$(curl https://go.dev/dl/?mode=json | grep -o '"version": "go.*"' | head -n 1 | xargs | cut -d ' ' -f 2).linux-amd64.tar.gz"
    # TODO: untar go.tgz into $GOROOT (/usr/local/go)
    # TODO: symlink the go binaries in /usr/local/go/bin into /usr/local/bin