Skip to content

Instantly share code, notes, and snippets.

View iflamed's full-sized avatar

New Bing iflamed

View GitHub Profile
@iflamed
iflamed / iptables-cloud-ip.sh
Created January 16, 2021 08:49
ECS 通过 iptables SNAT转发 共享一个IP上网
# 背景:
> 有一台A服务器不能上网,和B服务器通过内网来连接,B服务器可以上网,要实现A服务器也可以上网。
内网主机: A eth1:172.16.1.8
外网主机: B eth0:10.0.0.6 外网主机: B eth1:172.16.1.6
SNAT:改变数据包的源地址。防火墙会使用外部地址,替换数据包的本地网络地址。这样使网络内部主机能够与网络外部通信。
## 在可以上网那台服务器B上,开启内核路由转发功能
### 临时
@iflamed
iflamed / compress-video.sh
Created February 1, 2020 03:59
compress mp4 format video
for f in *.mp4;
do
ffmpeg -i "$f" -vcodec libx264 -crf 28 cpmmp4/"${f%.mp4}".mp4
done
@iflamed
iflamed / hostname.sh
Created April 19, 2019 10:56
centos7 change hostname
hostnamectl --static set-hostname qqmm
@iflamed
iflamed / optimize-table.sql
Created March 10, 2019 17:25
数据表碎片优化
select concat('optimize table ',table_schema,'.',table_name,';'),data_free,engine
from information_schema.tables
where data_free>0 and engine !='MEMORY'
ORDER BY data_free DESC ;
@iflamed
iflamed / iptables-forword.md
Last active October 30, 2018 06:50
iptables 端口转发、中继上网

开启防火墙的ipv4转发

echo -e "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p

配置iptables开机加载

首先我们设置一下iptables 防火墙的开机启动自动载入规则功能。

@iflamed
iflamed / deploy.php
Created October 16, 2018 12:35 — forked from martincarlin87/deploy.php
Deployer Laravel 5
<?php
namespace Deployer;
require 'recipe/laravel.php';
$repo_url = '';
$branch = 'master';
$server_url = '';
$user = '';
@iflamed
iflamed / ffmpeg-repeat-audio
Created September 23, 2018 15:24
ffmpeg repeat audio loop audio to some times and durations
# ffmpeg -i rain-drops.ogg -i pouring-rains.ogg -i distant-thounder.ogg -i close-thounder.ogg -i frogs.ogg -filter_complex amix=inputs=5:duration=shortest -acodec libmp3lame rain-thounder.mp3 -y
# 把ogg音频文件重复到1800秒,并压缩成为mp3。增加逐渐音量减小到0,也逐渐增加到正常音量
for f in *.ogg;
do
ffmpeg -i "$f" -vn -sn -c:a mp3 -ab 192k -acodec libmp3lame mp3src/"${f%.ogg}".mp3 -y \
&& ffmpeg -stream_loop 60 -i "$f" -vn -sn -c:a mp3 -ab 192k -t 1800 -acodec libmp3lame mp3src/"${f%.ogg}"-normal.mp3 -y \
&& ffmpeg -stream_loop 60 -i "$f" -vn -sn -c:a mp3 -ab 192k -t 1800 -af "afade=t=out:st=0:d=1800" -acodec libmp3lame mp3src/"${f%.ogg}"-evening.mp3 -y \
&& ffmpeg -stream_loop 60 -i "$f" -vn -sn -c:a mp3 -ab 192k -t 1800 -af "afade=t=in:ss=0:d=1800" -acodec libmp3lame mp3src/"${f%.ogg}"-morning.mp3 -y
done
@iflamed
iflamed / PassportToken.php
Last active April 4, 2018 19:54
Laravel Passport Generate Access_token By User Model
<?php
namespace App\Traits;
use App\User;
use DateTime;
use GuzzleHttp\Psr7\Response;
use Illuminate\Events\Dispatcher;
use Laravel\Passport\Bridge\AccessToken;
use Laravel\Passport\Bridge\AccessTokenRepository;
@iflamed
iflamed / ssl.conf
Last active April 8, 2017 06:22
The letsencrypt nginx config and issue shell script
server {
listen 443 http2 ssl;
server_name example.com www.example.com;
ssl_certificate /home/user/.acme.sh/example.com_ecc/fullchain.cer;
ssl_certificate_key /home/user/.acme.sh/example.com_ecc/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_stapling on;
ssl_stapling_verify on;
@iflamed
iflamed / squarebox.css
Created April 2, 2017 03:29
纯css实现正方形框,通过变形:after伪元素的margin-top 的值还可以实现其它比例的高度。
.responsive-bg {
display: block;
width: 100%;
background-color: #fff;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
overflow: hidden;
}
.responsive-bg:after {