Skip to content

Instantly share code, notes, and snippets.

View kylpo's full-sized avatar

Kyle Poole kylpo

View GitHub Profile
/**
* This script is used to generate `argTypes` for Storybook.
*
* For helpful documentation, see:
* - https://github.com/storybookjs/storybook/blob/next/addons/controls/src/components/ControlsPanel.tsx#L14
* - https://github.com/storybookjs/storybook/blob/next/lib/components/src/blocks/ArgsTable/ArgRow.tsx#L98
* - https://github.com/storybookjs/storybook/blob/next/lib/components/src/blocks/ArgsTable/ArgValue.tsx#L129
*
* @example <caption>Usage example for Avatar</caption>
* yarn docgen ./monorail/src/v2/core/Avatar/Avatar.tsx
import { pipe } from 'fp-ts/lib/pipeable'
import * as O from 'fp-ts/lib/Option'
import * as A from 'fp-ts/lib/Array'
import * as R from 'fp-ts/lib/Record'
// V1: First version that does a record lookup, then Option is unwrapped with a default [] to map over.
const data = R.lookup("someArray", someRecord)
.getOrElse([])
.map(toSomeTransformation)
@kylpo
kylpo / prettier+2.0.5.patch
Created April 27, 2020 16:23
Prettier patch for single-prop-per-line and break-before-else
diff --git a/node_modules/prettier/bin-prettier.js b/node_modules/prettier/bin-prettier.js
index 6acda2d..4f86b5b 100755
--- a/node_modules/prettier/bin-prettier.js
+++ b/node_modules/prettier/bin-prettier.js
@@ -40130,7 +40130,7 @@ function printPathNoParens(path, options, print, args) {
if (n.alternate) {
const commentOnOwnLine = hasTrailingComment$1(n.consequent) && n.consequent.comments.some(comment => comment.trailing && !comments$1.isBlockComment(comment)) || needsHardlineAfterDanglingComment$1(n);
- const elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
+ const elseOnSameLine = false
@kylpo
kylpo / Settings.swift
Created April 22, 2020 17:00
@userdefault Property Wrapper
import Foundation
import Combine
enum TimeFrameOption: String, CaseIterable {
case today
case week
case month
case year
case total
}
@kylpo
kylpo / Button.swift
Created July 10, 2019 21:34
Renderable
// Help with onTap from https://cocoacasts.com/elegant-controls-in-swift-with-closures
import UIKit
class Button: UIButton {
// typealias DidTapButton = (Button) -> Void
// var onTap: ((Button) -> Void)? {
var onTap: (() -> Void)? {
didSet {
// Logs all calls to preventDefault / stopPropagation in an user-friendly way
if ( process.env.NODE_ENV !== "production" ) {
(function monkeyPatchEventMethods() {
const logEventMethodCall = (event,methodName) => {
const MinimumMeaninfulSelectors = 3; // how much meaningful items we want in log message
const target = event.target;
const selector = (function computeSelector() {
@kylpo
kylpo / index.html
Last active December 19, 2016 20:07
object clone/delete vs new/loop-and-add (http://jsbench.github.io/#e66d4836d1afb2cbef779e9bcaa6365e) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
# Only load Liquid Prompt in interactive shells, not from a script or from scp
[[ $- = *i* ]] && source ~/github/liquidprompt/liquidprompt
# The cool apple symbol with system info
# archey
# git completion
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@kylpo
kylpo / codingStyle.md
Last active August 25, 2016 12:36
Kylpo's Coding Style

I am a web and mobile developer, using React and React Native. As such, my style has evolved to work more seamlessly with React, and may not work for other frameworks. Also, I LOVE Ruby’s (and CoffeeScript’s) syntax. It taught me the value of code that reads more like english and how aesthetics of a code base truly will affect your and others excitement to maintain/contribute to it.

Code Style

Semicolons

No

// Bad
import Foo from 'foo';