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
func snippetViewHandler(app *application) http.HandlerFunc { | |
return func(w http.ResponseWriter, r *http.Request) { | |
id, err := strconv.Atoi(r.PathValue("id")) | |
if err != nil || id < 1 { | |
app.clientError(w, http.StatusNotFound) | |
return | |
} | |
s, err := app.snippets.Get(id) |
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
contract Wallet is WalletEvents { | |
... | |
// METHODS | |
// gets called when no other function matches | |
function() payable { | |
// just being sent some cash? | |
if (msg.value > 0) |
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
// library contract - calculates Fibonacci-like numbers | |
contract FibonacciLib { | |
// initializing the standard Fibonacci sequence | |
uint public start; | |
uint public calculatedFibNumber; | |
// modify the zeroth number in the sequence | |
function setStart(uint _start) public { | |
start = _start; | |
} |
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
contract EtherGame { | |
uint public payoutMileStone1 = 3 ether; | |
uint public mileStone1Reward = 2 ether; | |
uint public payoutMileStone2 = 5 ether; | |
uint public mileStone2Reward = 3 ether; | |
uint public finalMileStone = 10 ether; | |
uint public finalReward = 5 ether; | |
mapping(address => uint) redeemableEther; |
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
contract TimeLock { | |
mapping(address => uint) public balances; | |
mapping(address => uint) public lockTime; | |
function deposit() external payable { | |
balances[msg.sender] += msg.value; | |
lockTime[msg.sender] = now + 1 weeks; | |
} |
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
contract EtherStore { | |
uint256 public withdrawalLimit = 1 ether; | |
mapping(address => uint256) public lastWithdrawTime; | |
mapping(address => uint256) public balances; | |
function depositFunds() external payable { | |
balances[msg.sender] += msg.value; | |
} |
Public Npm Packages
npm install <package-name>
From Git
npm install git+ssh://[email protected]:npm/cli.git#v1.0.27
npm install git+ssh://[email protected]:npm/cli#pull/273
npm install git+ssh://[email protected]:npm/cli#semver:^5.0
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
trait FileState {} | |
// We need this to define | |
// `close` method for multiple states | |
trait Closable { | |
fn close(self) -> File<ClosedFile>; | |
} | |
struct File<S: FileState> { | |
state: S, |
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
name: Rust | |
on: | |
pull_request: | |
branches: [ "master" ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: |
NewerOlder