Skip to content

Instantly share code, notes, and snippets.

View albertosouza's full-sized avatar
👨‍🔬
Creating things

Alberto Souza albertosouza

👨‍🔬
Creating things
View GitHub Profile
/**
* Script simples para importação de dados de cotação da Bovespa
*
* Requisitos:
* - Node.js instalado
* - instalar as dependencias: npm install extract-zip moment request
*
* Exemplo de uso: node script_simples_importaca_cota_hist_bovespa.js 05022019
*
* Post relacionado: https://albertosouza.net/artigos/22-importando-dados-bovespa
@albertosouza
albertosouza / check-if-file-exists.js
Created January 19, 2020 14:43
Simple script to show how to check if file exists with Node.js
// text.txt file is in same folder where we are running this script
let filePath = path.join(process.cwd(), 'text.txt');
// Check if file exists and have access with fs.access:
fs.access(filePath, fs.F_OK, function (err) {
if (err) {
console.log('file not exists or not have access');
} else {
console.log('file exists');
}
});
@albertosouza
albertosouza / easy-soap-request-index.js
Created December 5, 2019 14:22 — forked from circa10a/easy-soap-request-index.js
easy-soap-request-index.js
const axios = require('axios-https-proxy-fix');
/**
* @author Caleb Lemoine
* @param {object} opts easy-soap-request options
* @param {string} opts.url endpoint URL
* @param {object} opts.headers HTTP headers, can be string or object
* @param {string} opts.xml SOAP envelope, can be read from file or passed as string
* @param {int} opts.timeout Milliseconds before timing out request
* @param {object} opts.proxy Object with proxy configuration
@albertosouza
albertosouza / pegar-href-de-links-com-cherrio.md
Created October 28, 2019 16:29
Exemplos de como pegar o href de links com cherrio
@albertosouza
albertosouza / models-locale.js
Last active February 8, 2018 04:22
Sails.js simple example of localization with database
module.exports = {
adapter:'exampleDB',
//tableName:'locale',
attributes: {
text: {
type: 'string'
},
// locale config
@albertosouza
albertosouza / Organization json-ld
Created December 5, 2017 23:56 — forked from cjzopen/Organization json-ld
Organization json-ld example
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Organization",
"name" : "example",
"logo": "https://example.com.tw/logo.png",
"url" : "https://example.com.tw/",
"address" : "address",
"email" : "example@.com.tw",
"founder" : "you can use People type here",
@albertosouza
albertosouza / sails-acl-npm-module-proposal.md
Last active February 10, 2016 13:14
A Sails.js ACL with Roles / permissions configs proposal ... based in sails police

A ⛵ Sails.js ACL proposal ... based in polices

Please help build that feature with ideas 💭 here ... or code and tests here: https://github.com/wejs/sails-acl

How it will work? ...

What dependecies we need in our project?
  • User model - TODO add example link
@albertosouza
albertosouza / Cakefile
Created January 11, 2014 21:19
Cakefile for run sails.js testes with mocha config and suport to --grep <string> option
# Cakefile
{exec} = require "child_process"
option '', '--grep [string]', 'only run tests matching <pattern>'
REPORTER = "spec"
task "test", "run all tests", (options)->
grep
@albertosouza
albertosouza / run-supervision-app.sh
Created January 11, 2014 21:16
run-supervision-app.sh to run sails.js with ignore config
#! /bin/bash
# Script to run app.js with supervision and ignore folders
supervisor -i .tmp/,.git/,node_modules/,views/,assets/images/,assets/linker/templates,assets/templates,assets/js/angularjs,assets/angularjs/main.js app.js
#supervisor -i .tmp/,.git/,node_modules/,views/ -- --debug=5555 app.js
@albertosouza
albertosouza / graphics_magick_center_image_on_canvas.js
Created October 31, 2015 18:24 — forked from edwardhotchkiss/graphics_magick_center_image_on_canvas.js
Use GM Module (Graphics Magick) for Node.js to center an image on a white background canvas
var gm = require('gm');
var canvasWidth = 248;
var canvasHeight = 389;
gm(__dirname + '/original.jpg').size(function(error, size) {
if (error) {
console.error(error);