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]
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 / BoldKeywords.vba
Last active August 29, 2015 14:09
Quick VBA macro to bold keywords.
Sub BoldKeywords()
Dim triggers As Variant
' ------------------------------------------
' BEGIN EDIT-ME PART
' Help for non-geeks: each item is delimited by a comma, even at the end of a line
' each line break inside the array declaration needs an underscore at the end
' If you use apostrophes, they must be escaped, e.g. "Canada\'s"
' ------------------------------------------
'
' Formats tweet from clipboard and inserts it
' Assumptions:
' - Tweet text in clipboard, with user & tweet separated by a line break.
' - No trailing spaces; uses Trim().
'