Skip to content

Instantly share code, notes, and snippets.

View leancode's full-sized avatar

Dom leancode

View GitHub Profile
@leancode
leancode / composer
Last active June 15, 2020 07:50 — forked from aydancoskun/composer
composer start-up script to NOT run composer as root user accidentally.
#! /bin/bash
# composer start-up script to NOT run composer as root user accidentally.
# Lets say you are in /home/john/ as root and accidently run composer update
# normally composer would just warn you that you are root and continue anyway,
# possibly wrecking permissions or worse.
# This script runs composer as the correct user even though you are root.
# Sudo is used to switch to the non-root user
# A few checks are made to make sure it makes sense to run composer.
#
# Instructions:
@leancode
leancode / wp
Last active August 15, 2018 10:32
wp-cli start-up script to NOT run wp-cli as root user accidentally.
#! /bin/bash
# Shamelessly addapted from
# https://gist.github.com/aydancoskun/3f14835fdf000b307b89bf7414c0e18d,
# "composer start-up script to NOT run composer as root user accidentally."
# This is wp-cli.phar start-up script to NOT run wp-cli as root user accidentally.
# This script looks at owner of the current directoy and check if the user actually exists.
# If that is affirmative it would then run wp-cli.phar as user John from the current location.
#
# Instructions:
@leancode
leancode / gfonts.php
Created May 2, 2018 08:52 — forked from nikoskip/gfonts.php
Demo: http://nikoskip.me/gfonts.php | You only have to use the CSS import URL that Google gives you, for instance: http://fonts.googleapis.com/css?family=Cabin:500,700,500italic,700italic
<?php
$fontTypes = array('woff2', 'woff', 'ttf', 'svg', 'eot');
$gFontURL = 'http://fonts.googleapis.com/css?family=';
$uaFonts = array(
'woff2' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
'woff' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/4.0; GTB7.4; InfoPath.3; SV1; .NET CLR 3.1.76908; WOW64; en-US)',
'ttf' => 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-ca; LG-P505R Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
'svg' => 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10',
@leancode
leancode / make-sounds.sh
Created March 7, 2018 17:06
asterisk sound conversion script from .aiff to .gsm, .alaw, .ulaw and 16 bit .wav using sox
#!/bin/bash
for a in $(find . -name '*.aiff'); do
sox --norm $a -t gsm -r 8k -c 1 `echo $a|sed "s/.aiff/.gsm/"`;\
sox --norm $a -t raw -r 8k -c 1 -e a-law `echo $a|sed "s/.aiff/.alaw/"`;\
sox --norm $a -t raw -r 8k -c 1 -e u-law `echo $a|sed "s/.aiff/.ulaw/"`;\
# sox --norm $a -t wav -r 8k -c 1 -e signed-integer `echo $a|sed "s/.aiff/.WAV/"`;\
sox --norm $a -r 16k -c 1 -e signed-integer -b 16 `echo $a|sed "s/.aiff/.wav/"`;\
done
@leancode
leancode / php_formating_test_sample.php
Created November 24, 2017 13:28
This file is used to test any software that formats php code. With this you can see what effects the formatting had.
<?php
// array nested sample
if ($x == 1)
{
$x = "Any text with {$x} sign";
}
elseif ($x == 2)
{
$x = "Any text with ${x} sign";
}
@leancode
leancode / upgrade-debian8-to-debian9.sh
Last active November 17, 2017 12:22
Upgrade Debian 8 to Debian 9
#!/bin/bash
sudo apt update
sudo apt upgrade
sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
sudo apt clean
echo "now reboot ('reboot' or 'shutdown -r now')"

Keybase proof

I hereby claim:

To claim this, I am signing this object: