Skip to content

Instantly share code, notes, and snippets.

View strukturedkaos's full-sized avatar

Don Pottinger strukturedkaos

View GitHub Profile
@strukturedkaos
strukturedkaos / mailchimp-popup-for-wordpress.md
Created April 8, 2016 15:11 — forked from nickcernis/mailchimp-popup-for-wordpress.md
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

@strukturedkaos
strukturedkaos / tokenable.rb
Created April 7, 2016 18:57
Module concern for generating token
module Tokenable
extend ActiveSupport::Concern
included do
before_save :ensure_token
def ensure_token
generate_token(length: 32) if token.blank?
end
@strukturedkaos
strukturedkaos / nginx.conf
Created October 27, 2015 18:04 — forked from jeffrafter/nginx.conf
Nginx proxy pass to localhost:3000 for development
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@strukturedkaos
strukturedkaos / elasticsearch_codeship.sh
Created June 29, 2015 14:06
Elasticsearch Codeship
# Sets up elasticsearch in Codeship build
set -e
CACHED_DOWNLOAD="${HOME}/cache/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz"
mkdir -p "${ELASTICSEARCH_DIR}"
wget --continue --output-document "${CACHED_DOWNLOAD}" "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz"
tar -xaf "${CACHED_DOWNLOAD}" --strip-components=1 --directory "${ELASTICSEARCH_DIR}"
echo "http.port: ${ELASTICSEARCH_PORT}" >> ${ELASTICSEARCH_DIR}/config/elasticsearch.yml
# Copy elasticsearch scripts to elasticsearch config
mkdir ${ELASTICSEARCH_DIR}/config/kevy
@strukturedkaos
strukturedkaos / es.sh
Created June 4, 2015 12:42
Elasticsearch exploration
Setup snapshot repo:
curl -XPUT 'http://localhost:9200/_snapshot/demo_nyc_accidents' -d '{
"type": "url",
"settings": {
"url": "http://download.elasticsearch.org/demos/nycopendata/snapshot/"
}
}'

chruby can be installed in various ways. For OSX, it is as simple as:

brew install chruby

Next, add the two following lines to your shell profile file (.bashrc, .zshrc, etc.)

source '/usr/local/share/chruby/chruby.sh'
source '/usr/local/share/chruby/auto.sh'
import Ember from 'ember';
// ==========================================================================
// Project: Ember EasyForm
// Copyright: Copyright 2013 DockYard, LLC. and contributors.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
// Version: 1.0.0.beta.1
#! /bin/bash
# directory to save backups in, must be rwx by postgres user
BASE_DIR="/var/backups/postgres"
YMD=$(date "+%Y-%m-%d")
DIR="$BASE_DIR/$YMD"
mkdir -p $DIR
cd $DIR
# make database backup
@strukturedkaos
strukturedkaos / yard.rb
Created November 20, 2014 20:30
Serving Yard Documentation with Rails and HighVoltage
# config/routes.rb
get "/doc" => "docs#show", id: "index"
get '/doc/*id' => 'docs#show'
# app/controllers/docs_controller.rb
class DocsController < HighVoltage::PagesController
respond_to :html
layout false
def show

Data Integrity

Programming is hard. We must valiantly fight complexity on a daily basis. Conditional statements quickly increase the complexity of a system. Every time we’re unsure about a value, we add a conditions to decide how to proceed. If only we could become more confident with the state of the system…

Hurrah! Data integrity can give us this confidence. By constraining our data, we can make some assumptions about the state of the system. Gone are the days of guarding potentially nil values. Out with orphaned and duplicate records! Data is the [life] of our software. Let’s take [life] by the reigns.