ruby -retc -e 'puts Etc.nprocessors'
python -c "import multiprocessing; print(multiprocessing.cpu_count())"
| // Zed settings | |
| { | |
| "icon_theme": "Catppuccin Mocha", | |
| "auto_update_extensions": { | |
| "powershell": false | |
| }, | |
| "show_edit_predictions": true, | |
| "edit_predictions": { | |
| "mode": "eager" | |
| }, |
| #!/usr/bin/env elixir | |
| # | |
| # Simple example for concurrent request in Elixir | |
| # | |
| Mix.install([ | |
| {:req, "~> 0.5"} | |
| ]) |
| from subprocess import check_output | |
| def run_cd(cmd): return check_output(cmd, shell=True).decode('utf-8').split('\n')[:-1] |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| claim=$1 | |
| ns=$2 | |
| pod_name="pvc-inspector" | |
| kubectl get po "$pod_name" -n "$ns" && kubectl delete po "$pod_name" -n "$ns" | |
| cat <<EOF | kubectl apply -f - |
| # Reading file lines from stdin | |
| cat /tmp/test.txt | python -c 'import fileinput; [print(line, end="" for line in fileinput.input()] | |
| python -c 'import fileinput; [print(line, end="") for line in fileinput.input()]' < /tmp/test.txt | |
| # Printing the 3 lines of the file | |
| python -c "import sys; sys.stdout.write(''.join(sys.stdin.readlines()[:3]))" < /tmp/test.txt | |
| # Checking if file exists | |
| python -c 'from pathlib import Path; print("yes") if Path("/tmp/metrics.txt").is_file() else print("no")' |
| #!/bin/bash | |
| # | |
| # Creates a new TypeScript project ready to use with Node.js | |
| set -euo pipefail | |
| if [[ ! -f $(which npm) ]] || [[ ! -f $(which yarn) ]]; then | |
| echo "Please, install npm and yarn before continuing" | |
| echo "See https://docs.npmjs.com/downloading-and-installing-node-js-and-npm" | |
| echo "See https://yarnpkg.com/" | |
| exit |
| # Starting REPL | |
| perl -del | |
| # Search and replace in place | |
| perl -p -i -e "s/test/testing/g" /tmp/testing.txt | |
| # Search/replace in specific files in a directory | |
| perl -p -i -e 's/oldstring/newstring/g' `find ./ -name *.html` | |
| # Similar to awk |
| import java.util.ArrayList | |
| def MAX_TO_KEEP = 10 | |
| def JOB_NAME = "job_name_here" | |
| def hi = hudson.model.Hudson.instance | |
| def item = hi.getItemByFullName(JOB_NAME) | |
| def jobs = item.getAllJobs() | |
| Iterator<?> iterator = jobs.iterator() |
| #!/bin/bash | |
| # How to download a release file from a private GitHub repo | |
| set -eou pipefail | |
| TOKEN="<your_github_token>" | |
| API_URL="https://api.github.com/repos/<your_repo_here>" | |
| asset_id=$(curl -s -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3.raw" $API_URL/releases \ | |
| | jq '.[0].assets[0].id') |