Skip to content

Instantly share code, notes, and snippets.

View DaniloOliveira28's full-sized avatar
😁

Danilo Oliveira DaniloOliveira28

😁
View GitHub Profile
@DaniloOliveira28
DaniloOliveira28 / useLiveChatExternalApi.tsx
Last active April 12, 2024 08:01
Hook to manage the hubspot conversations chat using relay as global store
import { useState } from 'react';
import { useCommitLocalUpdate } from '../../components/utils/relay';
function loadOrRefreshChat(opened: boolean) {
if (window.HubSpotConversations.widget.status().loaded === true) {
window.HubSpotConversations.widget.refresh();
} else {
window.HubSpotConversations.widget.load({ widgetOpen: opened });
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const testArea = document.querySelector('#test-area')
const theTimer = document.querySelector('.timer')
const resetButton = document.querySelector('#reset')
const templateText = document.querySelector('#origin-text p')
var myTikTok;
const control = {
templateText: templateText.innerText,
isRunningTiming: false,
@DaniloOliveira28
DaniloOliveira28 / query_example.gql
Last active July 15, 2020 20:52
Exemplo de chamada para puxar os total de commits e adições/remoções na branch master.
link:
https://developer.github.com/v4/explorer/
query {
repository(name:"linux" owner:"torvalds"){
name
defaultBranchRef {
id
}
object(expression: "master") {
@DaniloOliveira28
DaniloOliveira28 / Cabeçalhos-Prestação de Contas
Created November 15, 2015 21:44
Diferença de cabeçalhos relativos aos dados do TSE de prestação de contas. (http://www.tse.jus.br/eleicoes/estatisticas/repositorio-de-dados-eleitorais)
2002
SEQUENCIAL_CANDIDATO;SG_UF;SG_PART;DS_CARGO;NO_CAND;NR_CAND;DT_RECEITA;CD_CPF_CGC;SG_UF_DOADOR;NO_DOADOR;VR_RECEITA;TP_RECURSO
2004
NO_CAND;DS_CARGO;CD_CARGO;NR_CAND;SG_UE_SUP;NO_UE;SG_UE;NR_PART;SG_PART;VR_RECEITA;DT_RECEITA;DS_TITULO;CD_TITULO;TP_RECURSO;TP_RECURSO;NO_DOADOR;CD_CPF_CGC_DOA;RV_MEANING
2006
SEQUENCIAL_CANDIDATO;NOME_CANDIDATO;DESCRICAO_CARGO;CODIGO_CARGO;NUMERO_CANDIDATO;UNIDADE_ELEITORAL_CANDIDATO;NUMERO_CNPJ_CANDIDATO;NUMERO_PARTIDO;SIGLA_PARTIDO;VALOR_RECEITA;DATA_RECEITA;TIPO_RECEITA;CODIGO_TIPO_RECEITA;DESCRICAO_TIPO_RECURSO;CODIGO_TIPO_RECURSO;NOME_DOADOR;NUMERO_CPF_CGC_DOADOR;UNIDADE_ELEITORAL_DOADOR;SITUACAO_CADASTRAL
2008
def get_max_brute_force(lst):
if len(lst) == 1:
return lst[0]
maximum = lst[0]
for i in range(1, len(lst)):
if lst[i] > maximum:
maximum = lst[i]
def mergesort(lst):
'''Recursively divides list in halves to be sorted'''
if len(lst) == 1:
return lst, 0
middle = len(lst) / 2
left = mergesort(lst[:middle])[0] # Ignore intermediate splits
right = mergesort(lst[middle:])[0] # Ignore intermediate splits
sortedlist, splits = merge(left, right)
return sortedlist, splits
def exp(a, n):
if n <= 0:
return 1
if n % 2 == 0:
return exp(a, n / 2) * exp(a, n / 2)
else:
return exp(a, (n - 1) / 2) * exp(a, (n - 1) / 2) * a
if __name__ == '__main__':
def find_peak(elements):
if len(elements) < 0:
return None
if len(elements) == 1:
return elements[0]
if len(elements) == 2:
if elements[0] > elements[1]:
return elements[0]
#!/usr/local/bin/python2.7
# encoding: utf-8
import numpy as np
def equal_letters_strings(X, Y):
N = len(X)
M = len(Y)