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 / page-content.js
Last active May 9, 2020 20:53
pageContent service for strapi tutorial
'use strict';
const modelName = 'page-content'
module.exports = {
_validate(data) {
if (!(data.startAt < data.endAt)){
throw new Error("startAt should be less than endAt date")
}
@luizamboni
luizamboni / link.js
Created May 9, 2020 20:51
link service for 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.spec.js
Last active May 9, 2020 21:00
link spec in strapi tutorial
@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 / 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 / mocha.opts
Created May 9, 2020 21:02
mocha.opts from strapi tutorial
--recursive
--reporter spec
--file ./test/setup.js
--timeout 20000
@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 / 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))