Skip to content

Instantly share code, notes, and snippets.

View kstevens715's full-sized avatar

Kyle Stevens kstevens715

View GitHub Profile
@kstevens715
kstevens715 / test_helper.rb
Created February 17, 2014 01:05
Make Factory Girl's `create` method give the name of the class that raises ActiveRecord::RecordInvalid. Useful when you have nested factories whose models have attributes with similar names ex. `name`.
include FactoryGirl::Syntax::Methods
def create_with_info(*args, &block)
create_without_info(*args, &block)
rescue => e
raise unless e.is_a? ActiveRecord::RecordInvalid
raise $!, "#{e.message} (Class #{e.record.class.name})", $!.backtrace
end
surround_test_suite { invoke1 }
surround_test_suite { invoke2 }
surround_test_suite { invoke3 }
def surround_test_suite(&block)
block.call
rescue => e
puts e
end
@kstevens715
kstevens715 / .bash_profile
Last active August 29, 2015 14:14
pair will start a new tmux session named pair, or if you're already in one with another name it'll rename it to pair. It would also be nice to go a step further and have a way to toggle it back off again. This is meant to be used in conjunction with the pairing setup shown in this blog article: http://collectiveidea.com/blog/archives/2014/02/18/…
alias getmyip='dig +short myip.opendns.com @resolver1.opendns.com'
function pair() {
if [ "$TMUX" = "" ]; then
tmux new-session -s pair \; set-option display-time 4000\; display-message "Pairing Enabled: ssh pair@`getmyip`"
else
tmux rename-session pair \; set-option display-time 4000\; display-message "Pairing Enabled: ssh pair@`getmyip`"
fi
}
@kstevens715
kstevens715 / partial_stage.md
Last active August 29, 2015 14:23
This shows how to partially stage a HUGE file, one piece at a time.

This shows how to partially stage a HUGE file, one piece at a time. git add -p also does this, but sometimes doesn't show enough context and if the file is big enough, regex searching doesn't seem to always work.

  1. This requires Vim, with the Fugitive plugin installed (see reference links).
  2. Open the file in Vim, and type :Gdiff. The screen will split in two, with the left hand side showing the indexed version of the file (what will be committed), and the right hand side showing the current working copy.
  3. Move the cursor to the right-side pane, and find the hunk you're interested in.
  4. With the cursor in the hunk, type :diffput. The hunk will disappear from the right hand side, and the left hand side will get a "+" in the status bar indicating unsaved changes.
  5. Complete steps 2-3 until everything is staged.
  6. When done, move the cursor to the left pane and save it to stage the files.

References

windows:
- name: vim
root: ~/code/transformer
layout: even-horizontal
panes:
- vim ~/code/transformer/spec/samples/schema_validated/tjcas.xml
- name: rabbitmq
root: ~/code/webadmit
layout: even-horizontal
panes:
" Installing plugins to /home/kstevens/.vim/bundle
Plugin 'gmarik/Vundle.vim'
Plugin 'Quramy/vim-js-pretty-template'
Plugin 'bling/vim-airline'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'kien/ctrlp.vim'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'mileszs/ack.vim'
Plugin 'sickill/vim-monokai'
class UserIdentity
def cas_attachments
sql = id_column.in(cas_attachment_belongs_to_my_cas).or(id_column.in(cas_attachment_belongs_to_my_programs))
CasAttachment.where(sql)
end
def table
CasAttachment.arel_table
end
@kstevens715
kstevens715 / install.log
Created November 17, 2016 13:22
SQL Server on Ubuntu install error
kstevens@liaison-dell:~$ sudo apt-get install mssql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
version: '2'
services:
etl:
build:
context: .
dockerfile: Dockerfile
command: sleep infinity
volumes:
- .:/opt/app
version: '2'
services:
msql:
image: microsoft/mssql-server-linux
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=1337Password