Skip to content

Instantly share code, notes, and snippets.

View ItsShadowl's full-sized avatar
🎯
Focusing

Hey Yo! ItsShadowl

🎯
Focusing
View GitHub Profile
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) {
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));
@ItsShadowl
ItsShadowl / try-catch-ex.c
Created October 2, 2019 11:32 — forked from rampion/try-catch-ex.c
TRY/CATCH/FINALLY macros for C
// 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");
@ItsShadowl
ItsShadowl / collision.js
Created June 20, 2018 09:22 — forked from samcorcos/collision.js
Algorithm for calculating hash collision probability
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
<?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;