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
filename = ARGV[0] | |
file = File.new(filename, "r") | |
while (line = file.gets) | |
array = line.scan(/./) | |
new_array = Array.new | |
array.length.times do |var| | |
new_array << array.count(var.to_s).to_s | |
end | |
if new_array.eql? array |
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
//Knapsack algorithm | |
//================== | |
// wikipedia: [Knapsack (0/1)](http://en.wikipedia.org/wiki/Knapsack_problem#0.2F1_Knapsack_Problem) | |
// Given a set `[{weight:Number, benefit:Number}]` and a capacity, | |
// find the maximum value possible while keeping the weight below | |
// or equal to the capacity | |
// **params**: | |
// `capacity` : Number, | |
// `items` : [{w:Number, b:Number}] | |
// **returns**: |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Decoding Morse Code With JavaScript</title> | |
<style type="text/css"> | |
div.output {} | |
div.output p.message { |
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
#!/bin/bash | |
echo 'Running Dev setup' | |
if [ "$(uname)" == "Darwin" ]; then | |
# Do something under Mac OS X platform | |
textMessage="--- OSX setup Summary ---\n" | |
if which xcode-select >/dev/null; then | |
textMessage=$textMessage"--not installing xcode-select, already installed \n" | |
else | |
textMessage=$textMessage"--installing xcode-select\n" | |
sudo xcode-select --install |
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; | |
}; |
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
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
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
#### 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
function isLoggedIn() { | |
return localStorage.getItem('id_token'); | |
} | |
export function requireAuth(nextState, replace) { | |
if (!isLoggedIn()) { | |
replace({ | |
pathname: '/login', | |
state: { nextPathname: nextState.location.pathname } | |
}); |
OlderNewer