Skip to content

Instantly share code, notes, and snippets.

View alecklandgraf's full-sized avatar

Aleck Landgraf alecklandgraf

View GitHub Profile
/*
* 100 million simulations reveal of 63.1% chance of winning First Orchard.
*/
const GREEN_APPLES = "green apples";
const RED_APPLES = "red apples";
const PLUMBS = "plumbs";
const PEARS = "pears";
const BASKET = "basket";
const RAVEN = "raven";
import React, { useState } from "react";
function App() {
const [todos, updateTodos] = useState([]);
const [currentTodo, updateTodo] = useState("");
return (
<div className="App">
<h3>Todos</h3>
@alecklandgraf
alecklandgraf / readme.md
Created March 2, 2018 04:01
Git cheatsheet
# rebase off master
git pull --rebase origin master`

# uncommit last files to re-add, useful to break one commit into multiple
git reset HEAD~

# squash etc, rebase (-i is an interactive rebase)
git checkout master
git pull
@alecklandgraf
alecklandgraf / factories_vs_services.js
Last active October 14, 2016 19:11
angular factories vs services
angular.module('myModule', [])
.factory('myModuleFactory', function() {
const state = {
loaded: false,
};
const setLoaded = () => {
state.loaded = true;
};
return {
@alecklandgraf
alecklandgraf / cachedFetch.service.js
Last active October 14, 2016 19:25
Angular 1.5 design pattern for a cached API resource
import angular from 'angular';
import assignIn from 'lodash/assignIn';
const meServiceModule = angular.module('meServiceModule', []);
meServiceModule.factory('meService', ['$http', '$q', ($http, $q) => {
const user = {};
const state = {
loaded: false,
@alecklandgraf
alecklandgraf / API.md
Created September 29, 2016 23:50 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@alecklandgraf
alecklandgraf / profile.component.js
Last active August 30, 2016 00:16
Profile Component with Routing
const Component = {
template: `...`,
bindings: {
userData: '<'
}
};
angular
.module('App.pages.profile', [uiRouter, meServiceModule])
.component('profile', Component)
.config(($stateProvider, $urlRouterProvider) => {
@alecklandgraf
alecklandgraf / angular app.js
Created August 25, 2016 22:55
Angular Component starter app
// -- in app.component.js --
import angular from 'angular';
const AppComponent = {
template: `
<app-header></app-header>
<app-nav></app-nav>
<div>
<div ui-view></div>
</div>
/**
* usage:
* <stateless-table
* data="[{first_name: 'Aleck', last_name: 'Landgraf'}, ...]"
* on-header-click="sortData()"
* ></stateless-table>
*/
module.component('statelessTable', {
bindings: {
data: '<',
<html>
<head>
<title>React StopWatch sample</title>
<meta name="viewport" content="width=device-width">
<script src="http://fb.me/react-0.13.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.13.1.js"></script>
</head>
<body>
<script type="text/jsx">
var StopWatch = React.createClass({