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 | |
$files = glob('*.{h,c}', GLOB_BRACE); | |
if (!$files) { | |
die('error'); | |
} | |
foreach ($files as $file) { | |
printf("%s -> %d bytes\n", $file, filesize($file)); |
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 getProductData(int $productId, string ... $predicates) | |
{ | |
$args = func_get_args(); | |
$hash = ''; | |
foreach ($args as $arg){ | |
$hash .= (string)($arg); | |
} |
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 | |
$a = 'oldValue'; | |
extract( | |
[ | |
'a' => 'test', | |
'b' => 'foo' | |
], | |
EXTR_SKIP |
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 validateMail(string $email): bool | |
{ | |
$parts = explode("@", $email); | |
$host = end($parts); | |
return checkdnsrr($host, 'MX'); | |
} | |
$email = '[email protected]'; |
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
brew link --overwrite --force [email protected] |
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 | |
$con = mysqli_connect("host","user", "password"); | |
mysqli_select_db($con, "dbname"); | |
$stepSize = 100000; | |
foreach(range(1,50000000, $stepSize) as $step){ | |
$sql = sprintf('insert into tmp_table select * from table where id >= %d and id < %d', $step, $step + $stepSize); | |
mysqli_query($con, $sql); |
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
curl -XPOST http://localhost:9200/_bulk?pretty --data-binary @/tmp/all.txt -H 'Content-Type: application/json' |
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
import queue | |
import threading | |
NUM_THREADS = 10 | |
def worker(channel): | |
while True: | |
value = channel.get() | |
if value is False: | |
break |
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 | |
$dir = dirname(__FILE__); | |
$exclude = [ | |
'bin', | |
'build', | |
'data', | |
'docs', | |
'docs-api', |
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 | |
const APP_NAME = "MyRunner"; | |
const APP_VERSION = '0.0.1'; | |
// If we're running from phar load the phar autoload file. | |
$pharPath = \Phar::running(true); | |
if ($pharPath) { | |
$autoloaderPath = "$pharPath/vendor/autoload.php"; | |
} else { |