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 / 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,
@lcherone
lcherone / dir.php
Created Sep 16, 2018
Directory Tree Menu
View dir.php
<?php
// https://stackoverflow.com/questions/52348639/how-to-generate-a-recursive-list-of-directories-and-files-with-hyperlinks-to-eac/52348780#52348780
function file_get_listing($path = '')
{
$return = [];
foreach (new IteratorIterator(new DirectoryIterator($path)) as $item) {
if ($item->isDot()) {
continue;
}
$info = [
View gist:8bd1e33dd90c5cc3d7d044f1a3660ad6
<?php
function isPrime($number) {
$n = abs($number);
$i = 2;
while ($i <= sqrt($n)) {
if ($n % $i === 0) {
return false;
}
$i++;
@lcherone
lcherone / developers.json
Last active Jul 11, 2018
snap-ui-featured items
View developers.json
[{
"id": "RT9mcUhVsRYrDLG8qnvGiy26NKvv6Qkd",
"title": "VLC",
"summary": "The ultimate media player",
"icon": "https://dashboard.snapcraft.io/site_media/appmedia/2016/07/vlc.png",
"name": "vlc",
"screenshots": [{
"url": "https://dashboard.snapcraft.io/site_media/appmedia/2016/07/vlc-2.0-poney.jpg"
},
{
You can’t perform that action at this time.