Skip to content

Instantly share code, notes, and snippets.

Avatar

Lawrence Cherone lcherone

View GitHub Profile
View php.js
function abs(mixed_number) {
return Math.abs(mixed_number) || 0;
}
function acos(arg) {
return Math.acos(arg);
}
function acosh(arg) {
return Math.log(arg + Math.sqrt(arg * arg - 1));
@lcherone
lcherone / file.php
Last active Jan 2, 2021
manual wordpress serialize fixer
View file.php
<?php
$str = 'a:1:{s:3:"foo";s:23:"https://beta.domain.com";}';
echo serialize(json_decode(str_replace('beta.domain.com', 'domain.com', json_encode(unserialize($str))), true));
// a:1:{s:3:"foo";s:18:"https://domain.com";}
@lcherone
lcherone / script.js
Last active Dec 12, 2020
Minio Migrate All - Script to migrate all buckets and files from one S3 server to another.
View script.js
/**
* S3 migration script
*
* Use this script to migrate all buckets and files from one S3 server to another.
*
* Author: Lawrence Cherone
*/
const HOSTS = {
from: {
View index.js
const range = (start, end, step) => {
const range = []
typeof step === 'undefined' && (step = 1)
if (end < start) step = -step
while (step > 0 ? end >= start : end <= start) {
range.push(start)
start += step
}
return range
}
@lcherone
lcherone / disposable-email-provider-domains
Last active Oct 27, 2020 — 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
@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 / WordPress.sh
Last active Aug 17, 2020
WordPress Installer
View WordPress.sh
#!/bin/bash
# LXC.systems - Cloud Script - https://lxc.systems/cloud-script/MQCeGU1
#
# Title -------: WordPress Install
# Description -: This cloud script will install all base system packages, a LAMP server and the latest version of WordPress. It will work on any Ubuntu server from version 12.04 to 17.04.
# Created -----: June 17th 2017, 8:58pm
# Updated -----: June 21st 2017, 12:09am
# Usage ------: wget -O - https://lxc.systems/cloud-script/MQCeGU1 | sudo sh
# bash <(curl -s https://lxc.systems/cloud-script/MQCeGU1)
@lcherone
lcherone / lxd 1000000.md
Last active Jul 21, 2020
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 / script.js
Created Jul 11, 2020
js async queue
View script.js
const queue = []
Object.defineProperty(queue, 'push', {
configurable: true,
enumerable: false,
writable: true,
value: function (...args) {
console.log('queue changed')
if (typeof args[0] === 'function') args[0]()
return Array.prototype.push.apply(this, args)
}
@lcherone
lcherone / script.js
Created Jun 27, 2020
asynchronous IIAFE in a for loop, with step timing
View script.js
console.log('asynchronous IIAFE in a for loop, with step timing')
for (let i = 0; i <= 10; i++)
setTimeout(
async () =>
(async function (index) {
console.log(index)
})(i),
i * 250
)