{"id":18336093,"url":"https://github.com/tpvasconcelos/howtos","last_synced_at":"2025-04-09T19:52:56.809Z","repository":{"id":97348534,"uuid":"389162999","full_name":"tpvasconcelos/howtos","owner":"tpvasconcelos","description":"Miscellaneous how-tos, and code snippets","archived":false,"fork":false,"pushed_at":"2024-09-19T16:53:22.000Z","size":402,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T12:18:15.821Z","etag":null,"topics":["howto","snippets"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpvasconcelos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-24T17:41:51.000Z","updated_at":"2024-09-19T16:53:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"c3744c71-026c-424a-80a9-ec260c65141d","html_url":"https://github.com/tpvasconcelos/howtos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpvasconcelos%2Fhowtos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpvasconcelos%2Fhowtos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpvasconcelos%2Fhowtos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpvasconcelos%2Fhowtos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpvasconcelos","download_url":"https://codeload.github.com/tpvasconcelos/howtos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103915,"owners_count":21048244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["howto","snippets"],"created_at":"2024-11-05T20:06:04.308Z","updated_at":"2025-04-09T19:52:56.783Z","avatar_url":"https://github.com/tpvasconcelos.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Miscellaneous how-tos, and code snippets\n\n## Shell\n\n### Ask for `sudo` password only once\n\nAdd this to the top of your shell script.\n\n```shell script\n################################################################################\n# Ask for root password upfront and keep updating the existing `sudo`\n# timestamp on a background process until the script finishes. Note that\n# you'll still need to use `sudo` where needed throughout the scripts.\n################################################################################\necho \"Some of the commands in this script require root access. Enter your password to unable root access when necessary...\"\nsudo -v\nwhile true; do\n  sudo -n true\n  sleep 30\n  kill -0 \"$$\" || exit\ndone 2\u003e/dev/null \u0026\n```\n\n### `ffmpeg` - Video from images\n\n```shell script\nffmpeg -framerate 24.994862 -i img%06d.png -c:v libx264 -vf fps=24.994862 -pix_fmt yuv420p myMovie.mp4\n```\n\n### [FIXME] Remove local CloudDocs copies\n\n```shell script\n# $ source ~/.zshrc\n\nfunction _safer_evict() {\n  input_path=$(realpath \"$@\")/\n  # shellcheck disable=SC2034\n  path_to_icloud=$(realpath ~/Library/Mobile\\ Documents/com~apple~CloudDocs)/\n  if [[ \"${input_path##path_to_icloud}\" != \"${input_path}\" ]]; then\n    echo yes;\n    echo \"$input_path\";\n  fi\n}\n\nfunction _evictall() {\n  _SAFER_EVICT=$(functions _safer_evict)\n  #find \"$1\" -type f -not -name .DS_Store -a -not -name .\\*.icloud -exec \"$SHELL\" -c '_safer_evict \"$@\"' -- {} \\;\n  #find \"$1\" -type f -not -name .DS_Store -a -not -name .\\*.icloud -exec zsh -c '_safer_evict \"$@\"' zsh {} \\;\n  #  find \"$1\" -type f -not -name .DS_Store -a -not -name .\\*.icloud -print0 | xargs -0 ls\n  #find \"$1\" -type f -not -name .DS_Store -a -not -name .\\*.icloud -print0 | xargs -0 bash -c '_safer_evict \"$@\"' _\n  #find \"$1\" -type f -not -name .DS_Store -a -not -name .\\*.icloud -print0 | xargs -0 -I{} \"$SHELL\" -c \"eval $_SAFER_EVICT; _safer_evict {}\"\n  find \"$1\" -type f -not -name .DS_Store -a -not -name .\\*.icloud -print0 | xargs -0 -I{} \"$SHELL\" -c \"eval ${_SAFER_EVICT}; ls {}\"\n}\n\n_evictall \"$1\"\n\n```\n\n## SQL\n\n### Compare two queries\n\nUse the following template to get the difference between two queries:\n\n```sql\nwith q1 as (\n    \u003cINSERT_Q1_HERE\u003e\n)\n, q2 as (\n    \u003cINSERT_Q2_HERE\u003e\n)\n, missing_from_q2 as (\n    select *\n    from (\n        select * from q1\n        except\n        select * from q2\n    )\n    cross join (select 'missing from q2' as diff_description)\n)\n, missing_from_q1 as (\n    select *\n    from (\n        select * from q2\n        except\n        select * from q1\n    )\n    cross join (select 'missing from q1' as diff_description)\n)\nselect * from missing_from_q2\nunion all\nselect * from missing_from_q1\n```\n\nReferences:\n\n- \u003chttps://stackoverflow.com/questions/11017678/sql-server-compare-results-of-two-queries-that-should-be-identical/63380681#63380681\u003e\n\n### [Amazon Redshift] Disable results caching for current session\n\n```sql\nset enable_result_cache_for_session to off;\n```\n\nReferences:\n\n- \u003chttps://docs.aws.amazon.com/redshift/latest/dg/r_enable_result_cache_for_session.html\u003e\n\n## Kubernetes\n\n### Sync current git working tree to a k8s pod\n\nThis utility helps you sync your current git working tree with a remote k8s pod. This assumes that the project\nis cloned under `/home/jovyan` on the remote pod. The repository name will be inferred from the current\nrepository using `git rev-parse --show-toplevel`. For this to work, you also need to have rsync installed in\nthe remote k8s pod (run: `sudo apt install rsync grsync`). Note that the `.git/` directory will not be synced.\nIn addition to this, nothing in `.gitignore` will be synced.\n\nSimply add a copy of [snippets/k8s/krsync.zsh](snippets/k8s/krsync.zsh) and\n[snippets/k8s/krsync-subshell.sh](snippets/k8s/krsync-subshell.sh) to the top level directory of your git\nrepository and run `./krsync.zsh my-pod`.\n\n- \u003chttps://serverfault.com/questions/741670/rsync-files-to-a-kubernetes-pod\u003e\n\n## Misc\n\n### GitHub Markdown style on JetBrains IDEs\n\nInspired and adapted from \u003chttps://github.com/sindresorhus/github-markdown-css\u003e\n\n1. Open the `Preferences -\u003e Language \u0026 Frameworks -\u003e Markdown`\n2. Copy the contents of [snippets/misc/github-markdown.css](snippets/misc/github-markdown.css) into the open\n   text box under `Custom CSS -\u003e CSS rules`\n\n![JetBrains IDE Custom Markdown CSS Rules](assets/img/jetbrains_markdown_css_rules.png)\n\n### Custom playback rate for Udemy videos\n\n```javascript\ndocument.querySelector(\"video\").playbackRate = 1.2\n\n// The above line above should be enough as there should only be a single \u003cvideo\u003e element\n// document.querySelector(\".video-player--video-player--1sfof\").querySelector(\"video\").playbackRate = 1.2\n```\n\nReferences:\n- \u003chttps://github.com/gitnix/chrome-extension-udemy-playback-rate\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpvasconcelos%2Fhowtos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpvasconcelos%2Fhowtos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpvasconcelos%2Fhowtos/lists"}