Skip to content

Instantly share code, notes, and snippets.

View AnthonyAkentiev's full-sized avatar
🙂

Anthony Akentiev AnthonyAkentiev

🙂
View GitHub Profile
@AnthonyAkentiev
AnthonyAkentiev / vim-init.sh
Created September 7, 2022 07:58 — forked from geopet/vim-init.sh
Vim Plugin Install and Update
#!/usr/bin/env bash
cd
# remove current vim directories
rm -rf ~/.vim
rm -rf ~/.vimrc
rm -rf ~/.gvimrc
library RoundedDivMath {
/**
* @dev Division, round to nearest integer (AKA round-half-up)
* @param a What to divide
* @param b Divide by this number
*/
function roundedDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity automatically throws, but please emit reason
require(b > 0, "div by 0");
uint orgGets = bankersRoundedDiv(markup_cents.mul(events[msg.sender].feeOrg_ppm),1000000);
// Calculate how much event Organizer gets
X = (((markup_cents * feeOrg_ppm) / 10000) / 100);
// Which can be simplified:
X = (markup_cents * feeOrg_ppm) / 1000000;
// WRITE
function start() public onlyOwner {
eventStartTime = now;
}
function transfer(address _to, uint256 _value) public returns (bool) {
updateCopyOnWriteMaps(msg.sender, _to);
return super.transfer(_to, _value);
}
// WRITE
function transfer(address _to, uint256 _value) public returns (bool) {
updateCopyOnWriteMap(msg.sender, _to);
return super.transfer(_to, _value);
}
function updateCopyOnWriteMap(address _from, address _to) internal {
if(!isDataInMapping(_from)){
balancesAtTheStartOfVoting[_for].balance = balances[_for];
}
balancesAtTheStartOfVoting[HolderA] is 100
balancesAtTheStartOfVoting[HolderB] is 20
balances[HolderA] is 70 
balances[HolderB] is 50
balancesAtTheStartOfVoting[HolderA] is 100
balancesAtTheStartOfVoting[HolderB] is 20
balances[HolderA] is 70 
balances[HolderB] is 50
balances[HolderA] is 100 
balances[HolderB] is 20