Skip to content

Instantly share code, notes, and snippets.

View KB1RMA's full-sized avatar

Christopher Snyder KB1RMA

  • Liberty Mutual
  • Newburyport, MA
  • X @kb1rma
View GitHub Profile
#!/usr/bin/env ruby
# Check DNS records against two authoritative nameservers
# usage: $ ruby record-checker.rb --input_file record-checker.csv --nameserver nina.ns.cloudflare.com
#
# Example output:
#
# | TYPE | RECORD | CURRENT | @NINA.NS.CLOUDFLARE.COM
# --|-------|--------------------------------|--------------------------------|-------------------------------
# ✗ | A | www.matternow.com | 45.56.118.101 | matternow.com.
@KB1RMA
KB1RMA / local-config.php
Last active January 19, 2016 08:34
Here is a quick and dirty little trick I often use for faking environments in Wordpress installs for local development. The real trick here is just detecting whether or not a local config file exists and setting credentials appropriately.
<?php
// Settings used for local development
// do NOT track in your repository for deployment
/**
* Following 2 lines overwrite the standard WP_HOME and WP_SITEURL in the
* wp_options table of the database. Doesn't solve all problems, but any
* URL's generated dynamically (You are using site_url('', 'relative'), aren't you?!)
* will generate correctly.
@KB1RMA
KB1RMA / performance-mixin.scss
Last active August 29, 2015 14:06
Seriously improves CSS performance when manipulating elements with transforms. Particularly helpful when using Skrollr. Very nearly maintains 60FPS throughout scrolling.
/**
* Helps for anything we're going to be animating. Makes a HUGE
* difference
*
* Performance tweaks found here:
* http://blog.teamtreehouse.com/increase-your-sites-performance-with-hardware-accelerated-css
*
* NOTE: You'll want to use autoprefixer with this, otherwise you need to add the appropriate vendor prefixes
*
* -webkit-transform: translate3d(0, 0, 0);
@KB1RMA
KB1RMA / wp_trace_log.php
Created August 14, 2014 14:51
Provides a useful function for debugging in Wordpress that gets sent to wp-content/debug.log
<?php
// Useage looks like: trace_log($awesomeVar);
if (!function_exists('trace_log')) {
function trace_log ($log) {
if (true === WP_DEBUG) {
if (is_array($log) || is_object($log)) {
error_log(print_r($log, true));
} else {
error_log($log);
@KB1RMA
KB1RMA / wp_category_link.php
Created August 14, 2014 14:45
Very useful to output a category link with just the slug of a category. Saves lots of hardcoded URL's ending up all over a theme that need to be rebuilt when the permalink structure changes/is changed.
@KB1RMA
KB1RMA / launch_checklist.md
Last active August 29, 2015 14:03
My constantly evolving list to avoid screw-ups

Launch Checklist

As always, a WIP.

Build Processes to be run (if no Grunt):

  • JS Lint
  • CSS Prefixer
  • Minify
  • Image Optimize (ImageOptim)
  • jQuery CDN (Google)
  • HTML Validation
@KB1RMA
KB1RMA / jquery.setAllToMaxHeight.js
Last active August 29, 2015 14:03
jQuery plugin to quickly set multiple divs to the same height. There's credit to be given to the original, but I can't remember where it came from.
// Usage:
// $('.unevenheights').setAllToMaxHeight();
;(function ($) {
'use strict';
$.fn.setAllToMaxHeight = function () {
return this.height(Math.max.apply(this, $.map( this , function (e) { return $(e).height() }) ) );
}
}(jQuery));
@KB1RMA
KB1RMA / jquery-outerhtml.js
Created March 31, 2014 17:52
jQuery plugin to select an element's HTML content **including** the outer HTML.
;(function ($) {
'use strict';
$.fn.outerHTML = function (s) {
return s
? this.before(s).remove()
: $("<p>").append(this.eq(0).clone()).html();
};
}(this.jQuery));
@KB1RMA
KB1RMA / fillForm.js
Last active August 29, 2015 13:57
A handy function to take an object and fill an HTML form with those values. It would be nice to not use $.each() as it's slow, but this clean and easy.
function fillForm(formSelector, data) {
$.each(data, function (name, val) {
var
$el = $(formSelector + ' [name="' + name + '"]'),
type = $el.attr('type');
switch (type) {
case 'checkbox':
$el.attr('checked', 'checked');
break;
function xViewState() {
var a = 0,
x = [
'9091968376',
'8887918192818786347374918784939277359287883421333333338896',
'877886888787',
'949990793917947998942577939317'
],
l = x.length,