Skip to content

Instantly share code, notes, and snippets.

@bartcis
bartcis / algo_mid_one_3.js
Last active August 5, 2019 18:42
Difference between two arrays - solution 3
const arrayOne = [1, 4, 5, 7, 3, 8, 1, 9];
const arrayTwo = [3, 7, 1, 12, 9, 5, 24, 16];
function diffArrayInt(array1, array2) {
// 1. Return a new array that will follow this rules
return (
// 2. Combine two arrays
[...array1, ...array2]
// 3. Check each element if it's unique return in a new array
.filter((item) => !array1.includes(item) || !array2.includes(item))
@bartcis
bartcis / algo_mid_one_2.js
Last active August 5, 2019 18:41
Difference between two arrays - solution 2
const arrayOne = [1, 4, 5, 7, 3, 8, 1, 9];
const arrayTwo = [3, 7, 1, 12, 9, 5, 24, 16];
function diffArrayInt(array1, array2) {
// 1. Create new array
const newArr = [];
// 2. Combine the two array and sort
const orderedArr = [...array1, ...array2].sort();
// 3. Loop through the ordered Array
@bartcis
bartcis / algo_mid_one_1.js
Last active August 5, 2019 18:41
Difference between two arrays - solution 1
const arrayOne = [1, 4, 5, 7, 3, 8, 1, 9];
const arrayTwo = [3, 7, 1, 12, 9, 5, 24, 16];
function diffArrayBasic(array1, array2) {
// 1 - Create empty string to be returned
let newArray = [];
// 2 - Function that finds unique element in regards to the other array
function uniqueElement(first, second) {
// 3 - Loop through an array
@bartcis
bartcis / specificity_solution2.css
Created May 12, 2019 14:51
Hack around !important
.new-input.new-input.new-input {
color: blue;
}
@bartcis
bartcis / specificity_solution1.css
Created May 12, 2019 14:49
First solution for the problem
.new-input[type="text"] {
color: blue;
}
@bartcis
bartcis / modified_style_2.css
Created May 12, 2019 14:43
Styles with !important rule
.old-input[type="text"],
.old-input[type="email"],
.old-input[type="number"] {
color: red;
}
.new-input {
color: blue !important;
}
@bartcis
bartcis / modified_style.css
Created May 12, 2019 14:41
First modification of styles
.old-input[type="text"],
.old-input[type="email"],
.old-input[type="number"] {
color: red;
}
.new-input {
color: blue;
}
@bartcis
bartcis / initial_styles.css
Created May 12, 2019 14:38
Initial styles for inputs
.old-input[type="text"],
.old-input[type="email"],
.old-input[type="number"] {
color: red;
}
@bartcis
bartcis / specificity_calc.css
Created May 12, 2019 14:02
Sample calculation of Specificity
// 0-1-0 + 0-1-0 + 0-1-0 = 0-3-0
.form__field__input:placeholder-shown + .form__field__label {
color: red;
}
// 1-0-0 + 0-0-1 + 0-0-1 = 1-0-2
#wrapper ul li {
color: red;
}
@bartcis
bartcis / placeholder.css
Last active May 12, 2019 10:00
Invaild status placeholde fix
// Zmodyfikowany styl
.form__field__input:invalid + .form__field__label {
top: -.5rem;
font-size: .6rem;
}
// Oryginalny styl - reset modyfikacji jeśli placeholder istnieje
.form__field__input:placeholder-shown + .form__field__label {
top: .35rem;
font-size: 1rem;