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
//Insta-perf-improvement for any #PHP codebase: | |
//replace ` | |
foreach ($b as $a) { $c = array_merge($c, $a) } | |
// with | |
array_merge($c, [], ...$b) |
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 | |
$string = 'string'; | |
$double = 12.12345; | |
$array = ['foo', 'bar']; | |
$a = 555; | |
$b = 'ZZZ'; | |
var_dump(@($a + $b)); | |
var_dump($a . $b); |
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
[In reply to Moroshka] | |
Распишу по буквам, потом в совокупности | |
S - (SRP): | |
https://www.youtube.com/watch?v=AEnePs2Evg0 | |
https://goo.gl/LatDmF (link wikipedia) | |
O - (Open/closed): | |
https://www.youtube.com/watch?v=DJF_sGOs2V4 | |
https://goo.gl/6p3jfY (link wikipedia) | |
L - (Liskov): | |
https://www.youtube.com/watch?v=bVwZquRH1Vk |
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
location ~/(admin|wp-admin|backend){ | |
access_log off; | |
log_not_found off; | |
return 404; | |
} |
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
$response = new StreamedResponse(function () { | |
while (true) { | |
echo 'event: message' . PHP_EOL; | |
echo 'data: ' . \json_encode(['data' => 1]) . PHP_EOL; | |
echo PHP_EOL . PHP_EOL; | |
ob_flush(); | |
flush(); | |
sleep(2); | |
}; | |
}); |
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
function &doSmth($arg1, $arg2){ | |
} |
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 | |
require_once __DIR__ . '/../vendor/autoload.php'; | |
require_once __DIR__ . '/../app/autoload.php'; | |
require_once __DIR__ . '/../app/AppKernel.php'; | |
$kernel = new AppKernel('test', true); | |
$kernel->boot(); | |
try { | |
$container = $kernel->getContainer(); |
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
source s_nginx { udp(); }; | |
#source s_nginx { file("/var/log/nginx/my-current/access.log"); }; | |
filter f_local7 { facility(local7); }; | |
destination d_loghost {tcp("10.74.0.139" port(1500));}; | |
#destination d_loghost {file("/tmp/access.log");}; | |
log { source(s_nginx); filter(f_local7); destination(d_loghost); }; |
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
#include <curses.h> | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <signal.h> | |
#include <string.h> |
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
#include <semaphore.h> | |
#include <stdio.h> | |
#include <errno.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <string.h> | |
#include <sys/mman.h> |
NewerOlder