Skip to content

Instantly share code, notes, and snippets.

@dominiek
dominiek / EtherDelta Trade Logic.sol
Created February 8, 2018 04:52
EtherDelta Trade Logic
mapping (address => mapping (bytes32 => bool)) public orders;
mapping (address => mapping (bytes32 => uint)) public orderFills;
function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) {
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
if (!(
(orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
block.number <= expires &&
safeAdd(orderFills[user][hash], amount) <= amountGet
)) throw;
@dominiek
dominiek / EtherDelta Fund Management.sol
Last active June 17, 2021 19:52
EtherDelta Fund Management
mapping (address => mapping (address => uint)) public tokens;
function deposit() payable {
tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value);
Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
}
function withdraw(uint amount) {
if (tokens[0][msg.sender] < amount) throw;
tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount);
function setSeed() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange(ss.getRangeByName('SEED').getA1Notation());
cell.setValue(Date.now());
}
function onOpen() {
setSeed()
}
loc_00000000:
0x00000000 60 60 PUSH1 60
0x00000002 60 40 PUSH1 40
0x00000004 52 MSTORE
0x00000005 60 04 PUSH1 04
0x00000007 36 CALLDATASIZE
0x00000008 10 LT
0x00000009 61 6c 00 PUSH2 6c 00
0x0000000c 57 JUMPI
Verifying my Blockstack ID is secured with the address 1KuRN2DXQX86WsU5egTmAnP91UBMxbhXFe https://explorer.blockstack.org/address/1KuRN2DXQX86WsU5egTmAnP91UBMxbhXFe
import tensorflow as tf
import os
import json
import subprocess
from scipy.misc import imread, imresize
from scipy import misc
from train import build_forward
from utils.annolist import AnnotationLib as al
from utils.train_utils import add_rectangles, rescale_boxes
const React = require('react')
const ReactDOM = require('react-dom')
const Api = require('./../../utils/Api')
const LoadingIndicator = require('./../common/LoadingIndicator')
const Dialog = require('./../common/Dialog')
const Dropzone = require('react-dropzone')
const async = require('async')
export default class UploadImagesDialog extends React.Component {
@dominiek
dominiek / twitter-as-rest.js
Created February 16, 2012 16:03
Example definition of the Twitter API
/**
* Example service definition for Twitter
*/
{
id: 'twitter',
name: 'Twitter',
url: 'http://twitter.com/',
siteName: 'Twitter.com',
rest: {
// Global REST configurations that are inherited by all subsequent definitions
@dominiek
dominiek / activitystreams.js
Created June 29, 2011 14:59
Unified activity stream format
[{ provider:
{ id: 'facebook',
displayName: 'Facebook',
url: 'http://facebook.com/' },
published: '2011-06-29T14:56:58+0000',
actor:
{ objectType: 'person',
id: '653038898',
displayName: 'Justin McCurry',
image: { url: 'https://graph.facebook.com/653038898/picture' } },
@dominiek
dominiek / twitter-error.js
Created February 3, 2011 14:19
Most fucked-up code I've written in 2010. Converts error data from Twitter to my own internal error objects.
exports.convertTwitterError = function(error_str) {
if(typeof error_str == 'object') {
var code = 500;
if(error_str.code) {
code = error_str.code;
}
if(error_str.status) {
code = error_str.status;
}
if(error_str.statusCode) {