Skip to content

Instantly share code, notes, and snippets.

@danshultz
danshultz / user-agent.json
Created September 13, 2013 17:40
Kibana Graphs
{
"title": "user-agent",
"rows": [
{
"title": "Options",
"height": "50px",
"editable": true,
"collapse": false,
"collapsable": true,
"panels": [
@danshultz
danshultz / dump_errors.rb
Created August 7, 2013 18:08
Errbit Errors to ElasticSearch/Kibana
require 'net/http'
require 'json'
require 'time'
es_host = "127.0.0.1"
es_port = "9200"
host = Net::HTTP.new(es_host, es_port)
apps = %w(App1 App2)
@danshultz
danshultz / OnException.cs
Created July 3, 2013 15:23
.NET MVC Sentry logging in OnException
public RavenClient raven
{
get
{
var ravenKey = "raven_key";
var raven = new RavenClient(ravenKey);
return raven;
}
}
@danshultz
danshultz / enc.yaml
Created May 9, 2013 17:59
I'm using a custom ENC which we are using to dump a yaml file based on an internal configuration wrapper. I want the ability to specify a parameter (variable) in the top scope and allow it to be be a default variable of a class. At this point, my research shows me this is not a bad idea
classes:
rsyslog::client:
port: 1234
parameters:
server: my-rsyslog-server
@danshultz
danshultz / bootstrap.rake
Created April 3, 2013 12:10
Basic Rails task to initialize the secrets.rb
require 'ostruct'
namespace :bootstrap do
desc "Boostrap development machine"
task :setup do
Rake::Task['bootstrap:secrets'].invoke
end
task :secrets do
@danshultz
danshultz / render.rb
Created March 15, 2013 00:51
Simple ERB render function
def render(template, save_path, vars)
template_file = File.open("lib/templates/#{template}", 'r').read
erb = ERB.new(template_file)
results = erb.result(OpenStruct.new(vars).instance_eval { binding })
File.open(save_path, 'w+') { |file| file.write(results) }
end
@danshultz
danshultz / find across commits.sh
Last active December 12, 2015 09:29
Git Tricks
# grep across all commits
git grep <pattern> $(git rev-list --all)
# find out which branch(es) contains said commit
git branch -r --contains <sha1>
@danshultz
danshultz / example.js
Created November 10, 2012 04:01
Promises
// compiled javascript file
(function() {
var appendToContainer, buildElement, buildElements, getAllPeople, getAllPets, getPeople, getPets,
__slice = [].slice;
$(document).ready(function() {
return getAllPeople().then(getAllPets).then(buildElements).then(appendToContainer);
});
@danshultz
danshultz / code.rb
Created November 8, 2012 14:25
Reply to Blog post activerecord-black-magic
# Ref http://spin.atomicobject.com/2012/10/30/activerecord-black-magic/
class EmployeeFinder
def self.accessible_by(user)
Employee.joins(:companies) \
.merge(Company.where(:id => user.company_ids)) \
.uniq
end
end
@danshultz
danshultz / script.sh
Created November 7, 2012 13:22
find script and view in Vim
vim $(grep -lr --include=*.rb omc_data_service .)