Skip to content

Instantly share code, notes, and snippets.

if (!function_exists('write_log')) {
function write_log ( $log ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
@joshweinstein
joshweinstein / gist:5043584
Created February 27, 2013 00:05
elastic search: setup for autocomplete
curl -XPUT 'http://127.0.0.1:9200/argmaps-development/?pretty=1' -d '
{
"mappings" : {
"questions" : {
"properties" : {
"question_text" : {
"fields" : {
"ngrams" : {
"type" : "string",
"analyzer" : "my_ngram"
@joshweinstein
joshweinstein / gist:3977183
Created October 29, 2012 23:21
Capistrano Performance Report
# Courtesy of PagerDuty
Capistrano::Configuration.instance(:must_exist).load do |config|
start_times = {}
end_times = {}
order = []
on :before do
order << [:start, current_task]
start_times[current_task] = Time.now
@joshweinstein
joshweinstein / gist:3693177
Created September 10, 2012 19:23 — forked from nono/gist:1600053
autocomplete with tire
#encoding: utf-8
require 'tire'
require 'json'
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/object/to_param'
conf = {
settings: {
number_of_shards: 1,
number_of_replicas: 0,
@joshweinstein
joshweinstein / index.html
Created May 11, 2012 16:35
100% height with header and footer
<!doctype html>
<head>
<style>
/**
* 100% height layout with header and footer
* ----------------------------------------------
* from http://peterned.home.xs4all.nl/examples/csslayout1.html
*/
html, body {
@joshweinstein
joshweinstein / Growl.rb
Created June 18, 2011 19:12 — forked from kurbmedia/Growl.rb
watchr + growl + rspec
class Growl
attr_accessor :report, :status
def initialize(report, opts = {})
@report, options = report, create_options(opts)
message = create_message
opts = options.inject([]) do |arr, item|
key, value = item.first, item.last