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

Keybase proof

I hereby claim:

  • I am shanethehat on github.
  • I am shanethehat (https://keybase.io/shanethehat) on keybase.
  • I have a public key whose fingerprint is 4080 3FA2 78D3 06B5 EEFF BB7E 756F D21E 6E71 2C52

To claim this, I am signing this object:

@shanethehat
shanethehat / Switcher.php
Created February 12, 2014 07:33
The var_dump on line 69 of switch.php returns an instance of Prophecy\Prophecy\MethodProphecy instead of the value '2'. This seems to be caused by the way phpspec unwraps the iterator created in spec.php line 26.
class Foo_Page_Block_Switch extends Mage_Page_Block_Switch
{
/**
* Application
* @var Mage_Core_Model_App
*/
private $_app;
/**
* Staging Collection
<?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.