Skip to content

Instantly share code, notes, and snippets.

View ranqiangjun's full-sized avatar
🏠
Working from home

Qiangjun Ran ranqiangjun

🏠
Working from home
View GitHub Profile
@ranqiangjun
ranqiangjun / extension-patterns.md
Created January 14, 2023 16:59 — forked from bojanz/extension-patterns.md
Extension patterns: events, tagged services, plugins

This documentation is destined for drupal.org. Created first as a gist to make initial comments easier. Rewrites and clarifications welcome. Code samples are simplified for clarity. Perhaps a bit too much?

When talking about extensibility, there are several distinct use cases:

  1. Reacting to an action that has already happened.

The reaction can be anything; outputting a message, sending an email, modifying a related object, etc. Examples:

  • "A node has been saved"
  • "A product has been added to the cart".
[
{
"user": "easyrdf",
"repository": "easyrdf",
"version": "0.9.0"
}
]
@ranqiangjun
ranqiangjun / gist:d44ccb8a05d14560725298c1f9670877
Created April 7, 2019 15:29
Two modules you might miss which were apart of devel
drupal/devel_entity_updates
drupal/devel_php
RUN export http_proxy=http://10.0.2.2:1087;export https_proxy=http://10.0.2.2:1087;
@ranqiangjun
ranqiangjun / webdev_online_resources.md
Created January 14, 2019 04:32 — forked from rubenribeiro/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@ranqiangjun
ranqiangjun / uuid.md
Last active December 13, 2018 10:45
Generate uuid by drush

ds ev '$uuid_service=\Drupal::service("uuid");$uuid=$uuid_service->generate();echo "$uuid\n";'

Overview

If you are in a location that allows SSH but doesn't allow access to GitHub (I'm looking at you India), here's an easy way to get around it.

Prerequisites

  1. You need a shell account on a network that doesn't filter GitHub. Ideas for that:
    1. Pay but Cheap: A micro instance on EC2 http://aws.amazon.com/ec2/pricing/
    2. Free-ish: One of the free shell solutions http://shells.red-pill.eu/
  2. The shell account will need access to the netcat binary called nc http://nc110.sourceforge.net/
@ranqiangjun
ranqiangjun / needs-help.md
Last active August 8, 2017 10:11
Computed_field:8.x-2.0-alpha4.

Code snippet tested.

$storage = \Drupal::entityManager()->getStorage("node");
$query = \Drupal::entityQuery('node');
$query->condition("type", $bundle);
$result = $query->execute();
foreach ($result as $nid) {
  $node = $storage->load($nid);
 $node->changed = REQUEST_TIME;
@ranqiangjun
ranqiangjun / gist:def7c18003c351c2f747ea95f070279e
Created March 28, 2017 00:09 — forked from senko/gist:2988592
Easy VirtualBox VM handling for the command line
#!/bin/bash -e
#
# Easy VirtualBox VM handling from the command line
BASE_TEMPLATE="<uid-of-template-vm>"
function show_help() {
echo "Usage: $0 [cmd]"
echo "Valid commands:"
echo " list List available virtual machines"
@ranqiangjun
ranqiangjun / my_sacrifice.md
Created March 26, 2017 00:11
The motherf*cking way the get Oracle access in PHP5 over Ubuntu