Skip to content

Instantly share code, notes, and snippets.

View Nukeer's full-sized avatar

Felipe Vieira Baehr Nukeer

  • Santa Catarina, Brazil
View GitHub Profile
// Caso queira gerar planilhas use array na var. conteudo
let conteudo = 'Conteúdo que estará dentro do arquivo';
let nomeArquivo = 'Nome do arquivo + .extensão';
var blob = new Blob([conteudo], { type: 'text/csv;charset=utf-8;' });
if (navigator.msSaveBlob) { // IE 10+
navigator.msSaveBlob(blob, nomeArquivo);
} else {
var link = document.createElement("a");
@Nukeer
Nukeer / redirect.js
Last active October 3, 2019 19:25
Redirect http to https
import { environment } from 'src/environments/environment';
if (environment.production) {
if (location.protocol === 'http:') {
location.href = location.href.replace('http', 'https');
}
}
// Bootstrap version 4
function detectSizeBootstrapGrid() {
let envs = ['xs', 'sm', 'md', 'lg', 'xl'];
// Create element to get name size
let el = document.createElement('div');
document.body.appendChild(el);
let size = envs.shift();
@Nukeer
Nukeer / http-redirect.js
Created December 6, 2019 18:41
Redirect from http to https for the server.js file of node js
const app = express();
const forceSSL = function() {
return function(req, res, next) {
if (req.headers["x-forwarded-proto"] !== "https") {
return res.redirect(["https://", req.get("Host"), req.url].join(""));
}
next();
};
};
@Nukeer
Nukeer / days-in-month.js
Last active January 26, 2021 17:35
get array of days in month
import { getYear } from 'date-fns';
getDaysInMonth(month): Array<number> {
const date = new Date(getYear(new Date()), month, 1);
const days = [];
while (date.getMonth() === month) {
days.push({ name: new Date(date).getDate() });
date.setDate(date.getDate() + 1);
}
return days;