Skip to content

Instantly share code, notes, and snippets.

@vades
vades / Uncover the 30 Most Popular Services.md
Last active April 28, 2023 11:32
AWS - Amazon Web Services
@vades
vades / intro.md
Last active December 17, 2021 11:50
Nodejs

Node.js intro

What is Node.js

Node.js is an open source platform built on Chrome's JavaScript runtime and can be run on Microsoft Windows, OS X and Linux.

What is Node.js used for?

Node.js is useful for easily building fast and scalable JavaScript applications.

Install NPM on Windows

@vades
vades / angular-font-awesome.md
Last active May 22, 2019 07:56
Using Font Awesome icons in Angular

Using Font Awesome icons in Angular

The following instructions assume you have already installed Angular with CLI.

Install via NPM

npm install --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons
npm install --save @fortawesome/angular-fontawesome

Usage

@vades
vades / wordpress-page-slug-body-class.md
Last active May 21, 2019 06:42
Add page slug to body class in WordPress

Add page slug to body class

function wps_add_slug_to_body($classes)
{
    global $post;
    if (is_home()) {
        $key = array_search('blog', $classes);
        if ($key > -1) {
 unset($classes[$key]);
@vades
vades / wordpress-remove-menu-items.md
Last active May 21, 2019 06:41
Remove items from admin menu for the subscriber in WordPress

Remove items from admin menu for the subscriber

function wps_remove_menu_pages()
{
    global $user_ID;

    if (current_user_can('subscriber')) {
        remove_menu_page('edit.php'); // Posts
 remove_menu_page('upload.php'); // Media
@vades
vades / wordpress-remove-emty-p-tags.md
Last active May 21, 2019 06:38
Remove empty p tags from WordPress posts

Remove empty p tags from WordPress posts

function wps_clear_content($content)
{
    // clean up p tags around block elements
    $content = preg_replace(array(
        '#<p>\s*<(div|aside|section|article|header|footer)#',
        '#</(div|aside|section|article|header|footer)>\s*</p>#',
 '#(div|aside|section|article|header|footer)&gt;\s*#',
@vades
vades / angular-expression-changed.md
Last active November 5, 2024 16:54
Fixing "Expression has changed after it was checked" in Angular

Fixing "Expression has changed after it was checked" in Angular

The exception appears (in the development mode) at the moment the value is checked and value is different of the updated value.

Error message example

AppComponent.html:1 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: true'. Current value: 'ngIf: false'.
    at viewDebugError (core.js:20440)
    at expressionChangedAfterItHasBeenCheckedError (core.js:20428)
    at checkBindingNoChanges (core.js:20530)
@vades
vades / laravel-clear-config-cache.md
Last active May 21, 2019 06:35
Clear Laravel config and cache

Clear Laravel config and cache

To clear Laravel config and cache run the following commands:

php artisan config:clear
php artisan cache:clear
@vades
vades / sass-directory-structure.md
Last active May 21, 2019 06:32
How to structure SASS project

SASS directory structure

Core

Contains SASS variables, functions, mixins, config and other stuff.

Base

Contains the project boilerplate code such as typo, resets, dimensions, media queries, colors and other helpers that are commonly shared among the entire project.

Layout

Holds all files that handle the layout, such as content, sidebars, header and footer.

Components

Contains all independent parts (modules) such as inputs, buttons, tables, accordions and many other components.

@vades
vades / php-language-class.md
Last active May 21, 2019 06:30
PHP class to detect a language

PHP Class to detect a language from url, session, cookie and browser

This class detects a language from the url, session, cookie and browser and then sets a current one.

LanguageSwitch.php

<?php

namespace Vades\Language;