Skip to content

Instantly share code, notes, and snippets.

View earlonrails's full-sized avatar

Kevin Krauss earlonrails

  • Disney Streaming
  • San Francisco
View GitHub Profile
@earlonrails
earlonrails / delete_logstash_indexes_by_date.sh
Created March 6, 2014 19:02
Delete logstash indexes by date starting from X number of days ago. IE ./delete_logstash_indexes_by_date.sh 60 # start 60 days ago and delete an index until the beginning of time
#!/usr/bin/env bash
days_ago="$1"
counter=$days_ago
get_month(){
if [ `uname` == "Darwin" ]; then
date -v-$1d "+%m"
else
date +"%m" --date='-$"$1" day'
fi
#!/bin/sh
### BEGIN INIT INFO
# Provides: jmeter-server
# Required-Start: $syslog $local_fs
# Required-Stop: $syslog $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache JMeter Remote Server
# Description: Apache JMeter Remote Server runs JMeter tests issued from a remote server.
### END INIT INFO
@earlonrails
earlonrails / newsyslog.d-development.conf
Created July 24, 2014 17:40
mac set project logs to be rotated /etc/newsyslog.d/development.conf
# truncate rails logs whenever they are larger than 40mb
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/Users/Krauss/Projects/**/**/log/*.log Krauss:staff 644 0 40960 * G
<script type="text/javascript">
BOOMR.init({
beacon_url: "/boomerang.gif",
BW: {
enabled: false
}
});
BOOMR.subscribe('before_beacon', trackInAnalytics);
var pageType = "homepage"; // customize this
@earlonrails
earlonrails / create_kitchenplan_config.rb
Created November 7, 2014 18:25
Generate a kitchenplan config based upon what you system already is configured with.
#!/usr/bin/env ruby
require 'pp'
require 'yaml'
homebrew_binaries = `brew ls`.split
applications = `\ls /Applications`.gsub(".app", "").split("\n")
node_packages = `npm -g ls --parseable --depth 0`.gsub("/usr/local/lib", "").gsub("/node_modules/", "").split
def cask_has_app?(app)
`brew cask search '#{app}'`["==> Exact match"]
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
class ObjectStash
def self.store obj, file_name
marshal_dump = Marshal.dump(obj)
file = File.new(file_name,'w')
file.write marshal_dump
file.close
@earlonrails
earlonrails / mock_net_http.rb
Created June 1, 2015 21:11
mock net http requests
def mock_net(uri = nil)
net_get = double('net get').as_null_object
if uri
expect(Net::HTTP::Get).to receive(:new).with(uri.request_uri) { net_get }
else
Net::HTTP::Get.stub(:new) { net_get }
end
http = double('net http').as_null_object
response = double('response')
@earlonrails
earlonrails / launch-list.rb
Created June 23, 2015 17:14
list only running process from launchctl and toggle pid or no pid
#!/usr/bin/env ruby
print_pid = ARGV[0]
list = IO.popen('launchctl list').readlines
running = list.inject([]) do |result, line|
if line[/^[0-9]/]
if print_pid
result << line.sub(/\t0/, '')
else
result << line.sub(/\d+\t0\t/, '')
end
@earlonrails
earlonrails / common_char.rb
Created July 21, 2015 20:17
two character string arguments and returns # a string containing only the characters found in both strings. A version which is order N-squared and one which is order N, in RUBY!
# Write a function f(a, b) which takes two character string arguments and returns
# a string containing only the characters found in both strings in the order of a.
# Write a version which is order N-squared and one which is order N.
string_a = "abcdefg"
string_b = "afcbedf"
def common_char_n_squared(string1, string2)
common_chars = ""
string1.each_char do |i|
@earlonrails
earlonrails / email_regex.rb
Last active August 29, 2015 14:25
Email regex ruby
/^[\w\-\.]+\@[\w\.\-]+\.\w{2,4}$/
# matches
# bob@gmail.com
# bob@ccsf.mail.edu
# bob123@city.org
# bob-123@conf.org
# bob.frank@city.com