Skip to content

Instantly share code, notes, and snippets.

View suissa's full-sized avatar
🏠
Working from home

Jean Carlo Nascimento suissa

🏠
Working from home
  • Oncorithms Institute
  • Brasil
View GitHub Profile
@suissa
suissa / npm-error-node-7
Created October 27, 2016 00:57
Erro do NPM com o Node 7
(import-export) ➜ () ➜ npm i express
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "express"
npm ERR! node v7.0.0
npm ERR! npm v3.10.8
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/fs'
npm ERR!
npm ERR! If you need help, you may report this error at:
var React = require('react'),
DOM = React.DOM, div = DOM.div, button = DOM.button, ul = DOM.ul, li = DOM.li
// This is just a simple example of a component that can be rendered on both
// the server and browser
module.exports = React.createClass({
// We initialise its state by using the `props` that were passed in when it
// was first rendered. We also want the button to be disabled until the
const config = {
method: 'POST',
body: JSON.stringify({ cat: 'grumpy' }),
cache: 'no-cache',
mode: 'no-cors',
}
fetch('http://localhost:8080/cats?categ=10&type=5', config)
.then(response => {
if(response.ok) {
@suissa
suissa / algo.js
Created November 9, 2016 10:40 — forked from halan/algo.js
module.exports = (distribuicao) => {
const pulaLinha = (linha, coluna) => [linha+1, coluna]
const pulaLinhaIniciaColuna = (linha, coluna) => [linha+1, 0]
const pulaLinhaColuna = (linha, coluna) => [linha+1, coluna+1]
const pulaLinhaDiminuiColuna = (linha, coluna) => [linha+1, coluna-1]
const Models = require('../../models/')
const MODEL_NAME = __dirname.split('modules')[1].slice(1)
const PREFIX = 'us_'
const PRIMARY_KEY = PREFIX + 'cod'
const ACTIONS_PATH = '../../actions/'
let offset = 0
let limit = 10
let attributes = [
PRIMARY_KEY,
module.exports = (Models, MODEL_NAME) => (req,res,next) => {
Models[MODEL_NAME].create(req.body)
.then((data) => {
res.json(data)
})
.catch((error) => {
console.log('error: ',error)
})
}
const tag = (name, children)=> ({
name,
children: children.map ? children: [children]
});
const div = tag.bind(null, 'div');
const span = tag.bind(null, 'span');
const p = tag.bind(null, 'p');
const b = tag.bind(null, 'b');
const a = tag.bind(null, 'a');
@suissa
suissa / cpf_consulta_api_sus.js
Last active June 21, 2020 19:57 — forked from Pompeu/cpf_consulta_api_sus.js
cpf_consulta_api_sus.js
const http = require('http')
const cpf = process.argv[2]
const url = 'http://dabsistemas.saude.gov.br/sistemas/sadab/js/buscar_cpf_dbpessoa.json.php?cpf='
const consult = `${url}${cpf}`
let body = ''
http.get(consult, (res) =>
res
.on('data', data => body += data)
@suissa
suissa / jsonFieldsToLower.js
Created December 11, 2016 20:15
Exemplo de como deixar todos os campos de um JSON em minúsuclo
const fieldsLower = JSON.stringify(json).replace(/"([\w]+)":/g,function($0,$1){return ('"'+$1.toLowerCase()+'":');})
@suissa
suissa / findIntrumentosComCalibracoesPendentes.js
Last active December 12, 2016 00:24
findIntrumentosComCalibracoesPendentes
const Calibracao = require('../modules/calibracao/organism')
module.exports = (Organism) =>
(req, res) => {
const query = {'calibracoes.0': {$exists: true}}
const success = (data) => res.json(data)
const error = (err) => res.json(err)
const sendValidacoes = (pendentes) => {
const testIfIsPendente = (cal) =>