Skip to content

Instantly share code, notes, and snippets.

"""Expression parser based on some templater
Pros:
- it is not a new language
- it has very strict api, so atleast we can try to guarantee its stability
- complex abstract logic can be hidden in simple python methods
Stements will be expressed in the form of:
api.cluster_status == 'operational'
api.role_in_deployment('ceph-osd')
@dshulyak
dshulyak / policies.py
Last active December 18, 2015 20:35
basic policy engine
#!/usr/bin/env python
"""
Q/A
1. What is operation?
Solar client/api action
2. What is rule?
Condition, based on which we produce operations.
Condition should work only with local data, passing correct data will
be responsibility of fuel or solar
@dshulyak
dshulyak / payments.sol
Last active April 2, 2018 06:27
protected payments for service model
pragma solidity 0.4.21;
import './ecrecovery.sol';
contract Payments {
event LogExit(address recepient, uint256 value, uint id);
struct Exit {
address recipient;
2069 sudo sysctl -w net.ipv4.neigh.default.gc_thresh1=1024
2071 sudo sysctl -w net.ipv4.neigh.default.gc_thresh2=4096
2072 sudo sysctl -w net.ipv4.neigh.default.gc_thresh3=8192
package main
import (
"bytes"
"crypto/ecdsa"
"fmt"
"math/rand"
"net"
"time"
@dshulyak
dshulyak / validation.go
Last active August 21, 2018 13:51
validation for addBalance transaction
package main
import (
"bytes"
"crypto/rand"
"math/big"
"strings"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
@dshulyak
dshulyak / hash.sol
Created September 3, 2018 06:26
test generate hash
pragma solidity ^0.4.21;
contract TestHash {
bytes32 public result;
constructor() public {}
function generate(bytes input) public {
result = keccak256(input);
@dshulyak
dshulyak / custody.go
Created September 5, 2018 07:23
merklezied proof of custody
package main
import (
"bytes"
"crypto/rand"
"fmt"
"github.com/ethereum/go-ethereum/crypto/sha3"
)
package main
import (
"crypto/elliptic"
"crypto/rand"
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
const crypto = require('crypto');
alice = crypto.createECDH('secp256k1')
alice.setPrivateKey('ce9873239e8c1126c1bb92086ab22e3f7c519afd530315f9b5ef92323bbddee3', 'hex')
bob = Buffer.from([4, 202, 191, 42, 27, 135, 133, 122, 201, 194, 207, 107, 136, 190, 242, 52, 229, 224, 20, 254, 233, 138, 194, 101, 9, 202, 37, 122, 237, 103, 143, 62, 28, 204, 159, 213, 185, 168, 60, 253, 145, 112, 153, 7, 2, 154, 113, 137, 71, 231, 53, 146, 209, 203, 219, 219, 142, 22, 115, 192, 199, 3, 24, 217, 152, 144, 176, 254, 186, 178, 137, 31, 37, 168, 176, 34, 18, 252, 177, 60, 231, 185, 53, 7, 76, 133, 215, 149, 78, 204, 137, 113, 171, 193, 181, 232, 224, 70, 214, 141, 213, 188, 22, 223, 49, 250, 199, 181, 200, 49, 115, 26, 26, 109, 174, 78, 124, 88])
alice.computeSecret(bob.slice(0, 65))