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
function sum (a, b) { | |
return a + b | |
} | |
console.log(sum(10, 5)) |
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
videojs.registerPlugin('playerPlugin', function (opts) { | |
... | |
}) | |
if (process.env.NODE_ENV !== 'production') { | |
const devPlayerOptions = { | |
"customOption": "customOptionValue", | |
} | |
videojs('player').playerPlugin(devPlayerOptions) |
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 discountFactor = 0.85 | |
const trainingSets = [] | |
for (let i = 0; i < numMoves - 1; i++) { | |
let currentNetStateNormalized = netConfig.netNormalizedOutput(moves[i].boardVector)[0] | |
let reward = moves[i].reward | |
let nextNetStateNormalized = netConfig.netNormalizedOutput(moves[i + 1].boardVector)[0] | |
let netOutput = normalizeReluOutput(reward + discountFactor * nextNetStateNormalized) |
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
router.get('/movie', auth, async function (req, res) { | |
const {username} = req | |
const similarityData = _(await db.similarity.getBy(function (similarity) { | |
return _.includes(similarity.users, username) | |
})).orderBy('pcc', 'desc').take(5).value() | |
const users = _(similarityData).map(function (similarity) { | |
return { | |
..._.omit(similarity, 'users'), | |
username: _.remove(similarity.users, function (user) { | |
return user !== 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
router.get('/user', auth, async function (req, res) { | |
const {username} = req | |
const similarity = helper.sortByAlgorithm(await db.similarity.getBy(function (user) { | |
return _.includes(user.users, username) | |
}), 'pcc') | |
const usersSimilarities = await Promise.map(similarity, async function (similarityData) { | |
return { | |
...similarityData, | |
user: await db.user.get(_.remove(similarityData.users, function (user) { |
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
async function updateUserSimilarityScores (username) { | |
const users = await db.user.getVals() | |
const mainUser = await db.user.get(username) | |
mainUser.reviews = await getUserMovieReviews(mainUser) | |
const mainUserMovies = _.map(mainUser.reviews, 'movieId') | |
return Promise.map(users, async function (user) { | |
user.reviews = await getUserMutualMovieReviews(user, mainUserMovies) |
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
function squaredNum (review) { | |
return Math.pow(review.rating, 2) | |
} | |
function pcc (user1, user2) { | |
const n = _.size(user1.reviews) | |
if (n === 0) { | |
return n | |
} |
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
function euclideanDistance (user1, user2) { | |
const n = _.size(user1.reviews) | |
let coefficient = 0 | |
if (n === 0) { | |
return n | |
} | |
for (let i = 0; i < n; i++) { | |
coefficient += Math.pow(user1.reviews[i].rating - user2.reviews[i].rating, 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
{% if collection.all_tags.size > 1 %} | |
{% comment %} | |
Get all of the filter groups | |
{% endcomment %} | |
{% for tag in collection.all_tags %} | |
{% if tag contains '_' %} | |
{% assign splitTag = tag | split: '_' %} | |
{% unless filterTags contains splitTag.first %} | |
{% capture filterTags %}{{ filterTags }}+{{ splitTag.first }}{% endcapture %} |