Skip to content

Instantly share code, notes, and snippets.

View kbrock's full-sized avatar

Keenan Brock kbrock

View GitHub Profile
@kbrock
kbrock / sort_test.rb
Last active August 27, 2015 00:52
Testing different ways to bring back active records by the source ids
#!/usr/bin/env ruby
require 'ostruct'
require 'byebug'
module Enumerable
def index_by
if block_given?
Hash[map { |elem| [yield(elem), elem] }]
else
to_enum(:index_by) { size if respond_to?(:size) }
@kbrock
kbrock / gitconfig
Last active August 29, 2015 14:02
gitconfig
[alias]
st = status
br = branch
co = checkout
cat = show
#origin = !sh -c 'git remote add -t ${2:-master} -m ${2:-master} ${1:-origin} ${0}'
prune = fetch --prune
#amend keeping the same comment
amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
# add file to .gitignore
digraph G {
label = "Enterprise"
rankdir = "TB";
node [ shape="Mrecord" ]
edge [ color="#555555"; dir="back"]
subgraph cluster_1 {
label = "Region: 1"
color = "#000000"
#!/usr/bin/env ruby
require 'nokogiri'
src =<<EOD
<wrapper xmlns="ns" xmlns:extra="extra">
<record xml:id="r1">
<field>aaa</field>
<field extra:type="second">bbb</field>
</record>
framework 'ScriptingBridge'
safari = SBApplication.applicationWithBundleIdentifier('com.apple.Safari')
google_tab=safari.windows.first.currentTab
cmd="document.f.q.value='mac ruby'"
safari.performSelector(:"doJavaScript:in:", withObject:cmd, withObject:google_tab)
--applescript
tell application "Safari"
activate
set google_tab to current tab of first window
-- google currently open in the screen
tell google_tab
do JavaScript "document.f.q.value='mac ruby'"
end tell
end tell
# Apple Script to open google in a new tab
# tell application "Safari"
# make new document
# set URL of first document to "http://www.google.com"
# end tell
# rb-appscript to do the same
# app("Safari").make(:new => :document)
# app("Safari").documents[1].URL.set("http://www.google.com")

You may find yourself in a situation where you have a modified v2_key.dev, and are missing a v2_key.

that is easy to fix:

mv v2_key.dev v2_key
git checkout v2_key.dev

@kbrock
kbrock / evm.log
Created September 4, 2015 15:40
evm.log with pruned timestamp to reduce width
# Logfile created on 2015-09-04 10:56:03 -0400 by logger.rb/47272
[-] I 10:56:03.728893 #13407] : MIQ(Vmdb::Loggers.apply_config) Log level for vim.log has been changed to [WARN]
[-] I 10:56:05.020030 #13407] : MIQ(Vmdb::Initializer.init) - Program Name: /Users/kbrock/.gem/ruby/2.2.2/bin/rake, PID: 13407, ENV['MIQ_GUID']: , ENV['EVMSERVER']:
[-] I 10:56:05.024106 #13407] : MIQ(Vmdb::Initializer.init) - Init complete
[-] I 10:56:05.711462 #13407] : MIQ(EvmApplication.start) EVM Startup initiated
[-] I 10:56:10.646710 #13413] : MIQ(Vmdb::Loggers.apply_config) Log level for vim.log has been changed to [WARN]
** EVM vmdb_development ** 1
[-] I 10:56:11.568937 #13413] : MIQ(Vmdb::Initializer.init) - Program Name: /Users/kbrock/src/manageiq/bin/rails, PID: 13413, ENV['MIQ_GUID']: , ENV['EVMSERVER']:
[-] I 10:56:11.572899 #13413] : MIQ(Vmdb::Initializer.init) - Init complete
[-] I 10:56:12.233358 #13413] : MIQ(MiqServer.validate_database) Database Adapter: [PostgreSQL], version: [PostgreSQL 9.2.8 on x86_64-apple-d
module ActiveRecord
##idea is from lovdbyless
##These extensions give database specific implementations for common functions
module ConnectionAdaptersExt
module MySQL
def rand
'RANDOM()'
end
def now
'NOW()'