Skip to content

Instantly share code, notes, and snippets.

@robcolburn
robcolburn / iframe-child.html
Created April 22, 2014 03:19
Cross-Site onbeforeunload
<!-- Sample content for demonstration -->
<p><a href="#" onclick="return setMessage();">Set Blocking Message</a></p>
<p><a href="#" onclick="return unsetMessage();">Unset Blocking Message</a></p>
<!-- Sample script for demonstration - see setMessageOnParent() function -->
<script>
try {
opera.setOverrideHistoryNavigationMode('compatible');
history.navigationMode = 'compatible';
script.onload = then;
script.onreadystatechange = function () {
if (/loaded|complete/.test(script.readyState)) {
script.onreadystatechange = null;
then();
}
};
function then () {
@robcolburn
robcolburn / private.htaccess
Created September 3, 2014 22:58
Drupal .htaccess files
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Deny from all
Options None
Options +FollowSymLinks
# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
# Override the handler again if we're run later in the evaluation list.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
<?php
function print_backtrace() {
$x = debug_backtrace();
for ($i = 0, $l = count($x); $i < $l; $i++) {
echo $x[$i]['file'], ':', $x[$i]['line'], "\n";
echo ($l - $i), ': ', $x[$i]['function'], '(';
foreach ($x[$i] ['args'] as $j => $arg) {
echo ($j > 0 ? ', ' : ''),
is_scalar($arg) ? $arg :
((is_array($arg) || is_object($arg)) ? json_encode($arg) :
jQuery(function ($) {
var $commits = $('.commit-message');
var message = $commits.text();
var rally_tickets = $.unique(message.match(/(US|DE|TA)-\d{3,}/g) || []).sort();
var rally_references = rally_tickets.map(function (ticket) {
return '* [' + ticket + '](https://rally1.rallydev.com/#/search?keywords=' + ticket + ')';
}).filter(identity);
var $files = $('.file .meta .info .js-selectable-text');
var files = $files.text();
@robcolburn
robcolburn / SassMeister-input.scss
Created December 24, 2014 19:33
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
$icons: (
action-left: "A",
action-right: "B"
);
<?
/**
* Determine if user can access invoice.
* @param WP_Post $invoice
* The invoice to check.
* @return boolean
* TRUE if user can access invoice.
*/
function can_access_invoice ($invoice) {
global $current_user;
function getDevice () {
var UA = navigator.userAgent;
var device = {};
device.isOldIE = UA.match(/MSIE\s[678]/);
device.isKindle = UA.match(/Kindle|Silk/i);
device.isAndroid = UA.match(/Android/i) && !device.isKindle;
device.isiOS = UA.match(/iPhone|iPad|iPod/i);
device.isUnsupportedMobile = (UA.match(/mobile|opera m/i) || device.isKindle) &&
!device.isiOS && !device.isAndroid;
return device;

Creating a culture a performance -- @iancarrico @rupl

For a small site, some slightly larger sites, none of this is mind-blowingly difficult it's just a matter of setting it up and commiting to it. @tsmith512

Getting everyone on board w/ performant on board w/ peformance.

Buy in at all levels

  • CXO - How will this effect our bottom line? People will stay around longer if website is quicker, more responsive. Loads ads more quickly. More pages, more ads
  • Product Owner - "We don't have time to work on performance" - Document in backlog to defer work to later. "Responsive cannot be performant" - Study "responsive" adds ~10% more code, and good techniques (lazy load images) take care of perf better.