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 ds_array_merge_recursive () { | |
$args = func_get_args(); | |
$numArgs = count($args); | |
if ($numArgs < 1) { | |
trigger_error(__FUNCTION__ . "() expects at least one parameter, $numArgs given", E_USER_WARNING); | |
return 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
<?php | |
require_once("vendor/autoload.php"); | |
use Aws\Sqs\SqsClient, | |
GuzzleHttp\Promise; | |
class AsyncQueueMonitor { | |
protected $sqsClient; |
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 | |
/* | |
Given a word between 1 and 20 characters in length, write a command-line script that outputs its "number". | |
A word's "number" is its alphabetical ordinal position in the set of permutations of its letters. | |
Examples: | |
ABAB = 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 ip2int (ip) { | |
var ipVal = 0; | |
ip.split(".").forEach(function (octet, i, arr) { | |
var exp = 8 * (arr.length - i - 1); | |
ipVal += octet * Math.pow(2, exp); | |
}); | |
return ipVal; | |
} |
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
// Behat code to wait for ajax calls to complete | |
public function waitForAjax ($seconds=5) { | |
if(!$this->getSession()->wait((1000 * $seconds), "jQuery.active == 0")) { | |
throw new Exception("Ajax calls still pending after $seconds seconds."); | |
} | |
} |
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
// invert a binary tree with root node $rootNode | |
function isLeafNode ($node) { | |
return is_null($node->left) && is_null($node->right); | |
} | |
function invert (&$node) { | |
if (isLeafNode($node)) { | |
return; |
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 FeatureContext.php | |
// Store session tokens for reauthentication | |
private static $credentialStore = array(); | |
// ... other code ... | |
/** | |
* Authenticates a user with password from configuration. | |
* |
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 getSMTPPassword ($key) { | |
$message = "SendRawEmail"; | |
$hexVersion = "02"; | |
$hexSignature = hash_hmac("sha256", $message, $key); | |
return base64_encode(hex2bin($hexVersion . $hexSignature)); | |
} |