Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mgk on github.
  • I am mgk (https://keybase.io/mgk) on keybase.
  • I have a public key whose fingerprint is F46C FA85 4D15 5519 8085 5DDD 56F4 7B0C AFAF 3866

To claim this, I am signing this object:

@mgk
mgk / SAMDChipId.ino
Created January 29, 2016 15:25
Arduino SAMD / Arduino Zero / Arduino M0 chip unique serial number
/**
* Print SAMD chip serial number.
*
* http://atmel.force.com/support/articles/en_US/FAQ/Reading-unique-serial-number-on-SAM-D20-SAM-D21-SAM-R21-devices
*/
void setup() {
Serial.begin(9600);
delay(1000);
}
@mgk
mgk / make-smoking-uncounted-data.py
Created November 13, 2015 17:42
chi squared test generated uncounted data for smoking example
#!/usr/bin/env/python
# Generate uncounted data for this example:
#http://www.r-tutor.com/elementary-statistics/goodness-fit/chi-squared-test-independence
# python make-smoking-uncounted-data.py < uncounted-data.csv
#
# R:
# chisq.test(table(read.csv("uncounted-data.csv")))
data = {
@mgk
mgk / warning-capture.r
Last active November 13, 2015 19:45
R capture chisq.test() warning
chi_square <- function(x, p) {
# chisq.test() wrapper that captures warning message and invocation string
if (missing(p)) {
expr <- substitute(chisq.test(x), list(x=x))
}
else {
expr <- substitute(chisq.test(x, p=p, rescale.p = TRUE), list(x=x, p=p))
}
res <- tryCatch({
@mgk
mgk / 3a4d4c6.diff
Created October 14, 2015 19:17
second patch for libvpx 1082
From 3a4d4c6b23c1d604f18437835a700182758717e9 Mon Sep 17 00:00:00 2001
From: Johann <[email protected]>
Date: Wed, 14 Oct 2015 10:42:41 -0700
Subject: [PATCH] Check for bswap* builtins before using
Canonical builtin checks for clang are to use
__has_builtin. Much less fragile than version checks.
https://code.google.com/p/webm/issues/detail?id=1082
@mgk
mgk / apple-clang-2.patch
Last active October 14, 2015 16:21
remove > 0 check in libvpx patch
diff --git a/media/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c b/media/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c
--- a/media/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c
+++ b/media/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c
@@ -27,21 +27,24 @@ DECLARE_ALIGNED(32, static const uint8_t
4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12
};
DECLARE_ALIGNED(32, static const uint8_t, filt4_global_avx2[32]) = {
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14,
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14
@mgk
mgk / ec623a.diff
Created October 14, 2015 15:50
test libvpx 1082 patch
From ec623a0bb712f3519cd8f5c5be1ac464081c7411 Mon Sep 17 00:00:00 2001
From: Johann <[email protected]>
Date: Tue, 13 Oct 2015 10:36:16 -0700
Subject: [PATCH] Upstream Mozilla fix for older Apple clang builds
Also use the _mm_broadcastsi128_si256 intrisic for
Apple clang versions 4.[012]
https://bugzilla.mozilla.org/show_bug.cgi?id=1085607
https://code.google.com/p/webm/issues/detail?id=1082
@mgk
mgk / redis-server
Last active August 29, 2015 14:27 — forked from four43/redis-server
Redis Server - Init Script
#!/bin/sh
# From - http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# - https://github.com/saxenap/install-redis-amazon-linux-centos/blob/master/redis-server
#
# redis - this script starts and stops the redis-server daemon
# Originally from - https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
@mgk
mgk / install-redis.sh
Last active August 29, 2015 14:27 — forked from four43/install-redis.sh
Install Redis
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.githubusercontent.com/four43/e00d01ca084c5972f229/raw/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
#############################################################
# Function -- Boot2Docker
#############################################################
if test "$(which boot2docker 2> /dev/null)"; then
function docker_shellinit {
local _shellinit="$(boot2docker shellinit)"
eval "$(echo ${_shellinit})"
echo "${_shellinit}" > ~/.boot2dockerrc
}