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 ForwarderFactory { | |
function cloneForwarder(address forwarder, uint256 salt) | |
public returns (Forwarder clonedForwarder) { | |
address clonedAddress = createClone(forwarder, salt); | |
Forwarder parentForwarder = Forwarder(forwarder); | |
clonedForwarder = Forwarder(clonedAddress); | |
clonedForwarder.init(parentForwarder.destination()); | |
} | |
function createClone(address target, uint256 salt) private returns (address result) { |
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 Forwarder { | |
address public destination; | |
constructor(address _destination) public { | |
destination = _destination; | |
} | |
function flushERC20(address tokenContractAddress) public { | |
IERC20 tokenContract = ERC20(tokenContractAddress); | |
uint256 forwarderBalance = tokenContract.balanceOf(address(this)); |
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
// gcc -o try-catch-ex try-catch.c try-catch-ex.c | |
#include <stdio.h> | |
#include "try-catch.h" | |
// Example of use for try-catch.h | |
int main(int argc, char *argv[]) | |
{ | |
int i = 101; | |
printf("before try block...\n"); |
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
<?php | |
/* | |
* This file is part of the Symfony package. | |
* | |
* (c) Fabien Potencier <[email protected]> | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file that was distributed with this source code. | |
*/ |
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
const calculate = (n, k) => { | |
const exponent = (-k * (k - 1)) / (2 * n) | |
return 1 - Math.E ** exponent | |
} | |
// where `n` is the number of possible unique hashes | |
// where `k` is the number of values created | |
// calculate(100000, 25) => 0.0029955044966269995 aka 0.29% chance of collision |
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
<!DOCTYPE html> | |
<html lang="en" > | |
<head> | |
<meta charset="UTF-8"> | |
<title>Modal without JavaScript</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
background: #ddd; | |
} |
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
<?php | |
/** | |
* example script to receive webhook events for a wallet and forward the bitcoin to another address (by the mapping) | |
*/ | |
use BitWasp\BitcoinLib\RawTransaction; | |
use Blocktrail\SDK\Blocktrail; | |
use Blocktrail\SDK\BlocktrailSDK; | |
use Blocktrail\SDK\Connection\Exceptions\ObjectNotFound; |