Skip to content

Instantly share code, notes, and snippets.

View ludo237's full-sized avatar
🇮🇹
Life is good when you have a good sandwich

Claudio Ludovico ludo237

🇮🇹
Life is good when you have a good sandwich
View GitHub Profile
@ludo237
ludo237 / prune-branches.sh
Created September 6, 2018 16:13
Delete all branches but keep master
git branch | grep -v "master" | xargs git branch -D
@ludo237
ludo237 / Assertions.php
Created March 7, 2018 15:11
Laravel PHP custom assertions
<?php
namespace Tests\Utils;
use Ramsey\Uuid\Uuid;
/**
* Trait Assertions
* @package Tests\Utils
*/
@ludo237
ludo237 / roundForHumans.php
Last active April 6, 2017 09:19
Round numbers in order to have something more human readable
<?php
/**
* Round a number into an human readable number
*
* The idea is to converts numbers like 999,999 into something like 0.9M or 999.99K
* using the scientific notation.
*
* @param $number
*
* @return string
@ludo237
ludo237 / installnode.sh
Created October 27, 2016 08:46
Install NodeJs on WSL
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
@ludo237
ludo237 / installcomposer.php
Created October 17, 2016 17:00
Installing Composer via PHP
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
@ludo237
ludo237 / wslps.ps1
Created October 11, 2016 13:10
Enable WSL using Poweshell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
@ludo237
ludo237 / init-tests.sh
Created July 4, 2016 16:27
Simple bash that allows to autorun a test suite for Laravel
#!/bin/bash
clear
echo "---------------------------------"
echo "---- Automatic Tester -----"
echo "---- -----"
echo "---- v1.4 -----"
echo "---------------------------------"
echo "==> Testing if PHP is on Version 7.0+..."
@ludo237
ludo237 / happybday.sh
Created April 15, 2016 08:41
Automate Happy B. Day
sh /home/YourUser/saints.sh | mutt -s "Happy Birthday! <3" [email protected]
@ludo237
ludo237 / ArrayPushAssoc.php
Created February 2, 2016 08:19
Array Push Hack
<?php\
/**
* array_push_assoc is a moch-up of the standard core.php Array Push
* @param array $array
* @param object $key
* @param object $value
* @return array $array
*/
public function array_push_assoc(&$array, $key, $value){
// Simply insert the key and the value into the array
@ludo237
ludo237 / myip.sh
Created June 4, 2015 07:37
Grab all networks and show the associated IP
# -------------------------------------------------------------------
# myIP address
# -------------------------------------------------------------------
function myip() {
ifconfig lo0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "lo0 : " $2}'
ifconfig en0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en0 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en0 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en0 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en1 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en1 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en1 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en1 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}'
}