Skip to content

Instantly share code, notes, and snippets.

Avatar

Luiz Zamboni luizamboni

View GitHub Profile
@luizamboni
luizamboni / sql_statements.R
Created Dec 18, 2020
examples of sql in R
View sql_statements.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
how add config by env vars in next.js
View index.html
<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
mocha.opts from strapi tutorial
View mocha.opts
--recursive
--reporter spec
--file ./test/setup.js
--timeout 20000
@luizamboni
luizamboni / setup.js
Created May 9, 2020
final mocha setup from strapi tutorial
View setup.js
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
mocha test startup for strapi tutorial
View setup.js
const strapi = require('strapi')();
before((done) => {
strapi.start(() => {
done()
});
});
after(() => {
strapi.stop(0);
@luizamboni
luizamboni / link.spec.js
Last active May 9, 2020
link spec in strapi tutorial
View link.spec.js
@luizamboni
luizamboni / ContentManager.js
Created May 9, 2020
ContentManager service for strapi tutorial
View ContentManager.js
'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
link service for strapi tutorial
View link.js
@luizamboni
luizamboni / page-content.js
Last active May 9, 2020
pageContent service for strapi tutorial
View page-content.js
'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")
}