Skip to content

Instantly share code, notes, and snippets.

@thefury
thefury / vaild-ip.rb
Created August 21, 2021 19:41
Simple ruby IP check
def valid?(ip)
rgx=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
ip.match(rgx) != nil
end
@thefury
thefury / areyousure.sh
Created August 9, 2021 18:11
Simple Bash Are You Sure function
#!/usr/bin/env bash
areyousure() {
read -p "${1}" bool
[ "${bool}" != "y" ] && echo "aborting..." && exit 0
}
# usage
areyousure "This file already exists. Overwrite? (y/N) "
echo "yep - was sure"
@thefury
thefury / convert_arbitrary_date_to_UTC.sh
Created February 28, 2021 18:18
Convert an arbitrary local date to UTC.
#!/usr/bin/env bash
# Convert an arbitrary date in the format of "YYY-MM-DD HH:MM" from
# local time to UTC.
date -u --date=@$(date "+%s" --date="2021-02-28 03:06")
# Adding a user only if the don't exist
useradd_if_not_exists() {
id -u ${1} >/dev/null 2>&1 || useradd --system ${1}
}
@thefury
thefury / wrapper.sh
Created August 23, 2018 18:39
Wrap a command to perform jobs before and after
#!/bin/bash
# usage:
# - wrapper.sh do-list ls -la
# - wrapper.sh import-job /usr/local/bin/import param1 param2
TIMESTAMP=$(date +%s)
MONITOR_NAME=$1
shift 1
COMMAND=$@
### Keybase proof
I hereby claim:
* I am thefury on github.
* I am trevoroke (https://keybase.io/trevoroke) on keybase.
* I have a public key ASA76kBMXta-la5TG7qVAHHfa6uQ4JdVCccxB5FHxJ2WfQo
To claim this, I am signing this object:
@thefury
thefury / gist:682f578fa9127b442020b4f6fdf51cc0
Created February 3, 2018 23:30
10 most modified files in git repository
git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -10
@thefury
thefury / workspace-project-name.sh
Created October 25, 2017 19:00
Setting up a multi-pane windowed environment with tmux
#!/bin/bash
# grabbed from somehwere else on the net. Can't remember where.
SESSION_NAME="my-project-name"
cd ~/golang/src/github.com/thefury/my-project-name
tmux has-session -t $SESSION_NAME
@thefury
thefury / gist:e258523d5312db9282fc7f26f70d701c
Created August 28, 2017 14:40 — forked from rmasoni/gist:6441804
Pomodoro notifications for OS X, powered by terminal-notifier (https://github.com/alloy/terminal-notifier).
function pomodoro {
case $1 in
start )
echo 'terminal-notifier -title "🍅 Pomodoro Done" -message "Starting short break…"' | at + 25 minutes &> /dev/null
;;
break )
echo 'terminal-notifier -title "⌛ Short Break Done" -message "Start your next Pomodoro."' | at + 5 minutes &> /dev/null
;;
esac
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'filesize'
require 'pry'
opts = {}
opts[:path] = '/'
opts[:number] = 15