storage permissions laravel

sudo chmod -R 755 laravel_blog
chmod -R o+w laravel_blog/storage

lemp centos

https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/

restart ssh centos

https://www.cyberciti.biz/faq/centos-stop-start-restart-sshd-command/

Module development


https://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/

convert hour to decimal

=HOUR(D3-C3)+(MINUTE(D3-C3)/60)

EVEN & ODD

IF mod(@sum,2) == 0 THEN
  outputline(concat("<br>", @sum, " is even"))
ELSE
  outputline(concat("<br>", @sum, " is odd"))
ENDIF

Global keyboard capture in C# application

I want to capture a keyboard shortcut in my application and trigger a dialog to appear if the user presses a keyboard combo even outside of the app. Similar to Google Desktop Search's Ctrl, Ctrl to bring up the search dialog. I have tried using some keyboard hook modules out there that basically use Win32 interop to get this effect but each implementation I've tried ties down the keyboard to some extent to where you start getting weird behaviors when the application is doing something intensive. Such as loading a large amount of data, this would cause the keyboard and mouse to lockup. I'm looking for a lightweight solution that would allow this to be done without tying down the keyboard and mouse.
class GlobalKeyboardHookEventArgs : HandledEventArgs
{
    public GlobalKeyboardHook.KeyboardState KeyboardState { get; private set; }
    public GlobalKeyboardHook.LowLevelKeyboardInputEvent KeyboardData { get; private set; }

    public GlobalKeyboardHookEventArgs(
        GlobalKeyboardHook.LowLevelKeyboardInputEvent keyboardData,
        GlobalKeyboardHook.KeyboardState keyboardState)
    {
        KeyboardData = keyboardData;
        KeyboardState = keyboardState;
    }
}

//Based on https://gist.github.com/Stasonix
class GlobalKeyboardHook : IDisposable
{
    public event EventHandler<GlobalKeyboardHookEventArgs> KeyboardPressed;

    // EDT: Added an optional parameter (registeredKeys) that accepts keys to restict
    // the logging mechanism.
    /// <summary>
    /// 
    /// </summary>
    /// <param name="registeredKeys">Keys that should trigger logging. Pass null for full logging.</param>
    public GlobalKeyboardHook(Keys[] registeredKeys = null)

Templates file modified hook

<?php
$templates->addHook('fileModified', function(HookEvent $event) {
    $template = $event->arguments(0);
    $event->log->message("Detected change to $template->filename");
});

Commands for Kafka

1. https://github.com/Paxa/kt
2. docker run -it evpavel/kt bash
3. kt consume -brokers 10.30.30.116 -topic Flight_Stats -encodevalue base64

console.log tips

Article Midudev: https://www.getrevue.co/profile/midudev/issues/mas-alla-de-console-log-descubre-de-lo-que-es-capaz-console-199625
- Filter by level:
  - console.warn
  - console.error
  - console.info
- console.table
- console.time and console.timeEnd
- console.count
- console.assert

GoUtils

Go常用操作
// ## 日期格式化时区 ##
time := time.Now()
loc, err := time.LoadLocation("")    // 默认UTC    
loc, err := time.LoadLocation("Local")    // 一般为CST
loc, err := time.LoadLocation("America/Los_Angeles")    // 美国洛杉矶PDT
loc, _:= time.LoadLocation("Asia/Chongqing")     // CST

// ## 获取当前时间并格式化 ##
// 格式化,golang中格式不是‘yyyy-MM-dd HH:mm:ss’,而是采用golang诞生时间作为格式
t = "2006-01-02 15:04:05" 
time := time.Now()
fmt.Println(time.Format(t))

// ## 格式化后的日期字符串转回Time ##
// 格式化
t = "2006-01-02 15:04:05" 
// 日期字符串
str = "2017-09-13 00:00:01"
loc, err := time.LoadLocation("Local")
time, err := time.ParseInLocation(t, str, loc)

fmt.Println(time)

if err == Nil{
}

Stock Levels, On Hand, Backorder Master

Realtime stock calculated with daily stock report, realtime stockin, and realtime shipped, reserved and backorder tallied for complete on hand quantities
-- calculate realtime stock levels
select 
	master.catalogno,
	master.stock_qty,
	master.in_qty,
	master.ship_qty,
	master.reserved_qty,
	master.backorder_qty,
	master.final_stock_qty,
	master.final_stock_qty - reserved_qty as on_hand_qty,
	master.releaseartist,
	master.releasetitle,
	master.format,
	master.releasedate,
	master.label,
	master.barcode
	from
(select
	totals.catalogno,
	totals.stock_qty,
	totals.in_qty,
	totals.ship_qty,
	coalesce(res_back.reserved_qty, 0) as reserved_qty,
	coalesce(res_back.backorder_qty, 0) as backorder_qty,
	totals.stock_qty + totals.in_qty - totals.ship_qty as final_stock_qty,
	catalognew.releaseartist,
	catalognew.releasetitle,
	catalognew.format,
	catalognew.releasedate,
	catalognew.label,
	catalognew.barcode
	from 
--get daily stock, recent stocked in, recent shipped 	
(select 
	kdgstock.catalogno,
	min(kdgstock.stock_qty) as stock_qty,
	sum(coalesce(stock_in.in_qty, 0)) as in_qty,
	sum(coalesce(not_shipped.ship_qty, 0)) as ship_qty
	from kdgstockt

Compattare una macchina virtuale virtualbox per liberare spazio su disco

https://www.howtogeek.com/312883/how-to-shrink-a-virtualbox-virtual-machine-and-free-up-disk-space/

How to monitor network bandwith

# Tools to monitor networking
## nload: 
Sinple tool to view the general network usage. 

Install:
```
$ sudo apt install nload
```

Use:

```
$ nload
```

## nethogs
Shows the bandwidth used by process

Install:
```
$ sudo apt install nethogs
```

Use:

```
$ nethogs
```

正则验证

/**
 * 正则验证
 * @param s     验证字符串
 * @param type  类型
 * @returns {boolean} true:验证通过
 */
function expValidate (s, type) {
    var objexp = null;
    switch (type) {
        case 'money': //金额格式,格式定义为带小数的正数,小数点后最多三位
            objexp = /^([1-9]\d{0,9}|0)([.]?|(\.\d{1,2})?)$/;
            break;
        case 'numletter_': //英文字母和数字和下划线组成
            objexp = /^[0-9a-zA-Z\_]+$/;
            break;
        case 'numletter': //英文字母和数字组成
            objexp = /^[0-9a-zA-Z]+$/;
            break;
        case 'numletterchina': //汉字、字母、数字组成
            objexp = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
            break;
        case 'email': //邮件地址格式
            objexp = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            break;
        case 'tel': //固话格式
            objexp = /^((\d2,3)|(\d{3}\-))?(0\d2,3|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
            break;
        case 'mobile': //手机号码
            objexp = /^1[3456789]\d{9}$/;
            break;
        case 'decimal': //浮点数
            

mark.parametrize使用范例

    @pytest.mark.test
    @pytest.mark.owner_zhaozonghao
    @pytest.mark.parametrize('host, memberid', [('api.1sapp.com', 1), ('api.2sapp.com', 2)])
    def test_fixture(self, host, memberid):
        print('这次的host等于{0}, member是{1}'.format(host, memberid))
        assert memberid == 1