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 / render_menu.php
Created January 13, 2016 07:58 — forked from eugene-ilyin/render_menu.php
Render menu programmatically in Drupal 7
// One level menu.
$menu = menu_tree('main-menu');
$menu_items = render($menu);
// Menu with many levels.
menu_tree_all_data('main-menu');
$menu = menu_build_tree('main-menu');
$menu_items = render(menu_tree_output($menu));
#!/bin/bash
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom \
| while read i; do
sudo rm /usr/local/${i}
done
sudo rm -rf /usr/local/lib/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*

Contribution setup instructions

Fork DrupalConsole

Fork your own copy of the DrupalConsole repository to your account

Clone

Get a copy of your recently cloned version of console in your machine.

$ git clone git@github.com:[your-git-user-here]/DrupalConsole.git
@ranqiangjun
ranqiangjun / vpnguide.md
Last active January 7, 2017 03:01
Setting up a private OpenVPN server [Linux users only]

Setting up a private OpenVPN server [Linux users only]

@ranqiangjun
ranqiangjun / my_sacrifice.md
Created March 26, 2017 00:11
The motherf*cking way the get Oracle access in PHP5 over Ubuntu
@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 / 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-&gt;changed = REQUEST_TIME;

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 / uuid.md
Last active December 13, 2018 10:45
Generate uuid by drush

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

@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)