Skip to content

Instantly share code, notes, and snippets.

@mhoran
mhoran / tarsnap.sh
Created September 23, 2011 02:06
tarsnap script
#!/bin/sh
PATH=/usr/local/bin:$PATH
PREFIX=`hostname -s`
format=%Y%m%d
DATE=`date +$format`
echo "Creating ${PREFIX}_$DATE"
tarsnap -cf ${PREFIX}_$DATE --quiet -X `dirname $0`/tarsnap-exclude /
@mhoran
mhoran / mailcomplete.vim
Last active December 1, 2022 01:10
goobook omnicomplete with awk ported to vimscript!
" http://recursivedream.com/blog/2012/auto-completing-google-contacts-in-vim/
" Escape query and handle goobook errors
function! mailcomplete#Complete(findstart, base)
if a:findstart == 1
let line = getline('.')
let idx = col('.')
while idx > 0
let idx -= 1
let c = line[idx]
" break on header and previous email
ruby-1.8.7-p352 :001 > class T
ruby-1.8.7-p352 :002?> def something
ruby-1.8.7-p352 :003?> do_something do
ruby-1.8.7-p352 :004 > raise 'hello'
ruby-1.8.7-p352 :005?> end
ruby-1.8.7-p352 :006?> end
ruby-1.8.7-p352 :007?> def do_something
ruby-1.8.7-p352 :008?> yield
ruby-1.8.7-p352 :009?> end
ruby-1.8.7-p352 :010?> end
==12001== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==12001== Access not within mapped region at address 0x4
==12001== at 0x5FFD516: JSC::JSObject::getPrimitiveNumber(JSC::ExecState*, double&, JSC::JSValue&) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12001== by 0x395A58ED: ???
==12001== by 0x5FB02F0: JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::ScopeChainNode*, JSC::JSObject*) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12001== by 0x5FCBF20: JSC::evaluate(JSC::ExecState*, JSC::ScopeChainNode*, JSC::SourceCode const&, JSC::JSValue) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12001== by 0x57AAE75: WebCore::ScriptController::evaluateInWorld(WebCore::ScriptSourceCode const&, WebCore::DOMWrapperWorld*) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12001== by 0x57AB911: WebCore::ScriptController::evaluate(WebCore::ScriptSourceCode const&) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==1200
==12103== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==12103== Access not within mapped region at address 0x0
==12103== at 0x5FC3847: JSC::JSValue::get(JSC::ExecState*, JSC::Identifier const&, JSC::PropertySlot&) const (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12103== by 0x5FB7D1E: cti_op_get_by_id (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12103== by 0x395F38D8: ???
==12103== by 0x5FB02F0: JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::ScopeChainNode*, JSC::JSObject*) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12103== by 0x5FCBF20: JSC::evaluate(JSC::ExecState*, JSC::ScopeChainNode*, JSC::SourceCode const&, JSC::JSValue) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12103== by 0x57AAE75: WebCore::ScriptController::evaluateInWorld(WebCore::ScriptSourceCode const&, WebCore::DOMWrapperWorld*) (in /usr/lib/x86_64-linux-gnu/libQtWebKit.so.4.9.0)
==12103== by 0x57AB911: WebCore::ScriptControl
0 *__GI_raise raise.c 64 0x7fb623f89475
1 *__GI_abort abort.c 92 0x7fb623f8c6f0
2 __libc_message libc_fatal.c 189 0x7fb623fc332b
3 malloc_printerr malloc.c 6283 0x7fb623fccb76
4 *__GI___libc_free malloc.c 3738 0x7fb623fd18ac
5 QString::free(QString::Data*) /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fb624d645f8
6 ?? /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fb624dcf9aa
7 QUrl::toString(QFlags<QUrl::FormattingOption>) const /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fb624dd2334
8 WebPageManager::requestCreated WebPageManager.cpp 52 0x4150f6
9 WebPageManager::qt_static_metacall moc_WebPageManager.cpp 64 0x41b817
0 _int_free malloc.c 4892 0x7fe57d941fca
1 *__GI___libc_free malloc.c 3738 0x7fe57d9458ac
2 QString::free(QString::Data*) /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fe57e6d85f8
3 ?? /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fe57e7439aa
4 ?? /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fe57e74407e
5 QUrl::toEncoded(QFlags<QUrl::FormattingOption>) const /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fe57e74470d
6 ?? /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4 0 0x7fe57eb6d62b
7 ?? /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4 0 0x7fe57eb6f859
8 ?? /usr/lib/x86_64-linux-gnu/libQtNetwork.so.4 0 0x7fe57ebd0af5
9 QObject::event(QEvent*) /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7fe57e79ea4e
0 *__GI_raise raise.c 64 0x7f10aa057475
1 *__GI_abort abort.c 92 0x7f10aa05a6f0
2 __libc_message libc_fatal.c 189 0x7f10aa09132b
3 malloc_printerr malloc.c 6283 0x7f10aa09ab76
4 *__GI___libc_free malloc.c 3738 0x7f10aa09f8ac
5 QString::free(QString::Data*) /usr/lib/x86_64-linux-gnu/libQtCore.so.4 0 0x7f10aae325f8
6 QString::~QString qstring.h 880 0x4072cd
7 Response::toString Response.cpp 27 0x40f903
8 PageLoadingCommand::commandFinished PageLoadingCommand.cpp 45 0x414aaa
9 PageLoadingCommand::qt_static_metacall moc_PageLoadingCommand.cpp 55 0x41b486
before_install: sudo apt-get install lighttpd libfcgi-dev libmemcache-dev memcached
install:
- gem env version | grep '^\(2\|1.\(8\|9\|[0-9][0-9]\)\)' || gem update --system
- gem install --conservative rake
- rake deps
script: rake ci
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
int yearsToRetirementHelper(float principal, float rateOfReturn, float annualPostTaxIncome, float annualExpenses, int yearsToRetirementAcc) {
float returnOnInvestment = principal * rateOfReturn;
if (returnOnInvestment > annualExpenses) {
return yearsToRetirementAcc;
} else {
float newStash = (principal + returnOnInvestment + annualPostTaxIncome) - annualExpenses;
return yearsToRetirementHelper(newStash, rateOfReturn, annualPostTaxIncome, annualExpenses, yearsToRetirementAcc + 1);
}
}