Skip to content

Instantly share code, notes, and snippets.

View heitoralthmann's full-sized avatar

Heitor Althmann heitoralthmann

  • Interactive Strategies
  • Paranavaí, PR, Brazil
View GitHub Profile
@heitoralthmann
heitoralthmann / drupal-core-update.sh
Last active October 25, 2018 12:10
How to quickly update Drupal core
# From: https://www.computerminds.co.uk/articles/quickly-update-drupal-core
# curl 'https://github.com/drupal/drupal/compare/<from_version>..<to_version>.patch' | patch -p1
# Ex:
curl 'https://github.com/drupal/drupal/compare/7.59..7.60.patch' | patch -p1
@heitoralthmann
heitoralthmann / vscode-settings.json
Last active October 31, 2018 20:09
My VSCode settings for Drupal development
{
"breadcrumbs.enabled": false,
"css.validate": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.tabSize": 2,
"editor.autoIndent": true,
"editor.insertSpaces": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.renderWhitespace": "boundary",
@heitoralthmann
heitoralthmann / tasks.json
Created October 31, 2018 20:01
VSCode task to clean a PHP file using the Drupal and DrupalPractice phpcs standards
{
"version": "2.0.0",
"tasks": [
{
"label": "PHP Clean",
"type": "shell",
"command": "phpcbf",
"args": [
"--standard=Drupal,DrupalPractice",
"--ignore-annotations",
@heitoralthmann
heitoralthmann / ex1.md
Created November 20, 2018 11:30
Exercícios para Carlens
  1. O que é/faz window.onload?
  2. O que é um canvas?
  3. Estudar documentação de document.createElement
  4. Estudar documentação de document.body.appendChild
  5. Estudar HTMLCanvasElement.getContext()
  6. Estudar CanvasRenderingContext2D.clearRect()
  7. Estudar CanvasRenderingContext2D.fillStyle
  8. Estudar CanvasRenderingContext2D.fillRect()
  9. Estudar setTimeout();
@heitoralthmann
heitoralthmann / redux_notes.md
Last active May 9, 2019 16:46
Egghead Redux Getting Started Notes

STATE OBJECT

  • I will be representing the whole state of my application with A SINGLE STATE OBJECT.
  • This state object is read only. Every time I want to change it, I must dispatch an action.
  • The STATE is the minimum representation of data in my app.

ACTIONS

  • The ACTION is the minimum representation describing the change to that data.
  • Action objects MUST HAVE AT LEAST a type property. We better use strings for this option because it is serialisable.
  • The only way to change the state tree is by dispatching an action.
  • An action is a plain javascript object describing in the minimum way, what changed in the application.
@heitoralthmann
heitoralthmann / react_beginners_guide.md
Last active May 13, 2019 14:48
The Beginner's Guide to React / Building React Applications with Idiomatic Redux - Dan Abbramov - EggHead - Notes

The Beginner's Guide to React

Lesson 5: Validate Custom React Component Props with PropTypes

Utilizamos propTypes para tipar as props de um componente e garantir que não vão passar um tipo de dado errado, quebrando a aplicação.

Para fazer a validação de nossas props, o time do React disponibiliza uma biblioteca chamada prop-types que nos fornece uma série de funções úteis para realizar este trabalho:

ComponentName.propTypes = {
 propName: PropTypes.string,
@heitoralthmann
heitoralthmann / theme_name.theme.php
Created November 20, 2019 13:08
How to add css classes to the <img> tag generated by an image field (Drupal 8)
<?php
/**
* @file
* Functions to support theming in the THEME_NAME theme.
*/
/**
* Implements hook_preprocess_theme().
*/
@heitoralthmann
heitoralthmann / migration.yml
Created April 29, 2020 14:41
Drupal 8 migrate: Using sub_process with entity_generate/entity_lookup: Looping through source field values and creating taxonomy terms for each of them.
# Looping through source field values and creating taxonomy terms for each of them (bundle_key and value_key are both required in this scenario)
field_name:
-
plugin: skip_on_empty
method: process
source: 'Source-Field-Name'
-
plugin: sub_process
process:
target_id:
@heitoralthmann
heitoralthmann / logger.php
Created June 10, 2020 20:02
Drupal 8 watchdog logger dump variable
<?php
\Drupal::logger('some_channel_name')->warning('<pre><code>' . print_r($responseObj, TRUE) . '</code></pre>');