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> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>Hexagons Test</title> | |
<!--<link href='http://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'>--> | |
<script type="text/javascript" src="https://d3js.org/d3.v3.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/2.7.4/d3.geom.min.js"></script> | |
<style type="text/css"> | |
svg { |
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> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>Hexagons Test</title> | |
<script type="text/javascript" src="https://d3js.org/d3.v6.min.js"></script> | |
<style type="text/css"> | |
svg { | |
border: solid 1px #aaa; |
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> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>Hexagons Test</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.min.js?1.29.6"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.behavior.min.js?1.29.6"></script> | |
<style type="text/css"> | |
svg { | |
border: none; |
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
for(var c = ''; c.length < 100;) c += Math.random().toString(36).substr(2, 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
db.grades.distinct('student_id').forEach(function(id) { | |
db.grades.findAndModify({ | |
query: { student_id: id, type: 'homework' }, | |
sort: { score: 1 }, | |
remove: true | |
}); | |
}) | |
// 600 | |
db.grades.count() |
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
db.students.find() | |
db.students.find().forEach(function(student) { | |
var lowest = -1; | |
for (var i = 0; i < student.scores.length; i++) { | |
if (student.scores[i].type == 'homework') { | |
lowest = lowest == -1 || student.scores[i].score < student.scores[lowest].score ? i : lowest; | |
} | |
} | |
if (lowest > -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
db.posts.aggregate([ | |
{$unwind: '$comments'}, | |
{$group: { _id: '$comments.author', comments: { $sum: 1 } }}, | |
{$sort: { comments: -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
db.zips.aggregate([ | |
{$match: {$or: [{state: 'CT'}, {state: 'NJ'}]}}, | |
{$group: {_id: {state: '$state', city: '$city'}, pop: {$sum: '$pop'}}}, | |
{$match: {pop: {$gt: 25000}}}, | |
{$group: {_id: null, avg: {$avg: '$pop'}}} | |
]) | |
db.zips.aggregate([ | |
{$match: {$or: [{state: 'CA'}, {state: 'NY'}]}}, | |
{$group: {_id: {state: '$state', city: '$city'}, pop: {$sum: '$pop'}}}, |
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
db.grades.aggregate([ | |
{$unwind: '$scores'}, | |
{$match: {'scores.type': {$ne: 'quiz'}}}, | |
{$project: {_id: 0, class: '$class_id', student: '$student_id', score: '$scores.score'}}, | |
{$group: {_id: {class: '$class', student: '$student'}, student_avg: {$avg: '$score'}}}, | |
{$group: {_id: {class: '$_id.class'}, avg: {$avg: '$student_avg'}}}, | |
{$project: {_id: 0, class: '$_id.class', avg: 1}}, | |
{$sort: {avg: -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
db.zips.aggregate([ | |
{$project: { _id: 1, city: 1, pop: 1, state: 1, first_char: {$substr : ["$city", 0, 1]} }}, | |
{$match: {first_char: {$regex: '[0-9]'}}}, | |
{$group: {_id: null, sum: {$sum: '$pop'}}} | |
]) |
OlderNewer