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
""" | |
Command Line tool that provides compatibility between poetry and cyclonus docker scans | |
""" | |
import argparse | |
import sys | |
from contextlib import contextmanager | |
from itertools import chain | |
from pathlib import Path | |
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union |
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
let cmp = function(a, b){ | |
if(a < b) return -1; | |
if(a > b) return 1; | |
return 0; | |
}; | |
function bsearch(arr, value, comparator) { | |
let low = 0, | |
high = arr.length - 1, | |
mid; |
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 math | |
def smallest_div(n): | |
if n <= 1: | |
return 1 | |
return min(i for i in range(2, n + 1) if n % i == 0) | |
def check_prime(n): | |
if n % 2 == 0: |
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 typing import Callable | |
def is_multiple(x: int, num: int) -> bool: | |
return x % num == 0 | |
def in_number(x: int, num: int) -> bool: | |
return str(num) in str(x) |
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 date_delta(startdate, enddate, no_of_ranges): | |
start_epoch = calendar.timegm(startdate.timetuple()) | |
end_epoch = calendar.timegm(enddate.timetuple()) | |
date_diff = end_epoch - start_epoch | |
step = date_diff / no_of_ranges | |
return datetime.timedelta(seconds=step) |
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 run_async(fn): | |
@wraps(fn) | |
def fn_wrapped(*args, **kwargs): | |
return asyncio.run(fn(*args, **kwargs)) | |
return fn_wrapped |
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 onReady(callbackFn) { | |
if (document.readyState !== 'loading') { | |
// Document is already ready, call the callback directly | |
callbackFn(); | |
} else if (document.addEventListener) { | |
// All modern browsers to register DOMContentLoaded | |
document.addEventListener('DOMContentLoaded', callbackFn); | |
} else { | |
// Old IE browsers | |
document.attachEvent('onreadystatechange', function() { |
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 gather_with_concurrency(n, *tasks): | |
semaphore = asyncio.Semaphore(n) | |
async def concurrent_task(task): | |
async with semaphore: | |
await task | |
await asyncio.gather(*(concurrent_task(task) for task in tasks)) |
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
goFullScreen() { | |
const fullScreenPrefixes = [ | |
'requestFullscreen', | |
'webkitRequestFullscreen', | |
'mozRequestFullScreen', | |
'msRequestFullscreen' | |
] | |
// HTMLElement is the DOM element you want to make full screen | |
const prefixedFn = fullScreenPrefixes.find( | |
prefixedFn => HTMLElement[prefixedFn] !== undefined |
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 Hide-Dots { | |
Param( | |
[Parameter(Position=0)] | |
[ValidateScript({ Test-Path $_ })] | |
[string] $path="." | |
) | |
if ($path -eq ".") { | |
$cwd = (Get-Location).Path.Substring((Get-Location).Path.LastIndexOf("\") + 1) | |
echo "Searching for files in $($cwd) ..." |
NewerOlder