Skip to content

Instantly share code, notes, and snippets.

View bayleedev's full-sized avatar
🍿

Baylee Schmeisser bayleedev

🍿
View GitHub Profile
<?php
class foo {
const bar = 'foobar';
}
$name = 'bar';
if (defined('foo::' . $name)) {
echo constant('foo::' . $name);
}
;;;;;;;;;;;;;;;;;;;
;; About this file ;
;;;;;;;;;;;;;;;;;;;;
;;
;; built by G. Giunta as a verbatim copy of info from xedbug website on 2007/11/08
;
;; You must uncomment one (and only one) line from the following to load
;; the xdebug extension.
;zend_extension="/usr/lib/php4/xdebug.so"
;;zend_extension_ts="/usr/lib/php4/xdebug.so"
{
"name": "QualityRuleset",
"rules": [
{
"name": "DoesntExceedMaxLineLength",
"vars": {
"soft": 80,
"hard": 100,
}
},
@bayleedev
bayleedev / test1.php
Last active December 10, 2015 07:09
Test2.php: 8.0589056015015 Test1.php: 8.0747842788696
<?php
// Create array
$items = range(0,100000);
$times = array();
$realArray = array(); // id and name
$metaArray = array(); // token and bob
foreach ($items as &$item) {
<?php
Media::type('xml', 'application/xml', array(
'layout' => false,
'encode' => function($data) {
$xml = new SimpleXMLElement('<root/>');
array_walk_recursive($data, array($xml, 'addChild'));
return $xml->asXML();
},
));
@bayleedev
bayleedev / output.txt
Created January 24, 2013 19:43
CURL Options by output number
CURLOPT_AUTOREFERER..............58
CURLOPT_BINARYTRANSFER...........19914
CURLOPT_RETURNTRANSFER...........19913
CURLOPT_COOKIESESSION............96
CURLOPT_CERTINFO.................172
CURLOPT_VERBOSE..................41
CURLOPT_CRLF.....................27
CURLOPT_DNS_USE_GLOBAL_CACHE.....91
CURLOPT_FAILONERROR..............45
@bayleedev
bayleedev / internalCall.php
Created January 28, 2013 19:43
Will check to see if the call was made internally or externally.
<?php
namespace foo\bar\baz;
use ReflectionClass;
use ReflectionMethod;
use Exception;
class foo {
@bayleedev
bayleedev / respondsTo.php
Created January 28, 2013 20:06
Determines if a given method name can be responded to. Classes with magic methods should extend the method. Originally, I was going to have the default `$visibility` to null and auto-detect if it was an internal class or not, but that turned out to be rather slow. (https://gist.github.com/4658402)
<?php
namespace foo\bar\baz;
use ReflectionClass;
use ReflectionMethod;
use Exception;
use BadMethodCallException;
error_reporting(-1);
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript">
document.parentWrite = document.write;
document.writeCounter = 0;
document.write = function(data) {
var id = 'writeCount' + String(this.writeCounter++);
this.parentWrite('<span id="' + id + '"></span>');
@bayleedev
bayleedev / tumblr.js
Created January 29, 2013 18:33
Do you "like" a lot of pretty images on tumblr? Add them to your queue to make your like list smaller!
jQuery('.post_control.reblog_button').each(function(i, el) {
setTimeout(function() {
// Buttons
reblogLink = jQuery(el);
unstarLink = reblogLink.next('a.like_button');
// Open Photo
jQuery(reblogLink).trigger('click');