Skip to content

Instantly share code, notes, and snippets.

🦊
Fox familiar.

Ken Keiter kenkeiter

🦊
Fox familiar.
Block or report user

Report or block kenkeiter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Dockerfile
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
file \
curl \
ca-certificates \
python2.7 \
git \
View twitter.css
.js-moments-tab {
display: none !important;
}
.wtf-module {
display: none !important;
}
.LiveVideoHomePageModuleContainer {
display: none !important;
@kenkeiter
kenkeiter / hktypes.swift
Created Apr 15, 2017
A full set of all HKObjectTypes (excluding correlation types, as of Apr. 15, 2017) because typing this out was a pain in the ass.
View hktypes.swift
let hkTypes:Set<HKObjectType> = [
// body measurements
HKObjectType.quantityType(forIdentifier: .bodyMassIndex)!,
HKObjectType.quantityType(forIdentifier: .bodyFatPercentage)!,
HKObjectType.quantityType(forIdentifier: .height)!,
HKObjectType.quantityType(forIdentifier: .bodyMass)!,
HKObjectType.quantityType(forIdentifier: .leanBodyMass)!,
// fitness identifiers
HKObjectType.quantityType(forIdentifier: .stepCount)!,
HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning)!,
View Non_North_America_Fulfillment_Centers.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kenkeiter
kenkeiter / impbcopy.m
Last active Sep 17, 2017
Take a selfie, archive it, and copy it to the clipboard -- all from the terminal! (bash + os x)
View impbcopy.m
/////////////////////////////////////////////////////////
// Copied from http://www.alecjacobson.com/weblog/?p=3816
/////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
View index.html
<!--
The MIT License (MIT)
Copyright (c) 2013 bill@bunkat.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kenkeiter
kenkeiter / storage.md
Last active Aug 29, 2015
Small + Low Power Storage for Max
View storage.md

Did my best to find a quick/cheap platform you can experiment with. This is an example of an underpowered SoC. Even though the board itself supports SATA 2.5, USB 3, and Gig-E, the CPU can't. Obviously, it doesn't fulfill your needs, but you can run benchmarks to figure out what you actually need based upon it.

@kenkeiter
kenkeiter / lmutracker.mm
Last active Apr 20, 2017
Read lux measurement using MBP ambient light sensor.
View lmutracker.mm
// lmutracker.mm -- Provides lux measurement using MacBook Ambient Light Sensor
//
// clang -o lmutracker lmutracker.mm -framework IOKit -framework CoreFoundation
//
// Adaptation of code originally posted at https://bugzilla.mozilla.org/show_bug.cgi?id=793728
// by Reuben Morais. Modified by Ken Keiter <ken@kenkeiter.com> to output a single *lux* value
// and exit, rather than repeating measurements on the sensor's arbitrary scale.
#include <mach/mach.h>
#include <math.h>
@kenkeiter
kenkeiter / homebrew_yosemite_valgrind.txt
Created Oct 20, 2014
Homebrew output when building valgrind on Yosemite.
View homebrew_yosemite_valgrind.txt
~ → brew install valgrind
valgrind: OS X Mavericks or older is required for stable.
Use `brew install devel or --HEAD` for newer.
Error: An unsatisfied requirement failed this build.
~ → brew edit valgrind
~ → brew install valgrind
==> Downloading http://valgrind.org/downloads/valgrind-3.10.0.tar.bz2
######################################################################## 100.0%
==> Downloading https://gist.githubusercontent.com/jacknagel/369bedc191e0a0795358/raw/a71e6c0fdcb786fdfde2fc33d71d555b18
######################################################################## 100.0%
@kenkeiter
kenkeiter / go_marshaling_thoughts.md
Created Oct 5, 2014
Quick thoughts on separation of representation from implementation in Go serialization.
View go_marshaling_thoughts.md

If your application demands marshaling to JSON or another serialiazation format using Go, it can be tempting to design your structures to be cleanly serializable – often to the detriment of the implementation.

You might find yourself exporting variables you shouldn't be exporting, or creating elaborate ways to prevent mutability of attributes you care about.

If you find yourself doing this, stop, and consider the separation of concerns. JSON is a representation of your structure, and should not be directly tied to its underlying implementation, unless it's convenient. Although it's a bit more expensive, consider creating custom marshaling functions and generating one-off structs with the exact fields you need to decouple the implementation from representation.

In the following example, you don't want to export the Value field from the Counter struct, because it exposes your value to potentially unsafe operations (two incrementations at the same time, for example):

type Counter struct {
You can’t perform that action at this time.