Skip to content

Instantly share code, notes, and snippets.

@NatasaPeic
NatasaPeic / chatServer.js
Created September 24, 2018 22:13 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@NatasaPeic
NatasaPeic / nodejs-tcp-example.js
Created September 24, 2018 22:13 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@NatasaPeic
NatasaPeic / GenericMultiListIterator.java
Created June 11, 2018 15:29 — forked from deepika087/GenericMultiListIterator.java
Iterates through (generic) List of List <<a1,a2>, <b1,b2,b3,b4>, <c1,c2,c3,c4,c5,c6,c7>> Generates output a1, b1, c1, a2, b2, c2, b3, c3, b4, c4,c5,c6,c7
package com.expedia.sample;
import java.util.ArrayList;
import java.util.Iterator;
public class MultiListIterator<E> implements Iterator<E> {
private ArrayList<ArrayList<E>> useThisList;
private int numOfList;
private int[] sizeOfEachList;
@NatasaPeic
NatasaPeic / README.md
Created May 14, 2018 13:37 — forked from markmarkoh/README.md
US Zip Codes

This is a d3.js visualization of US zip codes.

Original zip code dataset from Geocommons.

5MB shapefile with properties such as zipcode, state, name, population, area, more.

http://geocommons.com/overlays/54893 (Thank you Bill Greer)

This converts it nicely:

@NatasaPeic
NatasaPeic / toblob.js
Created May 10, 2018 16:37
Canvas toBlob() polyfill
(function(global) {
if (!('HTMLCanvasElement' in global)) return;
if (!('toDataURL' in global.HTMLCanvasElement.prototype)) return;
if ('toBlob' in global.HTMLCanvasElement.prototype) return;
Object.defineProperty(global.HTMLCanvasElement.prototype, 'toBlob', {
value: function(callback/*, type, encoderOptions*/) {
var url = this.toDataURL.apply(this, [].slice.call(arguments, 1));
var m = /^data:(.*?);base64,(.*)$/.exec(url), type = m[1], b64 = m[2];
setTimeout(function() {
callback(new Blob([
@NatasaPeic
NatasaPeic / index.html
Created March 13, 2018 14:45 — forked from pmanijak/index.html
Service example with AngularJS for sharing scope data between controllers
<!doctype html>
<html ng-app="project">
<head>
<title>Angular: Service example</title>
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<script>
var projectModule = angular.module('project',[]);
projectModule.factory('theService', function() {
return {
var util = require('util'),
http = require('http'),
httpProxy = require('http-proxy');
function request_handler(proxy, req, res) {
// http(s) requests.
proxy.web(req, res, function (err) {
console.log(err.stack);
res.writeHead(502);
res.end("There was an error. Please try again");
@NatasaPeic
NatasaPeic / app.js
Created September 18, 2017 22:38 — forked from clarle/app.js
Short tutorial on how to use Express and node-mysql
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@NatasaPeic
NatasaPeic / index.html
Created August 16, 2017 12:53 — forked from enjalot/index.html
Simple Pie Chart example with D3.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Testing Pie Chart</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script>
<style type="text/css">
@NatasaPeic
NatasaPeic / d3.html
Created July 14, 2017 19:49 — forked from LevelbossMike/d3.html
creating table from array of json with d3
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<table id="split">
<thead></thead>
<tbody></tbody>