Skip to content

Instantly share code, notes, and snippets.

View phuwin1995's full-sized avatar

Phu Nguyen phuwin1995

  • Helsinki, Finland
View GitHub Profile
@phuwin1995
phuwin1995 / index.js
Last active September 4, 2018 09:01
Get a project point to a closest line in an array of lines
// http://jsfiddle.net/soulwire/UA6H5/
function projectPointToLine(x, y, x1, y1, x2, y2) {
const p = {
x: x,
y: y
},
a = {
x: x1,
y: y1
},
@phuwin1995
phuwin1995 / filesread.js
Last active July 18, 2017 09:28
Filesread for angular input. This supports multiple files adding.
app.directive("filesread", [function () {
return {
scope: {
filesread: "="
},
link: function (scope, element, attributes) {
element.bind("change", function (changeEvent) {
var files = changeEvent.target.files;
for (var i = 0; i < files.length; i++) {
var reader = new FileReader();