Merge
def merge_overlap(a, b):
return [min(a[0], b[0]), max(a[1], b[1])]
Overlap?
before the rise of SPA (single page applications), web applications were rendered server-side. Let's go through how that would work:
https://url.com/
or https://url.com/about
or https://url.com/blog
.
/
, /about
, blog
are all examples of "paths" or endpointsCopy/paste each line (one at a time) to gitbash or terminal window.
git config --global --add alias.pr '!f() { git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'
and
git config --global --add alias.pr-clean '!git checkout master ; git for-each-ref refs/heads/pr/* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'Once created the aliases are used as shown below.
To pull a pull request: git pr to use the example above git pr 123
var Voting = artifacts.require("Voting") | |
module.exports = function(deployer) { | |
deployer.deploy(Voting) | |
} |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
<title>Ethereum Voting Dapp</title> | |
<!-- Bootstrap --> |
// import CSS. Webpack with deal with it | |
import "../css/style.css" | |
// Import libraries we need. | |
import { default as Web3} from "web3" | |
import { default as contract } from "truffle-contract" | |
// import and assign compiled contract data to variable | |
import votingArtifacts from "../../build/contracts/Voting.json" | |
var VotingContract = contract(votingArtifacts) |
// When the page loads, we create a web3 instance and set a provider. We then set up the app | |
window.addEventListener("load", function() { | |
// Is there an injected web3 instance? | |
if (typeof web3 !== "undefined") { | |
console.warn("Using web3 detected from external source like Metamask") | |
// If there is a web3 instance(in Mist/Metamask), then we use its provider to create our web3object | |
window.web3 = new Web3(web3.currentProvider) | |
} else { | |
console.warn("No web3 detected. Falling back to http://localhost:9545. You should remove this fallback when you deploy live, as it's inherently insecure. Consider switching to Metamask for development. More info here: http://truffleframework.com/tutorials/truffle-and-metamask") | |
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail) |
// import CSS. Webpack with deal with it | |
import "../css/style.css" | |
// Import libraries we need. | |
import { default as Web3} from "web3" | |
import { default as contract } from "truffle-contract" | |
// get build artifacts from compiled smart contract and create the truffle contract | |
import votingArtifacts from "../../build/contracts/Voting.json" | |
var VotingContract = contract(votingArtifacts) |
pragma solidity ^0.4.18; | |
// written for Solidity version 0.4.18 and above that doesnt break functionality | |
contract Voting { | |
// an event that is called whenever a Candidate is added so the frontend could | |
// appropriately display the candidate with the right element id (it is used | |
// to vote for the candidate, since it is one of arguments for the function "vote") | |
event AddedCandidate(uint candidateID); | |
// describes a Voter, which has an id and the ID of the candidate they voted for |
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.