Skip to content

Instantly share code, notes, and snippets.

@MichaelWhi
MichaelWhi / tplink.sh
Created November 10, 2017 21:39
Turn TP Link SmartPlug on and off via Command line

Keybase proof

I hereby claim:

  • I am MichaelWhi on github.
  • I am michaelwhi (https://keybase.io/michaelwhi) on keybase.
  • I have a public key whose fingerprint is 5674 1F7C D507 B90B 4925 35F3 C900 9A4D 098F B5DD

To claim this, I am signing this object:

@MichaelWhi
MichaelWhi / stats.rb
Created June 20, 2015 15:02 — forked from cpetersen/stats.rb
Bignum compatible StdDev
module Enumerable
def sum
self.inject(0){|accum, i| accum + i }
end
def mean
self.sum/self.length.to_f
end
def sample_variance
@MichaelWhi
MichaelWhi / ios-standalone-rails.js
Last active January 3, 2016 17:09
JavaScript Snippet to be put at bottom of the body, which will fix links including rails UJS links for WebApps ran from the iOS home screen.
if(("standalone" in window.navigator) && window.navigator.standalone){
var noddy, remotes = false;
var iosClickFixer = function(event) {
noddy = event.target;
while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") {
noddy = noddy.parentNode;
}
if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 && noddy.getAttribute("data-method") !== "post" && noddy.getAttribute("data-method") !== "delete" || remotes))
class String
def palindrome?
self.downcase.gsub(" ", "").reverse == self.downcase.gsub(" ", "")
end
end