Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / kibana-three
Created September 27, 2013 13:42
Simple ngxin config Taken from my Kibana three config
server {
listen *:80 ;
access_log /var/log/nginx/kibana.access.log;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
location / {
root /var/www/apps/kibana_three/current;
*.csproj text=auto merge=union
*.sln -text merge=union
@danshultz
danshultz / iframe-normalizer.js
Last active January 1, 2016 05:49
Sandboxing content in an iframe
/*globals $:true*/
(function () {
var resizeInterval = 42;
var resizeLimit = 1000 / 41 * 5;
var initialize = function () {
$('iframe[data-normalize]').each(function () {
$(this).on('load', normalizeIframe);
});
};
module ActiveRecord
module ConnectionAdapters
class Mysql2Adapter
alias :build_table_structure :structure_dump
def structure_dump
build_table_structure << build_view_structure << build_function_structure
end
@danshultz
danshultz / unicorn.rb
Last active August 29, 2015 13:57
Monitoring your unicorn workers with Sensu
# Monitor the unicorn processes on 10 second intervals
unicorn_monitor = Proc.new {
require 'socket'
require 'json'
require 'raindrops'
address = "0.0.0.0:8080"
socket = Raindrops::InetDiagSocket.new
udp = UDPSocket.new
while(true) do
@danshultz
danshultz / .bash_profile
Created September 3, 2014 19:21
bashrc
# source ~/bin/git-completion.bash
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
@danshultz
danshultz / application.js
Created February 19, 2015 20:33
Nested Url Support - Ember Data
import Ember from 'ember';
export default DS.ActiveModelAdapter.extend({
findQuery: function(store, type, query) {
// wrap the query in an Ember.Object and pass it through as the "record" to the buildUrl method
var url = this.buildURL(type.typeKey, null, Ember.Object.create(query));
return this.ajax(url, 'GET', { data: query });
},
@danshultz
danshultz / host-ember-app.md
Created March 1, 2015 21:13
Hosting Ember App on S3
  1. Use ember-deploy + ember-deploy-s3 + ember-deploy-s3-index
  2. npm install --save-dev ember-deploy ember-deploy-s3 ember-deploy-s3-index
  3. Update nginx with the following config
server {
  listen 80;
  server_name foo.example.dev;
  location / {
    set $s3_bucket 'my-ember-app-index.s3.amazonaws.com';
    set $url_full         '$1';