Skip to content

Instantly share code, notes, and snippets.

View GerardoLSJ's full-sized avatar

Gerardo Lopez Santibañez GerardoLSJ

View GitHub Profile
@GerardoLSJ
GerardoLSJ / bfs.js
Last active June 8, 2021 00:49
Breadth FIrst Search over a matrix using Javascript
/* Have the function ClosestNeighbour(strArr) read the matrix of numbers stored in strArr which
will be a 2D matrix that contains only the integers 1, 0, or 2.
Then from the position in the matrix where a 1 is, return the number of spaces either left,
right, down, or up you must move to reach an enemy which is represented by a 2.
You are able to wrap around one side of the matrix to the other as well.
For example: if strArr is ["0000", "1000", "0002", "0002"] then this looks like the following:
0 0 0 0
1 0 0 0
@GerardoLSJ
GerardoLSJ / shell.c
Created March 3, 2018 02:44 — forked from parse/shell.c
Simple shell in C
/* Compile with: g++ -Wall –Werror -o shell shell.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
@GerardoLSJ
GerardoLSJ / bar-chart.component.ts
Created November 23, 2017 18:24
Create a reusable chart component with Angular and D3.js RESPONSIVE TO WINDOW CHANGES
// ORIGINAL POST AND CREDITS:
// https://keathmilligan.net/create-a-reusable-chart-component-with-angular-and-d3-js/
// I just added a few changes to make it responsive
import { Component, OnInit, OnChanges, ViewChild, ElementRef, Input, ViewEncapsulation } from '@angular/core';
import * as d3 from 'd3';
@Component({
selector: 'app-bar-chart',
@GerardoLSJ
GerardoLSJ / material-image-angular.js
Created June 29, 2017 21:53
Google material images responsive in Angular Directive. CREDITS: GerardoLSJ and xieranmaya
.directive('materialImg', function () {
return {
restrict: 'EA',
scope: {
img: '=image'
},
replace: true,
template: '\n <div class="div-flex" ui-sref="app.detail( {imgObj:img} )" \n\t\t\t\tstyle="width:{{img.width*130/img.height}}px;flex-grow:{{img.width*200/img.height}}">\n <i class="i-flex" style="padding-bottom:{{img.height/img.width*100}}%"></i>\n <img class="img-flex" src="{{img.url}}" alt="">\n </div>\n \n '
/* ES6 VERSION: