Skip to content

Instantly share code, notes, and snippets.

Working from home

Sean Delaney seandelaney

Working from home
View GitHub Profile
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);
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);
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
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: {
yidas /
Last active Apr 1, 2020
JavaScript nl2br & br2nl functions

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.


izzygld / Wysiwyg.vue
Created Jan 9, 2019
Adding a “show html” button in Quill (Wysiwyg).
View Wysiwyg.vue
<vue-editor v-model="content" ref="editor" :editor-options="toolbarOptions" @text-change="updateValue" useCustomImageHandler @imageAdded="uploadImage"></vue-editor>
import Vue from "vue";
import axios from 'axios'
let VueEditor, Quill;
yidas /
Last active May 15, 2020
JavaScript HTML Entities Encode & Decode
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()) {
chrisjhoughton / wait-el.js
Last active Jun 25, 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) {
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
jfloff /
Last active Jun 30, 2020
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

You can’t perform that action at this time.