This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (LegoOmni::GetInstance()) { | |
close(); | |
MxOmni::DestroyInstance(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This came out of some work where we were sending an encoded JSON object as a query param in a network call. | |
* But, we can't send nothing, `param=`, or we crash the server, that's taken care of by restricting the type | |
* to at least `Record<string, string>`, but it left open the possibility of empty objects. Encoded as `'%7B%7D'`. | |
* | |
* So I went looking and it's definitely possible to restrict empty objects, but the type algebra is wild. And | |
* it makes use of something people are calling F-bounded quantification. And the error message isn't every helpful. | |
* | |
* See: | |
* - https://stackoverflow.com/a/72554458/769780 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatN (n) { | |
const unitList = ['y', 'z', 'a', 'f', 'p', 'n', 'μ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; | |
const zeroIndex = 8; | |
const nn = n.toExponential(2).split(/e/); | |
let u = Math.floor(+nn[1] / 3) + zeroIndex; | |
if (u > unitList.length - 1) { | |
u = unitList.length - 1; | |
} else | |
if (u < 0) { | |
u = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clickAwayListener (elementId, callback) { | |
return event => { | |
const outsideClick = !document.getElementById(elementId).contains(event.target) | |
if (outsideClick) { | |
callback() | |
} | |
} | |
} | |
export function useClickAway (elementId, callback) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// there's a sandbox to try this out on the react-dropzone website: | |
// https://react-dropzone.js.org/ | |
import React from 'react'; | |
import {useDropzone} from 'react-dropzone'; | |
function Basic(props) { | |
const {acceptedFiles, getRootProps, getInputProps} = useDropzone(); | |
const files = acceptedFiles.map(file => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
#local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
setopt promptsubst | |
autoload -U add-zsh-hook | |
PROMPT_SUCCESS_COLOR=$FG[117] | |
PROMPT_FAILURE_COLOR=$FG[124] | |
PROMPT_VCS_INFO_COLOR=$FG[242] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var e = this.velocity | |
, t = Date.now() | |
, n = t - this.lastFrame; | |
this.lastFrame = t, | |
e *= n / 16, | |
this.rotation = this.rotation + e; | |
var r = "rotate(" + this.rotation + "deg)"; | |
this.$el.css({ | |
"-webkit-transform": r, | |
"-moz-transform": r, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function openDropdown () { | |
document.querySelector('li-icon[type="ellipsis-horizontal-icon"]').click() | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve('opened dropdown') | |
}, 125) | |
}) | |
} | |
function clickDelete () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numeronym = word => word.length > 1 ? `${word[0]}${word.length-2}${word[word.length-1]}` : `${word}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react' | |
function clickAwayListener (elementId, callback) { | |
return event => { | |
const outsideClick = !document.getElementById(elementId).contains(event.target) | |
if (outsideClick) { | |
callback() | |
} | |
} | |
} |
NewerOlder