Skip to content

Instantly share code, notes, and snippets.

View kenkeiter's full-sized avatar
🦊

Ken Keiter kenkeiter

🦊
View GitHub Profile
@kenkeiter
kenkeiter / kicad6_arrange.py
Last active July 6, 2022 16:52
KiCAD 6 Script for arranging footprints circularly
import pcbnew
import math
# Based upon https://bit.ly/3agYp7f by Greg Davill (@GregDavill on Twitter)
#
# To use this with KiCAD 6.x.x:
# 1. Save this script in KiCAD's "scripting/plugins" directory as "arrange.py"
# 2. Open your PCB and refresh plugins by navigating to
# Tools > External Plugins > Refresh Plugins
# 3. Open the scripting console (Tools > Scripting Console) and execute
@kenkeiter
kenkeiter / markdown_to_pdf.py
Created October 17, 2019 17:23
Quick markdown file to PDF routine.
import os
import markdown
from markdown_include.include import MarkdownInclude
import weasyprint
from mako.template import Template
HTML_BOILERPLATE_TEMPLATE = """
<html>
<head>
<style>{css}</style>
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
file \
curl \
ca-certificates \
python2.7 \
git \
.js-moments-tab {
display: none !important;
}
.wtf-module {
display: none !important;
}
.LiveVideoHomePageModuleContainer {
display: none !important;
@kenkeiter
kenkeiter / hktypes.swift
Created April 15, 2017 16:25
A full set of all HKObjectTypes (excluding correlation types, as of Apr. 15, 2017) because typing this out was a pain in the ass.
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)!,
Loading
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 January 17, 2024 23:02
Take a selfie, archive it, and copy it to the clipboard -- all from the terminal! (bash + os x)
/////////////////////////////////////////////////////////
// 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;
@kenkeiter
kenkeiter / index.html
Last active August 29, 2015 14:19 — forked from bunkat/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 August 29, 2015 14:14
Small + Low Power Storage for Max

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 April 20, 2017 01:06
Read lux measurement using MBP ambient light sensor.
// 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>