Skip to content

Instantly share code, notes, and snippets.

😶
null

Adam Bohannon abohannon

😶
null
Block or report user

Report or block abohannon

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
@abohannon
abohannon / tictactoeconstanttime.js
Created Dec 23, 2018
TicTacToe game of any size that determines a winner in O(1)
View tictactoeconstanttime.js
class TicTacToe {
constructor(size) {
this.size = size
this.center = Math.floor(this.size / 2)
this.state = {
board: [],
score: [],
move: 0,
}
View setOfStacks.js
class StackSet {
constructor(maxSize) {
if (arguments.length < 1) {
throw new Error ('Woops, maxSize is required!')
}
this.stacks = [[]]
this.maxSize = maxSize
}
View Redux Reducer Boilerplate
const INITIAL_STATE = {};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case ACTION_TYPE: {
const newState = {};
return {...state, ...newState};
}
default:
return state;
@abohannon
abohannon / README-Template.md
Created Dec 29, 2017 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@abohannon
abohannon / PrivateRoute.js
Created Dec 22, 2017
React/Redux Auth with Private Route Component
View PrivateRoute.js
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
const PrivateRoute = ({ component: Component, authed, ...rest }) => (
<Route
{...rest}
render={props => (
authed
? <Component {...props} />
: <Redirect to="/login" />
View Express Server Snippet
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const routes = require('./routes');
app.use(bodyParser.json());
app.use(express.static(`${__dirname}/public`));
routes(app);
@abohannon
abohannon / index.js
Last active Aug 20, 2017
Gist for leaderboard react app
View index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import registerServiceWorker from './registerServiceWorker';
import axios from 'axios';
class Board extends React.Component {
constructor(props) {
super(props);
@abohannon
abohannon / eloquent-javascript-exercises.js
Last active Jul 20, 2017
Eloquent Javascript Exercise Solutions
View eloquent-javascript-exercises.js
// My answers to the exercises in Eloquent Javascript
// Looping a triangle
var myStr = '';
for (var i = 1; i < 7; i++){
console.log(myStr += "#");
}
View trump-quote2
[
{
"quote": "I will be the greatest jobs president that God ever created.",
"author": "Donald Trump",
"index": 1},
{
"quote": "When Mexico sends its people, they're not sending their best. They're sending people that have lots of problems...they're bringing drugs, they're bringing crime. They're rapists.",
"author": "Donald Trump",
"index": 2
}, {
You can’t perform that action at this time.