Skip to content

Instantly share code, notes, and snippets.

import React from 'react'
import { NavLink } from 'react-router-dom'
class Header extends React.Component {
state = {
isActive: false,
}
toggleNav = () => {
@aaronklaser
aaronklaser / loading.js
Last active February 13, 2018 22:08
Loading Spinner
import styled from 'styled-components'
export const Loader = styled.div`
color: #ffffff;
font-size: 50px;
text-indent: -9999em;
overflow: hidden;
width: 1em;
height: 1em;
border-radius: 50%;
@aaronklaser
aaronklaser / setting-up-the-app.js
Last active January 30, 2018 16:02
Setting up the App (React with Bulma)
//========//
// App.js //
//========//
import React from 'react'
import Layout from './app/Layout'
class App extends React.Component {
render() {
return (
<Layout />
@aaronklaser
aaronklaser / DeclarativeVsImperative.js
Created January 4, 2018 21:22
Let people smart then you do the work for you. Declarative code is more functional and easier to read.
// Do NOT do this
function double (arr) {
let results = []
for (let i = 0; i < arr.length; i++){
results.push(arr[i] * 2)
}
return results
}
// Do This
@aaronklaser
aaronklaser / antiTypescript.js
Last active January 4, 2018 20:57
Using TypeScript without the all the TypeScript extras, I know it defeats the purpose but so much cleaner and makes converting your code easier if you change framework in the future.
// Do NOT do this 🤢
public foo: IFoo = new Foo()
public bar: Foo
function setBar(foo: Foo): void {
this.bar = foo
}
// Do This
foo = new Foo()
@aaronklaser
aaronklaser / externalizedCallbacks.js
Last active January 4, 2018 19:41
Externalizing Callbacks
// Do NOT do this
let data
function getData() {
this.service.getDate().then((data) => {
this.data = data
})
}
// Do this
let data
@aaronklaser
aaronklaser / syknet-thevirus.js
Last active February 2, 2016 22:55
Javascript answer to Codingame's challenge Skynet: The Virus -- https://www.codingame.com/ide/35536499a6dd7e9b0c144176df5975b76b67088
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
var inputs = readline().split(' ');
var N = parseInt(inputs[0]); // the total number of nodes in the level, including the gateways
var L = parseInt(inputs[1]); // the number of links
var E = parseInt(inputs[2]); // the number of exit gateways