This file contains 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
def __init__(self, leaves): | |
self.leaves = [Node(leaf) for leaf in leaves] | |
self.layer = self.leaves[::] | |
self.root = None | |
self.build_tree() |
This file contains 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
def caluculator(markle_pass): | |
value = markle_pass[0] | |
for node in markle_pass[1:]: | |
sib = node[0] | |
position = node[1] | |
if position == "right": | |
value = sha256(value.encode() + sib.encode()).hexdigest() | |
else: | |
value = sha256(sib.encode() + value.encode()).hexdigest() | |
return value |
This file contains 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 json | |
import urllib.request | |
from warrant.aws_srp import AWSSRP | |
from urllib.request import urlopen | |
from datetime import datetime | |
def get_article(user_id, result=[],article_id=None,sort_key=None): | |
# api url | |
if not(article_id) and not(sort_key): | |
article_api = "https://alis.to/api/users/$s/articles/public?limit=100" % user_id |
This file contains 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 urllib.request import urlopen | |
import json | |
# 記事一覧取得 | |
def get_articles(page_lim): | |
article_api = "https://alis.to/api/articles/recent?limit=100&page=%d" | |
page = 1 | |
result = [] | |
while page <= page_lim: | |
raw_article_data = urlopen(article_api % page).read().decode("utf-8") |
This file contains 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 threading import Thread | |
from queue import Queue, Empty | |
from datetime import datetime | |
import pandas as pd | |
def worker(worker_queue, result_queue): | |
while not worker_queue.empty(): | |
try: | |
article = worker_queue.get(block=False) | |
except Empty: |
This file contains 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
def single_thread(page_lim): | |
articles = get_articles(page_lim) | |
df = pd.DataFrame() | |
for article in articles: | |
title = article["title"] | |
user = article["user_id"] | |
article_id = article["article_id"] | |
like = get_like_count(article_id) | |
result = {"title":title, "user":user, "like":like} | |
row = pd.DataFrame(result,index=[None]) |
This file contains 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 asyncio | |
import aiohttp | |
from datetime import datetime | |
import pandas as pd | |
session = aiohttp.ClientSession() | |
def main(page_lim): | |
row_queue = asyncio.Queue() |
This file contains 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 asyncio | |
async def parent(name, num): | |
print(f"{name} start") | |
await child(name, num) | |
print(f"{name} end") | |
async def child(name, num): | |
print(f"{name}'s child waiting...") | |
await asyncio.sleep(num) |
This file contains 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 asyncio | |
async def parent(name, num): | |
print(f"{name} start") | |
await child(name, num) | |
print(f"{name} end") | |
async def child(name, num): | |
print(f"{name}'s child waiting...") |
This file contains 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
function get_recent_articles(){ | |
var api = "https://alis.to/api/articles/recent?limit=100&page=1"; | |
var res=UrlFetchApp.fetch(api).getContentText(); | |
var result = JSON.parse(res); | |
return result["Items"] | |
} | |
function is_published_in_10min(article){ | |
var timestamp = parseInt(article["published_at"], 10); | |
var pub_time = Moment.moment.unix(timestamp) |