Skip to content

Instantly share code, notes, and snippets.

View Srushtika's full-sized avatar
:octocat:

Srushtika Neelakantam Srushtika

:octocat:
View GitHub Profile
@Srushtika
Srushtika / indian_women_in_data.md
Last active March 6, 2018 14:27 — forked from DevKhokhar/indian_women_in_data.md
List of Indian women who represent the data space in India and globally

Below is a list of Indian women who have contributed it to the data space in India and globally - be it Data Strategy, Data Engineering, Machine Learning, Artificial Intelligence, Data and Public Policy, or any other related field. Please feel free to add in the missing names. I have arranged the names alphabetically for easy searchability. Please do add the name, twitter handle (if available), linkedin profile (if available), link(s) to their public blogs/videos (if available) and the area of specialization. Also, don't forget to add in your name below to the link of contributors. This isn't an individual's effort - this will work only if more and more people contribute. Thanks!

*Note: I have started with just the Indian women here because I wanted to bring attention to some of the inspirational women at the national level. However, if you want to replicate it for any other country or even at a global level, please feel free to either add in into the same list (adding an additional column of course) or cr

@Srushtika
Srushtika / server.js
Created November 16, 2018 14:04
WebSockets server tutorial
const http = require('http');
const static = require('node-static');
const file = new static.Server('./');
const server = http.createServer((req, res) => {
req.addListener('end', () => file.serve(req, res)).resume();
});
const port = 3210;
server.listen(port, () => console.log(`Server running at http://localhost:${port}`));
@Srushtika
Srushtika / client.js
Created November 16, 2018 14:06
WebSocket server tutorial
console.log('WebSocket client script will run here.');
@Srushtika
Srushtika / index.html
Created November 16, 2018 14:08
WebSockets server tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebSocket Example</title>
<script src="client.js"></script>
</head>
<body>
<h1>WebSocket Example</h1>
<p>Open your browser's developer tools to see client/server activity.</p>
</body>
@Srushtika
Srushtika / run-server.sh
Created November 16, 2018 14:10
WebSockets server tutorial
node server.js
@Srushtika
Srushtika / server.js
Created November 16, 2018 14:27
WebSockets server tutorial
server.on('upgrade', (req, socket) => {
// Make sure that we only handle WebSocket upgrade requests
if (req.headers['upgrade'] !== 'websocket') {
socket.end('HTTP/1.1 400 Bad Request');
return;
}
// More to come…
});
@Srushtika
Srushtika / server.js
Created November 16, 2018 14:36
WebSockets server tutorial
// Read the subprotocol from the client request headers:
const protocol = req.headers['sec-websocket-protocol'];
// If provided, they'll be formatted as a comma-delimited string of protocol
// names that the client supports; we'll need to parse the header value, if
// provided, and see what options the client is offering:
const protocols = !protocol ? [] : protocol.split(',').map(s => s.trim());
// To keep it simple, we'll just see if JSON was an option, and if so, include
// it in the HTTP response:
if (protocols.includes('json')) {
// Tell the client that we agree to communicate with JSON data
@Srushtika
Srushtika / client.js
Created November 16, 2018 14:36
WebSockets server tutorial
const ws = new WebSocket('ws://example.org');
@Srushtika
Srushtika / client.js
Created November 16, 2018 14:38
WebSockets server tutorial
ws.addEventListener('open', () => {
// Send a message to the WebSocket server
ws.send('Hello!');
});