Skip to content

Instantly share code, notes, and snippets.

View JRJurman's full-sized avatar

Jesse Jurman JRJurman

View GitHub Profile
@JRJurman
JRJurman / multi-stroke-phrases.txt
Last active February 8, 2020 05:54
Get all phrases (that is, briefs that have spaces in them)
ethylenediaminetetraacetic acid *EFPLT/TK*FPLT/T*FPLT/A*FPLT
he'll rouse *EL/ROUS
El Salvador *EL/SAL/SRA/TKOR
Elk Club *ELG/KHRUB
{~|'^}em think *EPL/THEU
Earl Grey *ERL/TKPWRAEU
Ethel Merman *ET/EL/PHERPL/A*PB
Ethis Communication *ET/EUS/KAEUBGS
unh unh *UPB/*UPB
under the *UPBD/-D
@JRJurman
JRJurman / global-hook-problem.md
Last active December 14, 2019 17:25
Global Observable Hook?

Problem

I would like a single hook that exposes both global and local state. Something akin to:

const home = () => {
  const [count] = useObservable(0)
  const [globalCount] = useObservable('global-count', 0)
}

The issue is that if someone only wants to read a global variable, it might look like the following:

@JRJurman
JRJurman / threads-v2.js
Last active February 11, 2019 18:00
Single Thread Life
/* helper methods for checking if current page is a DM or a Room */
const isDM = () => document.location.href.split('/').slice(-2)[0] === 'dm';
const isRoom = () => document.location.href.split('/').slice(-2)[0] === 'room';
/* transform text from a thread summary */
const formatTitleFromThreadHeading = (title) => {
return title
.replace(/Thread by [^\.]*\./, '') /* remove thread creator */
.replace(/\d+ (Replies|Reply)\./, '') /* remove number of replies */
.replace(/\.[^\.]*\d+\:\d+ (A|P)M/, '') /* remove string with thread start date */
@JRJurman
JRJurman / thread-hiding.js
Created February 6, 2019 15:15
Files used to make single thread view possible in Google Chat
const hideAllThreads = (addSidebar, switchToThread) => {
// hide all added notifications
// assume if we have threads, we probably have some of these too
const hideAddedNotifications = () => {
const addedLabels = document.querySelectorAll('.mCOR5e')
Array.from(addedLabels)
.forEach(label => label.style.display = 'none')
}
// hide all threads until all threads are hidden (that way we know we've loaded them all)
@JRJurman
JRJurman / PowerCD
Created November 29, 2018 09:42
CD and SSH into the correct directory
$cd_path = $(pwd).ToString().replace("C:\Users\jrjur\Programs", "~/Programs/sf_Programs").replace("\","/")
ssh -t [email protected] 'cd ' $cd_path ';bash'
const Tram = require('tram-one')
const html = Tram.html({
'digit': require('../elements/digit')
})
module.exports = (attrs) => {
const {clock} = window.engine.store
const style = `
display: flex;
justify-content: center;
@JRJurman
JRJurman / clock.js
Last active October 6, 2018 01:27
Binary Clock Actions
module.exports = {
init: () => new Date(),
tick: () => new Date()
}
@JRJurman
JRJurman / digit.js
Last active October 6, 2018 15:44
Digit for Binary Clock Medium Article
const Tram = require('tram-one')
const html = Tram.html({
'led': require('./led')
})
module.exports = (attrs) => {
const binaryValue = parseInt(attrs.value).toString(2)
const fullBinaryString = '0000'.slice(0, 4 - binaryValue.length).concat(binaryValue)
const isOn = fullBinaryString.split('').map(value => value === '1')
@JRJurman
JRJurman / led.js
Last active October 5, 2018 23:13
Binary Clock Examples for Medium Article
const Tram = require('tram-one')
const html = Tram.html()
module.exports = (attrs) => {
const style = `
width: ${attrs.size};
height: ${attrs.size};
background: ${attrs.on ? 'blue' : 'lightblue'};
border-radius: 50%;
margin: 0.3em;