Skip to content

Instantly share code, notes, and snippets.

View itays's full-sized avatar

Itay Sidis itays

View GitHub Profile
@itays
itays / EventEmitter.ts
Created April 3, 2020 09:28
Singelton EventEmitter in TypeScript
// based on different implementations from this thread https://gist.github.com/mudge/5830382
export type Listener = (...args: any[]) => void;
export type Events = Record<string, Set<Listener>>;
class EventEmitter {
private events: Events = {};
on(event: string, listener: Listener) {
if (typeof this.events[event] !== "object") {
this.events[event] = new Set();
@itays
itays / ballot.sol
Created November 3, 2018 20:33
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.17+commit.bdeb9e52.js&optimize=false&gist=
pragma solidity ^0.4.17;
contract Inbox {
string public message;
function Inbox(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {