Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Diego Vinicius Diegow3b

🎯
Focusing
View GitHub Profile
View Tetris Move
/*
Tetris Move
Have the function TetrisMove(strArr) take strArr parameter being passed
which will be an array containing one letter followed by 12 numbers
representing a Tetris piece followed by the fill levels for the 12 columns
of the board.
Calculate the greatest number of horizontal lines that can be completed
when the piece arrives at the bottom assuming it is dropped immediately
after being rotated and moved horizontally from the top.
View Contra: React JS
/*
Answers:
1 - React is not being imported
2 - When calling setData at line 11 was overring the existing profile
3 - userEffect was watching at setData instead of data
4 - Suspense was being called without fallback with is required
Extras (Improviments):
1 - Considering that UserProfileList is the main component from the respective file
was added export default to be used externaly
2 - Calling SuspensefulUserProfile was changed from manually calling 3 to mapping a array with ids and interating them
View React Hooks and Context Basics
import React, { useState, createContext, useContext } from 'react';
import ReactDOM from 'react-dom';
// useForm
const useForm = (callback) => {
const [formValues, setFormValues] = useState([]);
const [loading, setLoading] = useState(false);
const handleChange = (event) => {
const auxValues = { ...formValues };
@Diegow3b
Diegow3b / express-passport-local.md
Created Mar 15, 2017 — forked from phalkunz/express-passport-local.md
Setup local (username/password) authentication in express.js (using passport.js)
View express-passport-local.md

Setup the project folder

    mkdir passport-local
    npm init
    # Use default values for npm init prompts

Install required packages

@Diegow3b
Diegow3b / filtro_dinamico.py
Created Dec 27, 2016
Filtros de Queryset com Colunas Dinamicas - Dinamic Column Filter
View filtro_dinamico.py
'''
Os campos filtrados dessa versão são do tipo inteiro ou decimal
Parametros:
1 - Queryset: Qual queryset deseja filtrar
2 - Coluna(String): Nome da coluna no qual deseja aplicar o filtro
3 - Filtro(String): String com o valor no qual deseja filtrar
- Menor ou Igual - "-<valor>" | Exemplo: "-250"
- Entre (Between) - "<valor>~<valor>" | Exemplo: "250~350"
- Maior ou igual - "+<valor>" | Exemplo: "+15"
@Diegow3b
Diegow3b / views.py
Last active Sep 29, 2016
Turning arround m2m_changed bug in admin from Django 1.8
View views.py
'''
Obs1: m2m_changed never trigger the remove signal (pre_remove, post_remove) when deleted, so this ways you can force he do it
obs2: Since the pre_clear data will be removed anyways to new valuei n post_add add it again and when you fully remove data
the add events wont be trigger, so this solution will simule the exacly action the m2m_changed should do
'''
class OtherModel(model.Models)
pass
class MyModel(model.Models):
m2m_attribute = models.ManyToManyField(OtherModel,related_name='other_model', blank=True)
View gist:43743af3f6a685870732a94d99450d55
#Pequeno script para pegar 100 valores aleatorios entre as strings"HAS","Has","has","DM","Dm"
pool <- c("HAS","Has","has","DM","Dm")
index <- sample(1:5,100,replace=T) #Amostra de 100 valores entre 1 e 5
comorb <- character(length=100) #Declara variavel comorb
#For loop para selecionar um item da lista conforme numero aleatorio sorteado
for (i in 1:100){
comorb[i] <- pool[index[i]]
}
id <- seq(1:100) #Identificacao para cada caso