Skip to content

Instantly share code, notes, and snippets.

@ejhayes
ejhayes / setup_rails_base.sh
Last active August 29, 2015 13:57
Quick and dirty script to setup a base rails app with minimal tests and whatnot
#!/bin/bash
function info {
# Blue'ish
echo -e "\033[1;36m$1\033[0m" 1>&2
}
function error {
# Red'ish
echo -e "\033[1;35m$1\033[0m" 1>&2
@ejhayes
ejhayes / count_lines_in_big_file.sh
Created July 15, 2014 19:18
Way to count lines in a big file that is compressed without having to decompress. Includes ability to monitor counting progress
zcat $FILENAME | pv -cN extracting -s $(gzip -l $FILENAME | awk '{ print $2 }' | tail -1) | wc -l
@ejhayes
ejhayes / import_mongo_data.sh
Created July 16, 2014 23:27
Installing mongo in OSX and importing data
#!/bin/bash
# http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
# unzip data
tar -xvzf <backup file in tgz or tar.gz format>
# install mongo
brew install mongo
# create data dir
@ejhayes
ejhayes / issue.md
Created July 23, 2014 21:35
kimonolabs issue

When I make this request:

curl --include --request GET "https://www.kimonolabs.com/api/cdc6zudo?kimpath2=alabama.htm&apikey=GHidQWblK9GtdgDvZuhFgn9qD4U3dqhy"

Then I get these headers:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Wed, 23 Jul 2014 21:31:15 GMT

Etag: "-1017315174"

### This file specifies server-specific parameters,
### including HTTP proxy information, HTTP timeout settings,
### and authentication settings.
###
### The currently defined server options are:
### http-proxy-host Proxy host for HTTP connection
### http-proxy-port Port number of proxy host service
### http-proxy-username Username for auth to proxy service
### http-proxy-password Password for auth to proxy service
### http-proxy-exceptions List of sites that do not use proxy
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAC0AAAAVuCAIAAABptCosAAAgAElEQVR4nOzdeZAk130f+N/vvZeZdXVV391zX8AMgMFBAiAp0yIlkxJoSKBtgpS1XpJaKewVFCs5LIVD8jpWQcky7ZB1xMoRUkiKoJYibYZMrUydS1MAD1CkCIowDmJmcM3VM9M9fXfXXXm89377R3b3NObC4Jjp7sH3Ex0PVVlZlS8zq3tQ9b75e9xoNAgAAAAAAAAAAAAAAAAAAAAANo7a6A4AAAAAAAAAAAAAAAAAAAAAvNUhwAEAAAAAAAAAAAAAAAAAAACwwRDgAAAAAAAAAAAAAAAAAAAAANhgCHAAAAAAAAAAAAAAAAAAAAAAbDAEOAAAAAAAAAAAAAAAAAAAAAA2GAIcAAAAAAAAAAAAAAAAAAAAABsMAQ4AAAAAAAAAAAAAAAAAAACADYYABwAAAAAAAAAAAAAAAAAAAMAGQ4ADAAAAAAAAAAAAAAAAAAAAYIMhwAEAAAAAAAAAAAAAAAAAAACwwRDgAAAAAAAAAAAAAAAAAAAAANhgCHAAAAAAAAAAAAAAAAAAAAAAbDAEOAAAAAAAAAAAAAAAAAAAAAA2GAIcAAAAAAAAAAAAAAAAAAAAABsMAQ4AAAAAAAAAAAAAAAAAAACADYYABwAAAAAAAAAAAAAAAAAAAMAGMxvdAYA3k4gQX+kxYr7SYwAAAAAAAAAAAAAAAAAAABsJAQ64SQiJFxHy4mklwyG09h8hYiJFiokVo/AMAAAAAAAAAAAAAAAAAABsLm/RAIfIxQsuW5vhGleDzYCJNTORulCBA+cKAAAAAAAAAAAAAAAAAAC2iLdWgENkpRqD5LdFVgb5L+QyZG3YX4SY8wyHMK+swULExEQIcmweQsIIawAAAAAAAAAAAAAAAAAAwFb2Vglw5GkMzsf5L4z1Xzrqf9kcwOVLOuT1OZDk2HD5WfXkY0l6PrZkvXiS1bwOUyZZ4hL2VOBCny73mY
@ejhayes
ejhayes / declarative_goal_specifications.rb
Created September 10, 2014 08:05
Goals are a high level concept--having a user set a goal should be validated in a way that keeps the model closed for modification, allows maximum flexibility in expressing goal validation per user, and keeps the data in the database rather than mixed throughout the application logic.
# - simplified
module Goals
class WeightLossGoal < Goal
db_identifier :weight_loss_goal
validates_goal_with do |user, amount_weight|
# user is the user we are validating against
if amount_weight >= user.weight
raise InvalidGoalError.new('cannot lose more than you weigh')
@ejhayes
ejhayes / logstash_setup_notes.md
Created February 18, 2015 20:03
Logstash setup notes

Logstash Master Setup on AWS

AWS Configurations

  • Port 80 should be open on the server so kibana can be accessed
  • Port 5000 should be open for incoming traffic via logstash-forwarder aka lumberjack (this is where logstash data comes in). I set this to 0.0.0.0/0 although you could restrict it to just the internal machines you are monitoring.

MASTER: ElasticSearch Install

@ejhayes
ejhayes / boot2docker_network_timeout.sh
Created April 3, 2015 21:30
Fix Boot2Docker network timeout issue (sometimes VPN might affect this)
# fix boot2docker network timeouts (check boot2docker network interface name, mine is vboxnet0, yours may vary)
sudo route -nv add -net 192.168.59 -interface vboxnet0
#u: inet 192.168.59.0; u: link vboxnet0:a.0.27.0.0.0; RTM_ADD: Add Route: len 140, pid: 0, seq 1, errno 0, flags:<UP,STATIC>
#locks: inits:
#sockaddrs: <DST,GATEWAY,NETMASK>
# 192.168.59.0 vboxnet0:a.0.27.0.0.0 (0) 0 ffff ff
# add net 192.168.59: gateway vboxnet0
/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.2.0
*/
body {font:13px 'Helvetica',arial,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}