Skip to content

Instantly share code, notes, and snippets.

View flashvnn's full-sized avatar

Huynh Khac Thao flashvnn

View GitHub Profile
<?php
namespace Drupal\example\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class AjaxAddMoreForm.
*
@flashvnn
flashvnn / command.sh
Created August 16, 2022 04:48
Command redirect output to log file
|| visible in terminal || visible in file || existing
Syntax || StdOut | StdErr || StdOut | StdErr || file
==========++==========+==========++==========+==========++===========
> || no | yes || yes | no || overwrite
>> || no | yes || yes | no || append
|| | || | ||
2> || yes | no || no | yes || overwrite
2>> || yes | no || no | yes || append
|| | || | ||
&> || no | no || yes | yes || overwrite
@flashvnn
flashvnn / tunnel.example.com.conf
Last active February 7, 2023 13:44
Go http proxy with apache
<VirtualHost 10.0.0.195:80>
ServerAlias *.tunnel.example.com
ProxyPass / http://localhost:7080/
ProxyPassReverse / http://localhost:7080/
UseCanonicalName on
ProxyPreserveHost on
</VirtualHost>
# Support ssl .well-known folder for virtualmin
<VirtualHost *:80>
@flashvnn
flashvnn / index.js
Created June 7, 2022 05:46
Totaljs http2
const spdy = require('spdy');
const fs = require('fs');
require('total4');
// Registers a route
ROUTE('GET /', function() {
// this === Controller
this.json({ message: 'Hello world' });
});
@flashvnn
flashvnn / get_module_php_version.js
Created June 2, 2022 06:46
Get php varsion requirement of Drupal contrib modules
require('total4');
const fs = require('fs');
var contrib = PATH.root() + '/../../docroot/modules/contrib'
const directories = source => fs.readdirSync(source, {
withFileTypes: true
}).reduce((a, c) => {
c.isDirectory() && a.push(c.name)
@flashvnn
flashvnn / install.zip.so
Created May 18, 2022 04:10
Install php zip.so from source
https://developpaper.com/aliyun-centos-7-6-install-php7-3/
@flashvnn
flashvnn / vite.config.js
Created April 28, 2022 04:42
Vite config for output without hash
import { fileURLToPath, URL } from 'url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
resolve: {
@flashvnn
flashvnn / php_kill_process.php
Created March 21, 2022 03:33
PHP kill process
<?php
$exe_command = 'ping google.com';
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout -> we use this
2 => array("pipe", "w") // stderr
);
$process = proc_open($exe_command, $descriptorspec, $pipes);
if (is_resource($process))
{
@flashvnn
flashvnn / php7.4-zip.sh
Last active July 7, 2023 03:56
Install php74-zip extension
pecl uninstall zip && pecl install zip
# if has error with zipconf.h
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
pecl install zip