Skip to content

Instantly share code, notes, and snippets.

View megrxu's full-sized avatar
😠
我很生气

megrxu

😠
我很生气
View GitHub Profile
@megrxu
megrxu / riscv-dump
Last active January 22, 2021 11:09
riscv-dump
#!/bin/env zsh
## Dump machine codes only to a Xilinx coefficient file.
## Usage: ./riscv-dump <.S file> > ROM.coe
## Tmp files
elf=(=())
bin=(=())
## Get the elf
@megrxu
megrxu / iptables.rules
Created October 22, 2020 02:26
Transparent proxy for TCP using systemd slice and iptables.
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:TRANS - [0:0]
-A OUTPUT -p tcp -j TRANS
# The proxy is running in `proxy.slice`, so no loop
@megrxu
megrxu / docker-compose@.service
Last active July 21, 2020 12:24
Systemd Services
[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service
[Service]
Restart=always
WorkingDirectory=/etc/docker/compose/%i
@megrxu
megrxu / build.yml
Last active March 6, 2024 14:16
A GitHub Actions workflow configuration to build TeX files with extra fonts.
name: Build
on: [push]
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v1
- name: Install TeX Live packages # (Note that you may don't need some of them)
run: sudo apt install -y texlive-base texlive-xetex texlive-lang-chinese latexmk
@megrxu
megrxu / config.yml
Created March 14, 2019 01:07
Circle CI config for Hugo + GitHub Pages + Custom Domain
version: 2
workflows:
version: 2
build:
jobs:
- build
- deploy:
requires:
- build
@megrxu
megrxu / client-config.json
Last active April 11, 2024 23:57
v2ray | WebSocket + VMess/VLess + TLS
{
"inbounds": [
{
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": false
}
}
@megrxu
megrxu / settings.json
Created February 23, 2019 12:39
latex-workshop
{
"latex-workshop.latex.recipes": [{
"name": "latexmk-thesis",
"tools": [
"latexmk-thesis",
]
}],
"latex-workshop.latex.tools": [{
"name": "latexmk-thesis",
"command": "latexmk",
@megrxu
megrxu / crop-matlab-figure.m
Created June 27, 2018 12:48
Exporting a figure in Matlab to PDF often outputs a A4-sized pdf file. This snippet can export an standalone pdf which can be used in TeX file directly.
% Exporting a figure in Matlab to PDF often outputs an A4-sized pdf file. This snippet can export a minimal size pdf which can be used in TeX files directly.
% some figures here
figure;
plot(zeros([1, 5]));
% codes that works
fig = gcf;
fig.PaperPositionMode = 'auto';
fig_pos = fig.PaperPosition;
@megrxu
megrxu / gh-pages-deploy.sh
Created February 26, 2018 10:56
deploy the gh-pages from a hugo site folder
#!/bin/bash
echo -e "\033[0;32mDeploying gh-pages to GitHub...\033[0m"
# Clean
rm -rf public
# Build the project.
hugo # if using a theme, replace with `hugo -t <YOURTHEME>`
@megrxu
megrxu / slides.tex
Created December 28, 2017 08:22
A beamer template.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Beamer Presentation
% LaTeX Template
% Version 1.0 (10/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)