Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Working on "This Artwork Is Always On Sale".

Simon de la Rouviere simondlr

💭
Working on "This Artwork Is Always On Sale".
View GitHub Profile
@simondlr
simondlr / gist:1594612
Created Jan 11, 2012
.vimrc of simondlr
View gist:1594612
set number "show line numbers
set numberwidth=1 "Line numbers width
set smartindent
set tabstop=4 "set tab character to 4 characters
set shiftwidth=4 "indent width for autoindent
"Show status line.
set laststatus=2
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
View tasks.py
from djcelery import celery
@celery.task
def add(x,y):
return x + y
@celery.task
def sleeptask(i):
from time import sleep
sleep(i)
View views.py
# Create your views here.
from django.http import HttpResponse
from app import tasks
def test_celery(request):
result = tasks.sleeptask.delay(10)
result_one = tasks.sleeptask.delay(10)
result_two = tasks.sleeptask.delay(10)
return HttpResponse(result.task_id)
@simondlr
simondlr / gist:8fb127c40177bc4d87cb
Last active Aug 29, 2015
Optionally mapping names to OpenBazaar GUIDs using Namecoin & DNSChain.
View gist:8fb127c40177bc4d87cb

User-friendly names that map to GUIDs have several benefits in the development of a web-of-trust for reputation based in commerce (as put forth by Dionysis: https://gist.github.com/dionyziz/e3b296861175e0ebea4b#pseudonymity). For example, to access specific stores, users send around their GUIDs (as can be seen here: http://www.reddit.com/r/BazaarMarkets/comments/2fjui8/selling_google_glass/). It's easier to remember reputable stores by their user-friendly names.

Here's a proposal to implement such a user-friendly system in OpenBazaar that is acceptably (debatable) decentralized using the Namecoin blockchain (http://namecoin.info/) & DNSChain (https://github.com/okTurtles/dnschain) model & server tools.

Namecoin + DNSChain + OpenBazaar GUIDs.

Namecoin

Namecoin is a decentralized key-value store using blockchain technology. It's been used to map decentralized domains (using .bit) & identities (using namespaces such id or u: https://github.com/opennamesystem/openspecs) amongst other uses. It is the m

@simondlr
simondlr / a.md
Last active Aug 29, 2015
Installing Counterparty/Dogeparty/ClearingHouse etc on OS X natively.
View a.md

Since there's always hiccups, I documented my install process to get a local Dogeparty Wallet running on OS X [there's no build procedure for it yet]. This will work with Counterparty & Clearinghouse as well (and other upcoming XCP implementations). This will likely be old-hat once a proper build-procedure is in place.

The dockers here from Lars give helpful tips on how the setup would work with VMs: https://github.com/Dogeparty.

  1. Install Dogecoind. Let it sync up with txindex=1 & server=1.
  2. Install Doge Insight. Problems with npm, so had to use npm upgrade. Dogecoin had old block store, so had to pipe blk.dats to bootstrap.dat, delete dogecoin conf, and reimport blocks for proper sync. Export proper variables for insight. Connect, and run node insight.js (after npm install). Halfway through, ran into magic number auxwow error. Switch to use RPC at block 371337 instead of PERCENTAGE_TO_SYNC_RPC_FROM.
  3. Clone dogepartyd. Install Python3. Upgrade virtualenv itself to use python3. Create virtu
@simondlr
simondlr / gist:48b77206b2483932f0f5
Last active Jun 30, 2021
Function hooks in Solidity
View gist:48b77206b2483932f0f5
contract Function_hook_example {
function Function_hook_example() {
owner = msg.sender;
}
modifier isOwner {
if (msg.sender == owner) {
_
}
@simondlr
simondlr / gist:45f0c8024a88d8dc54f8
Last active Jan 16, 2018
Standard Token Contract on Ethereum
View gist:45f0c8024a88d8dc54f8
//Most, basic default, standardised Token contract.
//Based on standardised APIs & slightly extended. https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs
//adds AddressApproval & AddressApprovalOnce events
//approve & approveOnce works on premise that approved always takes precedence.
//adds unapprove to basic coin interface.
contract Coin {
function sendCoin(uint _value, address _to) returns (bool _success) {}
function sendCoinFrom(address _from, uint _value, address _to) returns (bool _success) {}
function coinBalance() constant returns (uint _r) {}
View gist:b74e40039e570747b6e2
contract Generic is owned {
function() {
if(functions[msg.sig] != 0x0) {
functions[msg.sig].callcode(msg.data);
}
}
function changeMapping(bytes4 _functionSignature, address _addrOfFunction) {
if(msg.sender == owner) {
View gist:f48c5f47d06a0d4662b999903826bebf
Simon's peer:
enode://56d33cb7dcd7bcf147e18597ef6ea4270c2202bf3e63905ba9d95916c44ef0ac17a9dfae3afe2c38cb31967bbb813c48482e5294497ba6f7df20da09793ba49a@[::]:20010?discport=0
Simon's IP:
172.31.97.127
Together:
Do. admin.addPeer("enode://56d33cb7dcd7bcf147e18597ef6ea4270c2202bf3e63905ba9d95916c44ef0ac17a9dfae3afe2c38cb31967bbb813c48482e5294497ba6f7df20da09793ba49a@172.31.97.127:20010?discport=0")
Create Genesis Block using "sh createNewGenesisBlock.sh"
then run:
View gist:cd13348d0f578e2f5cd49cb7f5501801
pragma solidity ^0.4.4;
/*
This is for testing if a transaction would throw.
Contract calls rethrow when it encounters errors.
Raw calls do not.
You wrap your contract you want to test in a ThrowProxy.
You prime it by calling the fallback function.
Then executing it.