mouse hover for accordion

jQuery(function ($) {
  $(document).on('mouseenter.collapse', '[data-toggle=collapse]', function(e) {
    var $this = $(this),
      href,
      target = $this.attr('data-target')
        || e.preventDefault()
        || (href = $this.attr('href'))
        && href.replace(/.*(?=#[^\s]+$)/, ''), //strip for ie7
      option = $(target).hasClass('in') ? 'hide' : "show"

    $('.panel-collapse').not(target).collapse("hide")
    $(target).collapse(option);
  })
});

Laravel

## Example of Makefile for Laravel
## .cache
## .mysql
##     conf.d
##         my.cnf
##     data
##     initdb.d
##         *.sql
## .php
##     conf.d
##         apache.conf
##     php.ini
##

NAME = laravel
NODE_MODULES_DIR = node_modules

HOST = "0.0.0.0"
PORT = "80"

# Use $(shell pwd) || $(CURDIR) instead of $(PWD)?
FILES_JS = $(CURDIR)/src/**/*
APP_HOME = $(shell pwd)

PYTHON_PORT = $PORT

PHP_PORT = $PORT

DB_HOST = 0.0.0.0
DB_PORT = 3306
DB_DATABASE = main
DB_USERNAME = root
DB_PASSWOR

Generic htaccess redirect www to non-www

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Docker

> UPDATE: Docker has security issues:
>
> - Kernel exploits
> - Denial-of-service attacks
> - Container breakouts
> - Poisoned images
> - Compromising secrets
> 
> https://www.oreilly.com/content/five-security-concerns-when-using-docker/

- `docker image prune -a` - Remove all unused images
- `docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}'` - list images with their size
- 

固定小数(Q-format)を使った除算(負数とか上下限の判定はしていない)/*

/*
  整数型で小数の計算を行う

  1. シフト演算を使えるので計算が速い事や処理が分かり易いのが特徴
  1. 扱える数の範囲に限界があるので事前に決めておく必要がある
  1. 端数処理(丸め)を意識しないと結果が大きく変わる (1/3)*3 ≠ 1
*/
#define _SFT  (8)			/* Q8-format */
#define _HALF (1<<(SFT-1))	/* HALF = 0.5 を表現 */
 
// |--- Integer(8bit) ---|--- Decimal(8bit) ---|
#define _INTEGER(x) (x & ~0xFF) >> _SFT
#define _DECIMAL(x) (x &  0xFF)

int d1 = 87;
int d2 = 31;
int ret = 0;

// 87 / 31 = 2.806451612903226

// 固定小数の除算
ret = (d1 << _SFT) / d2;

// 商に除数をかければ被除数になる
ret = 

AWS IAM : Tips / MFA Enablable role

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowViewAccountInfo",
            "Effect": "Allow",
            "Action": [
                "iam:GetAccountPasswordPolicy",
                "iam:GetAccountSummary",
                "iam:ListVirtualMFADevices"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowManageOwnPasswords",
            "Effect": "Allow",
            "Action": [
                "iam:ChangePassword",
      

Remove smooth scroll event

 // Remove smooth scroll event
  $('[data-show]').off();
  $('[data-show]').on("click", function (e) {
    e.preventDefault();
  });

How to open video stream using GStreamer in OpenCV

# How to open video stream using GStreamer in OpenCV

To use gstreamer you need to have the gstremer backend activated for compilation.
The pre-build version of opencv installed with 'pip install opencv-python' does NOT have this option activated.

This is an example on how to load a RTSP streaming flow using opencv and gstreamer as backend.

```
import cv2

# RTSP in put path
camera_config = "rtsp://<camera configuration>"
# Main definition of the gstreamer pipeline for rtsp capture
gst_pipe_ma

Функция склонения слов

/*
echo num_decline( 4, 'книга, книги, книг' );     // 4 книги

echo num_decline( 5, ['книга','книги','книг'] ); // 5 книг

echo num_decline( 4, 'книга, книги, книг', 0 );  // книги
*/
public static function num_decline($number, $titles, $show_number = 1){
        if( is_string( $titles ) )
            $titles = preg_split( '/, */', $titles );

        // когда указано 2 элемента
        if( empty( $titles[2] ) )
            $titles[2] = $titles[1];

        $cases = [ 2, 0, 1, 1,

How to change VPN password

# How to change VPN password

If the network manager window does not change the VPN password, even when we specify in the application window, change the configuration files to do this.

Change the password in the configuration file of the VPN connection:

```
$ sudo vim /etc/NetworkManager/system-connections/<VPN connection name>
```

There should be a block whith this shape:

```
...
[vpn-secrets]
password=<Old password>
...
```

You must change the password to the new one, and save the changes

mysql remote connection

/etc/mysql/mysql.conf.d/mysqld.cnf - set bind-address to 0.0.0.0
restart mysql

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'username'@'%' IDENTIFIED BY 'password';

grant all on *.* to 'smacneall'@'%';
grant all on *.* to 'smacneall'@'localhost';

FLUSH PRIVILEGES; 

YUV -> RGB

typedef unsigned char UINT8;
typedef signed char   INT8;
typedef signed short  INT16;

void _yuv2rgb( UINT8 Y, INT8 U, INT8 V, INT16 *R, INT16 *G, INT16 *B ){

    /* 8bitフルスケールYUVと8bitフルスケールRGBの相互変換 */
    *R  = (INT16)(Y + 1.402 * V );
    *G  = (INT16)(Y - 0.344 * U - 0.714 * V );
    *B  = (INT16)(Y + 1.772 * U );

    /* RGBの各値が規定値を超えた場合 */
    if(*R > 0xFF)   *R =0xFF;
    if(*R < 0x00)   *R =0x00;
    if(*G > 0xFF)   *G =0xFF;
    if(*G < 0x00)   *G =0x00;
    if(*B > 0xFF

NodeJS

#Reiniciar localhost
npx kill-port 3000
#Para hacerlo en  múltiples puertos
npx kill-port 3000 8080 4200

mask an email to turn part into *

ysUtil::maskEmail($submission->user->username)

flash a notice

Notice::flash('This is a warning flash notice with minimum setting from redirected page', Notice_WARNING);

warning notice in page form

Notice::page('This is a warning page notice with full setting', Notice_WARNING, array(
			'urlLabel' => 'Go to Yahoo', 'url' => 'http://www.yahoo.com',
			'cancelUrlLabel' => 'Back to Egg', 'cancelUrl' => $this->createUrl('egg/notice'),
			'htmlMessage' => $this->renderPartial('_htmlContent', array('model' => $model), true)
		));