Skip to content

Instantly share code, notes, and snippets.

View jcanfield's full-sized avatar
💭
If I do not respond quickly, try me on Twitter at @creativeboulder.

Joshua Canfield jcanfield

💭
If I do not respond quickly, try me on Twitter at @creativeboulder.
View GitHub Profile
@jcanfield
jcanfield / googl.sh
Created June 11, 2017 07:33 — forked from trentm/googl.sh
Bash function to use the goo.gl URL shortener on stdin. See <https://developers.google.com/url-shortener/v1/getting_started> TODO: pbcopy it too if that command is available
# echo URL | googl
function googl {
local url=$(cat <&0)
(
set -e pipefail;
echo "{}" \
| json -e "this.longUrl='$url'" \
| curl -sf https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' -d@- \
| json id
@jcanfield
jcanfield / goo.gl.sh
Created June 11, 2017 07:28 — forked from wafflesnatcha/goo.gl.sh
Bash: goo.gl # Shorten a URL using the Google URL Shortener service (http://goo.gl).
#!/usr/bin/env bash
# Usage: goo.gl [URL]
#
# Shorten a URL using the Google URL Shortener service (http://goo.gl).
goo.gl() {
[[ ! $1 ]] && { echo -e "Usage: goo.gl [URL]\n\nShorten a URL using the Google URL Shortener service (http://goo.gl)."; return; }
curl -qsSL -m10 --connect-timeout 10 \
'https://www.googleapis.com/urlshortener/v1/url' \
-H 'Content-Type: application/json' \
-d '{"longUrl":"'${1//\"/\\\"}'"}' |
@jcanfield
jcanfield / .bash_aliases
Created June 11, 2017 00:02
Bash Aliases for HTPC Linux
### List of Bash Aliases
## Hard Drive and Directory space commands
alias ls-space='echo "Displaying Disk space used per directory..." && du -slh * | sort -h'
alias ls-hdspace='echo "Displaying Hard Drive space used and available" && df -H && echo "Script complete. Press Enter to continue"'
@jcanfield
jcanfield / rename-files_to-folder.sh
Last active June 11, 2017 00:23
Rename files in a folder to match folder name (useful for htpc usage)
#!/bin/bash
# SYPOPSIS: Rename files in folder to match folder.
# CREDIT: Unamed user on superuser or superadmin. If you find this, let me know and I will add you to the credits.
# UPCOMING: Allow for secondary input such as `rename-files-to-folder $MOVIENAME` so not to rename all movies in directory just one or two.
find * -type f -maxdepth 1 | while read file
do
dirname="$(dirname "$file")"
new_name="${dirname##*/}"
file_ext=${file##*.}
@jcanfield
jcanfield / move-show.sh
Created June 10, 2017 23:23
Move a TV Show or Movie directory to another folder or drive
#!/bin/bash
# SYNOPSIS: Move a TV Show or Movie directory to another folder or drive
# USAGE:
# NOTES: The Function cp_p was discovered on StackExchange at http://j.mp/1OOqAV1.
#cp_p()
#{
# strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
# | awk '{
# count += $NF
@jcanfield
jcanfield / rename-movie-titles.sh
Created June 10, 2017 23:19
Use bash and linux tools to rename files in a folder, to the folder name.
#!/bin/bash
# SYNOPSIS: Rename all files in folder to match folder name.
# Testing 1
# rename -vn 's:(/[^/]*)/[^/]*$:$1$1.mkv:' folder/*/*.mkv
# Testing 2
#for f in folder/*/*.mkv;do dn="${f%/*}";echo mv -v "$f" "${dn}/${dn##*/}.mkv";done
# Testing #3
@jcanfield
jcanfield / dns_servers.md
Created June 4, 2017 05:15 — forked from roge/dns.md
Public DNS Servers

This is a list of trusted DNS servers put together by Rogue in order of priority.

Last Updated: 6/13/2014

Public DNS Servers (US, IPv4)

8.8.8.8         # Google Primary
8.8.4.4         # Google Secondary
4.2.2.1         # Level3 Main Primary
4.2.2.2         # Level3 Main Secondary
@jcanfield
jcanfield / public_dns_list
Created June 4, 2017 05:13 — forked from oldsharp/public_dns_list
public dns servers list
# google public dns
8.8.8.8
8.8.4.4
# opendns
208.67.222.222
208.67.220.220
# v2ex dns
199.91.73.222
@jcanfield
jcanfield / giganews-vpn-list_updated-May-2017.md
Created May 20, 2017 03:47
Giganews/VyperVPN Server Lists

Giganews VPN Server List

North America VPN Servers

VyprVPN Server Hostname


Los Angeles, CA us1.vpn.giganews.com

Washington, DC us2.vpn.giganews.com