Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
find . -iname '*.jar' -print | while read jar; do
echo "$jar:"
unzip -qq -l $jar | sed 's/.* //' | while read cls; do
unzip -c $jar $cls | grep -q 'Tag read' && echo " "$cls
done
done
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
bootstrap='vendor/autoload.php'>
<testsuites>
@shanethehat
shanethehat / find_theme_preprocess.sh
Last active December 17, 2015 06:39
Find preprocess functions for theme functions
#!/bin/bash
for f in `grep -PhoR "(?<=function theme_)[a-z_]*"`
do
grep -iR "function template_preprocess_$f("
done
@shanethehat
shanethehat / assignment-test.php
Last active December 16, 2015 23:49
Speed test assigning to local variable vs reference variable vs array index
<?php
$arr = array('a' => 'c');
$arr2 = array('a' => 'c');
$ref = &$arr2['a'];
$startArr = microtime(true);
foreach (range(1,10000) as $i) {
$arr['a'] = 'b';
}
/**
* Implements hook_library_info_alter()
*/
function slukphp_library_info_alter(&$libraries, $module) {
if ($module == 'system' && isset($libraries['modernizr'])) {
$file = drupal_get_path('theme', 'slukphp') . '/'; //filename relative to .theme file
$libraries['modernizr']['version'] = '2.6.2';
$libraries['modernizr']['js'] = array(
$file => array(
'every_page' => 1,
array (size=1)
0 =>
object(Drupal\user\Plugin\Core\Entity\User)[1005]
public 'uid' => int 0
public 'uuid' => string '1489b0ea-0874-4220-9409-9b3206f6e4d4' (length=36)
public 'name' => string 'Me' (length=2)
public 'pass' => null
public 'mail' => string '' (length=0)
public 'theme' => null
public 'signature' => null
@shanethehat
shanethehat / test_null.php
Last active December 15, 2015 13:29
Demonstration of the speed difference between calling is_null and using a comparison operator.
<?php
function runTestFunction($name, Callable $function) {
$startTime = microtime(true);
for ($i = 0; $i < 10000000; $i++) {
$function();
}
$endTime = microtime(true);
echo $name . ' took ' . ($endTime - $startTime);
echo PHP_EOL;
[**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](http://j.mp/XqV7Lp). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ).

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

<div id="container">
<ul id=navList">
<li>Nav Item 1</li>
<li>Nav Item 2</li>
<li>Nav Item 3</li>
<li>Nav Item 4</li>
<li class="last">Nav Item 5</li>
</ul>
</div>
div#container {
width:500px;
}
ul#navList li {
width:100px;
margin-right:25px;
text-align:center;
}
li.last {
margin-right:0px;