Skip to content

Instantly share code, notes, and snippets.

@chfast
chfast / Dinder.sol
Last active March 6, 2017 11:13
Dinder - Decentralized Tinder
pragma solidity ^0.4.9;
contract Dinder {
mapping(address => mapping(address => bool)) connections;
mapping(address => int) thumbUps;
function thumbUp(address a) {
if (connections[a][msg.sender]) throw;
connections[a][msg.sender] = true;
thumbUps[a] += 1;
@chfast
chfast / u256_global_const.cpp
Created March 17, 2017 09:24
Compare global constant boost::multiprecision
#include <boost/multiprecision/cpp_int.hpp>
using u256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
namespace
{
u256 const lowMask256 = 0xffffffffffffffff;
auto const lowMaskNative = 0xffffffffffffffff;
}
0xbF5Eaf0B9508c84A1d63553aE304848E3A0D3E71
@chfast
chfast / ec_benchmarks
Last active June 20, 2017 14:03
Ethereum precompiled ECADD and ECMUL test cases
ECADD("18b18acfb4c2c30276db5411368e7185b311dd124691610c5d3b74034e093dc9063c909c4720840cb5134cb9f59fa749755796819658d32efc0d288198f3726607c2b7f58a84bd6145f00c9c2bc0bb1a187f20ff2c92963a88019e7c6a014eed06614e20c147e940f2d70da3f74c9a17df361706a4485c742bd6788478fa17d7") -> "2243525c5efd4b9c3d3c45ac0ca3fe4dd85e830a4ce6b65fa1eeaee202839703301d1d33be6da8e509df21cc35964723180eed7532537db9ae5e7d48f195c915"
ECADD("2243525c5efd4b9c3d3c45ac0ca3fe4dd85e830a4ce6b65fa1eeaee202839703301d1d33be6da8e509df21cc35964723180eed7532537db9ae5e7d48f195c91518b18acfb4c2c30276db5411368e7185b311dd124691610c5d3b74034e093dc9063c909c4720840cb5134cb9f59fa749755796819658d32efc0d288198f37266") -> "2bd3e6d0f3b142924f5ca7b49ce5b9d54c4703d7ae5648e61d02268b1a0a9fb721611ce0a6af85915e2f1d70300909ce2e49dfad4a4619c8390cae66cefdb204"
ECMUL("2bd3e6d0f3b142924f5ca7b49ce5b9d54c4703d7ae5648e61d02268b1a0a9fb721611ce0a6af85915e2f1d70300909ce2e49dfad4a4619c8390cae66cefdb20400000000000000000000000000000000000000000000000011138ce750fa15c2") -> "070a8d6a982153cae4
m 23:57:44|ethminer Got work package: #20393907
ℹ 23:57:44|cudaminer0 set work; seed: #cb5d57db, target: #0000000225c1
m 23:57:44|ethminer Mining on #20393907… : 20.97MH/s [A1+0:R0+0:F0]
m 23:57:45|ethminer Mining on #20393907… : 26.43MH/s [A1+0:R0+0:F0]
m 23:57:45|ethminer Mining on #20393907… : 27.31MH/s [A1+0:R0+0:F0]
m 23:57:46|ethminer Mining on #20393907… : 25.49MH/s [A1+0:R0+0:F0]
m 23:57:47|ethminer Mining on #20393907… : 26.66MH/s [A1+0:R0+0:F0]
m 23:57:47|ethminer Mining on #20393907… : 25.87MH/s [A1+0:R0+0:F0]
m 23:57:48|ethminer Mining on #20393907… : 25.49MH/s [A1+0:R0+0:F0]
ℹ 23:57:48|ethminer Solution found; Submitting to http://eth-eu.dwarfpool.com:80/0x55700844689b34718c20defdddf68410e3d6cc93/clevo ...
=================================================================
==2259==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 64 byte(s) in 2 object(s) allocated from:
#0 0x7f9dade76532 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99532)
#1 0x1c2ca48 in boost::phoenix::new_eval::result<boost::phoenix::new_eval (boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator<unsigned long long> >, (boost::multiprecision::expression_template_option)1> > >, 0l> const&, boost::phoenix::actor<boost::spirit::argument<0> > const&, boost::phoenix::vector2<boost::phoenix::vector4<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::assign, boost::proto::argsns_::list2<boost::proto::exprns_::e
@chfast
chfast / ethash_lazy_dag.cpp
Created September 19, 2017 18:28
A prototype of Ethash lazy DAG initialization
#include <array>
#include <atomic>
#include <chrono>
#include <iostream>
#include <random>
#include <thread>
#include <vector>
struct item
{
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
class HTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
@chfast
chfast / json-rpc-proxy-server-names.md
Last active December 21, 2017 19:00
Looking for project name for JSON-RPC Proxy Server

JSON-RPC Proxy Server

JSON-RPC Proxy Server extends JSON-RPC servers capabilities by providing additional request-response transport protocols. The basic use case is to add HTTP / WebSocket connectivity to servers available only by Unix Domain Sockets or Windows Named Pipes.

Proposed project names

  • dopple (from Doppelgänger)
  • surpass
@chfast
chfast / uninitialized.md
Created January 16, 2018 13:26
How to explicity uninitialize variables in C++

How to explicity uninitialize variables in C++

struct uninitialized_t
{
    template<typename T>
    operator T() const noexcept
    {
 char data alignas(T)[sizeof(T)];