Skip to content

Instantly share code, notes, and snippets.

View skwp's full-sized avatar

Yan Pritzker skwp

View GitHub Profile
class MyCode
def speak
"hello"
end
def do_something!
call_external_service
call_another_service("some parameter")
end
require File.join(File.dirname(__FILE__), "test_helper")
require 'my_code' # this is what I will be testing in this unit test
class MyFirstTest < Test::Unit::TestCase
context "testing something fun" do
setup do
# in this case MyCode makes a call to an external service
# for this test, I want to stub out method "call_external_service"
# for more stubbing examples: http://flexmock.rubyforge.org/
mongrel@es-mongrel1:/var/log/cft/mailer$ sudo monit status
The monit daemon 4.10.1 uptime: 15d 2h 8m
System 'es-mongrel1'
status running
monitoring status monitored
load average [0.27] [0.21] [0.12]
cpu 1.7%us 0.3%sy 0.0%wa
memory usage 848956 kB [47.6%]
data collected Thu Jan 6 22:08:59 2011
# untested
class WrappedException < RuntimeException
def initialize(msg_or_exception)
if msg_or_exception.respond_to?(:backtrace)
@parent_backtrace = msg_or_exception.backtrace
end
super(msg_or_exception)
end
def backtrace
-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 182M (Tables: 79)
[--] Data in InnoDB tables: 1M (Tables: 77)
[!!] Total fragmented tables: 77
-------- Security Recommendations -------------------------------------------
[!!] User 'root@127.0.0.1' has no password set.
[!!] User 'root@localhost' has no password set.
[!!] User 'root@skwp-mbp.local' has no password set.
@skwp
skwp / ruby_test.rb
Created June 23, 2011 06:08
Ruby Questions
# Instructions for this test:
# 1. Please clone this gist as a git repo locally
# 2. Create your own github repo called 'rubytest' (or a name of your choice) and add this repo as a new remote to the cloned repo
# 3. Edit this file to answer the questions, and push this file with answers back out to your own 'rubytest' repo.
# Problem 1. Explain briefly what this code does, fix any bugs, then clean it up however you
# like and write a unit test using RSpec.
def bracketed_list(values)
temp=""
@skwp
skwp / .vimrc
Created October 26, 2011 16:58
ConqueTerm Configuration
" Run the current file in a ConqueTerm, great for ruby tests
let g:ConqueTerm_InsertOnEnter = 0
let g:ConqueTerm_CWInsert = 1
nmap <silent> <Leader>r :call RunRubyCurrentFileConque()<CR>
nmap <silent> <Leader>R :call RunRakeConque()<CR>
nmap <silent> <Leader>c :execute 'ConqueTermSplit script/console'<CR>
nmap <silent> <Leader>i :execute 'ConqueTermSplit pry'<CR>
nmap <silent> <Leader>b :execute 'ConqueTermSplit /bin/bash --login'<CR>
nmap <silent> <Leader>S :call RunRspecCurrentFileConque()<CR>
@skwp
skwp / .gitconfig
Created October 27, 2011 01:28
gitconfig
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = auto
[gc]
auto = 1
[merge]
summary = true
@skwp
skwp / git_grep_partial.vim
Created October 31, 2011 16:32
git grep partial
" Find references to the currently opened partial
" by pressing P in command mode
function GitGrepCurrentPartial()
:call GitGrep(substitute(substitute(substitute(expand('%<'),'.*\/','','g'), '^_','','g'),'.html','','g'))
endfunction
command! GitGrepCurrentPartial call GitGrepCurrentPartial()
nnoremap <silent> P :GitGrepCurrentPartial<CR>
" Find references to current word, hit K
nnoremap <silent> K :GitGrep <cword><CR>
@skwp
skwp / logcaller.js
Created November 21, 2011 22:17
log the caller of the log function
function logCall() {
console.log(logCall.caller.name + '(' +
Array.prototype.slice.call(logCall.caller.arguments)
.map(JSON.stringify).join(', ') +
')');
}