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 / 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));

object-fit: cover (for img)
backgroud-size: cover (for url(''))
const obj = {video: {name: 'cat', duration:30}}
obj.map({video} => video.cat, video.duration)
const data = {
key: 314343214,
data: {
name: 'hello',
duration: 44
}
@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>`)
@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 / codewar-challenge.js
Last active December 7, 2018 15:13
alphabetPosition
function alphabetPosition(text) {
const arrayOfLetters = text.toLowerCase().split('')
return arrayOfLetters.map(letter => {
const code = letter.charCodeAt()
if(code < 97 || code > 122) return null
return code - 96
@mornir
mornir / react.js
Last active June 8, 2019 12:41
React Component in Sanity editor
/**
* This is the schema definition for the rich text fields used for
* for this blog studio. When you import it in schemas.js it can be
* reused in other parts of the studio with:
* {
* name: 'someName',
* title: 'Some title',
* type: 'blockContent'
* }
*/
@mornir
mornir / merge_clients.js
Created June 22, 2019 10:41
Merge preview and client sanity
import Vue from 'vue'
import imageUrlBuilder from '@sanity/image-url'
import sanityClient from '@sanity/client'
function setUpSanity(isDraft = false) {
return sanityClient({
// Find your project ID and dataset in `sanity.json` in your studio project
projectId: process.env.SANITY_PROJECT_ID,
dataset: 'production',
@mornir
mornir / index.js
Created August 5, 2019 08:35 — forked from dan-dr/index.js
Sanity Backup to Dropbox on webtask.io
const sanity = require('@sanity/client')
const fs = require('fs')
const EOL = require('os').EOL
const flatMap = require('lodash.flatmap')
const { subDays, isBefore } = require('date-fns')
const sanityExport = require('@sanity/export')
/**
* @param context {WebtaskContext}
*/
@mornir
mornir / list_file.js
Created August 12, 2019 18:45
Netlify Cloud Function List file from Google Drive
const {google} = require('googleapis');
const path = require('path');
const fs = require('fs');
function getCredentials() {
const filePath = path.join(__dirname, 'keys.json');
if (fs.existsSync(filePath)) {
return require(filePath);
}
if (process.env.CREDENTIALS) {