Skip to content

Instantly share code, notes, and snippets.

View excalq's full-sized avatar

Arthur Kepler excalq

View GitHub Profile
@excalq
excalq / dev_clusters.rb
Created February 9, 2017 04:47
DevClusters - Build/Start/Stop an AWS cluster for a user
#!/usr/bin/env ruby
USER="arthur"
AWS_KEY="/Users/arthur/.ssh/DevClusters.pem"
CLUSTER_ROLES={ # Build in this order:
nfs: {image: 'ami-a0951573', name: 'devcluster-nfs', secgroups: ['sg-b37b7886','sg-aa7a697f'], count: 1},
redis: {image: 'ami-10201b69', name: 'devcluster-redis', secgroups: ['sg-b37b7886','sg-aa7a697f'], count: 1},
databrain: {image: 'ami-8a30206d', name: 'devcluster-databrain', secgroups: ['sg-b37b7886','sg-aa7a697f'], count: 1},
mysql: {image: 'ami-cc5b10fd', name: 'devcluster-mysql', secgroups: ['sg-b37b7886','sg-aa7a697f'], count: 2},
mongodb: {image: 'ami-56102071', name: 'devcluster-mongodb', secgroups: ['sg-b37b7886','sg-aa7a697f'], count: 2},
@excalq
excalq / rails.rb
Last active September 18, 2018 13:49
A Logstash Grok Pattern for Rails 3
####################################
### Rais3 Log Grok (Unicorn and Thin supported at :info level)
## There are many non-capturing groups. For debugging, change them to named groups and use http://grokconstructor.appspot.com/do/match
#
## Assumes Rails is prepending :uuid to log lines, with one log per unicorn worker.
## Assumes the whole request is sent multiline (by Filebeat, not Logstash mulitline plugin)
#
## Add this to the Filebeat.yml prospector
## multiline:
# pattern: '\[[a-fA-F0-9]{32}\]( Started |$)'
23.23.192.96 gowatchit.com www.gowatchit.com mrqe.gowatchit.com ebert.gowatchit.com nytimes.gowatchit.com api.gowatchit.com radius.gowatchit.com
[Wed, 02 Apr 2014 12:28:12 -0700] INFO: Starting Chef Solo Run
/usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/node.rb:180:in `method_missing': Attribute default is not defined! (ArgumentError)
from /etc/chef-custom/recipes/cookbooks/main/attributes/default.rb:1:in `from_file'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/cookbook.rb:73:in `load_attributes'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/cookbook.rb:71:in `each'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/cookbook.rb:71:in `load_attributes'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/compile.rb:61:in `load_attributes'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/cookbook_loader.rb:107:in `each'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.4/lib/chef/cookbook_loader.rb:106:in `each_value'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.
@excalq
excalq / gist:4338714
Created December 19, 2012 17:48
Adding a Git Hook to prevent console.log() from appearing in your code

Place the code below into this file: (Inside your local project repo)

  .git/hooks/pre-commit
#!/bin/sh
 
if git rev-parse --verify HEAD >/dev/null 2>&1; then
 against=HEAD
@excalq
excalq / tmux-window-keys.sh
Created July 23, 2012 16:55
Using Back/Forward Mouse/Keyboard media keys to change Tmux/Screen Windows
# These two shortcuts allow your media keyboard or mouse's back/forward keys to change windows in screen.
# This is designed to work with tmux or screen (using ctrl+a as the command shortcut) inside a Guake terminal
# You'll also need xdotool installed (aptitude install xdotool)
# Enter these as shortcuts in Ubuntu's "System Settings" > "Keyboard" > "Shortcuts" (tab) > "Custom Shortcuts"
# Previous/Back Key
xdotool search --onlyvisible --name Guake key ctrl+a p
# Next/Forward Key
xdotool search --onlyvisible --name Guake key ctrl+a n
@excalq
excalq / gist:2961415
Last active March 19, 2024 17:45
Javacript: Set or Update a URL/QueryString Parameter, and update URL using HTML history.replaceState()
// 2024 Update, use URLSearchParams [https://caniuse.com/urlsearchparams]
export function createQueryString2(name: string, value: string, searchParams: any) {
const params = new URLSearchParams(searchParams);
params.set(name, value.toLowerCase());
return params.toString();
}
// ---- Original 2012 version, when browsers really sucked ----
// Explicitly save/update a url parameter using HTML5's replaceState().