This file contains hidden or 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
function isUnique( s ) { | |
var chars = {} | |
var dup = true; | |
for (var i = 0; i < s.length; ++i) { | |
if ((s[i] in chars)) { | |
return false; | |
} | |
chars[s[i]] = 1; | |
} |
This file contains hidden or 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
function s4(){ | |
return Math.floor((1+ Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1); | |
} | |
module.exports ={ | |
guidWithDash: function() { | |
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | |
s4() + '-' + s4() + s4() + s4(); |
This file contains hidden or 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
function Calculator() { | |
} | |
Calculator.prototype.calc = function(str) { | |
var signs = ["*", "+","/"]; // signs in the order in which they should be evaluated | |
var funcs = [multiply, add, divide]; // the functions associated with the signs | |
var tokens = str.split(" "); // split the string into "tokens" (numbers or signs) | |
console.log(tokens) | |
for (var round = 0; round < signs.length; round++) { // do this for every sign | |
for (var place = 0; place < tokens.length; place++) { // do this for every token |
This file contains hidden or 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 React from 'react'; | |
import { Route, IndexRoute } from 'react-router'; | |
import { requireAuth } from './utils/auth'; | |
import App from './components/App'; | |
import Login from './containers/LoginPage'; | |
import TeamPage from './containers/TeamPage'; // eslint-disable-line import/no-named-as-default | |
import NotFoundPage from './components/NotFoundPage.js'; | |
export default ( |
This file contains hidden or 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
function isLoggedIn() { | |
return localStorage.getItem('id_token'); | |
} | |
export function requireAuth(nextState, replace) { | |
if (!isLoggedIn()) { | |
replace({ | |
pathname: '/login', | |
state: { nextPathname: nextState.location.pathname } | |
}); |
This file contains hidden or 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
#### Run within Docker | |
For now we have to build the docker image locally. Late I will get it hosted | |
###### Building your image | |
Go to the directory that has your Dockerfile and run the following command to build a Docker image. The -t flag lets you tag your image so it’s easier to find later using the docker images command: | |
`docker build -t hamiltondanielb/record-web-react .` | |
Your image will now be listed by Docker: | |
`docker images` |
This file contains hidden or 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
Array.prototype.flatten = Array.prototype.flatten || function() { | |
var flattened = []; | |
for (var i = 0; i < this.length; ++i) { | |
if (Array.isArray(this[i])) { | |
flattened = flattened.concat(this[i].flatten()); | |
} else { | |
flattened.push(this[i]); | |
} | |
} |
This file contains hidden or 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
Date.prototype.isEqual = Date.prototype.isEqual || function(other) { | |
if (other && typeof other.getTime === 'function') { | |
return this.getTime() === other.getTime(); | |
} else { | |
return false; | |
} | |
}; |
This file contains hidden or 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
String.prototype.contains = String.prototype.contains || function(str) { | |
return this.indexOf(str) >= 0; | |
}; | |
String.prototype.startsWith = String.prototype.startsWith || function(prefix) { | |
return this.indexOf(prefix) === 0; | |
}; | |
String.prototype.endsWith = String.prototype.endsWith || function(suffix) { | |
return this.indexOf(suffix, this.length - suffix.length) >= 0; |
This file contains hidden or 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
Array.prototype.find = Array.prototype.find || function(predicate, thisArg) { | |
for (var i = 0; i < this.length; ++i) { | |
if (predicate.call(thisArg, this[i], i, this) === true) { | |
return this[i]; | |
} | |
} | |
return undefined; | |
}; |
NewerOlder