Skip to content

Instantly share code, notes, and snippets.

@rxhanson
rxhanson / usb_hid_keys.h
Created June 2, 2022 21:02 — forked from MightyPork/usb_hid_keys.h
USB HID Keyboard scan codes
/**
* USB HID Keyboard scan codes as per USB spec 1.11
* plus some additional codes
*
* Created by MightyPork, 2016
* Public domain
*
* Adapted from:
* https://source.android.com/devices/input/keyboard-devices.html
*/
@rxhanson
rxhanson / debounce-throttle.swift
Created April 21, 2020 13:55 — forked from simme/debounce-throttle.swift
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
@rxhanson
rxhanson / parseAppcast.js
Last active March 14, 2020 14:48
Parse your sparkle appcast into html, so you don't have to manually add it into your versions page
$(document).ready(function(){
$.ajax({
type: "GET" ,
url: "downloads/updates.xml" ,
dataType: "xml" ,
success: function(xml) {
var items = []
$(xml).find('item').each(function(){
var item = $(this)
@rxhanson
rxhanson / gist:df0f2b49f402ea181f5ed61b20f9cd8d
Last active March 28, 2024 13:17 — forked from bhumphrey/gist:3764983
Cherry-picking from another fork
git remote add <other-fork-alias> <other-fork-URL>
git checkout <branch>
git fetch <other-fork-alias>
git cherry-pick <commit-hash>
git push <your-fork-alias>
git remote remove <other-fork-alias>
git remote -v
// working one pulled from https://github.com/nytimes/svg-crowbar/issues/31#issuecomment-421054505
// Changing that to ss.hasOwnProperty('cssRules') fixed the issue for me.
!function(){var t='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';window.URL=window.URL||window.webkitURL;var e,n,o=document.body,l={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",svg:"http://www.w3.org/2000/svg"};function s(t){var e="untitled";t.id?e=t.id:t.class?e=t.class:window.document.title&&(e=window.document.title.replace(/[^a-z0-9]/gi,"-").toLowerCase());var n=window.URL.createObjectURL(new Blob(t.source,{type:"text/xml"})),l=document.createElement("a");o.appendChild(l),l.setAttribute("class","svg-crowbar"),l.setAttribute("download",e+".svg"),l.setAttribute("href",n),l.style.display="none",l.click(),setTimeout(function(){window.URL.revokeObjectURL(n)},10)}e=[window.document],n=[],iframes=document.querySelectorAll(
# Use the Raspberry Pi to detect motion and send an email
# When the motion sensor is tripped it will send an email with a duration of motion detection. The duration is so that it might be easier to determine if the motion sensor is being set off by an intruder or something else like changes in light.
# All you need is the Pi and a motion sensor. The motion sensor that I used is the Parallax PIR Sensor (Rev B).
# My setup is as follows
# pin1 -> Vcc on PIR Sensor
# pin15 -> Out on PIR Sensor
# pin6 -> GND on PIR Sensor
import RPi.GPIO as GPIO
import smtplib
@rxhanson
rxhanson / rxjs_event_emitter.js
Created October 18, 2017 22:11 — forked from bangedorrunt/rxjs_event_emitter.js
Pub Sub pattern with RxJS
// Reference from: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/howdoi/eventemitter.md
var hasOwnProp = {}.hasOwnProperty;
function createName (name) {
return '$' + name;
}
function Emitter() {
this.subjects = {};
@rxhanson
rxhanson / GCDPlayground.swift
Created July 22, 2017 00:59
Playground demoed during threads in swift meetup
//: Playground - noun: a place where people can play
import Cocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
//-----------------------------------
// Source: https://www.appcoda.com/grand-central-dispatch/
func queuesWithQosExample() {