Skip to content

Instantly share code, notes, and snippets.

View richellyitalo's full-sized avatar
🏹
Exploring RemixJs

Richelly Italo richellyitalo

🏹
Exploring RemixJs
View GitHub Profile
// IIFE - Immediately Invoked Function Expression
(function(yourcode) {
// The global jQuery object is passed as a parameter
yourcode(window.jQuery, window, document);
}(function($, window, document) {
// The $ is now locally scoped
// IIFE - Immediately Invoked Function Expression
(function($, window, document) {
// The $ is now locally scoped
// Listen for the jQuery ready event on the document
$(function() {
// The DOM is ready!

store/actions/todos.js

export const addTodo = text => ({ type: 'ADD_TODO', payload: { text } });

store/reducers/todos.js

const INITIAL_STATE = [
  { id: 1, text: 'Estudar pra caralho' },
  { id: 2, text: 'Estudar mais ainda' },
  { id: 3, text: 'Por em prática!' },

Instalação dos pacotes

yarn add eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react -D

".eslintrc" na raiz do projeto

{
  "env": {
    "browser": true,
    "jest": true,
 "es6": true

Converter valor string para tipo passado

import ast
boleano = 'True'
boleano_mesmo = ast.literal_eval(boleano)

flutuante = '100.50'
flutuante_mesmo = ast.literal_eval(flutuante)

Maneira 1

# A lógica é mantida dentro de um método da classe
# arquivo 'models.py'
from django.db.models.signals import post_save

class Product(TimestampableMixin):
    # ...

 @classmethod

View

from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.contrib.auth.mixins import LoginRequiredMixin

# protegendo da maneira *2
# @method_decorator(login_required(login_url='/login/'), name='dispatch')
class TesteView(LoginRequiredMixin, TemplateView):
 # protegendo da maneira *3 (LoginRequiredMixin)