Skip to content

Instantly share code, notes, and snippets.

View mhemmings's full-sized avatar
UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS

Mark Hemmings mhemmings

UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS
View GitHub Profile
@mhemmings
mhemmings / setOpacity(View view, float alpha)
Created January 6, 2014 21:48
An android method to set the opacity of a view while supporting API 1+.
/**
* Sets the opacity of the view. This is a value from 0 to 1, where 0 means the view is
* completely transparent and 1 means the view is completely opaque.
*
* @param alpha The opacity of the view.
* @param view The view to change.
*
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void setOpacity(View view, float alpha) {
@mhemmings
mhemmings / adminer.sh
Created January 30, 2014 22:52
Download Adminer like a boss! Found myself often wanting to quickly put Adminer on a box for a few minutes while I investigated something but couldn't remember the URL. This script downloads Adminer and also has some cool extra functionality, including automatic deletion (see --help for usage)
#!/bin/bash
usage() {
printf "%s\n" "Usage: $0 [-m] [-e] [-o] [-c] [-d]"
printf "\t%s\n\t%s\n\t%s\n\t%s\n" \
"-m MySQL only" "-e English only" "-o Output file" \
"-c CSS file to download" "-d Auto-delete time (minutes)"
exit 1
}
@mhemmings
mhemmings / node.nginxconf
Last active August 29, 2015 13:57
Proxy a Node.js app through Nginx
upstream app_name {
# where the app is running
server 127.0.0.1:3000;
}
server {
listen 0.0.0.0:80;
server_name domain.com;
access_log /var/log/nginx/app_name.log;
@mhemmings
mhemmings / googledns
Last active August 29, 2015 13:58
A DNS zone file to set up Google Apps For Business
; CNAME Records
mail 3600 IN CNAME ghs.google.com.
calendar 3600 IN CNAME ghs.google.com.
docs 3600 IN CNAME ghs.google.com.
; MX Records
@ 3600 IN MX 10 ASPMX.L.GOOGLE.COM.
@ 3600 IN MX 20 ALT1.ASPMX.L.GOOGLE.COM.
@ 3600 IN MX 20 ALT2.ASPMX.L.GOOGLE.COM.
@ 3600 IN MX 30 ASPMX2.GOOGLEMAIL.COM.
@mhemmings
mhemmings / chrome-popups.js
Created August 5, 2014 10:29
Enable <a> links in Chrome extension pop-ups.
var aTags = document.getElementsByTagName('a');
for (var i = 0; i < aTags.length; i++) {
aTags[i].addEventListener('click', function (e) {
chrome.tabs.create({url: e.target.href});
});
}

Keybase proof

I hereby claim:

  • I am mhemmings on github.
  • I am mhemmings (https://keybase.io/mhemmings) on keybase.
  • I have a public key whose fingerprint is EF6F 5F5D D3AC D8A2 6FA8 F6B9 1401 546F C018 6858

To claim this, I am signing this object:

@mhemmings
mhemmings / VPCF11J0E.md
Created March 10, 2015 20:06
Sony VPCF11J0E For Sale

Sony VPCF11J0E. Just shy of £1000 when new.

  • Intel® Core™ i5-520M Processor 2.4GHz, 4.8GT/s, 3MB L3 Cache
  • Windows® 7 Home Premium 64-bit
  • 6GB DDR3 SDRAM
  • NVIDIA® 1GB GeForce® GT 330M GPU
  • 16.4" 1920 x 1080 pixels
  • Hard drive 320GB SATA
  • Blu-ray Disc™ Player: BD ROM/ DVD Rewriter
  • SD card slot
@mhemmings
mhemmings / work.sh
Created March 31, 2015 16:53
Block Facebook and Twitter in your hosts file with one command: 'work'
alias work='echo -e "127.0.0.1 www.facebook.com\n127.0.0.1 twitter.com" | sudo tee -a /etc/hosts > /dev/null'
@mhemmings
mhemmings / README.md
Created May 3, 2016 13:17
cp-drawables.sh

Copy Android drawable assets from one directory to another using the standard drawables-hdpi, drawables-xhdpi etc

It can be a pain to copy new assets into your Android project when they are provided in the correct dpi directory structure. Inside the source res directory, you should have child directorys of drawables-hdpi, drawables-xhdpi etc which each contain the asset needed to copy. The destination directory should also be the res directory containing each drawables directory.

Example: ./cp-drawables.sh img_to_copy.png /path/to/res/dir

Will execute (and print out):

@mhemmings
mhemmings / delete-from-lib.sh
Created July 27, 2016 20:44
Delete the word "WORD" from the OSX user's dictionary after being added with the "Add To Dictionary" dropdown
sed -i -e "s/WORD//g" /Users/$(whoami)/Library/Spelling/LocalDictionary