# List all process of program "node"
ps -fe | preg node
# To list any process listening to the port 8080:
lsof -i:8080
# To kill any process listening to the port 8080
kill $(lsof -t -i:8080)
# or more violently:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* This snippet works with Drupal 8.3.x | |
* | |
* Template for using: node.html.twig. | |
* | |
* This code below works with conditions: | |
* - templates for using: node.html.twig and node convention templates | |
* - field is a reference to taxonomy_term entity name : "category" | |
* - field machine name "field_category" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_theme_suggestions_HOOK_alter(). | |
* | |
* This hook for adding a custom suggestion page template. | |
* | |
* Place this function in your THEME_NAME.theme file. | |
* then you can use the template page--[content-type].html.twig | |
* | |
* Tested and worked with Drupal Version 8.3.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Smooth scroll top | |
*/ | |
(function($){ $(function(){ | |
$("a[href='#top']").click(function(event) { | |
event.preventDefault(); | |
$("html, body").animate({ scrollTop: 0 }, 1000); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt install php7.0-common php7.0-fpm php7.0-cli php7.0-json php7.0-mysql php7.0-curl php7.0-intl php7.0-mcrypt php-pear php7.0-gd php7.0-zip php7.0-xml php7.0-mbstring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\MODULE_NAME\Plugin\views\style; | |
use Drupal\rest\Plugin\views\style\Serializer; | |
/** | |
* The style plugin for serialized output formats with pager. | |
* | |
* @ingroup views_style_plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_user_login(). | |
*/ | |
function mymodule_user_login(\Drupal\user\UserInterface $account) { | |
// Default login destination to the dashboard. | |
$current_request = \Drupal::service('request_stack')->getCurrentRequest(); | |
if (!$current_request->query->get('destination')) { | |
$current_request->query->set( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compare 2 strings in solidity ^0.4.23; | |
function compareStrings(string a, string b) internal pure returns (bool){ | |
return keccak256(a) == keccak256(b); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source reference: https://stackoverflow.com/questions/38612972/how-to-merge-two-array-of-object-by-using-lodash | |
_.mixin({ | |
mergeByKey(arr1, arr2, key) { | |
const criteria = {}; | |
criteria[key] = null; | |
return _.map(arr1, (item) => { | |
criteria[key] = item[key]; | |
return _.merge(item, _.find(arr2, criteria)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill | |
“In order to understand recursion, one must first understand recursion.” – Author Unknown | |
“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.” – Bjarne Stroustrup | |
“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila.” – Mitch Ratcliffe | |
“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -C.A.R. Hoare | |
“The gap between theory and practice is not as wide in theory as it is in practice.” – Author Unknown | |
“If builders built buildings the way progra |
OlderNewer