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
# Flattens nested lists/tuples into a single flat list. Other typles are | |
# returned as-is. | |
# | |
# | |
# Sample usage: | |
# | |
# >>> flatten([1, 2, 3, 4]) | |
# [1, 2, 3, 4] | |
# | |
# >>> flatten([1, [2, 3], 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
from collections.abc import Iterable | |
# Enumerate iterable containing iterables recursively. | |
# | |
# Like `enumerate` but can recursively go into nested iterables yielding each | |
# entry's index as a tuple. | |
# | |
# | |
# Sample usage: | |
# |
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
INPUT=input.mp4 | |
OUTPUT=output.mp4 | |
ffmpeg \ | |
-hwaccel cuda \ | |
-hwaccel_output_format cuda \ | |
-i $INPUT \ | |
-vf 'hwdownload,format=nv12,hwupload' \ | |
-c:a copy \ | |
-c:v h264_nvenc \ |
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
defmodule URIParser do | |
@doc """ | |
Extracts path, query params and UUIDs from the given URI and return them as a map. | |
## Examples | |
iex> URIParser.parse("https://example.com/resource/3776a9b5-5f69-4d9e-be5e-74e574df02d6?page[number]=5&page[size]=3") | |
%{ | |
path: "/resource/:id", | |
query: %{"page[number]" => "5", "page[size]" => "3"}, |
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
defmodule Zip do | |
@doc """ | |
Zips corresponding elements from a finite collection of enumerables into one list of tuples. | |
The zipping finishes when the longest enumerable is finished. Default padding value is `nil`. | |
Usage: | |
iex> Bla.zip_longest([1, 2, 3], [1, 2]) | |
[{1, 1}, {2, 2}, {3, nil}] |
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
class Hashable: | |
def __init__(self, arg): | |
self.arg = arg | |
def __hash__(self): | |
return hash(self.arg) | |
def __eq__(self, other): | |
return self.__hash__() == other.__hash__() |
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
class Hashable: | |
def __init__(self, arg): | |
self.arg = arg | |
def __hash__(self): | |
return hash(self.arg) | |
def __eq__(self, other): | |
return self.__hash__() == other.__hash__() |
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 | |
# Validates whether a phone number is in E.164 (https://en.wikipedia.org/wiki/E.164) | |
# format. | |
# | |
# Sample usage: | |
# | |
# >>> is_e164('55 (12) 98154-1281') | |
# True | |
# |
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 chain | |
# Fold iterable into itself. | |
# | |
# | |
# Sample usage: | |
# | |
# >>> list(fold([1, 2, 3])) | |
# [1, 2, 3, 2, 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
defmodule ProxyPass do | |
@docs """ | |
Dynamically delegate function calls to another module. | |
Usage: | |
defmodule RepoA do | |
def insert(), do: IO.puts("Called from RepoA") | |
end |
NewerOlder