Skip to content

Instantly share code, notes, and snippets.

View herestomwiththeweather's full-sized avatar
🏠
Working from home

Tom Brown herestomwiththeweather

🏠
Working from home
View GitHub Profile
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!}
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('') })();
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('') })();
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>') })();
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:
@herestomwiththeweather
herestomwiththeweather / gist:717659
Created November 27, 2010 07:00
RSpec and CanCan Authorization for Intentional Economics
@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!
@herestomwiththeweather
herestomwiththeweather / gist:717685
Created November 27, 2010 07:35
RSpec and CanCan Authorization for Intentional Economics
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
@herestomwiththeweather
herestomwiththeweather / gist:717686
Created November 27, 2010 07:39
RSpec and CanCan Authorization for Intentional Economics
def authorized?(amount)
credit_limit.nil? or (amount <= balance + credit_limit)
end
{
"action":
{
"_id":"single_payment",
"name":"single payment",
"icon_uri":"/images/icons/switch.gif"
}
}
@herestomwiththeweather
herestomwiththeweather / request_token
Created May 21, 2011 00:31
Single Payment Scope: Request Token
POST /oauth/request_token HTTP/1.1
Accept: */*
Connection: close
User-Agent: OAuth gem v0.4.4
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_callback="http%3A%2F%2Flocalhost%3A3001%2Foauth_callback", oauth_consumer_key="xBoHeeNNFt3LQ7U1tvAb8BVKr32duE6rdWtpCSFD", oauth_nonce="cde4xVNJBZm6XAy3V6EjMk8gy6uTPf5wEdZgKiMlk", oauth_signature="dyP6m%2FQm%2Bvnes86o6dLvD013Yy4%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1305937625", oauth_version="1.0"
Content-Length: 106
Host: demo.opensourcecurrency.org
scope=http%3a%2f%2fdemo.opensourcecurrency.org%2fscopes%2fsingle_payment.json%3fasset%3dbernalbucks%26amount%3d3