Skip to content

Instantly share code, notes, and snippets.

View juanbrusco's full-sized avatar
🏠
Working from home

Juan Ariel Brusco juanbrusco

🏠
Working from home
View GitHub Profile
@juanbrusco
juanbrusco / PY0101EN-1-1-Types.ipynb
Created July 23, 2020 15:49
Created on Skills Network Labs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
## HTML
<div class="row">
<div class="col-sm-12">
<ul class="list-inline rating-list"
*ngFor="let star of stars" style="display: inline-block" >
<li (click)="countStar(star)"
[ngClass]="{'selected': (star <= selectedValue)}">
<i class="fa fa-star"></i>
</li>
</ul>
@juanbrusco
juanbrusco / compare-to-sort-array.js
Created May 23, 2019 18:43
Sort arrays by key- Javascript
//https://www.sitepoint.com/sort-an-array-of-objects-in-javascript/
compare(a, b) {
const genreA = a.servicebillingfact.rec_version_num;
const genreB = b.servicebillingfact.rec_version_num;
let comparison = 0;
if (genreA < genreB) {
comparison = 1;
} else if (genreA > genreB) {
comparison = -1;
@juanbrusco
juanbrusco / clone-object.js
Last active June 27, 2019 18:04
Clone object (avoid mutation) - Javascript
// https://scotch.io/bar-talk/copying-objects-in-javascript
private clone(obj) {
let copy;
// Handle the 3 simple types, and null or undefined
if (null == obj || "object" != typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
@juanbrusco
juanbrusco / for-objects-array.js
Created April 9, 2019 18:45
Object array iteration - Javascript
// Método Array#forEach
var miArray = [ 2, 4, 6, 8, 10 ];
miArray.forEach( function(valor, indice, array) {
console.log("En el índice " + indice + " hay este valor: " + valor);
});
// Método Object#keys combinado con Método Array#forEach
var obj = {
first: "John",
last: "Doe"
@juanbrusco
juanbrusco / read-json-file.js
Created April 9, 2019 15:29
Read json file - Javascript
questions_template = [];
getQuestionsTemplate() {
let template = require('./datamodel_questions_template.json');
for (var key in template) {
if (!template.hasOwnProperty(key)) continue;
if (key === "questions") {
var obj = template[key];
for (var prop in obj) {
@juanbrusco
juanbrusco / remove-object-array.js
Last active January 25, 2019 15:19
Remove Object From Array - Javascript
// non destructive filter > noJohn = John removed, but someArray will not change
let someArray = getArray();
let noJohn = someArray.filter( el => el.name !== "John" );
// destructive splice /w findIndex
let someArray3 = getArray();
someArray3.splice(someArray3.findIndex(v => v.name === "John"), 1);
function getArray() {
return [ {name: "Kristian", lines: "2,5,10"},
@juanbrusco
juanbrusco / transform-text-link.js
Created November 7, 2018 19:57
Transform Text To Link - React + Js
@juanbrusco
juanbrusco / break-long-word.scss
Created November 7, 2018 19:05
Break Words - CSS
.dont-break-out {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
@juanbrusco
juanbrusco / order-array.js
Created November 5, 2018 18:19
Order Array - Javscript
function order(arraylist){
return arraylist.sort(this.sortThings);
}
function sortThings(a, b) {
if (a.NOMBRE > b.NOMBRE) {
return 1;
} else if (a.NOMBRE < b.NOMBRE) {
return -1;
} else if (a.NOMBRE === b.NOMBRE) {