Skip to content

Instantly share code, notes, and snippets.

View sbrichardson's full-sized avatar
:octocat:
In coding land

Stephen Richardson sbrichardson

:octocat:
In coding land
View GitHub Profile
@sbrichardson
sbrichardson / polar.js
Last active December 31, 2023 08:14
Connects to a nearby bluetooth heart rate monitor and logs the active heart rate at 1hz (once per second). Tested with a Polar H10 HR monitor using Google Chrome.
/*
Make sure you are wearing the hr monitor, as it typically
goes to sleep when inactive, not allowing you to connect to it.
Instructions
=============
1. Using Google Chrome, open the dev console and paste the below code.
2. A panel near the address bar will open, searching for nearby bluetooth (ble)
heart rate devices. Don't click away from the panel or Chrome will cancel the search.
@sbrichardson
sbrichardson / mongo-autostart-osx.md
Created March 2, 2022 00:57 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

import React, { memo, useReducer, useCallback } from 'react';
import ReactDOM from 'react-dom';
function random(max) { return Math.round(Math.random() * 1000) % max; }
const A = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean",
"elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive",
"cheap", "expensive", "fancy"];
const C = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
const N = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse",
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@sbrichardson
sbrichardson / patch-edid.md
Created November 7, 2021 16:51 — forked from ejdyksen/patch-edid.md
A script to fix EDID problems on external monitors in macOS

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn't already exist):

@sbrichardson
sbrichardson / main.yml
Created January 11, 2021 21:17 — forked from carlosedp/main.yml
Ansible playbook to automate new Kubernetes SBC nodes
---
- name: Setup SBC
hosts: all
#become: true
#become_user: root
gather_facts: false
vars:
#New user to be created
new_user: newuser
@sbrichardson
sbrichardson / zendesk-openapi.json
Created December 21, 2020 11:07 — forked from kinlane/zendesk-openapi.json
zenddesk-openapi
{
"swagger": "2.0",
"info": {
"version": "v2",
"title": "Swagger API"
},
"host": "{host}.zendesk.com",
"basePath": "/api/v2/",
"schemes": [
"http"
@sbrichardson
sbrichardson / gist:10ff12d4823aa493fee523e277a1fcf5
Created November 12, 2020 02:37 — forked from alexandernl/gist:8090a79a7af4197c5f5571e8cc8c05b8
Convert daily New York Times frontpage to jpg
<?php
// set the output-file
$outputfile = "/var/www/nyt/nyt.jpg";
// set path to todays NYT frontpage
$pathToPdf="https://static01.nyt.com/images/".date('Y')."/".date('m')."/".date('d')."/nytfrontpage/scan.pdf";
// check if there is any today
$file_headers = @get_headers($pathToPdf);
@sbrichardson
sbrichardson / MSWordHtmlCleaners.js
Created July 29, 2020 00:01 — forked from ronanguilloux/MSWordHtmlCleaners.js
2 js solutions to clean nasty MS Word HTML pasted in any CMS + 2 server-side tips
var CleanWordHTML = function ( str )
{
str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;