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
# Group equal consecutive items of iterable. | |
# | |
# | |
# Sample usage: | |
# | |
# >>> group_equal('aaabbcd') | |
# [['a', 'a', 'a'], ['b', 'b'], ['c'], ['d']] | |
# | |
def group_equal(iterable): | |
subgroups = [] |
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 | |
import base64 | |
from urllib.parse import urlparse | |
from urllib.parse import parse_qs | |
url = urlparse(sys.argv[-1]) | |
query = parse_qs(url.query) | |
encoded_url = query['url'][0].encode('utf8') |
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 zip_longest | |
# Group each `n` elements of the iterable, filling with `fillvalue` if needed. | |
# | |
# | |
# Sample usage: | |
# | |
# >>> list(grouper([1, 2, 3, 4, 5, 6], 2)) | |
# [(1, 2), (3, 4), (5, 6)] | |
# |
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 islice | |
# Slides through iterable each `n` elements. | |
# | |
# Sample usage: | |
# | |
# >>> list(sliding_window([1, 2, 3, 4])) | |
# [(1, 2), (2, 3), (3, 4)] | |
# | |
# >>> list(sliding_window([1, 2, 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 StringConverter do | |
@doc """ | |
Returns an ascii representation of the given string. | |
## Examples | |
iex> StringConverter.asciify("língüiça") | |
"linguica" |
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 Parallel do | |
@moduledoc """ | |
Utility functions to ease working with parallel processes. | |
""" | |
@doc """ | |
Equivalent to `Enum.map/2` but each `function` call is made inside its own | |
process. | |
""" | |
def map(enumerable, function) do |
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
// Regex to format text to whatsapp format | |
function whatsToHtml(msg) { | |
if (!msg) return; | |
return msg | |
.replace(/~(~*[^~\n]+~*)~/g, '<del>$1</del>') | |
.replace(/_(_*[^_\n]+_*)_/g, '<em>$1</em>') | |
.replace(/\*(\**[^*\n]+\**)\*/g, '<strong>$1</strong>'); | |
} |
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
# Sample usage: | |
# | |
# iex(1)> Calculator.calculate('123 + 27') | |
# 150 | |
# iex(2)> Calculator.calculate('123 - 27') | |
# 96 | |
# iex(3)> Calculator.calculate('123 * 27') | |
# 3321 | |
# iex(4)> Calculator.calculate('123 / 27') | |
# 4.555555555555555 |
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
# Return stirng representation of given array of building sizes (with overall height of 9) | |
# | |
# Sample usage: | |
# | |
# >>> print(buildings('252')) | |
# | |
# | |
# | |
# | |
# # |
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
<div class="container full--size"> | |
<div class="square first"></div> | |
<div class="square second"></div> | |
<div class="square third"></div> | |
</div> | |
<style> | |
.container { | |
display: flex; |