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 / Async_Await_Error_Handling.js
Created December 23, 2017 07:14
Async Await Error Handling
function catchErrors(fn) {
return function (...args) {
return fn(...args).catch((err) => {
console.error('Ohhhh nooo!!!!!');
console.error(err);
});
}
}
const catchError = (fn) => (...params) => fn(...params).catch(e => console.error(e))
@mornir
mornir / vertically_align_text_div.css
Created December 27, 2017 09:48
Vertically Align Short Text in a div
.container > div {
background: #373142;
color: #fff;
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
margin: 5px;
}
@mornir
mornir / nested.js
Created January 1, 2018 21:19
'This' in nested objects
//'this' can only access properties in its current level or below using the dot operator (this.friends.amis). It can access upper levels by referencing the object name (nestedObject.nom)
// no matter how nested the object is, 'this' is an arrow function will always reference the context right **outside** the object.
let nestedObject = {
nom: 'Jérôme',
logDenis() {
console.log(this.friends.amis)
},
friends: {
@mornir
mornir / string_manips.md
Last active January 5, 2018 11:53
strings manipulations

Manipulate strings

Prepend

// optionaly check if prefix already exists
const string = 'localhost:8080'
!string.startsWith('http://') ? 'http://localhost:8080' : ''
const newString = `http://${string}`
@mornir
mornir / my_reset.css
Created January 6, 2018 20:05
My Personal CSS reset rules
/* These rules focus Chrome in first line */
body {
margin: 0;
}
html {
box-sizing: border-box;
}
*,
//pass vm (name is up to you) to data function in order get access to the present vue instance in nested objects
data: vm => ({
valid: true,
name: '',
email: '',
password: '',
confirmPassword: '',
// in a non nested object, 'this' is enough to access the properties in the data function
/* matchPassword2() {
return this.password === this.confirmPassword || 'Password do not match.'
//pass vm (name is up to you) to data function in order get access to the present vue instance in nested objects
data: vm => ({
valid: true,
name: '',
email: '',
password: '',
confirmPassword: '',
// in a non nested object, 'this' is enough to access the properties in the data function
/* matchPassword2() {
return this.password === this.confirmPassword || 'Password do not match.'
<template functional>
<div class="test">
<h1>{{props.msg}}</h1>
<h2>Static content</h2>
<span v-for="n in 10">{{n}} </span>
<button @click="console.log('click', props.msg)"><slot></slot></button>
</div>
</template>
<script>
@mornir
mornir / README.md
Created January 16, 2018 10:36 — forked from CodingDoug/README.md
Building an assistant (chatbot) that translates languages, integrated with Slack
@mornir
mornir / animatefromdisplaynone.md
Last active January 28, 2018 19:36
animate from display none

use max-height or translate off screen