Skip to content

Instantly share code, notes, and snippets.

@Nicktho
Nicktho / keysettings.json
Created January 1, 2018 06:19
keysettings
{"version":1,"keyboard":{"keys":[{"id":0,"legend":"~\n`","state":{"x":0,"y":0,"r":0,"rx":0,"ry":0,"w":1,"h":1,"x2":0,"y2":0,"w2":0,"h2":0},"row":0,"col":0,"keycodes":[{"id":"KC_GRV","fields":[]},{"id":"KC_PWR","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]}]},{"id":1,"legend":"!\n1","state":{"x":1,"y":0,"r":0,"rx":0,"ry":0,"w":1,"h":1,"x2":0,"y2":0,"w2":0,"h2":0},"row":0,"col":1,"keycodes":[{"id":"KC_1","fields":[]},{"id":"KC_F1","fields":[]},{"id":"M()","fields":[1]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":
function addToQueue(...people) {
var positions = []
for (var i = 0; i < people.length; i++) {
positions[i] = function() {
return i + 1
}
}
return positions

Exercize

TodoMVC (http://todomvc.com/) is a common problem that many developers solve when learning a new language. We'll be tackling TodoMVC in pseudocode for tonight's homework.

Create a Todo app in pseudocode.

A user should be able to:

  • Add a todo
  • Edit a todo
* Write pseudocode for a program that allows uses to change a light colour.
* The light has three different coloured buttons - red, blue and yellow.
* When a user touches a button, the light changes to that colour.
* In the selected colour is touched again, make sure the light turns off!
* If we go overtime, complete the task for homework.

GitHub (10 min)

We will be using the GitHub service to share some of our code. We will learn about the underlying technology of GitHub known as git in the next lesson.

git config --global user.name "YOUR NAME"

export function combineReducers(reducers) {
return (oldState, action) => {
return Object.keys(reducers).reduce((newState, key) => {
const reducer = reducers[key];
newState[key] = reducer(oldState[key], action);
return newState;
}, {});
};
describe('combineReducers', () => {
it('should combine multiple reducers to a single reducer', () => {
const notes = (state = [ 'hello world' ], action) => {
switch(action.type) {
case 'ADD_NOTE':
return [ ...state, action.payload ];
default:
return state;
}
};
export function createStore(reducer, initialState) {
let listeners = [];
let currentState = initialState;
function getState() {
return currentState;
}
function subscribe(listener) {
listeners.push(listener);
describe('#subscribe', () => {
it('should add the passed function to the listeners', () => {
const store = createStore(x => x, {});
let called = false;
store.subscribe(() => called = true);
store.dispatch({ type: '' });
expect(called).to.be.true;