This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run in chrome console | |
(function(){ | |
$("#side").remove(); | |
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove(); | |
$(".nav_top_2011, #header, #navigator").remove(); | |
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box").remove(); | |
$("aside").remove(); | |
$(".tool-box").remove(); | |
$("#toolBarBox").remove(); | |
$("main").css('display','content'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
ts = 1597809600 | |
dt = datetime.fromtimestamp(ts) | |
# current date and time | |
now = datetime.now() | |
ts = datetime.timestamp(now) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import base64 | |
import json | |
import hmac | |
import hashlib | |
import requests | |
URL = 'https://api.bitfinex.com' | |
API_VERSION = '/v1' | |
API_KEY = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tuple | |
single_tuple = (1,) | |
# integer | |
# Python thinks it's part of a mathematical operation and has precedence | |
not_tuple = (1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. get deleted value | |
my_dict.pop('key', None) | |
# 2. simple but not atomic | |
if 'key' in my_dict: del my_dict['key'] | |
# 3. atomic | |
try: | |
del my_dict['key'] | |
except KeyError: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* event定義中的 keyword `indexed` 會被放在 topics當成參數做查詢, topics最多有四個, 第一個保留為 event的 hash值(識別用) */ | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
/* Send coins */ | |
function transfer(address _to, uint256 _value) { | |
if (_to == 0x0) throw; // Prevent transfer to 0x0 address. Use burn() instead | |
if (_value <= 0) throw; | |
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough | |
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows | |
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import concurrent.futures | |
from collections import namedtuple | |
BNB_transaction = namedtuple('BNB_transactions', ['hash', 'created_at', 'block', 'from_address', 'to_address', 'amount']) | |
def get_receipt(tx): | |
if isinstance(tx, AttributeDict): | |
tx = tx.hash | |
return web3.eth.getTransactionReceipt(tx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> web3.eth.getTransactionReceipt('0xba48fc0e658bfd927370ae0dda6fd37793e504e90289cd8216e986ebf714699b') | |
AttributeDict({ | |
'blockHash': HexBytes('0xf16ea2ee219d8ae91ce7dae021cfd9a5a9e959bd85d78b74be1ca4444e994a81'), | |
'blockNumber': 6259346, | |
'contractAddress': None, | |
'cumulativeGasUsed': 7095293, | |
'from': '0x98702707fe04c38ce752afad9c392f4a46289274', | |
'gasUsed': 22514, | |
'logs': [AttributeDict({ | |
'address': '0xB8c77482e45F1F44dE1745F52C74426C631bDD52', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.pyplot import figure | |
figure(num=None, figsize=(20, 16), dpi=80, facecolor='w', edgecolor='k') | |
import networkx as nx | |
import math | |
pos = nx.spring_layout(G) | |
# Draw Nodes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from decimal import Decimal | |
import networkx as nx | |
edges = defaultdict(lambda :defaultdict(Decimal)) | |
for tx in eth_transactions: | |
edges[tx.from_address][tx.to_address] += tx.amount | |
G = nx.DiGraph() | |
G.add_weighted_edges_from([(f, t, edges[f][t]) for f |
NewerOlder