Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Sean Delaney seandelaney

🏠
Working from home
View GitHub Profile
@julienbourdeau
julienbourdeau / webpack.mix.js
Created Apr 20, 2020
Laravel Mix with multiple Tailwind config and PurgeCSS (separate Admin dashboard and Front app)
View webpack.mix.js
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
const rootPath = Mix.paths.root.bind(Mix.paths);
const tailwindPlugins = function(configFile, paths) {
const pluginList = [tailwindcss(configFile)];
if (mix.inProduction()) {
pluginList.push(require('@fullhuman/postcss-purgecss')({
@izzygld
izzygld / Wysiwyg.vue
Created Jan 9, 2019
Adding a “show html” button in Quill (Wysiwyg).
View Wysiwyg.vue
<template>
<div>
<vue-editor v-model="content" ref="editor" :editor-options="toolbarOptions" @text-change="updateValue" useCustomImageHandler @imageAdded="uploadImage"></vue-editor>
</div>
</template>
<script>
import Vue from "vue";
import axios from 'axios'
let VueEditor, Quill;
@yidas
yidas / js-encode-decode.md
Last active May 15, 2020
JavaScript HTML Entities Encode & Decode
View js-encode-decode.md
@yidas
yidas / js-nl2br-br2nl.md
Last active Apr 1, 2020
JavaScript nl2br & br2nl functions
View js-nl2br-br2nl.md

JavaScript nl2br & br2nl functions

The exchange of new line & br HTML tag could refer to PHP - nl2br() function, which uses to inserts HTML line breaks before all newlines in a string.

These JavaScript functions consider whether to use insert or replace to handle the swap.

nl2br

@aganglada
aganglada / script-cache.js
Created Feb 24, 2017
Script Cache Promise based
View script-cache.js
let counter = 0;
let scriptMap = new Map();
export const ScriptCache = (function(global) {
return function ScriptCache (scripts) {
const Cache = {};
Cache._onLoad = function(key) {
return (cb) => {
let stored = scriptMap.get(key);
View webpack.config.js
let webpack = require('webpack');
let path = require('path');
module.exports = {
entry: {
app: './resources/assets/js/app.js',
vendor: ['vue', 'axios']
},
output: {
View typo-check.js
function checkForCloseMatch(longString, shortString) {
// too many false positives with very short strings
if (shortString.length < 3) return '';
// test if the shortString is in the string (so everything is fine)
if (longString.includes(shortString)) return '';
// split the shortString string into two at each postion e.g. g|mail gm|ail gma|il gmai|l
for (let i = 1; i < shortString.length; i++) {
const firstPart = shortString.substring(0, i);
@remarkablemark
remarkablemark / Dockerfile
Last active Jul 1, 2020
Install node and npm with nvm using Docker.
View Dockerfile
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@oslego
oslego / gist:f13e136ffeaa6174289a
Last active Jan 3, 2019 — forked from sl4m/gist:5091803
create self-signed certificate for localhost
View gist:f13e136ffeaa6174289a
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@chrisjhoughton
chrisjhoughton / wait-el.js
Last active Jul 10, 2020
Wait for an element to exist on the page with jQuery
View wait-el.js
var waitForEl = function(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
}
};
You can’t perform that action at this time.