Skip to content

Instantly share code, notes, and snippets.

View kmvan's full-sized avatar
🌏
What is the end and ultimate purpose of the universe?

Km.Van kmvan

🌏
What is the end and ultimate purpose of the universe?
View GitHub Profile
@kmvan
kmvan / imagick_average_colour.php
Created September 14, 2017 10:16 — forked from paulferrett/imagick_average_colour.php
This function will get the average colour of an image file using PHP and Image Magick using the IMagick extension.
<?php
/**
* Get the average pixel colour from the given file using Image Magick
*
* @param string $filename
* @param bool $as_hex Set to true, the function will return the 6 character HEX value of the colour.
* If false, an array will be returned with r, g, b components.
*/
function get_average_colour($filename, $as_hex_string = true) {
@kmvan
kmvan / gist:7ac38cf3cdb111254ffd24c0093ac2f2
Created October 22, 2018 08:43
git `ignore take effect`
git rm -r --cached .
git add .
git commit -m "ignore take effect"
@kmvan
kmvan / wordpress.conf
Created April 10, 2019 10:17
wordpress nginx rewrite
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
@kmvan
kmvan / domain.conf
Created April 10, 2019 10:23
nginx ssl site conf
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
if ($host != DOMAIN) {
return 301 $scheme://DOMAIN$request_uri;
}
@kmvan
kmvan / mysql-init.txt
Last active November 20, 2019 14:48
MySQL init
update mysql.user set plugin='mysql_native_password' where user='root';
update mysql.user set password=password("pwd") where user='root';
FLUSH PRIVILEGES;
@kmvan
kmvan / nfs.md
Last active December 20, 2019 15:25
Linux NFS

SERVER

  • apt install nfs-kernel-server
  • vi /etc/exports
  • /mnt/sharedfolder clientIP(rw,no_root_squash,sync,no_subtree_check)
  • exportfs -a

CLIENT

  • apt-get install nfs-common
@kmvan
kmvan / arch-with-php7.4.md
Created December 12, 2019 06:51
Arch with PHP7.4.
  • $ systemctl edit php-fpm.service
[Service]
ProtectHome=false
apt-get install libperl-dev gcc libjpeg-dev libbz2-dev libwmf-dev zlib1g-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev libexif-dev perl libltdl-dev graphviz pkg-config libtiff-dev libwebp-dev libcairo2-dev
@kmvan
kmvan / fontawesome-preview.html
Created January 29, 2020 08:21
FontAwesome preview
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>FontAwesome 预览页面 - INN STUDIO</title>
<link rel="stylesheet" href="https://fontawesome.inn-studio.com/releases/v5.9.0/css/all.css">
<style>
mysqldump是mysql官方机型逻辑备份的工具,作用非常多,可以进行全量备份,结合binlog还以做增量备份,也是做从库的利器,正确理解它非常有用。
今天列举我目前比较关心的几个点。
1:是否要锁表
默认的情况下它是锁表的,相当于调用—add-locks参数,在每个表备份前后增加LOCK TABLES和UNLOCK TABLES语句,这样数据库表就只读了。
去年我做副库的时候,以防万一,喜欢调用FLUSH TABLES WITH READ LOCK语句,让全库只读,实际上增加—lock-all-tables即可。