Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈

Ricardo Canelas ricardocanelas

🦈
View GitHub Profile
View preact-example.html
<!DOCTYPE html>
<html>
<head>
<title>Preact</title>
</head>
<body>
<script type="module">
import {
html,
render,
@ricardocanelas
ricardocanelas / embedVideo.js
Created Jul 16, 2020
Embed Video (youtube & vimeo)
View embedVideo.js
function stripParameters(str) {
// Split parameters or split folder separator
if (str.indexOf('?') > -1) {
return str.split('?')[0]
} else if (str.indexOf('/') > -1) {
return str.split('/')[0]
}
return str
}
View server.js
const { createServer } = require('https')
const { parse } = require('url')
const next = require('next')
const selfsigned = require('selfsigned')
// const fs = require('fs')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
View custom-checkbox-twbs.scss
$custom-checkbox-color: $color-brand-wcag-3-1;
$custom-checkbox-size: 24px;
.custom-checkbox {
.custom-control-input {
opacity: 0;
width: $custom-checkbox-size;
height: $custom-checkbox-size;
}
@ricardocanelas
ricardocanelas / utilities.scss
Last active Jun 24, 2020
Utility-Class (like Bootstrap 5) buut.. in a simple way
View utilities.scss
$grid-breakpoints: (
xs: 0,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1400px
);
$utilities: (
View template-engine-simple.js
export const template = function (tpl, data) {
if (typeof tpl !== 'string') return ''
if (typeof data !== 'object') return tpl
const interpolate = new RegExp('{{(.+?)}}', 'gi')
let result = tpl
result = result.replace(interpolate, (...args) => {
const values = args[1] ? args[1].trim().split('||') : ''
@ricardocanelas
ricardocanelas / class-fn.md
Created Jun 8, 2020
javascript-class-method
View class-fn.md

Class

class Star {
  constructor(name) {
    this.name = name;
  }
  getMessage(message) {
    return this.name + message;
@ricardocanelas
ricardocanelas / server-with-static.js
Last active May 14, 2020
Simple server using http
View server-with-static.js
const http = require('http');
const url = require('url');
const path = require('path')
const fs = require('fs');
const mimeTypes = {
"html": "text/html",
"mp3":"audio/mpeg",
"mp4":"video/mp4",
"jpeg": "image/jpeg",
View isTouchDevice.js
const isTouchDevice = () => {
const prefixes = ['', '-webkit-', '-moz-', '-o-', '-ms-', ''];
const mq = query => window.matchMedia(query).matches;
if (
'ontouchstart' in window ||
(window.DocumentTouch && document instanceof 'DocumentTouch')
) {
return true;
}