Skip to content

Instantly share code, notes, and snippets.

View jonathanj's full-sized avatar

Jonathan Jacobs jonathanj

View GitHub Profile
@jonathanj
jonathanj / App.tsx
Last active January 8, 2024 10:48
Skia RN gradient background
import { NavigationContainer, useFocusEffect } from "@react-navigation/native";
import React from 'react';
import {
Button,
Dimensions,
SafeAreaView,
ScrollView,
StyleSheet,
Text, useWindowDimensions,
View
@jonathanj
jonathanj / machine.js
Last active April 19, 2021 08:33
Generated by XState Viz: https://xstate.js.org/viz
function sdkPayment() {
return ({shouldFail}, ...args) => {
console.log(args)
console.log('💳 Starting SDK payment')
return new Promise((resolve, reject) => {
setTimeout(() => {
if (shouldFail) {
reject({
state: 'failed',
reason: 'Not enough funds',
@jonathanj
jonathanj / .ideavimrc
Last active November 11, 2020 15:17
.ideavimrc
let mapleader = ","
set ideajoin
set noerrorbells
set visualbell
set surround
set ignorecase
set smartcase
set incsearch
@jonathanj
jonathanj / machine.js
Last active March 6, 2020 06:30
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'shape',
initial: 'idle',
devTools: true,
context: {
mode: 'poly',
points: [],
shapes: [],
},
states: {
@jonathanj
jonathanj / machine.js
Last active November 3, 2019 17:55
Generated by XState Viz: https://xstate.js.org/viz
const guidedEvent = target => ({
target,
actions: assign({
waitingForGuidedEvent: (context, event) => false
})
})
const updateStates = (isGuided) => {
const guidedWrapper = isGuided ? guidedEvent : x => x;
@jonathanj
jonathanj / riot_userstyle.css
Created January 22, 2017 20:36
riot.im (Comfortable)
@-moz-document domain("riot.im") {
.mx_EventTile {
padding-top: 9px;
}
.mx_EventTile_line {
padding-top: 1px;
padding-bottom: 0px;
}
}
@jonathanj
jonathanj / riot_userstyle.css
Last active January 22, 2017 20:27
riot.im (Compact)
@-moz-document domain("riot.im") {
.mx_EventTile {
padding-top: 4px;
}
.mx_EventTile_line {
padding-top: 1px;
padding-bottom: 0;
}
}
@jonathanj
jonathanj / riot_userstyle.css
Last active January 22, 2017 20:25
riot.im (Solarized dark)
@-moz-document domain("riot.im") {
/*
Base0: 839496
Base1: 93a1a1
Base02: 073642
Base03: 002b36
Yellow: b58900
Blue: 268bd2
*/
const debugBoxColors = ['#f00', '#0f0', '#00f', '#0ff', '#f0f', '#ff0', '#fff'];
function debugBox(obj) {
const color = debugBoxColors.shift();
debugBoxColors.push(color);
return {
borderColor: color,
borderWidth: 1,
...obj
}
}
function keyedReducer(key, reducer, initialState) {
return (state=initialState, action) => {
// Having to explicitly handle this sucks.
if (action.type.startsWith('@@')) {
return state
}
// What if `action` is not handled by this reducer?
return state.update(key(action), s => reducer(s, action))
}
}