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
async function logRouteExecTime(req, res, next) { | |
const startTime = process.hrtime(); | |
res.once('finish', () => { | |
const endTime = parseHrtimeToSeconds(process.hrtime(startTime)); | |
const payload = { | |
server_method: req.method, | |
server_url: `${req.baseUrl}${req.route ? req.route.path : ''}`, | |
server_params: req.params, | |
server_time: endTime, |
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 WordPress_Http_Debug | |
{ | |
function __construct() | |
{ | |
/** | |
* Uses the filter bellow to create a timer for the request | |
*/ | |
add_filter('https_ssl_verify', [$this, 'request_timer']); | |
/** |
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
/** | |
* Tracks server pings for determining if the connection dropped. | |
* Will terminate non-responsive connections. | |
* This close event should initiate the process of recreating the connection in the ws module manager (eg ws/user.js and modules/ws-user.js) | |
*/ | |
function setupWsHeartbeat(ws) { | |
// will close the connection if there's no ping from the server | |
function heartbeat() { | |
clearTimeout(this.pingTimeout); |
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 | |
/** | |
* Horizon Provider | |
**/ | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
use Illuminate\Support\Facades\Route; |
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() { | |
var z = window.prompt("Zeplin Link", ""); | |
if (!z) return; | |
var pid = (/pid=(\w+)/).exec(z)[1]; | |
var sid = (/sid=(\w+)/).exec(z)[1]; | |
var u = `https://app.zeplin.io/project/${pid}/screen/${sid}`; | |
window.open(u, '_blank'); | |
})(); | |
// Oneliner to create a Bookmarklet |
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
const sinon = require('sinon'); | |
module.exports = function() { | |
/** | |
* Fake timers (setImmediate, setTimeout) | |
*/ | |
before(function() { | |
this.clock = sinon.useFakeTimers(new Date()); | |
}); |
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
/** | |
* Creates a app object in the global scope | |
*/ | |
function initAppSingleton() { | |
global = global || window; | |
if (!global.app) { | |
global.app = {}; | |
} | |
return global.app; |
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 -S 0.0.0.0 -t /home/site /home/site/wp-router.php |
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 | |
const FEATURE_FLAGS = [ | |
'MY_NEW_FEATURE' => false, | |
'MY_RELEASED_FEATURE' => 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 | |
require_once dirname( __FILE__ ) . '/lib/php-ga/src/autoload.php'; | |
use UnitedPrototype\GoogleAnalytics; | |
if (!function_exists('ga_tracker')) { | |
function ga_tracker() { | |
// Initilize GA Tracker | |
$tracker = new GoogleAnalytics\Tracker('UA-12345678-9', 'website.com'); | |
return $tracker; |