Skip to content

Instantly share code, notes, and snippets.

View luizamboni's full-sized avatar
💭
I may be slow to respond.

Luiz Zamboni luizamboni

💭
I may be slow to respond.
View GitHub Profile
@luizamboni
luizamboni / async-example.py
Last active October 21, 2021 00:15
artigo medium
import asyncio
from typing import Awaitable
async def mock_query(n: int) -> str:
print(f'chamada: {n}')
await asyncio.sleep(n)
return f'resultado da api chamada: {n}'
async def main() -> None:
@luizamboni
luizamboni / is_rage.py
Created August 3, 2021 17:09
detect ranges filter with nltk
import nltk
from typing import List,Union, Dict, TypedDict, Any
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
def is_range_value(sentence: str) -> bool :
tokens: List[str] = nltk.word_tokenize(sentence)
@luizamboni
luizamboni / sql_statements.R
Created December 18, 2020 02:02
examples of sql in R
sql_string_value <- function(value) {
return(ifelse(is.null(value) | is.na(value),"''", paste0("'", gsub("'", "", value), "'")))
}
sql_timestamp_value <- function(value) {
return(paste0("date(timestamp'", value, "')"))
}
sql_numeric_value <- function(value) {
return(ifelse(is.null(value) | is.na(value), '0', value))
@luizamboni
luizamboni / index.html
Created May 26, 2020 21:01
how add config by env vars in next.js
<script>
const configValues = document.cookie.split('; ').find(c => c.startsWith('config')).split('=')[1]
const config = JSON.parse(window.unescape(config))
</scrip>
@luizamboni
luizamboni / mocha.opts
Created May 9, 2020 21:02
mocha.opts from strapi tutorial
--recursive
--reporter spec
--file ./test/setup.js
--timeout 20000
@luizamboni
luizamboni / setup.js
Created May 9, 2020 21:01
final mocha setup from strapi tutorial
const strapi = require('strapi')();
/*
* nossa nova função start
* não iniciar servidor http
* nem printa nada na tela
*/
const start = async function(cb) {
try {
await this.load();
@luizamboni
luizamboni / setup.js
Created May 9, 2020 20:59
mocha test startup for strapi tutorial
const strapi = require('strapi')();
before((done) => {
strapi.start(() => {
done()
});
});
after(() => {
strapi.stop(0);
@luizamboni
luizamboni / link.spec.js
Last active May 9, 2020 21:00
link spec in strapi tutorial
@luizamboni
luizamboni / ContentManager.js
Created May 9, 2020 20:56
ContentManager service for strapi tutorial
'use strict';
const _ = require('lodash');
module.exports = {
fetchAll(params, query) {
const { query: request, populate, ...filters } = query;
const queryFilter = !_.isEmpty(request)
? {
@luizamboni
luizamboni / link.js
Created May 9, 2020 20:51
link service for strapi tutorial