Skip to content

Instantly share code, notes, and snippets.

View ronaiza-cardoso's full-sized avatar
🏳️‍🌈

Ronaiza Cardoso ronaiza-cardoso

🏳️‍🌈
View GitHub Profile
@henrycunh
henrycunh / _responsive.scss
Created October 21, 2021 14:01
Responsiveness SASS mixins
@mixin support($size) {
@if $size == phone {
@media (max-width: 599px) { @content; }
} @else if $size == tablet-portrait {
@media (min-width: 600px) { @content; }
} @else if $size == tablet-landscape {
@media (min-width: 900px) { @content; }
} @else if $size == desktop {
@media (min-width: 1200px) { @content; }
} @else if $size == big-desktop {
@lucashmsilva
lucashmsilva / TESOURODIRETO(taxa).js
Last active January 11, 2024 13:26
API para criar a função TESOURODIRETO Google Sheets
/*
* @return Retorna a cotação atual de um título específico do Tesouro Direto Junto com a taxa anual de retorno
* @customfunction
**/
function TESOURODIRETO(bondName) {
let srcURL = "https://www.tesourodireto.com.br/json/br/com/b3/tesourodireto/service/api/treasurybondsinfo.json";
let jsonData = UrlFetchApp.fetch(srcURL);
let parsedData = JSON.parse(jsonData.getContentText()).response;
for(let bond of parsedData.TrsrBdTradgList) {
@LauraBeatris
LauraBeatris / Spinner.js
Created April 16, 2020 21:59
Roullete Spinner made with React Hooks
const spinWheel = useCallback(() => {
// Receives the winner prop and search for his position in the spinner bets array
const order = [8, 1, 14, 2, 13, 3, 12, 4, 0, 11, 5, 10, 6, 9, 7];
const position = order.indexOf(winner);
// Determine position where to land
const rows = 12;
const card = 80 + 2 * 2;
let landingPosition = rows * 15 * card + position * card;
@klzns
klzns / picture-in-picture.js
Last active July 2, 2018 15:11
Adicione esse script para abrir a transmissão da copa em picture in picture no Safari.
(function () {
var video = document.querySelector('video:not([title="Advertisement"])')
if (!video.webkitSupportsPresentationMode || typeof video.webkitSetPresentationMode !== 'function') {
console.error('Esse código só funciona no Safari!')
return
}
var scoreX = document.querySelector('.placar__equipes')
var button = document.createElement('button')
@BrunoDSouza
BrunoDSouza / flattenResults.js
Last active July 25, 2017 14:30 — forked from Woodsphreaker/flattenResults.js
Flatten Results
const arrObj = [
//Primeiro element
[{
"name": "Distri Equipamente Cirurgicos",
"data": 18
},
{
"name": "DNAPet",
"data": 70
}
@kiok46
kiok46 / NoItemComponent.md
Created June 28, 2017 17:41
Display a nice Component when no Items are available to show.

NoItemComponent

Display a nice Component when no Items are available to show.

import React, { Component } from 'react';
import { Text, View, Dimensions, StyleSheet } from 'react-native';
import { FontAwesome } from '@expo/vector-icons';
import Colors from '../constants/Colors';
@clarkbw
clarkbw / redux-performance-mark.js
Last active February 8, 2024 05:03
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
performance.mark(`${action.type}_start`);
let result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
);
return result;
@coolvasanth
coolvasanth / uploadingresume.txt
Last active April 3, 2020 05:40
choosing .jpg,.pdf,.docs etc files from galley and uploading it to server via your API using IONIC 2. (DOESN'T WORK ON IOS)
// Install file chooser and file transfer API from ionic 2 and import them into your page.ts. and don't forget to add providers in
app.component.ts
import { Component } from '@angular/core';
import { NavController, NavParams} from 'ionic-angular';
import { Home } from '../../homemodule/home';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { UserProfileService } from '../../services/login.service';
const userData = {name: 'lubien'}
localStorage.setItem('user', JSON.stringify(userData))
const persisted = JSON.parse(localStorage.getItem('user'))
console.log(persisted)

Recuperar todos os valores do objeto

Tive uma situação em que precisei recuperar todos os valores de um objeto, mas esse objeto tinha vários níveis.

O que fiz então foi, criar uma recursividade, verificando cada nó do objeto, se o nó fosse o tipo Object, como quase tudo no JS é, a função é novamente chamada entrando em um loop até que todos os nós fossem processados e seus valores armazenados.

O reduce permite um valor inicial, então usando o concat e o valor inicial como um array vazio