Skip to content

Instantly share code, notes, and snippets.

View cleanunicorn's full-sized avatar
🦄
Hacking stuff for fun and profit

Daniel Luca cleanunicorn

🦄
Hacking stuff for fun and profit
View GitHub Profile
@cleanunicorn
cleanunicorn / fisher-yates.sol
Created October 6, 2021 09:55
Fisher Yates Shuffle, aka Knuth Shuffle proof of concept
contract Shuffle {
function shuffle(
uint size,
uint entropy
)
public
pure
returns (
uint[] memory
) {
@cleanunicorn
cleanunicorn / peers
Last active July 16, 2021 08:17
Ropsten
admin.addPeer("enode://8536a2f199c769555219113a22f784ad390fc7ffa5e6403a466f8336b14706348d49d99afe5b43f3562d39024a91ac67c5edf01f3419c359636ffa052f472464@3.231.157.25:30303")
admin.addPeer("enode://b71ea82682d28136d5783d8472d8cb4ccc4edef18c61983a6418e6422cf0d54a786fbbae402113b576d26f4c3b5597f30c9c3e2014d35283256596ce94c55292@188.35.22.48:30324")
admin.addPeer("enode://0d0787f95e42be5e26c9e716bc4a1d6bb32d592d0ae952640bc85d24b0863094d89dfb4cbe1bfa3b31a024bc3eac942b885644e73c6a37196adaff0cbab10f55@38.105.126.120:30303")
admin.addPeer("enode://07182e7f9e813604d3676b1c0831233f8f973c111e55d7634966990e027d88136c6e6824381cd1aeddbefeda5d577ce21d243da0794baa0fcd2be46b00a90f66@195.201.203.182:30303")
admin.addPeer("enode://9056edda5f52cbe1a7e46b21a6dbc382b4b4a2546728eb4d1f366815cd969ebbda022a89b883b173acf8fd4182cbac6061124bb4e11412c65759aa30a3751714@3.238.114.192:30303")
@cleanunicorn
cleanunicorn / Resize-LVM.md
Last active November 12, 2024 14:33
How to extend an LVM partition to use the available disk space.

Tell LVM to resize to the physical partition size.

$ sudo pvresize /dev/sda3

Find the actual path of the LVM logical volume. The LV Path is the value needed.

contract A {
uint[10] list = [1,2,3,4,5,6,7,8,9,10];
function loop(uint _n) public view returns (uint) {
uint sum = 0;
uint start = list.length - 1;
uint end = list.length - _n;
for (uint i = start; i >= end; i--) {
@cleanunicorn
cleanunicorn / C.sol
Created March 31, 2021 14:07
One can change the calldata arguments using other calldata arguments.
contract C {
function getCalldata(
bytes calldata _a,
bytes calldata _b
) public pure returns (bytes calldata, bytes calldata) {
_a = _b;
return (_a, _b);
}
}
@cleanunicorn
cleanunicorn / MintMaxKDAI.sol
Created March 29, 2021 14:37
Mint max tokens
import {IERC20} from "./IERC20.sol";
contract MintMaxKDAI {
address owner = msg.sender;
constructor() {
IERC20 tDAI = IERC20(0x7d669A64deb8a4A51eEa755bb0E19FD39CE25Ae9);
tDAI.mint(
owner,
contract PingPong {
mapping(address => uint) public pinged;
mapping(address => uint) public ponged;
address[] public players;
function ping() public {
if (pinged[msg.sender] == 0) {
players.push(msg.sender);
}

Contract

contract Storage {
    bytes arr;
    
    function storeArr(bytes memory _arr) public {
        arr = _arr;    
    }
}
pragma solidity >=0.6.6;
contract AssemblyProblems {
address owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
#!/bin/bash
./geth.bin --datadir=./chaindata \
--rpc --rpcapi="eth,net,rpc,web3,txpool,personal,debug,account" --ws \
--rpccorsdomain='*' --port 30303 \
--syncmode=fast \
console