Skip to content

Instantly share code, notes, and snippets.

@bashcoder
bashcoder / elasticsearch.yml
Created November 11, 2017 07:32 — forked from reyjrar/elasticsearch.yml
ElasticSearch config for a write-heavy cluster
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
@bashcoder
bashcoder / API.md
Created August 11, 2017 19:56 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,
@bashcoder
bashcoder / elasticsearch-handlers-main.yml
Created February 20, 2017 04:18 — forked from labrown/elasticsearch-handlers-main.yml
Ansible rolling restart of Elasticsearch Cluster
---
###
# Elasticsearch Rolling restart using Ansible
###
##
## Why is this needed?
##
#
# Even if you use a serial setting to limit the number of nodes processed at one
@bashcoder
bashcoder / migrate-redis.py
Created January 3, 2017 21:59 — forked from thomasst/migrate-redis.py
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@bashcoder
bashcoder / ftp-upload.rb
Created November 16, 2016 20:32 — forked from taf2/ftp-upload.rb
uploading a file in ruby is hard. ftp is hard.
# fireway configured with: http://major.io/2007/07/01/active-ftp-connections-through-iptables/
require 'net/ftp'
require 'stringio'
# allows us to upload files by content instead of writing to disk first
class Net::FTP
def puttextcontent(content, remotefile, &block)
f = StringIO.new(content)
begin
@bashcoder
bashcoder / rails 3.2.11 params patch
Created February 11, 2016 14:00 — forked from Unpakt/rails 3.2.11 params patch
Put "repair_empty_param_associations" in your before filters in the application_controller.rb
def repair_empty_param_associations
params.keys.each do |key|
repair_nested_params(params, key, params[key])
end
end
private
def repair_nested_params(current_params, key, value)
if key =~ /^(.*)_attributes$/ && value.nil?
@bashcoder
bashcoder / main.yml
Created February 10, 2016 20:08 — forked from rothgar/main.yml
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@bashcoder
bashcoder / gist:fa512a44e8cbb4a4db7b
Created February 4, 2016 02:02 — forked from pjobson/remove_mcafee.md
OSX McAfee Removal
launchctl stop com.mcafee.menulet
launchctl stop com.mcafee.reporter
launchctl remove com.mcafee.menulet
launchctl remove com.mcafee.reporter
sudo su -
launchctl stop com.mcafee.virusscan.fmpd
launchctl stop com.mcafee.ssm.ScanManager
@bashcoder
bashcoder / vim-ruby-folding-1.1.vim
Created October 24, 2013 14:33
vim ruby folding for methods
" FoldSearch-based folding.
" Copyright (C) 2005 Mauricio Fernandez <mfp@acm.org>
" Current version: http://eigenclass.org/hiki.rb?Usable+Ruby+folding+for+Vim
"
" Add this to your .vimrc and fold with :R. The default fold expression will
" work with Ruby scripts; you can specify where folds start with
" let b:foldsearchexpr = 'myexpression'
" e.g.
" let b:foldsearchexpr='\(^\s*\(\(private\|public\|protected\|class\)\s\)\)'
" or so for Java.