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 | |
function multiple_download(array $urls, $save_path = '/tmp') | |
{ | |
$multi_handle = curl_multi_init(); | |
$file_pointers = []; | |
$curl_handles = []; | |
// Add curl multi handles, one per file we don't already have | |
foreach ($urls as $key => $url) { |
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 | |
define('PROCESSES_NUM', 6); | |
/** | |
* @param array $arr | |
* @param callable $func | |
*/ | |
function parallelForeach(array $arr, callable $func) | |
{ | |
$pid = null; |
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
apt-get install percona-toolkit | |
pt-online-schema-change --print --progress time,5 --max-load Threads_running=500 --critical-load Threads_running=5000 --chunk-time 5 --set-vars "innodb_lock_wait_timeout=600" --nocheck-plan --execute -h {localhost} -u {user} --p "{password}" --alter "ADD {column} varchar(32) DEFAULT NULL" D={database},t={table} |
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 | |
/* | |
* Convert seconds to human readable text. | |
* Found at: http://csl.sublevel3.org/php-secs-to-human-text/ | |
* | |
*/ | |
function secs_to_h($secs) | |
{ | |
$units = [ |
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
SELECT | |
payments.paywall, paywall.views, payments.money | |
FROM | |
(SELECT p.paywall, concat("$", round(sum(p.productPrice)) AS money FROM payments AS p GROUP BY p.paywall) AS payments | |
LEFT JOIN | |
(SELECT pw.paywall, count(*) AS views FROM paywall AS pw GROUP BY pw.paywall) AS paywall ON payments.paywall = paywall.pay |
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 Person | |
* @Table people | |
*/ | |
class Person | |
{ | |
/** | |
* @Prop Yep | |
*/ |
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
-module(plists). | |
-export([pmap/2,pforeach/2,npforeach/2, parmap/2]). | |
%%% Map | |
pmap(F, L) -> | |
S = self(), | |
Pids = lists:map(fun(I) -> spawn(fun() -> pmap_f(S, F, I) end) end, L), | |
pmap_gather(Pids). |
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
# nano /etc/fail2ban/filter.d/nginx-4xx.conf | |
# | |
[Definition] | |
failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$ | |
ignoreregex = | |
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 | |
namespace App\Services\Roles; | |
use App\User; | |
use Illuminate\Contracts\Auth\Access\Gate; | |
/** | |
* Class Permissions | |
* @package App\Services\Roles | |
* |
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 | |
if (($_SERVER['HTTP_PASSWORD'] ?? null) !== 'ProxyPassword') { | |
http_response_code(401); | |
exit(); | |
} | |
$response = file_get_contents(urldecode($_GET['url']), false, stream_context_create([ | |
'http' => [ | |
'ignore_errors' => true, |
NewerOlder