Skip to content

Instantly share code, notes, and snippets.

@justinweiss
justinweiss / 0001-oxp-sensors-hwmon-Add-GPD-Win-Mini.patch
Created March 22, 2024 03:58
0001-oxp-sensors-hwmon-Add-GPD-Win-Mini.patch
From 48433f6b5b56fdee0f3c8172e7edba331235d999 Mon Sep 17 00:00:00 2001
From: Justin Weiss <[email protected]>
Date: Thu, 21 Mar 2024 20:50:56 -0700
Subject: [PATCH] oxp-sensors: hwmon: Add GPD Win Mini
Adds the GPD Win Mini handheld to PWM fan control. The Win Mini
has a register for reading fan speed and a register for reading and
writing the PWM. It does not have a separate enable register, but
treats writing 0 to the PWM as fan auto mode. Values from 1-244 set a
manual fan speed, and 245-255 have undetermined behavior.
@justinweiss
justinweiss / 0001-iio-imu-Add-driver-for-Bosch-BMI260-IMU.patch
Last active February 18, 2024 17:36
0001-iio-imu-Add-driver-for-Bosch-BMI260-IMU.patch
From 3f6507504828019e2812df1d7930d782e2ddeb23 Mon Sep 17 00:00:00 2001
From: Justin Weiss <[email protected]>
Date: Tue, 13 Feb 2024 21:28:09 -0800
Subject: [PATCH] iio: imu: Add driver for Bosch BMI260 IMU
The ultra-low power BMI260 is an IMU consisting of a 16-bit tri-axial
gyroscope and a 16-bit tri-axial accelerometer combining precise
acceleration, angular rate measurement and intelligent on-chip
motion-triggered interrupt features.
@justinweiss
justinweiss / npm-publish-fork
Last active September 6, 2019 16:13
Publish a version of an npm package to your own scope, without (permanently) changing package.json
#!/usr/bin/env ruby
require "json"
require "optparse"
$options = {}
def system!(*args)
puts "> #{args.join(" ")}"
system(*args) || raise("Error running #{args.join(" ")}: #{$?} ")
@justinweiss
justinweiss / tiny_object_model.rb
Last active November 11, 2016 18:38
Sample code from my "Metaprogramming? Not Good Enough!" RubyConf 2016 talk.
# We'll start by inheriting from a BasicObject, with our two properties: state and behavior.
class TinyObject < BasicObject
attr_accessor :state
attr_accessor :behavior
end
# `add_method`, for adding a method implementation to a behavior / class's state.
behavior_add_method = lambda do |behavior, method_name, method|
behavior.state[:methods][method_name] = method
### Keybase proof
I hereby claim:
* I am justinweiss on github.
* I am justinweiss (https://keybase.io/justinweiss) on keybase.
* I have a public key whose fingerprint is 6FF0 E872 CACA 2A9A 8942 95E3 08F4 4018 35C2 8D55
To claim this, I am signing this object:
@justinweiss
justinweiss / settings.rb
Created May 27, 2014 16:54
Simple settings for Rails
require 'yaml'
require 'erb'
require 'ostruct'
class Settings < OpenStruct
# Settings.new(:google_analytics)
def initialize(config_file_base_name)
super(YAML.load(ERB.new(File.read(Rails.root.join("config", "#{config_file_base_name}.yml"))).result)[Rails.env])
end
@justinweiss
justinweiss / filterable.rb
Last active August 12, 2024 10:10
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
module HashExtensions
def string_merge(other, separator = " ")
merge(other) {|key, old, new| old.to_s + separator + new.to_s}
end
end
@justinweiss
justinweiss / DefaultKeyBinding.dict
Created May 19, 2011 16:17
Extra emacs keybindings in cocoa.
/* Picked up from Help search on Key Bindings. Good stuff -shane */
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
"~f"="moveWordForward:";
"~b"="moveWordBackward:";
"~<"="moveToBeginningOfDocument:";
"~>"="moveToEndOfDocument:";
"~v"="pageUp:";
"~d"="deleteWordForward:";
"~^h"="deleteWordBackward:";
def book_with_endorsements(endorsement_count)
book = Factory(:book)
endorsement_count.times do |n|
Factory(:endorsement, :book_id => book.id)
end
book
end