Skip to content

Instantly share code, notes, and snippets.

@achambers
achambers / gist:1109960
Created July 27, 2011 17:46
insufficient_funds_java
public Account withdraw(long accountNumber, BigDecimal withdrawalAmount) {
Account account = accountDao.get(accountNumber);
if(!account.hasSufficientFunds(withdrawalAmount)) {
throw new InsufficientFundsException();
}
//some code here
return account;
@achambers
achambers / gist:1109964
Created July 27, 2011 17:48
insufficient_funds_ruby
def withdraw account_number, withdrawal_amount do
account = Account.find account_number
unless account.sufficient_funds? withdrawal_amount do
raise "Insufficient funds"
end
#...more code...
end
@achambers
achambers / include_vs_extend.rb
Created August 26, 2011 16:24
Include vs Extend
module Tweet
def save
puts 'Tweet saved'
end
end
class Foo
include Tweet # Add methods from Tweet as Instances Methods
end
@achambers
achambers / indextank_gem_install.rb
Created August 26, 2011 17:07
Indextank Gem Install
gem install 'indextank'
@achambers
achambers / indextank_create_index.rb
Created August 26, 2011 17:16
Indextank Create Index
require 'indextank'
client = IndexTank::Client.new("http://my-indextank-api-url.api.indextank.com")
index = client.indexes("my_index_name")
index.add()
print "Waiting for index to be ready"
while not index.running?
print "."
@achambers
achambers / gist:2305759
Created April 4, 2012 21:19
Install instantclient in Linux
digital-alley:tmpdir aaron$ vagrant up
digital-alley:tmpdir aaron$ vagrant ssh
vagrant@lucid32:~$ sudo apt-get install unzip
vagrant@lucid32:~$ sudo apt-get install rpm
vagrant@lucid32:~$ cd /tmp
vagrant@lucid32:~$ cp /vagrant/instantclient-* .
vagrant@lucid32:~$ cd /opt
vagrant@lucid32:~$ sudo mkdir oracle
vagrant@lucid32:~$ cd oracle
@achambers
achambers / gist:2305772
Created April 4, 2012 21:21
Require oci8
vagrant@lucid32:~$ irb
irb(main):001:0> require 'rubygems'
irb(main):001:0> require 'oci8'
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@achambers
achambers / Client.js
Created February 25, 2014 09:39
Unit testing an arbitrary Ember.Object
export default Ember.Object.extend({
location: function() {
return new Ember.RSVP.Promise(function(resolve, reject) {
//Simulate some async operation
Ember.run.later(function() {
resolve({lat: "123", lon: "234", city: "London"});
}, 2000);
});
}
});

Keybase proof

I hereby claim:

  • I am achambers on github.
  • I am achambers (https://keybase.io/achambers) on keybase.
  • I have a public key whose fingerprint is 2A39 4297 B06D 227B CE11 5A56 5CFB 14B6 EE41 872C

To claim this, I am signing this object: