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 / README.md
Created April 23, 2018 19:43 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@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
}
})
}