Skip to content

Instantly share code, notes, and snippets.

View gnidan's full-sized avatar

g. nicholas d'andrea gnidan

View GitHub Profile
#!/usr/bin/env python3
TARGET = "cnut"
AVOID = { "cnut", "\x63\x75\x6E\x74" }
WIDTH = 20
HEIGHT = 10
DIRS = [ (0,1), (1,1), (1,0), (1,-1), (0,-1), (-1,-1), (-1,0), (-1, 1) ]
import random
contract MazeHashFunction {
function generateRandomNumber(uint _treasureMap) view public returns (uint) {
bytes memory randomNumber = new bytes(32);
bytes memory treasureMapInBytes = toBytes(_treasureMap);
uint8 nextByteInTreasureMap = uint8(treasureMapInBytes[31]);
uint8 pointerToNextPosition = nextByteInTreasureMap;
for(uint i = 31; i >0; i--) {
uint nextHashInLabyrinth = uint(blockhash(block.number - 1 - pointerToNextPosition));
@VictorTaelin
VictorTaelin / ethereum_delayed_computations.md
Last active April 12, 2018 16:42
Make Ethereum massively scalable today with delayed computations

Make Ethereum massively scalable today with delayed computations

Suppose you're writing a contract which involves a huge amount of participants. As an example, think of an online, blockchain-based Trading-Card Game with tournaments. How would you program a playCard function? You might be thinking of something like this:

function playCard(uint player, uint card){
    ...
    else if (card == PROFESSOR_OAK){
        // shuffles the player's hand on his deck
 shuffleHand(player)
/// @title Stablecoin Token API. Extension of the Token standard (https://github.com/ethereum/EIPs/issues/20)
/// @author Hadrien Charlanes - <hadrien.charlanes@consensys.net>
contract StablecoinTokenAPI {
/// @dev Getters of the conversion rates between USDcents and Wei
function getUSDcentstoWEIPrice(uint amountInUSDCents) constant returns (uint purchasePricesInWei);
function getWEItoUSDCentsPrice(uint amountinWei) constant returns (uint purchasePriceinUSDCents);
///@dev Return if a convertion ETH -> USD will be successful
///@param amountInWei WEI amount willing to be converted
import "StablecoinTokenAPI.sol";
/// @title Simple bet contract using USD Stablecoins.
/// @author Hadrien Charlanes - <hadrien.charlanes@consensys.net>
contract USDPool {
//Address of the private stablecoin Contract previously ordered by the SimpleBet dapp.
address public stablecoinLicensedAddress;
//Private Stablecoin service Contract Instance.
StablecoinTokenAPI public licensedStablecoin;
@jlinoff
jlinoff / os.path.sh
Last active January 24, 2018 19:06
Bash path functions modeled after python: os.path.normpath, os.path.abspath, os.path.relpath.
#!/bin/bash
#
# Some useful path functions. Modelled after Python.
#
# License: MIT Open Source
# Copyright (c) 2016 Joe Linoff
#
# Normalize a path.
# Similar to Python's os.path.normpath()
@interfect
interfect / nomic.sol
Created December 14, 2015 09:04
Nomic on Ethereum
/*
This creates a basic nomic.
There is a list of addresses that are "players", holding 1 unit of citizenship.
Motions can be proposed by any player.
Motions can be rejected by any player, or passed unanimously.
This contract is live on the Ethereum blockchain with address 0xcc0ee510bc4b5cd4d31da49f672ab5aa6806f70a.
@tkafka
tkafka / LICENSE.txt
Last active September 5, 2019 13:38
Drop-in replacement for ReactCSSTransitionGroup that uses velocity.js instead of CSS transforms. Add your own transitions to `transitions` hash.
The MIT License (MIT)
Copyright (c) 2014 Tomas Kafka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@