Skip to content

Instantly share code, notes, and snippets.

View Arachnid's full-sized avatar

Nick Johnson Arachnid

View GitHub Profile

Excerpt from For The Win, by Cory Doctorow

Once, when he'd been working on his Masters, he'd participated in a study for a pal in the economics department. They'd locked twenty five grad students into a room and given each of them a poker chip. "You can do whatever you want with those chips," the experimenter had said. "But you might want to hang onto them. Every hour, on the hour, I'm going to unlock this door and give you twenty dollars for each poker chip you're holding. I'll do this eight times, for the next eight hours. Then I'll unlock the door for a final time and you can go home and your poker chips will be worthless -- though you'll be able to keep all the money you've acquired over the course of the experiment."

He'd snorted and rolled his eyes at the other grad students, who were mostly doing the same. It was going to be a loooong eight hours. After all, everyone knew what the value of the poker chips were: $160 in the first hour, $140 in the next, $120 in th

Nicks-MBP:azkube nickjohnson$ docker build .
Sending build context to Docker daemon 58.82 MB
Step 1 : FROM scratch
--->
Step 2 : ADD ca-certificates.crt /etc/ssl/certs/
---> Using cache
---> 2595831e39e2
Step 3 : ADD azkube /opt/azkube/azkube
---> acdf0edd49c6
Removing intermediate container a52b7ba90687
import urllib
import sha3
message = urllib.urlopen('http://pastebin.com/raw/CcGUBgDG').read()
clean = message.split('=====\r\n')[1].split('=====')[0].replace('\r\n', '\n').strip()
sha3.sha3_256(clean).hexdigest()
library itmap {
struct entry {
// Equal to the index of the key of this item in keys, plus 1.
uint keyIndex;
uint value;
}
struct itmap {
mapping(uint => entry) data;
uint[] keys;
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
library StringTools {
struct Slice {
uint _ptr;
uint _len;
}
function memcpy(Slice dest, Slice src) private {
var len = src._len;
var destPtr = dest._ptr;
var srcPtr = src._ptr;
Compressed public key: 03495f43cf0b672ca09e29fe028e826dc5ac019d22edb03ed958d59ffaefd63893
Candidate address: C94E05C8A3D016AAE330D81C1CE12FB9808EFFB5
contract Test{
function test(string input) {
Slice remainder = input.slice();
while(!remainder.empty()) {
Slice first = remainder.copy();
remainder = remainder.find(".");
first = first.until(remainder);
// Do something with first
remainder = remainder.advanceBy("."); // or something
}
// Returns a slice containing the entire string.
function slice(string self) returns (Slice);
// Returns a slice containing the requested byte range of the string.
function slice(string self, int start, int end) returns (Slice);
// Returns a new slice pointing at the same underlying string
function slice(Slice self) returns (Slice);
// Returns a slice containing the requested byte range of the parent slice.
library StringTools {
struct Slice {
uint _ptr;
uint _len;
}
function memcpy(Slice dest, Slice src) private {
var len = src._len;
var destPtr = dest._ptr;
var srcPtr = src._ptr;