Skip to content

Instantly share code, notes, and snippets.

/**
* Sort string chars.
*
* @param {Function} compareFn Sort comparisson function resolver.
* @return {String} Sorted string.
*/
String.prototype.sort = function (compareFn) {
return this
.normalize()
.split('')
#!/bin/bash
exec &>> ./output.log
echo `date`
ls -lash
#!/bin/bash
echo "# arguments --------> ${@} "
echo "# \$1 --------------> $1 "
echo "# \$2 --------------> $2 "
echo "# script path ------> ${0} "
echo "# script basedir----> ${0%/*} "
echo "# script name ------> ${0##*/} "
# https://stackoverflow.com/a/3588939/8098829
#!/bin/sh
ROOT_DIR="./"
if [ -d "$1" ]; then
ROOT_DIR="$1"
fi
find "$ROOT_DIR" -type d -name .git -execdir test -e .git/refs -a -e .git/objects \; -exec git --git-dir={} --work-tree={}/../ pull origin master \;
@coisa
coisa / README.md
Last active January 15, 2020 22:42
PHP Composer Autoloader

Usage

Copy autoload.php to the root of your composer project and import in your script or class file.

Ex.:

<?php
# Always use relative path for autoloading.
require_once __DIR__ . '/autoload.php';
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;
$development = require __DIR__ . '/config/development/config.php';
$production = require __DIR__ . '/config/production/config.php';
@coisa
coisa / composer-in-docker.sh
Created November 28, 2019 12:27
Composer Shell Function using Docker
composer()
{
# Export composer ENV vars
export COMPOSER_HOME=${COMPOSER_HOME:-$HOME/.composer}
export COMPOSER_CACHE_DIR=${COMPOSER_CACHE_DIR:-$COMPOSER_HOME/cache}
# Ensure composer home & cache folders
mkdir -p $COMPOSER_HOME $COMPOSER_CACHE_DIR
# Ensure SSH agent
#!/bin/bash
filename=$(basename $1)
openssl pkcs12 -in $1 -out $filename.nokey.pem -nokeys
openssl pkcs12 -in $1 -out $filename.withkey.pem
openssl rsa -in $filename.withkey.pem -out $filename.key
cat $filename.nokey.pem $filename.key > $filename.pem
<?php
/**
* Class GeneratorCallableIteratorAggregate
*/
class GeneratorCallableIteratorAggregate implements IteratorAggregate
{
/**
* @var callable
*/
<?php
/**
* Class CachingGeneratorIteratorAggregate
*/
class CachingGeneratorIteratorAggregate implements IteratorAggregate
{
/**
* @var CachingIterator
*/