Skip to content

Instantly share code, notes, and snippets.

View pfaocle's full-sized avatar

Paul Byrne pfaocle

View GitHub Profile
@pfaocle
pfaocle / sql-long-lines.sh
Created July 4, 2013 15:37
Check a SQL dump for the longest line and either outputs the line, or a character count.
# Output longest line to bigfile.txt
cat ./local.sql | awk ' { if ( length > x ) { x = length; y = $0 } }END{ print y }' > bigfile.txt
# Count characters in longest line
cat ./local.sql | awk ' { if ( length > x ) { x = length; y = $0 } }END{ print y }' | wc -m
@pfaocle
pfaocle / SaveFileEntityDisplaySettings.php
Created June 3, 2013 21:41
Save File Entity file display settings in code - uses CTools exportables.
<?php
// We assume that a custom module is implementing a file formatter
// called 'mymodule_custom_file_formatter'.
$filetype = 'video'; // File type to alter file display for.
$display = 'preview'; // File display to alter - 'default', 'teaser' or 'preview'.
$video_display = file_display_new($filetype, $display, 'mymodule_custom_file_formatter');
$video_display->export_type = 1;
@pfaocle
pfaocle / date-form.php
Created September 27, 2012 19:22
PHP for CMS Developers - DateTime exercise
<html>
<head>
<title>PHP for CMS Developers - Exercise 1</title>
</head>
<body>
<p>Enter a date, using a format understood by <a href="http://php.net/manual/en/class.datetime.php">http://php.net/manual/en/class.datetime.php</a></p>
@pfaocle
pfaocle / php-scream.sh
Created August 29, 2014 10:54
Run PHP script - ignore @ error suppressions and show a backtrace.
#!/bin/sh
# SCREAM ERR0R.
php -d xdebug.scream=1 vendor/bin/codecept build
@pfaocle
pfaocle / GuysInCest.php
Last active August 29, 2015 14:05
Best option for chucking around $I in Cest classes?
<?php
class CheeseCest
{
/**
* A test.
*
* @param AuthenticatedStepsInterface $I
* The Guy object being used to test.
*/
#!/bin/sh
cat **/*.(php|module|inc|css|js) | wc -l