Skip to content

Instantly share code, notes, and snippets.

View hdvianna's full-sized avatar
🎯
Focusing

hdvianna hdvianna

🎯
Focusing
View GitHub Profile
@hdvianna
hdvianna / spiral.js
Created April 2, 2019 19:50
JS Spiral Matrix Iterator
function border(matrix, row, col, len) {
var items=[];
var endCol = col - 1;
var endRow = row;
//top
for(;col < len; col++) {
items.push(matrix[row][col]);
@hdvianna
hdvianna / compare-files.php
Created April 2, 2019 19:48
PHP Dummy File Comparator
<?php
define("STOP_WORDS", ["the","of","in","and","a","to","on","by","when","or","with","that","this","also","from","an","it","as","these","."]);
function iteratesWords($lineA, $lineB) {
$wordsA = preg_split("/[\s\.\,\?\;\(\)\-\%\{\}]/", $lineA);
$wordsB = preg_split("/[\s\.\,\?\;\(\)\-\%\{\}]/", $lineB);
$words = [];
foreach($wordsA as $wordA) {
foreach($wordsB as $wordB) {
@hdvianna
hdvianna / closure-test.js
Created April 2, 2019 19:47
JS Closure Examples
/**
* Bind com let i = 0
* Bind com let i = 1
* Bind com let i = 2
* Bind com let i = 3
* Bind com let i = 4
*/
for(let i = 0; i < 5; i++) {
setTimeout(function(){
console.log('Bind com let i = '.concat(i));