Skip to content

Instantly share code, notes, and snippets.

View slow-is-fast's full-sized avatar

slow-is-fast slow-is-fast

View GitHub Profile
@slow-is-fast
slow-is-fast / gist:2a20c14a7b4ebf5a7104f34a59a75cb7
Created September 24, 2017 01:45
show processlist in postgresql
select * from pg_stat_activity;
You should set
stats_command_string = on
in your postgresql.conf
@slow-is-fast
slow-is-fast / mysql_db_tab_size
Created September 14, 2017 05:07
select mysql database table size
SELECT table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024 /1024, 1) "DB Size in MB"FROM information_schema.tables GROUP BY table_schema;
SELECT table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES WHERE table_schema = "lemeng_recv1" ;
@slow-is-fast
slow-is-fast / laravel_diff_humans
Last active September 12, 2017 05:58
Laravel显示发布时间为’几分钟前’,’几天前’这种time ago的格式
我们会经常遇到这样的情况,比如将我们的发布时间显示为’几分钟前’,’几天前’这种time ago的格式哪在laravel中我们如何做到呢?
第一步: 在app/Providers/AppServiceProvider.php 中设置地区:
```php
public function boot()
{
\Carbon\Carbon::setLocale('zh');
}
```
第二步: 模板中使用Carbon的diffForHumans方法来显示时间
@slow-is-fast
slow-is-fast / gist:d0bf4b50fb939a7158ff7a26f958499b
Created September 2, 2017 18:02
Force safari sync history
After quitting Safari on your Mac, open Terminal and enter the following line of text:
defaults write com.apple.Safari IncludeInternalDebugMenu 1

ffmpeg -i input.mp4 -b:a 128k output.mp3

@slow-is-fast
slow-is-fast / mysql disk usage.md
Created March 23, 2017 01:52
mysql disk usage

select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;

MySQL 出现 The table is full 只有一个原因,对应的表数据容量达到系统上限。 具体限制请查看官方手册:http://dev.mysql.com/doc/refman/5.1/zh/introduction.html#table-size。你可以使用SHOW TABLE STATUS语句查看该表的相关信息。

解决方法1: 执行ALTER TABLE tbl_name MAX_ROWS=1000000000;

解决方法2: 修改Mysql的配置文件/etc/my.cnf,在[mysqld]下添加/修改两行(下面的值仅供参考,请根据实际情况酌情处理): tmp_table_size = 256M // 临时表大小 max_heap_table_size = 256M // 内存表大小

@slow-is-fast
slow-is-fast / gist:4b48230af0a4ed8311e11a2c3241034c
Created March 17, 2017 06:20
raspi disable auto mount removable media device
~/.config/pcmanfm/LXDE/pcmanfm.conf
[volume]
mount_on_startup=0
mount_removable=0
@slow-is-fast
slow-is-fast / ngx_access_ana.md
Last active March 16, 2017 09:50
nginx access log ip statistics

grep 'xxx' access.log | awk '{printf $1 ; print " " }' | sort| uniq -c

with default access log

when you change nginx log format,you should adapt $1 to yours

@slow-is-fast
slow-is-fast / ubuntu_14_php_7.1.md
Last active March 16, 2017 05:08
ubuntu install php7.1

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.1