Skip to content

Instantly share code, notes, and snippets.

View bruno2ms's full-sized avatar

Bruno Mendes Soares bruno2ms

  • Yahoo Finance
  • Brazil
View GitHub Profile
// https://github.com/miragejs/site/blob/master/src/lib/persist.js
// secret stuff in here.
// increase this number to bust all locally stored mirage
// databases
let currentVersion = 1
let initialData: object
function saveDb(server: any) {
localStorage.setItem('mirage:db:version', String(currentVersion))
@bruno2ms
bruno2ms / tab.js
Created July 30, 2018 13:06
Textarea handle tab
export const tab = (text, start = 0, end = start, tab_size = 4) => {
let tab = ' '.repeat(tab_size);
let lines = splitLines(text);
let indexes = getStartIndexes(lines);
indexes.push(text.length);
if (start == end) {
return `${text.slice(0, start)}${tab}${text.slice(start, text.length)}`;
} else if (lines.length == 1) {
return `${tab}${text}`;
@bruno2ms
bruno2ms / info.md
Created July 25, 2018 11:38 — forked from marteinn/info.md
Using the Fetch Api with Django Rest Framework

Using the Fetch Api with Django Rest Framework

Server

First, make sure you use the SessionAuthentication in Django. Put this in your settings.py

# Django rest framework
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
 'rest_framework.authentication.SessionAuthentication'
@bruno2ms
bruno2ms / SassMeister-input.scss
Last active February 27, 2018 14:00
Generated by SassMeister.com.
// ----
// Sass (v4.0.0.alpha.1)
// Compass (vundefined)
// ----
// Var definition no Geral
$props:();
$props: map-merge($props, (main-menu__menu-home__span--props: (
color: blue,
@bruno2ms
bruno2ms / toggle_api_google_spreadsheet.gs
Last active February 27, 2018 13:54
Script para preencher planilha de horas com base na API do Toggl
// Acesse o menu na aba da sua Planilha de Jornada de Horas
// Ferramentas > Editor de Script
// Cole e salve este script, o Google provavelmente pedirá permissão de execução do script
// Acesse as configurações do Toggl no endereço https://toggl.com/app/profile
// Copie a sua apiToken
// Substitua aqui as variáveis necessárias
var apiToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
// Para obter os id`s de workspace e clientes, acesse a página reports, selecione o workspace e cliente e aplice o filtro
@bruno2ms
bruno2ms / parse.gs
Created January 30, 2018 22:22
Parse Google Spreadsheet Vendas
var ss = SpreadsheetApp.getActiveSpreadsheet();
function onOpen() {
var entries = [{
name : "Export JSON",
functionName : "exportJSON"
}];
ss.addMenu("Export JSON", entries);
};
@bruno2ms
bruno2ms / index.html
Created January 29, 2018 20:44 — forked from bummzack/index.html
Webpack using browser-sync and SASS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dummy</title>
<link rel="stylesheet" href="dist/css/styles.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<body>
<div id="app" >
@bruno2ms
bruno2ms / iframe-size.js
Created January 5, 2018 11:03
Acessar dados do iframe
// Página externa
// Ajusta o tamanho do Iframe com base na informação recebida pelo proprio iframe
// Isto é necess;ario porque os browsers não aceitam mais o acesso direto ao conteudo do iframe ou do parent
window.addEventListener('message', function(event) {
if (event.data.bodyHeight) {
$('#foreign').height(event.data.bodyHeight);
}
});
// Página dentro do Iframe
var aulas = [375]
var locais = [
{
local: 'São Paulo',
endereco: 'São Paulo, Avenida Paulista, 500 - Bela Vista'
},
{
local: 'Goiania',
endereco: 'Goiania, Avenida Goianiense, 500 - Bela Vista'
// import React from 'react';
// import ReactDOM from 'react-dom';
class PainelUsuarioView extends React.Component {
constructor(props, context) {
super(props, context);
this.state = $.extend({}, props.view, this.setupLayout(props));
this.handleScroll = this.handleScroll.bind(this);
}