This file contains 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 | |
$storedIds = [ | |
'abc', | |
'def', | |
// ... more stored Ids | |
]; | |
do { | |
$id = uniqid('image',true); |
This file contains 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 Hash | |
{ | |
/** | |
* Cost for hashing. | |
*/ | |
const COST = 10; | |
/** |
This file contains 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
Show hidden characters
{ | |
"color_scheme": "Packages/Colorsublime - Themes/Facebook.tmTheme", | |
"highlight_line": true, | |
"save_on_focus_lost": true, | |
"always_show_minimap_viewport": true, | |
"trim_trailing_white_space_on_save": true, | |
"draw_white_space": "all", | |
"atomic_save": true, | |
"bold_folder_labels": false, | |
"show_full_path": true, |
This file contains 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 Yii2ValetDriver extends ValetDriver | |
{ | |
/** | |
* Determine if the driver serves the request. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri |
This file contains 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
# Tunnels to valet project with custom domain name. | |
# Uses ngrok.com with my personal github account and auth token | |
function tunnel_valet() { | |
HOST="${PWD##*/}" | |
DOMAIN=$(valet domain) | |
SUBDOMAIN="$HOST" | |
[[ "$1" ]] && SUBDOMAIN=$1; | |
for linkname in ~/.valet/Sites/*; do | |
if [[ "$(readlink $linkname)" = "$PWD" ]] |
This file contains 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 | |
$array = [ | |
'personal' => [ | |
'name' => 'Haven Shen', | |
'age' => 18, | |
], | |
'gift' => [ | |
'name' => 'car', | |
'key' => [ |
This file contains 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 | |
// Bad demo | |
$errorHandler = new ErrorHandler(); | |
set_error_handler(function($errno, $errstr, $errfile, $errline) use ($errorHandler) { | |
return $errorHandler->error($errno, $errstr, $errfile, $errline); | |
}); | |
set_exception_handler(function($exception) use ($errorHandler) { |
This file contains 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 | |
// Bad demo | |
$user = new User(); | |
$user->create([]); | |
class User | |
{ | |
public function create(array $data) |
This file contains 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 | |
// Bad demo | |
$paypal = new Paypal(); | |
$paymentManager = new PaymentManager($paypal); | |
$paymentManager->process(); | |
class PaymentManager |
This file contains 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 | |
$car = new Car(); | |
$driver = new Driver($car); | |
$driver->go(); | |
class Driver | |
{ |
OlderNewer