Skip to content

Instantly share code, notes, and snippets.

View mhammonds's full-sized avatar

Mark Hammonds mhammonds

View GitHub Profile
@mhammonds
mhammonds / HideMobileAddressBar.js
Created September 3, 2011 03:23
Hide Browser Address Bar - Android + iPhone
function hideAddressBar()
{
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + 50) + 'px';
}
setTimeout( function(){ window.scrollTo(0, 1); }, 50 );
@mhammonds
mhammonds / Bash Image Prefixer
Last active December 10, 2015 15:19
Quick script for prefixing images with Bash.
#!/bin/bash
if [ ! -z "$1" ]
then
PREFIX=$1
else
echo "Enter the filename prefix:"
read PREFIX
fi
@mhammonds
mhammonds / WordPress Tab Removal Shortcut
Created February 18, 2013 22:33
Add this snippet of JavaScript to your web browser shortcuts bar to quickly replace all tab characters in a WordPress post with four spaces.
javascript:var tab = RegExp("\\t", "g");
document.getElementById("content").value =
document.getElementById("content").value.replace(tab,' ');
@mhammonds
mhammonds / bash_color_demo.sh
Created May 17, 2014 19:44
Demo: Color Output From Bash Script on Linux
#!/bin/bash
# This script is a simple demo showing
# how to color output from a bash script.
green='\e[0;32m'
red='\e[0;31m'
NC='\e[0m' #No Color
echo -e "
@mhammonds
mhammonds / manual_network_config.vagrant
Created May 20, 2014 12:17
Manual Vagrant/VirtualBox Network Config
# Example Vagrantfile customizations from older
# config before "private_network" was supported.
# Typically no need to do this manually anymore.
v.customize ["hostonlyif", "ipconfig", "vboxnet0", "--ip", "192.168.33.1", "--netmask", "255.255.255.0"]
v.customize ["modifyvm", :id, "--nic1", "nat"]
v.customize ["modifyvm", :id, "--nic2", "hostonly"]
v.customize ["modifyvm", :id, "--hostonlyadapter2", "vboxnet0"]
@mhammonds
mhammonds / .gvimrc
Created May 22, 2014 17:02
MacVim Configuration
" Customize font. I like Source Code Pro
" URL - http://www.google.com/fonts/specimen/Source+Code+Pro
" But sometimes use Anonymous Pro
" URL - https://www.google.com/fonts/specimen/Anonymous+Pro
set guifont=Source\ Code\ Pro:h16
" Disable cursor blinking
set gcr=n:blinkon0
" Enable the Solarized Theme
" My ~/.vimrc is quite minimal as everything
" is inherited from Vim Boilerplate.
" Enable Vim Boilerplate Shortcuts
autocmd VimEnter * :call VBPShortcuts()
@mhammonds
mhammonds / ansible_selinux_check.yml
Created May 27, 2014 16:50
Ansible: SELinux Check
- name: Check if SELinux is running
command: getenforce
register: sestatus
changed_when: false
tags: selinux
@mhammonds
mhammonds / recent_rpms.sh
Created May 28, 2014 01:27
List recently installed RPM packages
rpm -qa --qf '%{INSTALLTIME} (%{INSTALLTIME:date}): %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n'
@mhammonds
mhammonds / mac_cores.sh
Last active August 29, 2015 14:02
Mac Core Finder
# Return the number of cores on a Mac OS machine
sysctl -n hw.ncpu
# This also works
sysctl hw.ncpu | awk '{print $2}'