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
1. Install `flack8` and `import-order` plugin: | |
Note: Below all examples imply the use of venv for the project. | |
``` | |
python3 -m pip install flake8 | |
python3 -m pip install flake8-import-order | |
``` | |
2. Add `File Watcher`: |
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 kilo(value): | |
return f'{value / 1000:.1f}kN' | |
def fall_force(m, fall_factor, elongation_factor=0.3): | |
return (9.8 * 2 * m * fall_factor) / elongation_factor | |
print(kilo(fall_force(80, 2))) # 10.5kN | |
print(kilo(fall_force(80, 1.7))) # 8.9kN |
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 argparse | |
import asyncio | |
import logging | |
from pathlib import Path | |
from types import SimpleNamespace | |
import libtorrent | |
from pony.orm import db_session | |
from tribler_core.modules.libtorrent.torrentdef import TorrentDef |
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
@dataclass | |
class Ping: | |
... | |
@dataclass | |
class Pong: | |
... | |
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
#!/bin/bash | |
# | |
################################################################################ | |
## Script to merge multiple git repositories into a new repository | |
## - The new repository will contain a folder for every merged repository | |
## - The script adds remotes for every project and then merges in every branch | |
## and tag. These are renamed to have the origin project name as a prefix | |
## | |
## Usage: mergeGitRepositories.sh <new_project> <my_repo_urls.lst> | |
## - where <new_project> is the name of the new project to create |
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
""" | |
Pydantic configuration BaseModels for IPv8. | |
If you want to see the available configuration options, print the schema as follows: | |
:: | |
from json import dumps | |
print(dumps(format_schema_recursive(IPv8Configuration), indent=4)) |
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 datetime | |
import logging | |
import math | |
import time | |
from pathlib import Path | |
from typing import Optional | |
from elastic_transport import TransportError | |
from elasticsearch import Elasticsearch |
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 sys | |
from elasticsearch import Elasticsearch | |
elastic_client = Elasticsearch('http://localhost:9200', request_timeout=120) | |
print('query:') | |
for line in sys.stdin: | |
query = { | |
"simple_query_string": { |
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 datetime | |
import subprocess | |
def run_git_command(command, repo_path): | |
return subprocess.check_output(command, cwd=repo_path, shell=True).decode('utf-8').strip() | |
# Repository path | |
repo_path = 'path/to/tribler/repo' |
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 requests | |
def fetch_github_data(repo, endpoint, params={}): | |
""" Fetch data from a GitHub repository endpoint. """ | |
data = [] | |
page = 1 | |
base_url = f'https://api.github.com/repos/{repo}/{endpoint}' |
OlderNewer