Skip to content

Instantly share code, notes, and snippets.

View nguyenthanhxuan's full-sized avatar
😃

Xuan Nguyen nguyenthanhxuan

😃
View GitHub Profile
@nguyenthanhxuan
nguyenthanhxuan / module_name.install
Created February 29, 2024 08:32
Create a New Content Entity During Module Update
<?php
use Drupal\Core\Database\Database;
/**
* Create the entity table if it does not exist.
*/
function twist_opsf_update_9001(){
//check if the table exists first. If not, then create the entity.
if(!Database::getConnection()->schema()->tableExists('maestro_process_status')) {
Name: Flash
Serial: eNrzzU/OLi0odswsqnHLSSzOqDGoca7JKCkpsNLXLy8v1ytJTczVLUotKNFLzs8FAJHYETc=
if anyone wants to thank ETH: 0x527c2aB55b744D6167dc981576318af96ed26676
Thank you!
@nguyenthanhxuan
nguyenthanhxuan / webpack.config.js
Last active November 24, 2017 09:15 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : '',
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@nguyenthanhxuan
nguyenthanhxuan / Math.php
Created May 3, 2017 21:25 — forked from jgrossi/Math.php
Math class from Taylor Otwell. Thanks to @brad ([email protected]) for the class content.
<?php
class Math {
/**
* The base.
*
* @var string
*/
private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
<?php
/*
1. Add a product programmatically to cart.
2. Get line item id for a product in cart from product id.
3. Delete a product programmatically from cart
4. Alter product quantity in cart(add/remove).
*/
<?php
/**
*
* function to check if a product exist in cart or not
* @param
* $product_id takes product id we are checking if exists or not as input.
* type take product id as integer or array of product ids
* @return
* return -1 if product does not exists
* returns -2 if cart if empty
<?php
/**
* @param tid
* Term ID
* @param child_count
* TRUE - Also count all nodes in child terms (if they exists) - Default
* FALSE - Count only nodes related to Term ID
*/
function term_nc($tid, $child_count = TRUE) {
$tids = array($tid);
<?php
/**
* Theme_menu_tree doesn't provide any context information
* THIS SUCKS
* But you can use hook_block_view_alter to change the theme wrapper
* OUF!
*/
function MYTHEME_menu_tree(&$variables) {
<?php
/**
* @file
* Demo module, Basic Ajax form submit (Ajax framework).
*/
/**
* Implements hook_menu().
*/
<?php
/**
* Implements hook_menu_alter().
*/
function MY_MODULE_menu_alter(&$items) {
$items['user/%user_category/edit/profile']['access callback'] = FALSE;
}
/**