Skip to content

Instantly share code, notes, and snippets.

View EnetoJara's full-sized avatar
🐼
I may be slow to respond.

Ernesto Jara Olveda EnetoJara

🐼
I may be slow to respond.
View GitHub Profile
importScripts(
"https://storage.googleapis.com/workbox-cdn/releases/6.0.2/workbox-sw.js"
);
// Note: Ignore the error that Glitch raises about workbox being undefined.
workbox.setConfig({
debug: true,
});
self.skipWaiting();
/**
* Registers a valid service worker.
*
* @param {string} swUrl - url of the service worker.
* @param {Object} [config] - functions that will trigger on success or update.
* @param {(registration: ServiceWorkerRegistration) => void} [config.onSuccess] - after the service worker is installed successfully this callback will be called.
* @param {(registration: ServiceWorkerRegistration) => void} [config.onUpdate] - after the service worker is updated successfully this callback will be called.
*/
function registerValidSW(swUrl, config) {
return navigator.serviceWorker
@EnetoJara
EnetoJara / mysql
Last active January 21, 2021 23:36
version: "3.3"
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./mysql-dump:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: "tutorial"
import React from "react";
import defaultImage from "./default-profile.jpg";
function If (props) {
if (!props.condition) {
return <>{ null }</>;
}
return <>{ props.children }</>;
}
function ImageUpload () {
import React, { FormEvent } from "react";
import "./styles.scss";
export interface Pics {
id: number;
path: string;
alt: string;
}
export interface CarouselProps {
pics: Pics[];
const crypto = require("crypto");
const algorithm = "aes-256-cbc";
const iv = "%i!>Z+e"
const key = "7xFx-oli,Szlc%5D/k0&vq4b"
function scrypt (num, secret) {
return new Promise((res, rec) => {
return crypto.scrypt(secret, "salt", num, (err, key) => {
if (err) return rec(err);
function encryptText (toEncript) {
let i, k;
return getIv()
.then(iv => {
i = iv;
return getKey()
}).then(key => {
k = key;
import { AccountAttributes, Repository } from "@eneto/models";
import { DataTypes, Sequelize } from "sequelize";
/**
* Account factory
*
* @param {import("sequelize").Sequelize} sequelize Sequelize database instance.
* @returns {Repository<AccountAttributes>} Instance of Accounts Entity.
*/
function AccountFactory(sequelize: Sequelize): Repository<AccountAttributes> {
import { connect } from "react-redux";
import { AppState } from "@eneto/api-client";
import { LandingPage } from "../components/lists";
import { lists } from "../modules/lists";
import { listsAction } from "../modules/lists/lists-actions";
const stateToProps = (state: AppState) => ({
lists: [...lists(state)],
});
const dispatchToProps = {
import * as React from "react";
import * as Loadable from "react-loadable";
const Loading = (): React.ReactElement => <span>Loadong</span>;
export const List = Loadable({
loader: () => import(/* webpackChunkName: "lists" */ "./list-constainer"),
loading: Loading,
});