Skip to content

Instantly share code, notes, and snippets.

View mdp's full-sized avatar

Mark Percival mdp

View GitHub Profile
package com.dotp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import com.facebook.react.LifecycleState;
import com.facebook.react.ReactInstanceManager;
@mdp
mdp / heroku_slides.md
Last active September 29, 2015 23:19

name: inverse layout: true class: center, middle, inverse

#Babel on Heroku await yourHerokuBill

layout: false .left-column[

Heroku in 60 seconds

@mdp
mdp / week5.md
Created September 22, 2015 23:35

class: center, middle

Testing

Safety starts with you.


Testing

@mdp
mdp / gist:a591c4163e4f39104266
Last active September 1, 2015 21:37 — forked from hazrac/gist:4470427
# This is a script to use two factor authentication with public ssh keys (since you can't use PAM (g2fa) and public keys) # You must refrence this script in your sshd config: ForceCommand="/usr/bin/two_factor_ssh" # The script has to be executible by the user logging in Work to use google 2 factor auth for ssh, based on these two posts: http://w…
#!/usr/bin/env ruby
require 'rubygems'
require 'rotp'
# This is a script to use two factor authentication with public ssh keys (since you can't use PAM (g2fa) and public keys)
# You must refrence this script in your sshd config: ForceCommand="/usr/bin/two_factor_ssh"
# The script has to be executible by the user logging in
# get the username of the user logging in
user = ENV["USER"]
@mdp
mdp / dropboxbackup.sh
Created May 21, 2015 23:07
Backup your git based projects on Dropbox
#!/bin/bash
projectName=${PWD##*/} # Basename of current dir
gitRemote=~/Dropbox/src/${projectName}.git
echo "Creating bare repo in ${gitRemote}"
git init --bare ${gitRemote}
echo "Adding new remote 'dropbox'"
git remote add dropbox ${gitRemote}
git remote -v
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is E1E8 7928 C499 5D0A E31D 1514 D4BF DAC7 74ED EA2A
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is 3D13 2F63 3496 5AD3 5ECF 8001 8162 FA3B 5DE5 6C9A
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is 3D13 2F63 3496 5AD3 5ECF 8001 8162 FA3B 5DE5 6C9A
To claim this, I am signing this object:
@mdp
mdp / gist:e733fff433ccbe3d41cd
Created May 29, 2014 16:54
Local time in javascript
function localTime(offset) {
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
return new Date(utc + (3600000*offset));
}
localTime(5.5);
localTime(-8)
@mdp
mdp / luhn.java
Created March 21, 2014 17:38
Luhn algorithm (mod10) in Java
/**
* Luhn Class is an implementation of the Luhn algorithm that checks validity of a credit card number.
*
* @author <a href="http://www.chriswareham.demon.co.uk/software/Luhn.java">Chris Wareham</a>
* @version Checks whether a string of digits is a valid credit card number according to the Luhn algorithm. 1. Starting with the second to last digit and
* moving left, double the value of all the alternating digits. For any digits that thus become 10 or more, add their digits together. For example,
* 1111 becomes 2121, while 8763 becomes 7733 (from (1+6)7(1+2)3). 2. Add all these digits together. For example, 1111 becomes 2121, then 2+1+2+1 is
* 6; while 8763 becomes 7733, then 7+7+3+3 is 20. 3. If the total ends in 0 (put another way, if the total modulus 10 is 0), then the number is valid
* according to the Luhn formula, else it is not valid. So, 1111 is not valid (as shown above, it comes out to 6), while 8763 is valid (as shown
* above, it comes ou