View erase group currencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exchange.all.each {|e| e.destroy if e.group} | |
Account.all.each {|a| a.destroy if a.group} | |
Group.all.each {|g| g.adhoc_currency = false; g.unit = nil; g.save!} |
View rel-payment bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ asset_urls = [];var links = document.getElementsByTagName("a");for(var i=0;i<links.length;i++){if (links[i].getAttribute('rel') == 'payment') { asset_urls.push(links[i].getAttribute('href'));}} window.name = 'receiver'; var remoteWin=window.open('','','resizable=yes,width=550,height=550'); remoteWin.document.write('<html><body>'); for(var j=0;j<asset_urls.length;j++){remoteWin.document.write('<a href="' + asset_urls[j] + '/new?to=' + encodeURIComponent(window.location.href) + '">' + asset_urls[j] + '</a><br><br>');} remoteWin.document.write('') })(); |
View simpler opentransact
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ asset_urls = [];var links = document.getElementsByTagName("a");for(var i=0;i<links.length;i++){if (links[i].getAttribute('href').match(/\/transacts/)) { asset_urls.push(links[i].getAttribute('href'));}} var remoteWin=window.open('','','resizable=yes,width=550,height=550'); remoteWin.document.write('<html><body>'); for(var j=0;j<asset_urls.length;j++){remoteWin.document.write('<a href="' + asset_urls[j] + '/new?to=' + encodeURIComponent(window.location.href) + '">' + asset_urls[j] + '</a><br><br>');} remoteWin.document.write('') })(); |
View twitter & opentransact
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ asset_urls = [];var twitter_id='';var metatags=document.getElementsByTagName("meta");for(var j=0;j<metatags.length;j++){if(metatags[j].getAttribute('name') == 'session-userid') {twitter_id=metatags[j].getAttribute('content');}} var links = document.getElementsByTagName("a");for(var i=0;i<links.length;i++){if (links[i].getAttribute('href') && links[i].getAttribute('href').match(/\/transacts/)) { asset_urls.push(links[i].getAttribute('href'));}} var remoteWin=window.open('','','resizable=yes,width=550,height=550'); remoteWin.document.write('<html><body>'); for(var j=0;j<asset_urls.length;j++){remoteWin.document.write('<a href="' + asset_urls[j] + '/new?to=' + twitter_id + '">' + asset_urls[j] + '</a><br><br>');} remoteWin.document.write('</body></html>') })(); |
View groupy branch migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. create a group -> group_id | |
2. delete new group's forum and assign old main forum to new group: | |
Forum.find_by_group_id(group_id).delete | |
g = Group.find(group_id) | |
f = Forum.first(:conditions => ['group_id IS ?',nil]) | |
f.group = g | |
f.save | |
3. change all members' default accounts to belong to the new group: |
View gist:717659
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@e.amount = 1.0 | |
@e.customer = @p2 | |
@membership.roles = ['individual'] | |
@membership.save | |
account = @p2.account(@g) | |
account.balance = 0.0 | |
account.credit_limit = 0.5 | |
account.save! |
View gist:717685
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
can :create, Exchange do |exchange| | |
unless exchange.group | |
# the presence of group is validated when creating an exchange | |
# group will be nil for the new method, so allow it | |
true | |
else | |
membership = Membership.mem(person,exchange.group) | |
unless membership | |
false | |
else |
View gist:717686
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authorized?(amount) | |
credit_limit.nil? or (amount <= balance + credit_limit) | |
end |
View create_request_token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_request_token(params={}) | |
if params[:scope] | |
scope_uri = URI.parse(params[:scope]) | |
# XXX ignoring host:port and assuming it's our host:port | |
filepath = RAILS_ROOT + '/public' + scope_uri.path | |
if File.exist?(filepath) | |
# valid asset is required | |
asset = CGI::parse(scope_uri.query)['asset'][0] | |
unless asset.blank? | |
group = Group.find_by_asset(asset) |
OlderNewer