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) {

@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

@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) => {
@kidjp85
kidjp85 / LazilyLoad.js
Created April 25, 2017 14:02 — forked from iammerrick/LazilyLoad.js
Lazily Load Code Declaratively in React + Webpack
import React from 'react';
const toPromise = (load) => (new Promise((resolve) => (
load(resolve)
)));
class LazilyLoad extends React.Component {
constructor() {
super(...arguments);
@kidjp85
kidjp85 / index.html
Created September 22, 2016 05:06 — forked from anonymous/index.html
Auto complete RxJS [source https://jsbin.com/dakicez]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Auto complete RxJS</title>
</head>
<body>
<form action="" class="form">
<input type="text" id="title">