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 express = require('express'), | |
reqpromise = require('request-promise'); | |
function register(req, res, next) { | |
var user = {}; | |
user.username = req.body.username; | |
user.password = req.body.password; | |
user.firstName = req.body.firstName; | |
user.lastName = req.body.lastName; | |
user.email = req.body.username; |
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
#!/usr/bin/env bash | |
############ CONFIGURE GIT from this repo | |
git config user.email "bamboo@company.com" | |
git config user.name "Bamboo Dev" | |
# Add a remote master to Heroku (if one does not exist) | |
(git remote -v | grep "^heroku" > /dev/null) || | |
heroku git:remote --app $HEROKU_APP_NAME --org $HEROKU_ORG_NAME |
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
(ns car-configurator.core | |
(:require [schema.core :as s])) | |
; NO CODE YET ... Just data | |
;---> define some basic attributes | |
(def fuel (s/enum :diesel :petrol :hybrid)) | |
(def engine {:name s/Str :fuel fuel :volume s/Num :bhp s/Int}) ; c02, etc. | |
(def colour {:name s/Str :rgb {:red s/Int :green s/Int :blue s/Int} :hex s/Int}) ; metallic, etc. | |
; STILL NO CODE YET ... Just data |
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
private Map<CartItem, Integer> cart = new HashMap<CartItem, Integer>(); | |
public Double getTotalItemFees() { | |
Double fees = 0.0; | |
for (Map.Entry<CartItem, Integer> entry : cart.entrySet()) { | |
Integer quantity = entry.getValue(); | |
CartItem cartItem = entry.getKey(); | |
fees += (quantity * cartItem.getFee()) | |
} | |
return fees; |
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
def getTotalItemFees = { | |
val fees = | |
for (item <- items) | |
yield item._1.getFee() * item._2 | |
fees.sum // High order function on the list that came out of the for loop | |
} |
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
def getTotalItemFees = { | |
( for (item <- items) yield item._1.getFee * item._2 ).sum | |
} | |
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
private val items = new HashMap[CartItem, Int] | |
def getTotalItemFees : Double = { | |
var sum = 0.0 | |
for (item <- items) | |
sum += (item._1.getFee() * item._2) | |
sum | |
} |
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
def getTotalItemFees = { | |
items.foldLeft(0.0d)((accum, item) => accum + (item._1.getFee * item._2) | |
} |
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
def getTotalItemFees = { | |
items.\(0.0d)((accum, item) => accum + (item._1.getFee * item._2) | |
} |
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
def scrubOut(line: String, keys: List[String]): String = { | |
def containsKeys(found: Boolean = false, local_line: String = line, local_keys: List[String] = keys): Boolean = { | |
if (local_keys.isEmpty || found) found | |
else { | |
containsKeys(line.contains(local_keys.head), local_line, local_keys.tail) | |
} | |
} | |
if (!line.contains("=") || !line.contains("\"") || keys.isEmpty || containsKeys() == false) |
OlderNewer