Skip to content

Instantly share code, notes, and snippets.

@bru
bru / core.cljs
Created December 10, 2016 15:02
dynamically update a dev card when changing the initial values
(defonce feedback-state (atom {}))
(defn init-state []
(reset! feedback-state
{:awesome 1
:sleep 1
:good 1}))
(defcard interactive-card
(fn [state-atom owner]
@bru
bru / 40_cronjobs.config
Last active August 24, 2016 20:48
Elastic Beanstalk extension to run a cron job
files:
"/tmp/cronjob" :
mode: "000777"
owner: webapp
group: webapp
content: |
# retrieve assets
* * * * * bash -l -c "/usr/local/bin/wp --allow-root --path='/var/app/current/blog1/' eval 'fetch_external();'" >> /var/log/httpd/wp-cli.log 2>&1
* * * * * bash -l -c "/usr/local/bin/wp --allow-root --path='/var/app/current/blog2/' eval 'fetch_external();'" >> /var/log/httpd/wp-cli.log 2>&1 encoding: plain
commands:

Keybase proof

I hereby claim:

  • I am bru on github.
  • I am bru (https://keybase.io/bru) on keybase.
  • I have a public key ASBRVfof_MBs69T6sqwkeIXiqK1hn7MCToKsY1GBWTSxwQo

To claim this, I am signing this object:

@bru
bru / gist:ed89bf695fdb98f1dfed
Created November 16, 2014 18:38
expand query params in jsonified apache log file
#!/bin/sh
#
# this scripts expands the query string for jsonified apache logs.
# In order to work, it expects an apache log as produced by:
#
# LogFormat "{\"time\":\"%t\", \"remoteIP\":\"%a\", \"forwardedFor\":\"%{X-Forwarded-For}i\", \"host\":\"%V\", \"pid\":\"%P\", \"request\":\"%U\", \"query\":\"%q\", \"method\":\"%m\", \"status\":\"%>s\", \"userAgent\":\"%{User-Agent}i\", \"referer\":\"%{Referer}i\", \"requestTime\":\"%D\"}" jsonlog
sed -r 's/"query":"\?([^"]+)"/"query":{ \&\1 }/' |
sed -r '
/"query":\{/, /\}/ {
@bru
bru / my_artifice_spec.rb
Created May 15, 2014 08:05
Artifice example with more than one endpoint
require 'rubygems'
require 'artifice'
describe "MyArtifice" do
FakeTwoApp = proc do |env|
text = case env["PATH_INFO"]
when "/hello"
"world"
["redis-brain.coffee", "shipit.coffee", "clojure.coffee", "xkcd.coffee", "applause.coffee",
"brb.coffee", "conversation.coffee", "rimshot.coffee", "hangout.coffee", "google.coffee",
"flip.coffee", "dice.coffee"]
@bru
bru / Gemfile
Created August 4, 2012 14:22
Sinatra HStore setup
source :rubygems gem "sinatra"
gem "pg" gem "activerecord-postgres-hstore"
gem "sinatra-activerecord"
@bru
bru / quicksandra.rb
Created July 2, 2012 08:51
Quicksandra - light wrapper around Cassandra
require 'cassandra_helper'
module Quicksandra
attr_accessor :key
attr_reader :column_names
def get(key)
cassandra.get :CdfItems, key.to_s
end
@bru
bru / tracker_csv_export_to_pdf.rb
Created August 24, 2011 16:28 — forked from rheaton/tracker_csv_export_to_pdf.rb
takes a csv file from tracker and makes story cards. be careful of the order when you are cutting them up.
#!/usr/bin/env ruby
# Script to generate PDF cards suitable for planning poker
# from Pivotal Tracker [http://www.pivotaltracker.com/] CSV export.
# Inspired by Bryan Helmkamp's http://github.com/brynary/features2cards/
# Example output: http://img.skitch.com/20100522-d1kkhfu6yub7gpye97ikfuubi2.png
require 'rubygems'
$:.unshift './lib'
require 'rubygems'
require 'rjb'
require 'rjbextension'
Document = Rjb::import('org.apache.lucene.document.Document')
StandardAnalyzer = Rjb::import('org.apache.lucene.analysis.standard.StandardAnalyzer')
Field = Rjb::import('org.apache.lucene.document.Field')
IndexWriter = Rjb::import('org.apache.lucene.index.IndexWriter')