This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Recursive builder pattern | |
| * | |
| * Usage: | |
| * $tree = \Tree\Builder::init() | |
| * ->setName('parent') | |
| * ->addChild() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function salesForceIdChecksum($id) | |
| { | |
| $map = implode('',array_merge(range('A', 'Z'), range(0, 9))); | |
| $checksum = ''; | |
| foreach (str_split($id, 5) as $chunk) { | |
| $checksum .= substr($map, bindec( strrev(array_reduce(str_split($chunk, 1),function($carry, $item){ | |
| $carry .= (!is_numeric($item) && $item == strtoupper($item)) ? '1' : '0'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function stringSimilarity( $a) { | |
| $a = trim($a); | |
| $cutPrefix = $sum = 0; | |
| $length = strlen($a); | |
| do{ | |
| $count = 0; | |
| while($a[$count] === substr($a,$cutPrefix+($count++), 1)){} | |
| $sum += $count -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Class GeoOffsetByDistance | |
| */ | |
| class GeoOffsetByDistance | |
| { | |
| //Earth’s radius, sphere in meters | |
| const R = 6378137; | |
| /** @var float */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # cleaner.sh by Philipp Dahse <[email protected]> | |
| # ------------------------------------------------ | |
| # checks all files and directories next to itself. | |
| # If there "last modified date" is older then given days (file_live_time_in_days) | |
| # it remove those data. | |
| # I use this script in something like a personal tmp directory: | |
| # | |
| # /home/my/tmp/cleaner.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Trait EnumTrait | |
| * @author Philipp Dahse <[email protected]> | |
| */ | |
| trait EnumTrait | |
| { | |
| /** | |
| * @return array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let M = 255; | |
| let C = (x,y) => (M - Math.sqrt((Math.pow(M-x,2)+Math.pow(M-y,2))/2)).toFixed(0); | |
| let mixColors = (x,y) => [C(x[0],y[0]),C(x[1],y[1]),C(x[2],y[2])]; | |
| mixColors([255,125,23],[0,255,0]) // ["75","163","11"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| LINES=$(tput lines) | |
| COLUMNS=$(tput cols) | |
| declare -A snowflakes | |
| declare -A lastflakes | |
| clear |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "type": "https://tools.ietf.org/html/rfc2616#section-10", | |
| "title": "An error occurred", | |
| "detail": "Class rray<string,string> does not exist", | |
| "trace": [ | |
| { | |
| "namespace": "", | |
| "short_class": "", | |
| "class": "", | |
| "type": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| docker context create remote --docker "host=ssh://user@remotemachine" | |
| docker-compose -f docker-compose.production.yml --context remote up -d --no-deps --build |
OlderNewer