Skip to content

Instantly share code, notes, and snippets.

View guyhughes's full-sized avatar

guy hughes guyhughes

  • /boot/efi/vmlinuz+0x0
View GitHub Profile
#!/usr/bin/env sh
echo "WARNING: This is a one way operation on a single file."
echo "WARNING: Errors will be printed to console."
echo "Enter image filename to be sanitized: "
read theimage
mogrify -strip "$theimage"
xattr -c "$theimage"
@guyhughes
guyhughes / whoip.sh
Last active August 29, 2015 13:59
Determine host's IP address with DuckDuckGo and curl
#!/usr/bin/env sh
curl -fs --include --request GET \
'https://api.duckduckgo.com/?q=ip&l=1&no_redirect=1&skip_disambig=1&format=json' \
| grep -E -o '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
@guyhughes
guyhughes / useliterals.vim
Last active August 29, 2015 14:00
Vim regex substitue double quotes for literals in array initalization.
:'<,'>s:\v(.*)(\[)(\")(.*)(\")(\])(.*):\1\2\'\4\'\6\7
# http://stackoverflow.com/questions/10606101/automatically-add-all-submodules-to-a-repo
for i in $(ls -d bundle/*); do if [ -d "$i"/.git ]; then git submodule add $(cd $i && git remote show origin | grep Fetch | awk '{print $3}') ./$i; fi; done
" vim delete all hashbanglines
:bufdo! %g:\v\#\!:d
@guyhughes
guyhughes / basicLogger.rb
Last active August 29, 2015 14:01
Ruby: Using Logger class with Thor.
require 'thor'
require 'logger'
class_option :verbose, :type => :boolean, :aliases => "-v"
class_option :debug, :type => :boolean, :aliases => "-d"
class_option :quiet, :type => :boolean, :aliases => "-q"
def initialize(*args)
@log = Logger.new(STDOUT)
if options[:debug]
@guyhughes
guyhughes / LoadConfig.rb
Created May 18, 2014 01:44
Ruby: Load the best available config file using ::YAML, of course
require 'thor'
class_option :config, :type => :string, :aliases => "-c", :desc => "Use an alternative YAML config file."
def initialize(*args)
super
config_files = Array.new
config_files.push(options[:config]) if options[:config]
config_files.push("#{ENV['XDG_CONFIG_HOME']}/awesomeness/awesomeness.yaml") if ENV['XDG_CONFIG_HOME']
config_files.push("#{ENV['HOME'] || '~'}/.config/awesomeness.yaml")
server {
listen 80;
server_name openvbx.local;
root /u/apps/openvbx;
access_log /var/log/nginx/openvbx.local.access.log;
error_log /var/log/nginx/openvbx.local.error.log;
index index.php;
if ($request_filename !~ (js|css|jpg|png|gif|robots\.txt|index\.php.*) ) {
rewrite ^(.*)$ /index.php?vbxsite=$1 last;

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@guyhughes
guyhughes / rsync.md
Last active December 30, 2016 04:24
rsync

rsync as mv replacement

rsync -chavP --inplace --remove-source-files ./src ./dest

awesome rsync options

  • -c checksum