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 inspect | |
async def test_coro(): | |
await asyncio.sleep(1) | |
print('coro') | |
return 1 | |
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 __future__ import print_function | |
def get_mil(d, v0, ds): | |
t = d * 1.0 / v0 | |
mil = (5 * t * t - ds) * 1000 / d | |
return int(mil * 10 + 0.5) / 10.0 | |
cols = [600, 700, 800, 900, 1000, 1100, 1200] | |
header = [''] + cols | |
print(*header, sep='\t') |
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 collections import OrderedDict | |
class LRUCache(object): | |
def __init__(self, size=5): | |
self.size = size | |
self.cache = OrderedDict() | |
def get(self, key): | |
if key in self.cache: |
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 re | |
regex = re.compile(r'\\(\d+)' | |
def repl(m): | |
return r'\x' + hex(int(m.group(1), 8)).replace('0x', r'').zfill(2) | |
lines = vscode.editor.lines | |
lines = [line.decode() for line in lines] | |
lines = [regex.sub(repl, line) for line in lines] |
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_close_nodes_for_duplicate_onetab_items() { | |
let closeNodes = []; | |
let cache = {}; | |
let selector = '#contentAreaDiv > div > div:nth-child(2) > div > div:nth-child(2)'; | |
let nodes = Array.from(document.querySelectorAll(selector)); | |
for (let node of nodes) { | |
let linkNode = node.querySelector('a.clickable'); | |
let closeNode = node.querySelector('img:nth-child(3)'); | |
let url = linkNode.getAttribute('href'); | |
if(cache[url]) { |
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 os | |
import sys | |
import traceback | |
from functools import wraps | |
from multiprocessing import Process, Queue | |
def processify(func): | |
'''Decorator to run a function as a process. |
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
document.querySelectorAll('.torrent-details tr').forEach(function (node) { | |
var name = node.querySelector('.col-name').textContent; | |
if (name.match(/^_____padding_file_/)) { | |
console.log(name); | |
node.querySelector('.deselect-file').click(); | |
} | |
}) |
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
document.querySelectorAll('.torrent-details tr').forEach(function (node) { | |
var name = node.querySelector('.col-name').textContent; | |
if (name.match(/^_____padding_file_/)) { | |
console.log(name); | |
node.querySelector('.deselect-file').click(); | |
} | |
}) |
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 itertools import tee, islice as slice, chain, izip as zip | |
def previous_and_next(iterable, fill_value=None): | |
prevs, items, nexts = tee(iterable, 3) | |
prevs = chain([fill_value], prevs) | |
nexts = chain(slice(nexts, 1, None), [fill_value]) | |
return zip(prevs, items, nexts) |
NewerOlder