Skip to content

Instantly share code, notes, and snippets.

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

Jose Carlos Ixcoatl Gomez Briones brion25

🏠
Working from home
View GitHub Profile
@brion25
brion25 / challenges.tsx
Last active March 17, 2023 22:21
MediaLab challenges
// [1,1,2,2,3,4,4,5,5]
// Version using purely arrays:
// Complexity: LogO because I'm filtering the main array
// to find the repetitions, best scenario, we would need
// 1 iteration (scenario where the first element is the
// one that doesn't have any repetition)
function findRepeatedNumberV1(arr: number[]) {
for(let i = 0; i < arr.length ; i ++) {
const repetitions = arr.filter(num => num === arr[i])
@brion25
brion25 / namespaces.html
Created May 13, 2020 19:20
Implementation Examples
<style>
.bordered {
border-top: dotted 1px var(--color);
border-bottom: solid 2px var(--color);
}
#menu a.bordered {
--color: #111;
}
@brion25
brion25 / namespaces.css
Created May 13, 2020 19:13
CSS namespaces
.bordered {
border-top: dotted 1px var(--color);
border-bottom: solid 2px var(--color);
}
#menu a.bordered {
--color: #111;
}
.post a.bordered {
.bordered(@color) {
border-top: dotted 1px @color;
border-bottom: solid 2px @color;
}
#menu a {
.bordered(#111);
}
.post a {
:root {
--width: 30px;
}
.container {
width: var(--width, 100%);
}
@brion25
brion25 / variables.css
Created April 15, 2020 16:45
use of custom properties
:root {
--width: 30px;
}
.container {
width: var(--width);
}
@brion25
brion25 / variables.css
Last active April 15, 2020 16:39
Variables in preprocessors
--width: 10px;
--shadow: box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
@brion25
brion25 / extends.js
Created February 14, 2019 14:38
Inheritance in JS
class FancyArray extends Array {
multiply() {
this.forEach(el => this.push(el * el))
}
}
const a = new FancyArray(1,2,3,4,5)
a.multiply()
console.log(a)
<my-component [(title)]="myAwesomeTitle"></my-component>
<!--
This means that the 'title' variable is going to point to the variable 'myAwesomeTitle'
if something changes the variable 'title' inside the component 'my-component', the change
is going to be propagated until the variable 'myAwesomeTitle'
-->
<input [(ngModel)]="name" />
<!--
This is an example of a two-way binding to an special directive. This directive is the one
<p>{{myAwesomeText | uppercase}}</p>
<!--
After the expression is evaluated, the value is going to be tranformed to uppercase
-->
<p>{{myAwesomeText?.fallbackValue}}</p>
<!--
In case the variable 'myAwesomeText' is null or undefined, Angular will render the variable
'fallbackValue' As a good practice, the 'fallbackValue' must not be null or undefined
-->