Skip to content

Instantly share code, notes, and snippets.

View ryanberckmans's full-sized avatar

Ryan Berckmans ryanberckmans

View GitHub Profile
@vitaLee
vitaLee / key bindings
Created June 28, 2012 08:22
Cycle group tabs
{ "keys": ["super+alt+right"], "command": "prev_next_view_in_group", "args":{"dir": 1} },
{ "keys": ["super+alt+left"], "command": "prev_next_view_in_group", "args":{"dir": -1} }
@MiloXia
MiloXia / ConditionalCompilation.scala
Last active October 24, 2018 21:36
Scala Conditional Compilation
import scala.language.higherKinds
object Conditions {
//based on: An Introduction to Functional Programming Through Lambda Calculus
trait BOOL {
type body[e1 <: E, e2 <: E, E] <: E //select: (E, E) => E
}
trait TRUE extends BOOL {
type body[e1 <: E, e2 <: E, E] = e1 //true = select_first
}
// Augur's oracle can be used to bring information on-chain,
// allowing money to move automatically based on real-world facts.
// Augur's oracle is secure so long as money that depends on Augur
// is properly tracked in the Augur system.
// Money that depends on Augur's oracle, but isn't tracked in Augur,
// is said to be "parasitic" and is at risk of attack and a threat
// to Augur itself.
@xmlking
xmlking / Enum.es6.js
Last active June 25, 2019 18:09
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@egonelbre
egonelbre / telnet.sc
Last active May 28, 2020 21:06
Telnet parsing in Scala
object Telnet {
type ByteString = Vector[Byte]
type Commands = Vector[Command]
abstract class Command
case class Line(text: String) extends Command
case class SubNegotiaton(option: Byte, data: ByteString) extends Command
case class Will(option: Byte) extends Command

Anonymous: a proof-of-unique-human system

Anonymous is a coordination game for global proof-of-unique-human, through monthly pseudonym events that last 15 minutes, where every single person on Earth is randomly paired together with another person, 1-on-1, to verify that the other is a human being, in a pseudo-anonymous context. The proof-of-unique-human is that you are with the same person for the whole event. The proof-of-unique-human is untraceable from month to month, much like cash. True anonymity.

When you register for Anonymous, you use register(). You need a “registrationToken” that you got if you were verified in the last event. You can see one be deducted from your account with registrationToken[msg.sender]--. The purpose of the registration tokens is that you can easily mix them, so that your personhood is not traceable from month to month.

function register() public scheduler {

require(isReg(msg.sender) == false && data[schedule].tokens[1

@spalladino
spalladino / revert.ts
Created September 11, 2020 22:38
Get the revert reason before sending an Ethereum transaction if the transaction would fail
export async function tryGetRevertReason(to: string, from: string, data: string): Promise<string | undefined> {
const provider = ethers.getDefaultProvider();
const tx = { to, from, data };
try {
await provider.estimateGas(tx);
} catch {
const value = await provider.call(tx);
return hexDataLength(value) % 32 === 4 && hexDataSlice(value, 0, 4) === '0x08c379a0'
? defaultAbiCoder.decode(['string'], hexDataSlice(value, 4))
: undefined;
@pagreczner
pagreczner / nftp.md
Created December 14, 2021 12:39
NFT Proxy Idea

NFT Proxy

Overview / Goal

Proxy your NFT into a provable ERC-721 ownership format that can live in a different wallet from the proxied NFT. The proxied NFT can prove ownership while maintaining safety from the true asset by living in a different wallet. This proxied NFT can then be used safely for whitelists and other functions where signing a transaction may be connsidered "dangerous". This proxied NFT in theory could also be safely leased to other users in a way that NFTs can not be be done today.

Motivation

Many high end NFT collections that are have both significant underlying financial value and emotional value to users have become besieged by scammers and hackers. Part of the value in holding one of these NFTs is showing it off and being part of the community. However, in order to provably show it off you must expose your wallet to sign messages. Given the nascent UX in web3, it's not always easy to discern what is a trusted UX from an untrusted. And given that, there "should be a better way"

@wmitsuda
wmitsuda / README.md
Last active June 17, 2022 19:20
Otterscan + Erigon + Prysm (ropsten)
@navicore
navicore / sha256.scala.md
Last active September 15, 2022 13:58
sha256 single line function in scala

def sha256Hash(text: String) : String = java.security.MessageDigest.getInstance("SHA-256").digest(text.getBytes()).map(0xFF & ).map { "%02x".format() }.foldLeft(""){_ + _}

def sha256Hash(text: String) : String = String.format("%064x", new java.math.BigInteger(1, java.security.MessageDigest.getInstance("SHA-256").digest(text.getBytes("UTF-8"))))

verify via:

scala&gt; sha256Hash("Rusty is a cowboy!")