Skip to content

Instantly share code, notes, and snippets.

View christianparpart's full-sized avatar
🎃
Loading

Christian Parpart christianparpart

🎃
Loading
View GitHub Profile
@christianparpart
christianparpart / underline.sh
Created June 11, 2020 13:32
quick'n'dirty underline rendering test
#! /bin/bash
function ul_color1() {
echo -ne "\033[58:2:255:250:32m"
}
function ul_color2() {
echo -ne "\033[58:2:255:32:32m"
}
@christianparpart
christianparpart / solidity-error-type-technical-proposal.md
Last active May 6, 2020 11:10
Solidity error type - technical proposal

Solidity error type - a technical proposal

The Problem

In solidity there are currently two ways of generating and catching errors - by Error(string) or a raw bytes message.

This may not be enough and a more high level distinction would be nice by introducing custom error types the Solidity developer can create and use.

Motivation

#include <array>
#include <cstdio>
#include <type_traits>
template <typename T> struct remove_move { using type = T; };
template <typename T> struct remove_move<T&&> { using type = std::remove_reference_t<T>; };
template <typename T> using remove_move_t = typename remove_move<T>::type;
template <typename T>
auto f(T&& _value) {
@christianparpart
christianparpart / launch.json
Created September 30, 2019 07:59
Solidity VSCode settings
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "solc",
"type": "cppdbg",
"request": "launch",
@christianparpart
christianparpart / vertical-scroll-test.sh
Created September 14, 2019 23:03
VT vertical scrolling test
#! /bin/bash
LINES=${LINES:-${1}}
echo -ne "\033[2J" # clear screen
echo -ne "\033[H" # cursor to home
# fill lines with known pattern (numbers from 1 upwards)
for i in `seq 1 ${LINES}`; do
echo -n "$i ..."
@christianparpart
christianparpart / windows-terminal-config.json
Last active August 7, 2019 22:18
my Windows Terminal configuration file
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{2c4de342-38b7-51cf-b940-2309a097f519}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@christianparpart
christianparpart / min_element_of_map.cpp
Last active May 26, 2019 00:53
Getting the minimum element of a map<>.
#include <map>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, const char* argv[])
{
// hint: ternary operator ? :
string const text =
@christianparpart
christianparpart / soltest-valgrind-output.txt
Created April 3, 2019 09:57
soltest valgrind output (a use-after-free case)
==27560== Memcheck, a memory error detector
==27560== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==27560== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==27560== Command: ./test/soltest --show_progress=yes -t SolidityEndToEndTest/abi_encode_with* -- --ipcpath /home/trapni/.ethereum/geth.ipc
==27560==
==27560== error calling PR_SET_PTRACER, vgdb might block
Running 4 test cases...
0% 10 20 30 40 50 60 70 80 90 100%
|----|----|----|----|----|----|----|----|----|----|

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@christianparpart
christianparpart / Visitor.hpp
Created November 5, 2018 16:33
some super-generic visitor API
// This file is part of the "klex" project, http://github.com/christianparpart/klex>
// (c) 2018 Christian Parpart <christian@parpart.family>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
#pragma once
#include <type_traits>