Skip to content

Instantly share code, notes, and snippets.

{
"fields": [
"login",
"geoip.country_code2",
"geoip.country_name",
"source_ip"
],
"query": {
"filtered": {
Sidekiq is usual install in Rails 5 right now (7/26)
Sidekiq web is usual, except you need to install sinatra from master and add rack-protection from it's master before sinatra.
The master branch of Sinatra currently has a dependency on rack-protection 2.0 (rack-protection's master branch).
gem 'rack-protection', github: 'sinatra/rack-protection'
gem 'sinatra', github: 'sinatra'
@ETetzlaff
ETetzlaff / validate.sh
Created April 11, 2016 18:46 — forked from hrwgc/validate.sh
bash wget - check if file exists at url before downloading
#!/bin/bash
# simple function to check http response code before downloading a remote file
# example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi
}
@ETetzlaff
ETetzlaff / install_elasticsearch_osx.md
Last active February 22, 2016 17:50 — forked from djonsson/install_elasticsearch_osx.md
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@ETetzlaff
ETetzlaff / data2csv-data2json-data2arr.rb
Created February 1, 2016 21:58 — forked from szabcsee/data2csv-data2json-data2arr.rb
Sinatra delivers data as json and deliver data in csv as attachment
require 'sinatra'
require 'json'
require 'csv'
# Serve data as JSON
get '/hi/:name' do
name = params[:name]
content_type :json
{ :message => name }.to_json
end
@ETetzlaff
ETetzlaff / capybara cheat sheet
Last active September 3, 2015 18:27 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ETetzlaff
ETetzlaff / rspec_rails_cheetsheet.rb
Last active August 29, 2015 14:27 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
#!/usr/bin/env ruby
# If you get "unknown OID 705: failed to recognize type of '<field>'. It will be treated as String."
# it probably means that type of column could not be identified when retriving records
# Example
User.where("'something' as something")
# Will results in unknown OID. However doing this:
@ETetzlaff
ETetzlaff / README.md
Last active August 29, 2015 14:18 — forked from fnichol/README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@ETetzlaff
ETetzlaff / pgupgrade.md
Last active August 29, 2015 14:16
Upgrade Postgres 9.3 -> 9.4

Upgrade through Brew

$ brew update
 
$ brew upgrade

Ensure current psql instance is shut down