This file contains hidden or 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
| // objMap(x => x*x, {a: 2, b: 3}) -> {a: 4, b: 9} | |
| const objMap = (f, obj) => | |
| Object | |
| .entries(obj) | |
| .reduce((acc, [k, v]) => | |
| (acc[k] = f(v, k, obj), acc) | |
| , {}); | |
| // Need this function or equivalent to deep map |
This file contains hidden or 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 functools import reduce | |
| def groupby(f, it): | |
| def reducer(acc, n): | |
| key = f(n) | |
| if key in acc: | |
| acc[key].append(n) | |
| else: | |
| acc[key] = [n] |
This file contains hidden or 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
| npm i -g slugify-cli | |
| npm i -g puppeteer-screenshot-cli | |
| print_all() { | |
| urls="$1" | |
| output="$2" | |
| mkdir -p "${output}" | |
| cat "${urls}" | | |
| while read line |
This file contains hidden or 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 .lexer import Lexer | |
| code = ''' | |
| (define (fib x) | |
| (if (lt x 2) | |
| x | |
| (add (fib (sub x 1)) | |
| (fib (sub x 2))))) | |
| ''' |
This file contains hidden or 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 | |
| from random import randint | |
| async def get(url): | |
| # simula a demora na request | |
| await asyncio.sleep(1) | |
| # simula uma resposta duma realistica função 'get' | |
| return bool(randint(0, 1)) |
This file contains hidden or 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
| [ | |
| {"letter": "A", "number": 4}, | |
| {"letter": "B", "number": 6}, | |
| {"letter": "C", "number": 10}, | |
| {"letter": "D", "number": 3}, | |
| {"letter": "E", "number": 7}, | |
| {"letter": "F", "number": 8} | |
| ] |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>Vega Lite pie chart</title> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/3.23.1/vega-embed.min.css" /> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/vega/4.3.0/vega.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/vega-lite/2.6.0/vega-lite.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/3.23.1/vega-embed.min.js"></script> |
This file contains hidden or 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
| [ | |
| {"sign":"Aries","count":2328,"sum_of_votes":39017358}, | |
| {"sign":"Taurus","count":2281,"sum_of_votes":51056695}, | |
| {"sign":"Gemini","count":2301,"sum_of_votes":42472945}, | |
| {"sign":"Cancer","count":2230,"sum_of_votes":41106817}, | |
| {"sign":"Leo","count":2297,"sum_of_votes":35133564}, | |
| {"sign":"Virgo","count":2287,"sum_of_votes":26846077}, | |
| {"sign":"Libra","count":2292,"sum_of_votes":41968051}, | |
| {"sign":"Scorpio","count":2167,"sum_of_votes":56140744}, | |
| {"sign":"Sagittarius","count":2019,"sum_of_votes":32702931}, |
This file contains hidden or 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 infix: | |
| """ | |
| Makes a function 'infix' eg: | |
| >>> @infix | |
| ... def power(x, n): | |
| ... return x ** n | |
| >>> 2 |power| 3 | |
| 8 |
This file contains hidden or 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
| Maybe::Just() { | |
| printf 'Maybe::Just(%s)' "${1}" | |
| } | |
| Maybe::Nothing() { | |
| printf 'Maybe::Nothing' | |
| } | |
| Maybe::map() { | |
| case "${2}" in |
OlderNewer