Skip to content

Instantly share code, notes, and snippets.

Lawrence Cherone lcherone

Block or report user

Report or block lcherone

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.js
/**
* A handy module pattern
*/
const Module = (function () {
/*
** Private variables
*/
let private = {
i: 0
@lcherone
lcherone / gist:5e2283e5659a2ebba1de09013ce223ba
Last active May 23, 2019
Express SPA history API express.static fallback
View gist:5e2283e5659a2ebba1de09013ce223ba

Mostly taken from: https://gitlab.com/sebdeckers/express-history-api-fallback, without all the repo/package fluff.

let staticPath = '/path/to/dist'

app.use(express.static(staticPath))

app.use('/', ((...args) => (req, res, next) => {
  if ((req.method === 'GET' || req.method === 'HEAD') && req.accepts('html')) {
    (res.sendFile || res.sendfile).call(res, ...args, err => err && next())
@lcherone
lcherone / index.md
Created May 19, 2019
Template variable replacement, js and php
View index.md

In PHP

<?php
$vars = [
  'name' => 'Loz'
];

$template = 'Hello {{ name }}!';
@lcherone
lcherone / lxc-exec-all.sh
Created Sep 20, 2017
LXD run command in all running containers
View lxc-exec-all.sh
#!/bin/bash
#
# Run command in all running containers
# Usage: $ ./lxc-exec-all.sh apt update && apt upgrade
#
for container in $(lxc list volatile.last_state.power=RUNNING -c n --format csv); do
lxc exec "$container" "$@"
done
@lcherone
lcherone / asyncDirListNaturalSort.js
Last active May 3, 2019 — forked from oliverswitzer/nonModuleDirList.js
Async load list of files from directory, with optional extensions filtering and natural sort in nodejs
View asyncDirListNaturalSort.js
// asyncDirListNaturalSort.js
const path = require('path')
const fs = require('fs')
/**
* Asynchronous load list of files from directory,
* - with optional extensions filtering and natural sort
*
* @param {string} dirPath directory path to folder
@lcherone
lcherone / lxd 1000000.md
Last active Apr 29, 2019
Broken LXD 1000000 mapping, since some update
View lxd 1000000.md

Make sure got volatile keys in config:

lxc config edit my-borked-container

Lookout for these, if they are missing adding them and restarting the container should fix it.

  volatile.idmap.base: "0"
@lcherone
lcherone / encryption.js
Last active Apr 22, 2019
AES CBC Encryption helper nodejs
View encryption.js
const crypto = require("crypto");
/**
* AES CBC Encryption helper
*
* Usage:
* ``` javascript
//
const encryption = require('@lib/encryption');
View gist:55d982b6bd67421451dabde708d25522
.social_wrapper2,
.social_youtube,
.socialaccounts,
.socialakamai,
.socialarea,
.socialb,
.socialb_tg,
.socialbadge,
.socialbar-mobile,
.socialbar-wrap-bottom,
View c9-lamp-prep.sh
#!/bin/bash
#
# Cloud9 Prep & LAMP Server
# Apache2 (rewrite, headers enabled), PHP7, MariaDB, Git, Composer, nodejs & npm
#
# Set envioroment, for cloud-init
set -e
export DEBIAN_FRONTEND=noninteractive
@lcherone
lcherone / disposable-email-provider-domains
Last active Sep 20, 2018 — forked from michenriksen/disposable-email-provider-domains
List of disposable email provider domains
View disposable-email-provider-domains
0815.ru
0815.ru0clickemail.com
0815.ry
0815.su
0845.ru
0clickemail.com
0-mail.com
0wnd.net
0wnd.org
10mail.com
You can’t perform that action at this time.