git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
<h2>Svelte Clock</h2> | |
<p>Look how fast Svelte goes!</p> | |
<p>{{hours}}:{{leftPad(minutes, 2, '0'}}:{{leftPad(seconds, 2, '0'}}:{{leftPad(milliseconds, 3, '0'}}</p> | |
<script> | |
import leftPad from 'left-pad' | |
export default { |
const path = require('path'); | |
const webpack = require('webpack'); | |
const ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
const javascript = { | |
test: /\.(js)$/, | |
use: [{ | |
loader: 'babel-loader', | |
options: { presets: ['es2015'] } | |
}], |
My request to the API returns an array of objects. I need to group each item in this array based on the value of one of its keys. Thus, I need to end up with a 2d array of arrays.
import React, { Component, PropTypes } from 'react' | |
export default function onScreen (WrappedComponent) { | |
return class extends Component { | |
constructor () { | |
super() | |
this.handleScroll = this.handleScroll.bind(this) | |
this.isRefOnScreen = this.isRefOnScreen.bind(this) | |
this.state = { | |
isOnScreen: false |
Sometimes you want to have a subdirectory on the master
branch be the root directory of a repository’s gh-pages
branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master
branch alongside the rest of your code.
For the sake of this example, let’s pretend the subfolder containing your site is named dist
.
Remove the dist
directory from the project’s .gitignore
file (it’s ignored by default by Yeoman).
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
const _this = this // the React Component | |
const ref = this.nodeRef // Using react to get a ref of my DOM element | |
const { width } = ref.getBoundingClientRect() | |
const scrollCoeffecient = 0.5 // this is retrieved from a config object in my app | |
const scrollSpeed = 1 * scrollCoefficient | |
function loop () { | |
if (!loop.aggregatedDistance) { | |
loop.aggregatedDistance = 0 | |
} |
// Given the grid below, create a function that determines | |
// if the grid is a valid sudoku | |
const grid = [ | |
['.', '.', '.', '1', '4', '.', '.', '2', '.'], | |
['.', '.', '6', '.', '.', '.', '.', '.', '.'], | |
['.', '.', '.', '.', '.', '.', '.', '.', '.'], | |
['.', '.', '1', '.', '.', '.', '.', '.', '.'], | |
['.', '6', '7', '.', '.', '.', '.', '.', '9'], | |
['.', '.', '.', '.', '.', '.', '8', '1', '.'], |
function memoizedFibonacci (n) { | |
if (!memoizedFibonacci.memo) { | |
memoizedFibonacci.memo = {} | |
} | |
if (memoizedFibonacci.memo[n]) { | |
return memoizedFibonacci.memo[n] | |
} else { | |
let value | |