Recommended innodb pool size

SUBSTR(' KMG',IF(PowerOf1024<0,0, 
IF(PowerOf1024>3,0,PowerOf1024))+1,1)) recommended_innodb_buffer_pool_size 
FROM (SELECT SUM(data_length+index_length) KBS FROM information_schema.tables 
WHERE engine='InnoDB') A, 
(SELECT 2 PowerOf1024) B; 
5 июня 2019, 10:19

Increase maxproc on OSX

sudo nano /Library/LaunchDaemons/limit.maxproc.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN"
<plist version="1.0">
      <true />
      <false />
sudo chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
15 мая 2019, 12:24

Increase ulimit on OSX

sudo nano /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
<plist version="1.0">
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
ulimit -n
15 мая 2019, 12:22

Resize /dev/shm

To increase or decrease /dev/shm filesystem size

1) Open /etc/fstab with vi or any text editor of your choice,

2) Locate the line of /dev/shm and use the tmpfs size option to specify your expected size,

e.g. 512MB:
tmpfs      /dev/shm      tmpfs   defaults,size=512m   0   0

e.g. 2GB:
tmpfs      /dev/shm      tmpfs   defaults,size=2g   0   0

The /etc/fstab content format is documented in man fstab and the tmpfs filesystem options can be found in man mount

3) To make change effective immediately, run this mount command to remount the /dev/shm filesystem:
mount -o remount /dev/shm

12 февраля 2019, 22:00

ssh tunneling

ssh -f -N -L 9906:
Host tunnel
  HostName database.example.comm
  IdentityFile ~/.ssh/id_rsa
  LocalForward 9906
  User root
$ ssh -f -N tunnel
27 декабря 2018, 17:18

Create ubuntu flash boot on macos

hdiutil convert -format UDRW -o destination_file.img source_file.iso
diskutil list
diskutil partitionDisk /dev/disk2 1 "Free Space" "unused" "100%"
sudo dd if=destination_file.img.dmg of=/dev/disk2 bs=1m
21 ноября 2018, 10:39

Fix pkg after upgrade

pkg-static upgrade -f 
6 июня 2018, 09:56

uuid v4 php

function getUuid()
        // by Andrew Moore (
        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            // 32 bits for "time_low"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),
            // 16 bits for "time_mid"
            mt_rand(0, 0xffff),
            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand(0, 0x0fff) | 0x4000,
            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand(0, 0x3fff) | 0x8000,
            // 48 bits for "node"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
5 марта 2018, 00:27

Mysql expire password

After version 5.7.11 password expires in 360 days
20 февраля 2018, 15:58

Installing php-intl on homebrew

PHP Startup: Unable to load dynamic library '/usr/local/opt/php70-intl/'
brew reinstall --build-from-source php70-intl
17 декабря 2017, 02:47

Restart Spotlight on mac os

sudo mdutil -i on 
sudo rm -rf /.Spotlight-V100
7 ноября 2017, 21:05

MYSQL 5.7 root password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
18 августа 2017, 10:34

Upgrade complete

7 июля 2017, 12:45

Copy git repository

git push --mirror
13 мая 2017, 15:33

VestaCP update ip address

30 марта 2017, 16:29

Homebrew my.cnf

cp $(brew --prefix mysql)/support-files/my-default.cnf /usr/local/etc/my.cnf
21 марта 2017, 20:14

Show disk partitions

gpart show
18 марта 2017, 14:54

Change the permission to npm's default directory

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
8 марта 2017, 16:15

CORS in nginx

if ($request_method = 'OPTIONS') {
			add_header 'Access-Control-Allow-Origin' "$http_origin";
			add_header 'Access-Control-Allow-Credentials' 'true';
			add_header 'Access-Control-Allow-Methods' 'GET, POST,PUT,DELETE,OPTIONS';
			add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Origin,Accept';
			add_header 'Content-Type' 'application/json';
			add_header 'Content-Length' 0;
			return 204;
31 января 2017, 13:28

Set up global variable in Laravel

App::instance('var', $var);
$var = \App::make('var');
20 января 2017, 23:03