Bash tab completion for the npx command
Save complete_npx
in your home folder and then source it on your .bash_profile
with:
. ~/complete_npx.sh
const crypto = require('crypto'); | |
let hash; | |
let index = 0; | |
function check() { | |
const data = hash.read().toString('hex'); | |
hash.removeListener('readable', check); |
#!/usr/bin/env bash | |
main() { | |
local commit_message_file=$1 | |
local branch_name=$(__git_ps1 '%s' | cut -d '|' -f 1) | |
local commit_message=$(cat "$commit_message_file") | |
# do nothing if the commit_message already begins with the branch_name | |
if [[ "$commit_message" == "$branch_name"* ]]; then |
#!/usr/bin/env bash | |
# | |
# Convert any webm video file inside the Downloads folder to mp4 | |
# | |
# Usage: | |
# ./webm2mp4 | |
main() { | |
local videos=$(find ~/Downloads -name '*.webm') |
#!/usr/bin/env bash | |
# | |
# Reset Quick Look and all of its cache | |
# | |
# Usage: | |
# ./delete-quicklook-cache | |
main() { | |
qlmanage -r cache > /dev/null | |
local exit_code=$? |
Simple example of how to properly launch background jobs and then gracefully terminate them.
EXIT
signal, but then after killing workers we get an unwanted "Terminated" message.exit
when cleaning, to break out of the infinite loop#!/usr/bin/env bash | |
# | |
# Make your server get traffic from port 80 without having to run it with sudo privilege. | |
# Based on: Running Jenkins on Port 80 or 443 using iptables | |
# https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+on+Port+80+or+443+using+iptables | |
# allow traffic on ports 80 and 8080 | |
sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT | |
sudo iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT |
#!/usr/bin/env bash | |
# | |
# Scale up or down the duration of the given video | |
# The final video will be in the mp4 format | |
# | |
# Usage: | |
# scale-duration <video-path> <desired-duration> | |
# | |
# Options: | |
# video-path The video to scale |
#!/usr/bin/env node | |
class CancelError extends Error { | |
constructor(message) { | |
super(message) | |
this.name = 'CancelError' | |
} | |
} | |
function random(minimum, maximum) { |
#!/usr/bin/env bash | |
# | |
# Slide an image to the left using ffmpeg | |
# | |
# Usage: | |
# ./slide photo_input.jpg video_output.mp4 | |
# | |
# See: | |
# https://ffmpeg.org/ffmpeg-filters.html#overlay-1 | |
# https://easings.net/ |