Skip to content

Instantly share code, notes, and snippets.

@lcherone
lcherone / wait.sh
Last active April 6, 2018 17:22
Linux wait for network connection before continuing. Docker, LXC, containers, cloud-init
#/bin/bash
echo "Waiting for network connection."
while [ 1 ]; do
if ping -q -c 1 -W 1 8.8.8.8 > /dev/null 2>&1; then
break;
fi
sleep 1
done
@lcherone
lcherone / hash_file_multi.php
Created March 26, 2018 12:35
hash_file_multi() hash a single file with multiple algorithms PHP
<?php
function hash_file_multi($algos = [], $filename) {
if (!is_array($algos)) {
throw new \InvalidArgumentException('First argument must be an array');
}
if (!is_string($filename)) {
throw new \InvalidArgumentException('Second argument must be a string');
}
@lcherone
lcherone / WordPress.sh
Last active August 17, 2020 06:53
WordPress Installer
#!/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 / CSS inline custom properties.md
Created February 7, 2018 11:12
CSS inline custom properties

CSS inline custom properties

Markup

<div class="el" 
style="
   --spacetop:40px;
   --spaceleft:20px;
   --spacetopmobile:10px;

--spaceleftmobile:5px

@lcherone
lcherone / write_ini_file.md
Created January 24, 2018 23:31
PHP write_ini_file implementation

Below is an implementation of write_ini_file() which PHP is currently lacking, it will create an almost identical (except comments) of the input:

  • Supports cross platform (PHP_EOL) new lines added between sections.
  • Handles both index and key value arrays.
  • Handles CONSTANT style values.
  • And file locking to stay consistent.

Source

php

{
"current": [
{
"version": "Ubuntu 17.10",
"codename": "Artful Aardvark",
"release_date": "October 19, 2017",
"end_of_life": "July 2018",
"links": [
"https://wiki.ubuntu.com/ArtfulAardvark",
"https://wiki.ubuntu.com/ArtfulAardvark/ReleaseNotes",
@lcherone
lcherone / 33.php
Created January 18, 2018 17:23
Tiny procedural MVC example, with template and nested views.
<?php
// passed from rewrite
$_GET['controller'] = ''; // index page
// controllers map
$controllers = [
'' => 'index.php',
'foobar' => 'foobar.php'
];

You can achieve this by using the [modulus operator][1].

<?php
$result = [
    ['id' => 1, 'product_name' => 'a'],  
    ['id' => 2, 'product_name' => 'b'],  
    ['id' => 3, 'product_name' => 'c'],  
    ['id' => 4, 'product_name' => 'd'],  
    ['id' => 5, 'product_name' => 'e'],  

['id' => 6, 'product_name' => 'f'],

@lcherone
lcherone / reelgood.md
Created January 8, 2018 18:09
Curl requests to access reelgood.com API

Curl requests to access reelgood.com API

<?php
$options = [
    'nocache' => 'true',
    'kind' => 0,
    'minimumScore' => 0,
    'sources' => [
        'amazon_prime',

'fx_tveverywhere',

@lcherone
lcherone / adminer.md
Last active January 3, 2018 23:14
Adminer download

downloads and names the file adminer.php

wget http://www.adminer.org/latest.php -O adminer.php

downloads and names the file adminer-4.2.1.php (E.G with its version number)

wget -N --content-disposition http://www.adminer.org/latest.php