Skip to content

Instantly share code, notes, and snippets.

View morganwu277's full-sized avatar

Morgan Wu morganwu277

View GitHub Profile
@morganwu277
morganwu277 / dump_socket.sh
Created March 6, 2024 19:32 — forked from jhass/dump_socket.sh
Capture unix socket to pcap file with socat and tshark
#!/bin/bash
# Parameters
socket="/run/foo.sock"
dump="/tmp/capture.pcap"
# Extract repetition
port=9876
source_socket="$(dirname "${socket}")/$(basename "${socket}").orig"
@morganwu277
morganwu277 / encoding-video.md
Created April 26, 2022 00:08 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@morganwu277
morganwu277 / gist:20859d563b3419478e288d485ce5973a
Created September 28, 2021 05:22 — forked from carlosmcevilly/gist:1881721
split a .mov file without loss of quality
#!/usr/bin/perl
# command from:
# http://www.linuxquestions.org/questions/linux-newbie-8/how-do-you-split-mpg-files-using-a-ffmpeg-command-542607/
# -vcodec copy copies the raw data
# -ss start seconds?
# -to ?
my $infile = shift;
# This is an example for building the open source components of Docker for Mac
kernel:
image: linuxkit/kernel:4.14.39
cmdline: "console=ttyS0 page_poison=1"
init:
- linuxkit/vpnkit-expose-port:4e2ea826aaefdd196c7473255654d06ad96c4c21 # install vpnkit-expose-port and vpnkit-iptables-wrapper on host
- linuxkit/init:11929b0007b87384f7372e9265067479c4616586
- linuxkit/runc:acba8886e4b1318457c711700f695a02fef9493d
- linuxkit/containerd:f197e7cbb2ede4370b75127c76de6f7b2e3d9873
- linuxkit/ca-certificates:fb5c7bf842a330f5b47cdf71f950fe0c85f4a772
@morganwu277
morganwu277 / build-tmux.sh
Last active December 15, 2020 05:13 — forked from mbreese/build-tmux.sh
HOWTO build a statically linked tmux in one script (downloads and builds dependencies from source)
#!/bin/bash
set -ex
# we can use docker image centos:7 to build
# install tools to build
yum install gcc kernel-devel make ncurses-devel file -y
alias make="make -j"
TARGETDIR=$1
if [ "$TARGETDIR" = "" ]; then
TARGETDIR=$(python -c 'import os; print os.path.realpath("local")')
fi
@morganwu277
morganwu277 / docker-for-mac.md
Created May 1, 2019 20:05 — forked from BretFisher/docker-for-mac.md
Getting a Shell in the Docker for Mac Moby VM

2018 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Moby VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@morganwu277
morganwu277 / tmux-cheatsheet.markdown
Created February 14, 2019 18:47 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@morganwu277
morganwu277 / nginx-location
Created April 23, 2018 18:31 — forked from luxixing/nginx-location
nginx location 匹配规则
1 普通匹配,遵循最长匹配规则,假设一个请求匹配到了两个普通规则,则选择匹配长度大的那个
例如:
location /{
[matches]
}
location /test{
[matches]
}
2 精确匹配
location = /{
@morganwu277
morganwu277 / my.cnf
Created September 23, 2017 14:54 — forked from fevangelou/my.cnf
Optimized MySQL configuration [socket & PID paths taken from stock Ubuntu Server setups] (updated July 2017)
# Optimized MySQL configuration by Fotis Evangelou - Updated July 2017
#
# The settings provided below are a starting point for a 4GB - 8GB RAM server with 4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
# should be adjusted for your system by using MySQL DB diagnostics tools like:
# http://mysqltuner.com/
# or
# https://launchpad.net/mysql-tuning-primer (supports MySQL up to v5.6)
@morganwu277
morganwu277 / Fabric-UserSetup.py
Created March 1, 2017 23:27 — forked from btompkins/Fabric-UserSetup.py
Simple fabric function to create a new user
def new_user(admin_username, admin_password):
env.user = 'root'
# Create the admin group and add it to the sudoers file
admin_group = 'admin'
runcmd('addgroup {group}'.format(group=admin_group))
runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format(
group=admin_group))
# Create the new admin user (default group=username); add to admin group