Skip to content

Instantly share code, notes, and snippets.

@willhoney7
willhoney7 / return_type.tsx
Last active September 10, 2020 22:09
For function return types: Use "unknown", not "void" or "any"
// when passing functions as props and you don't care about the return value, use "unknown"
type Props = {
onUpdate: () => unknown; // Use "unknown"!
};
function Component({onUpdate}: Props) {
return <button onClick={onUpdate}>update</button>
}
// With "unknown", both of these are valid!
@willhoney7
willhoney7 / ReopenTeams.scpt
Last active March 7, 2019 22:28
AppleScript to Reopen Microsoft Teams every 15 minutes if not open
# OpenTeams.scpt
# To run automatically, see: https://apple.stackexchange.com/a/192654
repeat
if application "Microsoft Teams" is not running then
tell application "Microsoft Teams" to activate
end if
delay 60 * 15 # every 15 minutes
end repeat
@willhoney7
willhoney7 / DeferredPromise.ts
Last active December 17, 2018 23:42
A simple way to do a deferred or inside-out promise.
interface IDeferredPromise<T> {
resolve: (T) => void,
reject: (T) => void,
promise: Promise<T>,
}
function DeferredPromise<T>(): IDeferredPromise<T> {
this.promise = new Promise<T>((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
module.exports = {
// Fit code within this line limit
printWidth: 100,
// If true, will use single instead of double quotes
singleQuote: true,
tabWidth: 4,
// arrowParens: 'always',
// Controls the printing of trailing commas wherever possible.
@willhoney7
willhoney7 / play_pause_youtube
Created September 6, 2018 17:45
play/pause youtube via applescript
tell application "Google Chrome"
set found_video to false
set window_list to every window
repeat with the_window in window_list
if found_video is equal to true then
exit repeat
end if
set tab_list to every tab in the_window
repeat with the_tab in tab_list
if the title of the_tab contains "- YouTube" then
@willhoney7
willhoney7 / Popover.jsx
Created August 31, 2018 21:55
Popover component can be used for Dropdowns/Tooltips/etc
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import _throttle from 'lodash/throttle';
let portalsRoot = document.getElementById('portals-root');
const validate = value => (value !== undefined && value < 0 ? 0 : value);
class Popover extends Component {
@willhoney7
willhoney7 / LocalStorage.jsx
Last active April 17, 2018 15:25
A React localStorage render props component
// MIT License
// By Will Honey at Operational Results, Inc.
import React from 'react';
import PropTypes from 'prop-types';
const SUPPORTS_LOCAL_STORAGE = (function() {
try {
localStorage.setItem('a', 1);
localStorage.removeItem('a');

Keybase proof

I hereby claim:

  • I am tibfib on github.
  • I am tibfib (https://keybase.io/tibfib) on keybase.
  • I have a public key whose fingerprint is 33F1 9B71 05D2 ECC0 B3E5 A343 CC4B F134 E1BA 8CCE

To claim this, I am signing this object:

enyo.kind({
name: "custom.SwipeableItem",
kind: "onyx.SwipeableItem",
components: [
{name: "client", kind: "Slideable", min: -100, unit: "%", ondragstart: "clientDragStart"},
{name: "confirm", kind: "onyx.Toolbar", canGenerate: false, classes: "onyx-swipeable-item-confirm enyo-fit", style: "text-align: center;", ontap: "confirmTap", components: [
{kind: "onyx.Button", content: "Delete", ontap: "deleteTap"},
{kind: "onyx.Button", content: "Cancel", ontap: "cancelTap"},
{kind: "onyx.Button", content: "HEY!", ontap: "lalala"}
]}
function callSpaz(serviceParams, onFailure) {
var appids = ['com.funkatron.app.spaz-sped', 'com.funkatron.app.spaz', 'com.funkatron.app.spaz-beta'], index = 0;
function makeCall() {
if (index < appids.length) {
Mojo.Log.info('Trying to post with appid %s', appids[index]);
var request = new Mojo.Service.Request("palm://com.palm.applicationManager", {