Skip to content

Instantly share code, notes, and snippets.

View wen-long's full-sized avatar
☘️
wish to be lucky

wen-long

☘️
wish to be lucky
View GitHub Profile
root@raspberrypi:~# dd if=/dev/zero of=/mnt/sda1/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 17.071 s, 31.4 MB/s
root@raspberrypi:~# mkswap /mnt/sda1/swapfile
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=be997b16-5b25-4366-a804-674c296f8616
root@raspberrypi:~# swapon /mnt/sda1/swapfile
root@raspberrypi:~# free -m

total used free shared buffers cached

openssl genrsa -out privatekey.pem 2048

openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 365000

python gencrt.py signedcrtfilename CA.key publickey.cer

第三部其实用OpenSSL就可以完成,不过需要配置文件,略麻烦

#!/usr/bin/env python

自动挂载硬盘 nano /etc/fstab

/dev/sda1 /mnt/sda1 xfs defaults 0 0

/etc/minidlna.conf

media_dir=/mnt/sda1/DLNA
db_dir=/var/lib/minidlna

/etc/udev/rules.d/11-media-by-label-auto-mount.rules

KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"

在 DLNA SERVER直接相连的路由器运行

iptables -t mangle -I PREROUTING -d 239.255.255.250/32 -j TEE --gateway 192.168.0.101

192.168.0.101是 DLNA 播放设备的 IP

至于在192.168.0.0/24网段广播,可能需要两个路由器都对 DLNA 通告特殊处理

1.用iptables的TEE模块

iptables -t mangle -A PREROUTING -s 192.168.8.0/24 -j TEE --gateway 192.168.8.161
iptables -t mangle -A POSTROUTING -d 192.168.8.0/24 -j TEE --gateway 192.168.8.161
iptables -t mangle -A PREROUTING  -j TEE --gateway 192.168.8.161

涉及自己的包会重复,可在规则中指定

iptables -t mangle -A PREROUTING  ! -s 192.168.8.161 -j TEE --gateway 192.168.8.161

###C++ Primer第5版 学习笔记

####第二章

  1. 字符类型除了char以外.wchar_t,char16_t,char32_t
    1. wchar_t类型用于确保可以存放机器最大拓展字符集中的任意一个字符
    2. char16_t和char32_t用于Unicode
  2. 字符型有char,signed char,unsignedchar三种,char的表现由编译器决定,因此不在算术运算中使用char,应标明signed或unsigned
  3. 浮点数用double
  4. 算数表达式既有无符号也有int时,int会被转换为无符号数
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++0x",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"encoding":"cp936",
"variants":
[
{
"name": "Run",

###C++ Primer第5版 学习笔记

####第三章

  1. string::size返回string::size_type类型,体现标准库机器无关,结果与有符号数运算时要谨慎
  2. vector int初始化与range for
	using vi = vector<int>;
vi v1(5);

###C++ Primer第5版 学习笔记

####第四章

  1. 函数调用也是一种运算符,对运算对象的个数没有限制
  2. 重载运算符时,运算对象的个数,运算符的优先级和结合律都无法改变
  3. 左值表达式的求值结果是一个对象或者函数,但常量对象左值不能被赋值
  4. 赋值运算符需要左值作为左侧运算对象,结果也是左值
  5. 解引用,下标运算符求值结果为左值
  6. 如果表达式求值结果为左值,decltype 作用于该表达式得到引用类型