Skip to content

Instantly share code, notes, and snippets.

@aquabu
aquabu / Noncommercial-Nonviolent-Public-License-1.1.md
Created July 7, 2023 21:59
Sharing this Noncommercial Nonviolent Public License

Noncommercial Nonviolent Public License 1.1

Contributor: [Legal Entity or Person Name,or names separated by commas]

Source Code: [https://sourceode-repo-url.example]

Purpose

This license allows you to use and share this software for noncommercial nonviolent purposes for free and to try this software for commercial nonviolent purposes for thirty days.

@aquabu
aquabu / over_under.sol
Last active May 22, 2018 20:44
demonstrating uint overflow and underflow in solidity
/* demonstrating uint overflow and underflow in ethereum solidity
this is why you need guards like:
if (balances[_to] + _amount < balances[_to]) throw;
*/
contract C {
// (2**256 - 1) + 1 = 0
function overflow() returns (uint256 _overflow) {
uint256 max = 2**256 - 1;
return max + 1;
}
@aquabu
aquabu / WorkHistory.sol
Last active June 25, 2016 02:08
WorkHistory smart contract
contract WorkHistory {
event TaskProof(string taskProof, int amount, address authorizer, address to);
mapping(string => bool) taskProofExists;
/* taskProof is a unique id such as an IPFS hash
amount is the amount granted to the _to address by the _authorizer
*/
function register(string _taskProof, int amount, address _authorizer, address _to) returns(bool success) {
if(taskProofExists[_taskProof]) {
return false;
@aquabu
aquabu / governance.md
Last active February 4, 2016 18:57
Draft of Swarmbot License

Decentralized Cooperation needs Decentralized Reputation

White Paper By Noah Thorp

We are in the midst of a techno-cultural trend that re-envisions ownership, protocols of trust, organizational decision making, and ecosystems of work. This zeitgeist can broadly be called decentralized collaboration.

In the United States, organizations are atomizing into flexible services and autonomous, purpose-driven small businesses. Deloitte reports the ecosystems of value creation that are emerging create both competitive and collaborative advantage. Several forces are driving this change.

Freelance work represents a significant driver. Today, freelancers and gig workers make up 34% of the US work force. In keeping with these trends, Intuit and MBO Partners optimistically predict that by 2020 freelancers will represent 43-50% of the work force. Although these numbers may be inflated, there is strong evidenc

# so you have a list of domain names you want to search for in a text file
# maybe you generated them with my pattern_matcher gem: https://github.com/aquabu/pattern_expander
# here's a cheap and dirty way to see if they are available
require 'whois' # this is the ruby-whois gem
def lookup(name)
domain = name.chomp + '.com'
w = Whois.whois(domain)
STDOUT.syswrite(domain + "\n") if w.available?
@aquabu
aquabu / nested_struct.rb
Created December 2, 2011 03:09
NestedStruct
# evolved from http://stackoverflow.com/questions/4911807/cannot-access-id-field-of-openstruct-instance
class NestedStruct
def initialize( hash= {})
hash.each{ |key, value| add_field(key,value) }
end
def add_field( attribute_name, value=nil )
(class << self; self; end).class_eval do
attr_accessor attribute_name
end
@aquabu
aquabu / gist:793783
Created January 24, 2011 19:32
generate rails ctags for vim
# would be cool to write a script to lookup all the gems in the project and index them...
# activerecord manually included below
ctags -f /Your/rails/project/root/tmp/tags --exclude="*.js" --exclude="*.log" --langmap="ruby:+.rake.builder.rjs" -R /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8 -R /Your/rails/project/root
sort /Your/rails/project/root/tmp/tags
def to_boolean(value, nil_value = false)
value.downcase! if value.class == String
case value
when "no","false",false, "0", 0
false
when "yes","true",true, "1", 1
true
when nil
nil_value
else