Intro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = { | |
activeIndex: null, | |
flights: [] | |
} | |
export default function reducer (state = initialState, action){ | |
switch(action.type) { | |
// lets create first. | |
// This means we create a flight then add it to a *copy* of the list. | |
case CREATE_NEW_FLIGHT: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 of the week: arrow functions and lexical scope | |
// https://github.com/lukehoban/es6features | |
// arrow functions are a shorthand for function syntax, | |
// which make them a lot more succint for functions that take functions | |
// (i.e. 'higher order functions') | |
var evens = [2,4,6,8,10]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Product Model definition, called 'product' and associated with table 'products' | |
var Product = this.sequelize.define('product', { | |
title: Sequelize.STRING | |
}); | |
// User Model definition, called 'user' and associated with table 'users' | |
var User = this.sequelize.define('user', { | |
first_name: Sequelize.STRING, | |
last_name: Sequelize.STRING | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
url = require('url'); | |
var database = {}; // will need to read from file here | |
var setRegex = /^\/set\?.+=.+$/, // /set?somekey=somevalue | |
getRegex = /^\/get\?key=.+$/; // /get?key=somekey | |
http.createServer(requestListener).listen(4000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# we want to match data, not a Node, as search | |
# shouldn't require any Node creation either | |
def search(self, data): | |
node = self.head | |
while node: | |
if node.data == data: | |
return node | |
else: | |
node = node.nextNode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (inits, tails) | |
main :: IO () | |
main = do | |
print $ perms [1..4] | |
print $ perms' "abcd" | |
print $ perms'' [Nothing, Just 1, Just 2, Just 3] | |
perms, perms', perms'' :: [a] -> [[a]] |
NewerOlder