Skip to content

Instantly share code, notes, and snippets.

@manojiksula
manojiksula / project.docker-compose.yml
Created December 22, 2022 13:55 — forked from hranicka/project.docker-compose.yml
Traefik & multiple docker-compose projects
version: '3'
services:
nginx:
labels:
- "traefik.enable=true"
- "traefik.http.routers.provys-transformer.rule=Host(`www.example.com`)"
- "traefik.http.routers.provys-transformer.tls=true"
networks:
- traefik
@manojiksula
manojiksula / module.install
Created May 27, 2021 12:56 — forked from Erikdekamps/module.install
Drupal 8 - Load taxonomy terms sorted by weight
/**
* Get taxonomy terms sorted by weight.
*
* @param int $vid
* The vocabulary id.
*
* @return array
* Returns an array of term id | name.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
@manojiksula
manojiksula / formattingtest.php
Created January 27, 2021 18:00 — forked from bryanburgers/formattingtest.php
Forcing four-digit years on IntlDateFormatter::SHORT
<?php
$d = new DateTime("2012-10-11");
function unalteredFormat($date, $locale) {
$fmt = new IntlDateFormatter(
$locale,
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE);
$fmtted = $fmt->format($date);
@manojiksula
manojiksula / LayoutLoadBeforeObserver.php
Created October 6, 2020 13:39 — forked from 0-Sony/LayoutLoadBeforeObserver.php
Magento 2 : Add Body Class using an observer
<?php
/**
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Phuong LE <phuong.le@agence-soon.fr> <@>
* @copyright Copyright (c) 2017 Agence Soon (http://www.agence-soon.fr)
*/
namespace MyVendor\MyModule\Observer;
@manojiksula
manojiksula / get_node_by_path.php
Created August 11, 2020 13:45 — forked from crittermike/get_node_by_path.php
Drupal 8 Get node ID by path alias
<?php
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
@manojiksula
manojiksula / import.php
Created July 24, 2020 15:09 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
@manojiksula
manojiksula / drupal-8.form.reset-button.php
Created July 18, 2020 15:59 — forked from RuZniki/drupal-8.form.reset-button.php
Drupal 8 Adding a Reset Button to a form
<?php
/**
* Implements template_preprocess_form().
*/
function TEMPLATE_preprocess_form(&$vars) {
$vars['form']['actions']['reset'] = [
'#type' => 'html_tag',
'#tag' => 'input',
'#attributes' => [
'class' => 'button',
@manojiksula
manojiksula / download_file.py
Created June 15, 2020 15:35 — forked from kissgyorgy/download_file.py
Python: Download file, get file size and Content type.
import requests
r = requests.get("http://download.thinkbroadband.com/10MB.zip",
cookies={'cookie1': 'working'}
)
open('10MB.zip', 'wb').write(r.content)
@manojiksula
manojiksula / Apache.md
Created May 21, 2020 15:54 — forked from ignatisD/Apache.md
MailHog localhost xampp/wamp integration

#MailHog example page

MailHog is an email testing tool for developers.

It gives the developer the option to intercept and inspect the emails sent by his application.

You can download the MailHog Windows client from one of the links below.

@manojiksula
manojiksula / example.php
Created May 10, 2020 09:09 — forked from signalpoint/example.php
Drupal 8 Set Message Example
<?php
// The drupal_set_message() function is being deprecated!
// @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x
// > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
// > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
// In some custom code.
\Drupal::messenger()->addMessage('Say something else');