Skip to content

Instantly share code, notes, and snippets.

@levhita
Created January 17, 2017 22:23
Show Gist options
  • Save levhita/3b72712394eade168d8e6e086c97f743 to your computer and use it in GitHub Desktop.
Save levhita/3b72712394eade168d8e6e086c97f743 to your computer and use it in GitHub Desktop.
tips and tricks for mongo
<!doctype html>
<html>
<head>
<title>Network | Basic usage</title>
<script type="text/javascript" src="http://visjs.org/dist/vis.js"></script>
<link href="http://visjs.org/dist/vis-network.min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#mynetwork {
width: 1270px;
height: 980px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<p>
Create a simple network with some nodes and edges.
</p>
<div id="mynetwork"></div>
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet([
{id:'10157521588920515', label: 'Levhita Arias'},
]);
// create an array with edges
var edges = new vis.DataSet([
{from:'10209700427879693', to: '10155527253184465'},
]);
// create a network
var container = document.getElementById('mynetwork');
var data = {
nodes: nodes,
edges: edges
};
var options = {};
var network = new vis.Network(container, data, options);
</script>
</body>
</html>
#walkcursor and extractt info in an especific format
var cursor = db.collection.find();
while (cursor.hasNext()) { data=cursor.next(); for(var x=0; x< data.friends.length;x++){print("{from:'"+data.facebook_id+"', to: '"+data.friends[x].id+"'},")}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment