Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle Poole kylpo

View GitHub Profile
View fp-stuff.ts
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 Apr 27, 2020
Prettier patch for single-prop-per-line and break-before-else
View prettier+2.0.5.patch
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
View Settings.swift
import Foundation
import Combine
enum TimeFrameOption: String, CaseIterable {
case today
case week
case month
case year
case total
}
View Button.swift
// 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 {
View monkeyPatchEventMethods.js
// 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 Dec 19, 2016
object clone/delete vs new/loop-and-add (http://jsbench.github.io/#e66d4836d1afb2cbef779e9bcaa6365e) #jsbench #jsperf
View index.html
<!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>
View .profile
# 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
View init.coffee
# 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 Aug 25, 2016
Kylpo's Coding Style
View codingStyle.md

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';
View tmp
## _type_activity.html.erb
<div class="well">
<p>
<label><b>Sentiment</b></label>
<label class="checkbox inline">
<%= f.check_box :sentiment_positive, :checked => true %>
Positive
</label>
<label class="checkbox inline">
You can’t perform that action at this time.