Skip to content

Instantly share code, notes, and snippets.

View mornir's full-sized avatar
🎮
Gaming

Jérôme Pott mornir

🎮
Gaming
View GitHub Profile
@mornir
mornir / furigana.js
Created April 20, 2018 13:35
Transform furigana
const str = "I can speak {日本語,にほんご} read {漢字,かんじ}"
const regex = /{(\S+?),(\S+?)}/g
const newStr = str.replace(regex, `
<ruby>
$1 <rp>(</rp><rt>$2</rt><rp>)</rp>
</ruby>`)
const obj = {video: {name: 'cat', duration:30}}
obj.map({video} => video.cat, video.duration)
const data = {
key: 314343214,
data: {
name: 'hello',
duration: 44
}
object-fit: cover (for img)
backgroud-size: cover (for url(''))
@mornir
mornir / info.md
Last active April 5, 2018 16:49
#flexbox #grid

Flexbox

justify-content = main axis

align-items = cross axis

align-content = cross axis with wrap; to be used when weird gap appear between rows/columns

Grid

photo gallery: grid-template-columns: repeat(auto-fit, minmax(154px, 1fr));

@mornir
mornir / path.md
Created April 5, 2018 16:47
Absolute path vs Relative path

absolut path: /images/flower.png relative path: ./images/flower.png (or images/flower.png) or ../../images/flower.png

background-color: #f5f5f5 nice to the eyes nice yellow : #ffc600 or #ffc40e nice gray: #222;

@mornir
mornir / fetch_get.js
Created March 14, 2018 20:50
Passing parameters to fetch when making fetch requests
const params = { a: 'foo', b: 'bar' };
const urlParams = new URLSearchParams(Object.entries(params));
fetch('/some/url?' + urlParams);
@mornir
mornir / sorting_array_objects.js
Created March 13, 2018 07:58
sorting array of objects
function sortListBy(Parameter, List) {
return List.sort((a, b) => {
if (a[Parameter] > b[Parameter]) {
return 1
} else {
return -1
}
})
}
@mornir
mornir / reduce.js
Created February 28, 2018 19:51
Use_Cases for reduce
const javDetails = detailsList.reduce((acc, detail) => {
let key = detail.childNodes[0].textContent
let value = detail.childNodes[1].textContent
return { ...acc, [key]: value }
}, {})