Skip to content

Instantly share code, notes, and snippets.

@shellus
shellus / README.md
Last active October 2, 2017 08:45
Nginx use GeoIP show IP And Location Info Guide

download GeoIP databases

mkdir /etc/nginx/geoip
cd /etc/nginx/geoip
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
@shellus
shellus / vue-router-nginx.conf
Last active July 31, 2018 02:28
vue-router Vue路由+laravel后端的同域名解决跨域问题的nginx配置
server {
server_name love.endaosi.com;
charset utf-8;
location / {
index index.html;
root /data/www/love-vue/dist;
try_files $uri $uri/ /index.html;
}
location ~ /api {
@shellus
shellus / pipe-caller.php
Created December 25, 2018 02:15
进程管道调用php函数
$handle = fopen("php://stdin", 'r');
while (!feof($handle)) {
$line = stream_get_line($handle, 1024*1024*10, "\r\n");
$requestObj = json_decode($line, true);
$response = (new $requestObj['calss'])->$requestObj['method'](...$requestObj['args']);
echo json_encode($response) . "\r\n";
}
fclose($handle);
@shellus
shellus / ffmpeg.sh
Last active September 26, 2021 11:51
ffmpeg multiple processes directory videos
#!/bin/bash
set -e
handler(){
path=$@
filename=$(basename "${path}")
basename=${filename%.*}
dirname=$(dirname "${path}")
newname=$dirname/$basename.mp4
ffmpeg -i "$path" "$newname"
@shellus
shellus / Counter.php
Last active September 29, 2021 06:17
Laravel mysql Counter code
/**
* @param $tag
* @param int $num
* @return int|mixed
*/
public static function incr($tag, $num = 1)
{
if ($num < 1) {
throw new \Exception('num err');