Skip to content

Instantly share code, notes, and snippets.

Steve Chester schester44

Block or report user

Report or block schester44

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@schester44
schester44 / gist:16be0720bbe7b2d01a38eb1baa3a2d89
Created Mar 6, 2019
find the shortest distance between a point and a line segment.
View gist:16be0720bbe7b2d01a38eb1baa3a2d89
import { render } from "react-dom";
import React from "react";
import { Stage, Text, Layer, Line, Circle } from "react-konva";
const originalPoints = [
{ x: 294, y: 344 },
{ x: 322, y: 451 },
{ x: 547, y: 379 },
{ x: 505, y: 251 },
{ x: 417, y: 317 }
@schester44
schester44 / gist:d71e02e230ee457437f6482a22d954a1
Created Oct 16, 2018
access nested objects by string key
View gist:d71e02e230ee457437f6482a22d954a1
function resolve(path, obj=self, separator='.') {
return (Array.isArray(path) ? path : path.split(separator)).reduce((prev, curr) => prev && prev[curr], obj)
}
@schester44
schester44 / flatten object.js
Last active Oct 16, 2018
deep flatten nested object
View flatten object.js
const flatten = (obj, prefix = '') => {
return Object.keys(obj).reduce((acc, key) => {
const value = obj[key]
const prefixedKey = `${prefix}${prefix !== '' ? '.' : ''}${key}`
if (typeof value === "string") {
return {
...acc,
prefixedKey]: curr
@schester44
schester44 / DeviceList.js
Created Feb 26, 2018
React-based Pagination component & HOC
View DeviceList.js
# Example Usage:
import React from "react"
import Pagination, { withPagination } from "components/Pagination"
const DeviceList = ({ data, setCurrentPage, currentPage }) => {
const perPage = 25
const lastIndex = currentPage * perPage
const firstIndex = lastIndex - perPage
@schester44
schester44 / zshrc
Last active Aug 22, 2018
zsh backup
View zshrc
POWERLEVEL9K_MODE='nerdfont-complete'
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{cyan}\u256D\u2500%f"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{014}\u2570%F{cyan}\uF460%F{073}\uF460%F{109}\uF460%f "
POWERLEVEL9K_STATUS_VERBOSE=false
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time)
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
You can’t perform that action at this time.