Skip to content

Instantly share code, notes, and snippets.

View kidjp85's full-sized avatar
💭
I may be slow to respond.

Asher Nguyen kidjp85

💭
I may be slow to respond.
View GitHub Profile
@kidjp85
kidjp85 / codility_solutions.txt
Created May 12, 2019 04:11 — forked from lalkmim/codility_solutions.txt
Codility Solutions in JavaScript
Lesson 1 - Iterations
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/
Lesson 2 - Arrays
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/
Lesson 3 - Time Complexity
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/
@kidjp85
kidjp85 / formik.tsx
Created April 29, 2019 01:01 — forked from tgriesser/formik.tsx
Formik w/ Hooks
import React, {
useContext,
createContext,
createElement,
useEffect,
useRef,
useCallback,
useState,
} from 'react';
import isEqual from 'react-fast-compare';
@kidjp85
kidjp85 / what-forces-layout.md
Created April 10, 2019 13:33 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@kidjp85
kidjp85 / Hide.js
Created April 4, 2019 00:57 — forked from Kikobeats/Hide.js
Hide + rebass
import styled from 'styled-components'
import { theme } from 'rebass'
const { breakpoints } = theme
const lastIndex = breakpoints.length - 1
const getMediaBreakpoint = (breakpoints, breakpoint, index) => {
if (index === 0) return `@media screen and (max-width: ${breakpoint})`
const prevBreakpoint = breakpoints[index - 1]
if (index === lastIndex) {
@kidjp85
kidjp85 / keybase.md
Last active November 30, 2018 00:17

Keybase proof

I hereby claim:

  • I am kidjp85 on github.
  • I am phucnguyen (https://keybase.io/phucnguyen) on keybase.
  • I have a public key ASAoDVmT81CttJZBI5pBfvUYg2jtxX6pVvEqnJF6Rnf4Igo

To claim this, I am signing this object:

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {
@kidjp85
kidjp85 / iterm2-solarized.md
Created March 13, 2018 08:20 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

import React from 'react'
import PropTypes from 'prop-types'
import { compose, pure, setPropTypes, withHandlers, withProps } from 'recompose'
const Symbol = props => {
const {
style,
handleMouseClick,
handleMouseMove,
backgroundNode,
@kidjp85
kidjp85 / fibonacci-generator.js
Created November 1, 2017 04:52 — forked from jfairbank/fibonacci-generator.js
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@kidjp85
kidjp85 / dynamically-import-component.js
Created June 20, 2017 03:05 — forked from pozylon/dynamically-import-component.js
React & Recompose & Meteor dynamic-import
import { compose, withState, lifecycle } from 'recompose';
let AsyncComponent = null;
export default (loader, loadingComponent) => compose(
withState('isDynamicallyLoaded', 'updatedIsDynamicallyLoaded', false),
lifecycle({
componentDidMount() {
const { updatedIsDynamicallyLoaded } = this.props;
loader.then((LoadedModule) => {