Skip to content

Instantly share code, notes, and snippets.

@rodmcnew
rodmcnew / ProfileDoctrine.php
Last active August 29, 2015 14:05
Easily see what queries doctrine is running for a page load
<?php
/**
* Inside doctrine locate the executeQuery() method inside the \Doctrine\DBAL\Connection class.
* ADD THE FOLLOWING TO THE BEGINNING OF THE executeQuery() METHOD:
*/
/**
* ADDED TO PROFILE QUERIES
*/
if (!isset($GLOBALS['queryCount'])) {
@rodmcnew
rodmcnew / props.conf
Last active December 27, 2015 14:28
Prevent Splunk from breaking PHP stack traces into multiple error events with this LINE_BREAKER regular expression.
# props.conf is at /opt/splunk/etc/system/local/props.conf in debian/ubuntu
#
# Example log entry:
#[Wed Nov 06 17:10:30.436963 2013] [:error] [pid 1238] [client 127.0.0.1:51876] PHP Notice: this is a test warning 22 in /var/www/warning.php on line 2
#[Wed Nov 06 17:10:30.437020 2013] [:error] [pid 1238] [client 127.0.0.1:51876] PHP Stack trace:
#[Wed Nov 06 17:10:30.437037 2013] [:error] [pid 1238] [client 127.0.0.1:51876] PHP 1. {main}() /var/www/warning.php:0
#[Wed Nov 06 17:10:30.437050 2013] [:error] [pid 1238] [client 127.0.0.1:51876] PHP 2. trigger_error() /var/www/warning.php:2
#
# This will prevent Splunk from breaking PHP stack traces into multiple events:
SHOULD_LINEMERGE = false
#There are many other ways to do this but i've found using these commands work best and are the least error prone
### How to pull down ###
git fetch origin master; git merge origin/master
#If there is an error here, fix it with:
#Open all conflict files, fix them, save them (you could use a diff tool here)
git add .; git commit -m "Merged change"
git fetch origin master; git merge origin/master
@rodmcnew
rodmcnew / BasicAuthMiddleware.php
Created April 22, 2016 20:12
HTTP Basic Auth Implementing Zend\Stratigility\MiddlewareInterface
<?php
namespace App\Controller;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Stratigility\MiddlewareInterface;
/**
* Class HttpBasicAuth
@rodmcnew
rodmcnew / addAdvancedSAS
Created May 26, 2016 04:36
KSP add KER, MechJeb, and Advanced SAS to every command part (module manager must be installed first)
@PART[*]:HAS[@MODULE[ModuleCommand],!MODULE[MechJebCore]]:Final
{
MODULE
{
name = ModuleSAS
SASServiceLevel = 3
}
}
/**
* Paste this code at the top of \Doctrine\DBAL\Connection:executeQuery()
*/
$startTime = microtime(true);
//Body of \Doctrine\DBAL\Connection:executeQuery() goes here
<html>
<head>
<!-- @TODO uso more official polymer urls than cdn.rawgit.com/download-->
<script src="https://cdn.rawgit.com/download/polymer-cdn/1.5.0/lib/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="https://cdn.rawgit.com/download/polymer-cdn/1.5.0/lib/iron-ajax/iron-ajax.html">
<style>
h1 {
text-align: center;
font-size: 50px;
@rodmcnew
rodmcnew / repeat.js
Last active July 19, 2016 16:57
repeat.js
var exec = require('child_process').exec;
var cmd = process.argv[2];
console.log(' - - - ');
console.log('Running the following command repeatedly:');
console.log(cmd);
var count = 0;
var averageSumTime = 0;
var averageTime = 0;
@rodmcnew
rodmcnew / select-between-xml-tags.sql
Last active October 10, 2016 13:48
mysql - select between xml tags
SELECT
substring_index(substring_index(log, '<FUNTAG>', -1),'</FUNTAG>', 1) as funtag,
substring_index(substring_index(log, '<ANOTHERFUNTAG>', -1),'</ANOTHERFUNTAG>', 1) as anotherfuntag
<script>
var testData = JSON.parse('{"m1":{"n":100,"d":82,"w":{"0":-1.1459447899883408,"1":-0.43760018570338904,"2":-0.007912300055782289,"3":-0.7775195174649078,"4":-0.9506407588688986,"5":-0.968010860301908,"6":-2.691807922209082,"7":-0.7431428809376434,"8":-1.5005473247243273,"9":-1.1238916004732475,"10":-0.34714691839944173,"11":0.30981333481408,"12":2.06758659398065,"13":-0.17417269832816004,"14":2.7456379240225486,"15":-0.676815649332452,"16":-2.309467615365306,"17":-2.341013203261767,"18":-1.6477384673749218,"19":-0.13356181468961806,"20":0.5181641866009631,"21":0.4362678106428555,"22":0.6827575787588762,"23":1.1358291360377544,"24":0.5452701986935545,"25":2.099832304806032,"26":0.03848688361846758,"27":1.7635262899682158,"28":2.644560543014539,"29":2.739290274928228,"30":0.8032392854292526,"31":-1.9310798293188054,"32":-0.3086325669036704,"33":0.6428509078110665,"34":-0.2200382207693386,"35":-1.6599938011512325,"36":-0.3232515071583018,"37":-1.8415199880552184,"38":0.22430170963057436,"39":-1.236