Skip to content

Instantly share code, notes, and snippets.

@D-Nice
D-Nice / script-template.sh
Created December 15, 2020 21:42 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
/*
Kraken-based ETH/XBT price ticker
This contract keeps in storage an updated ETH/XBT price,
which is updated every ~60 seconds.
*/
pragma solidity ^0.4.0;
import "oraclizeLib.sol";
@D-Nice
D-Nice / api
Created June 1, 2017 00:29 — forked from anonymous/api
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.11+commit.68ef5810.js&optimize=false&gist=
// <ORACLIZE_API>
/*
Copyright (c) 2015-2016 Oraclize SRL
Copyright (c) 2016 Oraclize LTD
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@D-Nice
D-Nice / tlsn-notarization-file-format.md
Created November 9, 2016 21:45 — forked from AdamISZ/tlsn-notarization-file-format.md
TLSNotary notarization file format

Data format: binary. Default file extension: '.tlsn'

Contents

Field description (size in bytes) code in Python version
Header (29) 'tlsnotary notarization file\n\n'
@D-Nice
D-Nice / BigInt.sol
Created September 29, 2016 23:39 — forked from axic/BigInt.sol
Big number library in Solidity (for modexp)
//
// Big number library in Solidity for the purpose of implementing modexp.
//
// Should have a similar API to https://github.com/ethereum/EIPs/issues/101
//
// Internally bignumbers are represented as an uint array of 128 bit values.
//
// NOTE: it assumes usage with "small" (<256bit) exponents (such as in RSA)
//
@D-Nice
D-Nice / stringaskey.sol
Created August 20, 2016 18:01 — forked from axic/stringaskey.sol
How to use string as a key in a mapping in Solidity aka. how to store short strings cheape
//
// In Solidity, a mapping is like a hashmap and works with `string` like this:
// mapping (string => uint) a;
//
// However it doesn't support accessors where string is a key:
// mapping (string => uint) public a;
//
// "Internal compiler error: Accessors for mapping with dynamically-sized keys not yet implemented."
//
// An accessor returns uint when called as `a(string)`.
contract Creator {
function newContract(bytes data) public returns (address) {
address theNewContract;
uint s = data.length;
assembly {
calldatacopy(mload(0x40), 68, s)
theNewContract := create(callvalue, mload(0x40), s)
}
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.