old stuff

This commit is contained in:
Tyrel Souza 2022-10-05 00:45:20 -04:00
parent b36c918621
commit 79b37243c3
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
16 changed files with 250 additions and 24 deletions

14
bin/SC
View File

@ -1,14 +0,0 @@
#!/bin/bash
set -e
FILENAME="/Users/tyrel/tmp/screenshot.png"
screencapture -io $FILENAME
sleep 1
MD5=($(md5 -q "$FILENAME"))
fname=$MD5.png
scp -rp "$FILENAME" vps:/www/tyrelsouza.com/screenshots/$fname;
osascript -e "display notification \"Uploaded $FILENAME to https://tyrelsouza.com/screenshots/$fname\" with title \"Tyrel Upload\""
echo -ne https://tyrelsouza.com/screenshots/$fname | pbcopy
rm "$FILENAME"

View File

@ -1,2 +1,6 @@
#!/bin/bash #!/bin/bash
$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@") &
APPS=/Applications
if [ -d "$APPS" ]; then
$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@") &
fi

BIN
bin/gochk Executable file

Binary file not shown.

3
bin/goland.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
/bin/bash -l '/home/tyrel/src/GoLand-2019.3/bin/goland.sh' %f

BIN
bin/golangci-lint Executable file

Binary file not shown.

3
bin/killtransmission.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
killall transmission-gtk

View File

@ -1 +0,0 @@
/Users/tyrel/.pre-commit-venv/bin/pre-commit

3
bin/pycharm.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
/bin/bash -l '/home/tyrel/src/pycharm-2017.3.7/bin/pycharm.sh' %f

3
bin/rubymine.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
/bin/bash -l '/home/tyrel/src/RubyMine-2019.3/bin/rubymine.sh' %f

103
bin/sc Executable file
View File

@ -0,0 +1,103 @@
#!/usr/bin/env bash
# Take a screenshot of a selected area and upload it somewhere.
#
# Requires:
# * scrot
# * xclip
### CHANGE THESE FUNCTIONS:
upload() {
# Given a filepath and a target name, upload the screenshot
chmod +r "$1"
scp "$1" "tyrelsouza.com:/www/tyrel.pw/s/$2"
}
url() {
# Given a target name, echo the expected URL of the uploaded screenshot
echo "https://tyrel.pw/s/$1"
}
### (End)
screenshot() {
if $(which maim &> /dev/null); then
maim -s $1 || return -1
elif $(which scrot &> /dev/null); then
scrot -s $1 || return -1
elif $(which screencapture &> /dev/null); then
screencapture -i $1 || return -1
else
echo "No screenshot utility found. Install scrot."
return -1
fi
}
clipboard() {
if $(which xclip &> /dev/null); then
echo $1 | xclip -r -selection clipboard
elif $(which pbcopy &> /dev/null); then
echo $1 | pbcopy
else
echo "No clipboard utility found. Install xclip."
return -1
fi
}
notify() {
if $(which osascript &> /dev/null); then
osascript -e "display notification \"$2\" with title \"$1\""
elif $(which notify-send &> /dev/null); then
notify-send "$1" "$2"
else
echo "Notification not supported, skipped: $1: $2"
return -1
fi
}
fail() {
echo "$2"
exit $1
}
# Fail early
set -e
# If a path is given, use that instead of taking a screenshot
target="$1"
name="$(date '+%d')"
tmppath="$(mktemp -t ss.XXXX.png)" || fail 1 "failed to allocate a temporary file"
# Make it hard to guess
random_string=$(head -c512 /dev/urandom | shasum | head -c4)
# Compose full filename
filename="${name}_${random_string}.png"
if [[ "${target}" ]]; then
cp -p "${target}" "${tmppath}"
else
# Take the screenshot
screenshot "${tmppath}" || fail 2 "failed to take screenshot"
fi
# Clear clipboard
clipboard " "
# Upload it
url=$(url "${filename}")
echo "Uploading: $url"
upload "${tmppath}" "${filename}" && rm "${tmppath}" || fail 3 "failed to upload ${tmppath}"
# Copy to clipboard
clipboard "${url}"
echo "Copied to clipboard."
# Clean up
if [[ -f "${tmppath}" ]]; then
rm "${tmppath}"
fi
notify "Uploaded Screenshot" "${url}"

103
bin/scf Executable file
View File

@ -0,0 +1,103 @@
#!/usr/bin/env bash
# Take a screenshot of a selected area and upload it somewhere.
#
# Requires:
# * scrot
# * xclip
### CHANGE THESE FUNCTIONS:
upload() {
# Given a filepath and a target name, upload the screenshot
chmod +r "$1"
scp "$1" "tyrelsouza.com:/www/tyrel.pw/s/$2"
}
url() {
# Given a target name, echo the expected URL of the uploaded screenshot
echo "https://tyrel.pw/s/$1"
}
### (End)
screenshot() {
if $(which maim &> /dev/null); then
maim $1 || return -1
elif $(which scrot &> /dev/null); then
scrot -s $1 || return -1
elif $(which screencapture &> /dev/null); then
screencapture -i $1 || return -1
else
echo "No screenshot utility found. Install scrot."
return -1
fi
}
clipboard() {
if $(which xclip &> /dev/null); then
echo $1 | xclip -r -selection clipboard
elif $(which pbcopy &> /dev/null); then
echo $1 | pbcopy
else
echo "No clipboard utility found. Install xclip."
return -1
fi
}
notify() {
if $(which osascript &> /dev/null); then
osascript -e "display notification \"$2\" with title \"$1\""
elif $(which notify-send &> /dev/null); then
notify-send "$1" "$2"
else
echo "Notification not supported, skipped: $1: $2"
return -1
fi
}
fail() {
echo "$2"
exit $1
}
# Fail early
set -e
# If a path is given, use that instead of taking a screenshot
target="$1"
name="$(date '+%d')"
tmppath="$(mktemp -t ss.XXXX.png)" || fail 1 "failed to allocate a temporary file"
# Make it hard to guess
random_string=$(head -c512 /dev/urandom | shasum | head -c4)
# Compose full filename
filename="${name}_${random_string}.png"
if [[ "${target}" ]]; then
cp -p "${target}" "${tmppath}"
else
# Take the screenshot
screenshot "${tmppath}" || fail 2 "failed to take screenshot"
fi
# Clear clipboard
clipboard " "
# Upload it
url=$(url "${filename}")
echo "Uploading: $url"
upload "${tmppath}" "${filename}" && rm "${tmppath}" || fail 3 "failed to upload ${tmppath}"
# Copy to clipboard
clipboard "${url}"
echo "Copied to clipboard."
# Clean up
if [[ -f "${tmppath}" ]]; then
rm "${tmppath}"
fi
notify "Uploaded Screenshot" "${url}"

4
bin/startup_i3.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
xrandr --output DP-4 --right-of DP-2
xrandr --output DP-4 --rotate left

View File

@ -1 +0,0 @@
/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl

8
bin/update-neovim.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
sudo rm -rf /opt/nightlies/neovim
git clone https://github.com/neovim/neovim /opt/nightlies/neovim
cd /opt/nightlies/neovim
git checkout stable
make -j4
sudo make install

View File

@ -1,11 +1,10 @@
#!/usr/bin/env bash #!/bin/bash
set -eu
# Lists the current directory's files in Vim, so you can edit it and save to rename them # Lists the current directory's files in Vim, so you can edit it and save to rename them
# USAGE: vimv [file1 file2] # USAGE: vimv [file1 file2]
# https://github.com/thameera/vimv # https://github.com/thameera/vimv
declare -r FILENAMES_FILE=$(mktemp "${TMPDIR:-/tmp}/vimv.XXX") declare -r FILENAMES_FILE="$(mktemp --tmpdir vimv.XXX)"
trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT
@ -23,7 +22,7 @@ ${EDITOR:-vi} "${FILENAMES_FILE}"
IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))' IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))'
declare -i count=0 count=0
for ((i=0;i<${#src[@]};++i)); do for ((i=0;i<${#src[@]};++i)); do
if [ "${src[i]}" != "${dest[i]}" ]; then if [ "${src[i]}" != "${dest[i]}" ]; then
mkdir -p "`dirname "${dest[i]}"`" mkdir -p "`dirname "${dest[i]}"`"
@ -32,7 +31,7 @@ for ((i=0;i<${#src[@]};++i)); do
else else
mv "${src[i]}" "${dest[i]}" mv "${src[i]}" "${dest[i]}"
fi fi
((++count)) ((count++))
fi fi
done done

View File

@ -5,3 +5,12 @@ function pulldep() {
bundle bundle
bundle exec rake db:migrate bundle exec rake db:migrate
} }
function tide() {
for var in "$@"
do
open -a iTerm ~/code/tidelift/$var
settitle $var
done
}