socks5 -> http/https proxy, privoxy/cow

‘socks5 -> http/https proxy, privoxy/cow’ curl -L git.io/cow | bash #edit /home/user0/.cow/rc listen = http://127.0.0.1:7777 proxy = socks5://127.0.0.1:1080 #config http/https proxy export http_proxy=http://127.0.0.1:7777 export https_proxy=http://127.0.0.1:7777 sudo pacman -S privoxy edit /etc/privoxy/config forward-socks5 / 127.0.0.1:1080 . listen-address 127.0.0.1:8118 sudo systemctl start privoxy proxychains ProxyChains是Linux和其他Unix下的代理工具。它可以使任何程序通过代理上网, 允许TCP和DNS通过代理隧道。ProxyChains通过一个用户定义的代理列表强制连接指定的应用程序, 直接断开接收方和发送方的连接。 ProxyChains是一个开源Unix/Linux代理工具,能够强制使任何应用的TCP连接使用SOCKS4,SOCKS或者HTTP(S)代理进行连接。 #Arch Linux sudo pacman -S proxychains-ng #Debian/Ubuntu apt-get install proxychains #Mac OS X brew install proxychains-ng # 用户级配置文件 ~/.proxychains/proxychains.conf # 系统级配置文件 vim /etc/proxychains.conf # content [ProxyList] socks5 192.168.50.205 1080 http 127.0.0.1 4321 proxychains looks for config file in following order: ...

2017-02-15 · 1 min · 190 words · -

urxvt

urxvt urxvt is a highly customizable terminal emulator. # install sudo pacman -S rxvt-unicode #start rxvt-unicode urxvt # 没有的话就创建这个文件, urxvt 启动的时候自动加载 vim ~/.Xresources ! 起始的行是注释 !!$HOME/.Xresources URxvt.preeditType:Root !!调整此处设置输入法 URxvt.inputMethod:fcitx !!颜色设置 URxvt.depth:32 !!中括号内数表示透明度 URxvt.inheritPixmap:true URxvt.background:#000000 URxvt.foreground:#ffffff URxvt.colorBD:Gray95 URxvt.colorUL:Green URxvt.color1:Red2 URxvt.color4:RoyalBlue URxvt.color5:Magenta2 URxvt.color8:Gray50 URxvt.color10:Green2 URxvt.color12:DodgerBlue URxvt.color14:Cyan2 URxvt.color15:Gray95 !!URL操作 URxvt.urlLauncher:chromium URxvt.matcher.button:1 Urxvt.perl-ext-common:matcher !!滚动条设置 URxvt.scrollBar:False URxvt.scrollBar_floating:False URxvt.scrollstyle:plain !!滚屏设置 URxvt.mouseWheelScrollPage:True URxvt.scrollTtyOutput:False URxvt.scrollWithBuffer:True URxvt.scrollTtyKeypress:True !!光标闪烁 URxvt.cursorBlink:True URxvt.saveLines:3000 !!边框 URxvt.borderLess:False !!字体设置 Xft.dpi:96 URxvt.font:xft:Source Code Pro:antialias=True:pixelsize=18,xft:WenQuanYi Zen Hei:pixelsize=18 ...

2017-02-10 · 1 min · 133 words · -

mitmproxy

mitmproxy mitmproxy 是用 Python 和 C 开发的一个中间人代理软件 (man-in-the-middle proxy), 它可以用来拦截、修改、重放和保存 HTTP/HTTPS 请求。 它提供了两个命令行工具: mitmproxy 具备交互界面 mitmdump 不具备交互界面, 类似 tcpdump

2017-02-06 · 1 min · 19 words · -

traefik

traefik podman run -d \ --name traefik \ -p 80:80 \ -p 8080:8080 \ -v nginx-config:/etc/nginx \ -v nginx-www:/var/www \ -v cert:/etc/letsencrypt \ -v /etc/localtime:/etc/localtime:ro \ traefik:v2.9.6 dashboard http://192.168.50.51:8080/

2017-01-15 · 1 min · 29 words · -

ES Modules

ES Modules, or ECMAScript Modules foo.js class ArticleNode { constructor(node, paragraph) { this.node = node this.paragraph = paragraph } } export function createOneArticleNode(){ let articleNode0 = new ArticleNode('foo', 'bar') console.log('a n: ', articleNode0) } bar.js // jest test import { createOneArticleNode } from '../content_module.js' test('test es module 0', () => { console.log('print foo') createOneArticleNode() console.log('print bar') }); npm run test

2016-12-14 · 1 min · 60 words · -

c basic, c, c lang, c 语言

c basic, c, c lang, c 语言 hello world vim main.c #include <stdio.h> int main(){ printf("hello world!\n"); return 0; } gcc main.c ./a.out # 也可以不使用 a.out 这个名字,我们自己对其进行命名: gcc main.c -o hello ./hello 预处理(或称预编译) 预处理(或称预编译)是指在进行编译的第一遍扫描(词法扫描和语法分析)之前所作的工作。预处理指令指示在程序正式编译前就由编译器进行的操作,可放在程序中任何位置。 预处理是C语言的一个重要功能,它由预处理程序负责完成。当对一个源文件进行编译时,系统将自动引用预处理程序对源程序中的预处理部分作处理,处理完毕自动进入对源程序的编译。 C语言提供多种预处理功能,主要处理#开始的预编译指令,如宏定义(#define)、文件包含(#include)、条件编译(#ifdef)等。合理使用预处理功能编写的程序便于阅读、修改、移植和调试,也有利于模块化程序设计。 头文件, header 头文件是扩展名为 .h 的文件,包含了 C 函数声明和宏定义,被多个源文件中引用共享。有两种类型的头文件: 程序员编写的头文件和编译器自带的头文件。 在程序中要使用头文件,需要使用 C 预处理指令 #include 来引用它。前面我们已经看过 stdio.h 头文件,它是编译器自带的头文件。 引用头文件相当于复制头文件的内容,但是我们不会直接在源文件中复制头文件的内容,因为这么做很容易出错,特别在程序是由多个源文件组成的时候。 A simple practice in C 或 C++ 程序中,建议把所有的常量、宏、系统全局变量和函数原型写在头文件中,在需要的时候随时引用这些头文件。 引用头文件的语法 使用预处理指令 #include 可以引用用户和系统头文件。它的形式有以下两种: include 这种形式用于引用系统头文件。它在系统的标准列表中搜索名为 file 的文件。在编译源代码时,您可以通过 -I 选项把目录前置在该列表前。 ...

2016-11-16 · 2 min · 362 words · -

linux 环境 变量, /etc/profile, /etc/profile.d/

linux 环境 变量, /etc/profile, /etc/profile.d/ ~/.bashrc, ~/.profile Archlinux Interactive, non-login shells 会加载 ~/.bashrc, login shell 不会加载 ~/.bashrc /root/.bashrc 主要是为交互式的 非登录 shell 准备的,而 root 用户登录时的默认 shell 会加载的文件是 /root/.profile,而不是 ~/.bashrc win10 WSL + zsh + oh my zsh 用 root 用户 SSH 登录 archlinux 会加载 .bash_profile, 不会加载 .bashrc win10 putty SSH 登录 同上 /etc/profile.d 自定义的环境变量要加到 /etc/profile.d 下, 这里的配置会开机加载, 配置到 ~/.zshrc 的话会每打开一个 terminal 加载一次, 不建议手动修改 /etc/profile, /etc/profile 文件属于 filesystem 包, 这个包的的更新有可能会导致 /etc/profile 的更新, 如果 filesystem 升级的时候发现 /etc/profile 被修改过, 会把新的文件安装到 /etc/profile.new 并且是不生效的状态, 有可能会导致某些不兼容的问题, 比如 perl 包安装的/etc/profile.d/perlbin.sh 使用的 append_path 函数. ...

2016-10-28 · 3 min · 521 words · -

select for update

select for update 行级锁 排他锁 行级锁 行级锁不影响对数据的查询,它们只阻塞对同一行的写入和锁定。 排他锁 for update select for update 会导致由 select 语句查询的行被锁定 (行级锁, 排他锁), 会阻塞其它线程对这行数据加排他锁或共享锁. for update nowait 使用 nowait 子句的作用就是避免进行等待, 当发现请求加锁资源被锁定未释放的时候, 直接报错返回。 Select … for update 语句是我们经常使用手工加锁语句。通常情况下, select 语句是不会对数据加锁, 妨碍影响其他的 DML 和 DDL 操作。同时, 在多版本一致读机制的支持下, select 语句也不会被其他类型语句所阻碍。 借助 for update 子句, 我们可以在应用程序的层面手工实现数据加锁保护操作。本篇我们就来介绍一下这个子句的用法和功能。 下面是采自 Oracle 官方文档《SQL Language Reference》中关于for update子句的说明: 从 for updat e子句的语法状态图中, 我们可以看出该子句分为两个部分: 加锁范围子句和加锁行为子句。下面我们分别针对两个方面的进行介绍。 加锁范围子句 在 select…for update 之后,可以使用 of 子句选择对 select 的特定数据表进行加锁操作。默认情况下,不使用of子句表示在select所有的数据表中加锁。 //采用默认格式for update ...

2016-10-14 · 4 min · 664 words · -

Go unit test, 单体测试

Go unit test, 单体测试 执行某一个测试文档 go test foo_test.go go test -v foo_test.go // 强制 go test 运行一次,不使用缓存, 在配置了 -count 参数的情况下,go test 会忽略缓存 // -count, 执行测试的次数 go test -count=1 foo_test.go # 执行某一个文件中的某一个或几个函数 go test path/to/foo_test.go -run "^TestFunc0$" go test 会默认缓存测试运行的结果(Test Cache),缓存判断的依据是: 测试本身的代码(如 *_test.go 文件) 测试依赖的源文件是否发生变更 测试的相关环境参数是否发生变化(环境变量、命令参数等) Go 语言推荐测试文件和源代码文件放在一块,测试文件以 _test.go 结尾。比如,当前 package 有 calc.go 一个文件,我们想测试 calc.go 中的 Add 和 Mul 函数,那么应该新建 calc_test.go 作为测试文件。 calc_test.go package main import "testing" func TestAdd(t *testing.T) { t.Log("test foo") if ans := Add(1, 2); ans != 3 { t.Errorf("1 + 2 expected be 3, but %d got", ans) } if ans := Add(-10, -20); ans != -30 { t.Errorf("-10 + -20 expected be -30, but %d got", ans) } } 测试用例名称一般命名为 Test 加上待测试的方法名。 测试用的参数有且只有一个, 在这里是 t *testing.T ...

2016-07-13 · 4 min · 644 words · -

cd pushd

cd pushd http://os.51cto.com/art/200910/158752.htm cd - # list current dir pwd /foo # cd to /bar cd /bar pwd /bar # 可以在 $OLDPWD 变量里查看旧目录 echo $OLDPWD # cd - return to previous dir /foo cd - pwd /foo # cd -, return to previous dir /bar cd - pwd /bar pushd、popd 和 dirs pushd 和 popd 是对一个目录栈进行操作,而 dirs 是显示目录栈的内容。而目录栈就是一个保存目录的栈结构,该栈结构的顶端永远都存放着当前目录(这里点从下面可以进一步看到)。 dirs 的 参数: -p 每行显示一条记录 -v 每行显示一条记录,同时展示该记录在栈中的 index -c 清空目录栈, 将目录栈中除当前目录之外的其它目录清除 每次 cd 之后, 新目录都会被记录到目录栈中 ...

2016-07-02 · 2 min · 271 words · -

英语, English

英语 English 句子成分 主语 Subject 谓语 Predicate 宾语 Object 主语 Subject 指句子中动作的执行者或状态的承受者,通常是名词、代词或相当于名词的词或短语。 在祈使句中,主语通常是隐含的 “You”。 谓语 Predicate 通常是一个动词(或动词短语),说明主语做什么或处于什么状态。 主语 和谓语的关系 主语是动作的执行者,谓语是主语所做的动作或状态的描述。 主谓一致(Subject-Verb Agreement) 主语和谓语在数(单复数)和人称上必须一致。 宾语 Object 宾语是动作的承受者,通常是谓语动词的作用对象。换句话说,就是“谁”或“什么”受到了这个动作。 通常出现在 及物动词(transitive verb) 后面 通常是名词、代词,或相当于名词的词/短语(名词短语)/从句 直接宾语 Direct Object 动作直接作用的对象 I read a book. 间接宾语 Indirect Object 表示动作的接受者或受益者,通常在人之前 She gave me a gift. me: 间接宾语, a gift: 直接宾语 宾语从句 Object Clause 整个从句作为宾语 I think (that he is right). 动词后不一定有宾语, 及物动词需要宾语,比如 need, like, see, eat, 不及物动词通常不需要宾语, 比如: sleep, arrive, go ...

2016-05-15 · 19 min · 3849 words · -

ansible basic command

ansible basic command commands # 临时的 inventory file ansible -i '192.168.50.111,' all -m shell -a 'whoami' -u root ansible-galaxy collection install community.general # localhost ansible localhost -m shell -a 'ls' # 指定私钥 --key-file ansible -i 'wiloon.com,' all -m shell -a 'systemctl stop enx-api' -u root --key-file ~/.ssh/id_ed25519_w10n hibernate ansible -i '192.168.50.31,' all -m shell -a 'sudo systemctl hibernate' -u user0 install Installing Ansible on Ubuntu sudo apt update sudo apt install software-properties-common sudo add-apt-repository --yes --update ppa:ansible/ansible sudo apt install ansible macos brew install ansible ansible 配置文件 /etc/ansible/ansible.cfg 文件内容 [defaults] interpreter_python = auto_legacy_silent # gather 超时时间 gather_timeout=30 inventory 默认的 Inventory 路径 /etc/ansible/hosts ...

2016-05-13 · 2 min · 382 words · -

e2fsck command

e2fsck command linux 下磁盘检查修复命令 # 注意, 是对分区进行检查, 如果参数只写磁盘 /dev/sda, 有可能会报分区表异常之类的... e2fsck: Bad magic number in super-block while trying to open /dev/vdb1 e2fsck -f /dev/sda2 e2fsck 用于检查和修复 ext 文件系统的硬盘分区, 不过这个命令还有专有形式: fsck.ext3, fsck.ext2分别用于检测ext3和ext2。 使用方法: 1。首先在检查之前一定要卸载待检查的文件系统分区。 2。主要参数包括: -a: 检查 partition,如发现问题会自动修复。 -b: 设定 superblock 位置。 -B size: 指定 size 作为区块大小。 -c: 检查 partition 是否有坏轨。 -C file: 将检查结果储存到 file。 -d: 输出 e2fsck debug 结果。 -f: e2fsck 预设只会对错误的档案系统检查,加上 -f 是强制检查。 -F: 在检查前将硬盘它的参数包括有: -a:

2016-04-18 · 1 min · 67 words · -

javascript class

// Declaration class Rectangle { constructor(height, width) { this.height = height; this.width = width; } }

2016-03-07 · 1 min · 16 words · -

BigDecimal

BigDecimal package com.wiloon.javax; import java.math.BigDecimal; public class BigDecimalTest { public static void main(String[] args) { BigDecimal a = new BigDecimal(1234567890123456.1234); System.out.println("a values is:" + a); BigDecimal b = new BigDecimal(123456789012345.1234); System.out.println("b values is:" + b); BigDecimal c = new BigDecimal(12345678901234.1234); System.out.println("c values is:" + c); BigDecimal d = new BigDecimal(1234567890123.1234); System.out.println("d values is:" + d); BigDecimal e = new BigDecimal(123456789012.1234); System.out.println("e values is:" + e); // 创建一个BigDecimal对象 BigDecimal bigDecimal = new BigDecimal("1234567890123456.1234"); // 输出 System.out.println("处理的浮点数为: " + bigDecimal); System.out.println(bigDecimal.add(new BigDecimal(1))); System.out.println(bigDecimal.add(new BigDecimal(0.0001))); } } a values is:1234567890123456 b values is:123456789012345.125 c values is:12345678901234.123046875 d values is:1234567890123.123291015625 e values is:123456789012.1233978271484375 处理的浮点数为: 1234567890123456.1234 1234567890123457.1234 1234567890123456.123500000000000000004792173602385929598312941379845142364501953125 Java 在 java.math 包中提供的 API 类 BigDecimal, 用来对超过 16 位有效位的数进行精确的运算。双精度浮点型变量 double 可以处理 16 位有效数。在实际应用中,需要对更大或者更小的数进行运算和处理。 float和double只能用来做科学计算或者是工程计算,在商业计算中要用java.math.BigDecimal。BigDecimal所创建的是对象,我们不能使用传统的+、-、*、/等算术运算符直接对其对象进行数学运算,而必须调用其相对应的方法。方法中的参数也必须是BigDecimal的对象。构造器是类的特殊方法,专门用来创建对象,特别是带有参数的对象。 ...

2016-02-29 · 2 min · 258 words · -

sway

sway virtualbox 里的 sway virtualbox 窗口在不同分辨率的显示器之间切换时花屏, 剪贴板不好用, 窗口不能自动缩放 2024-01-08T08:17:03+08:00 fedora sway download Fedora Sway Spin iso virtualbox 配置显存128, 3D加速 用 iso 启动后 win + enter 打开 terminal 用 text mode 安装 liveinst –text fedora disable firewall sudo systemctl stop firewalld # replace dnf mirror with 163 dnf upgrade --refresh dnf install kernel-headers – archlinux + sway virtualbox guest addition failed to start sudo pacman -S sway sudo pacman -S swaylock swayidle swaybg sudo pacman -S dmenu # install yay yay -S wmenu sudo pacman -S foot sudo pacman -S polkit virtualbox 虚拟机要打开 3D 加速 ...

2016-02-26 · 1 min · 104 words · -

tightvnc, tigervnc

tightvnc, tigervnc tighervnc nightly build https://github.com/TigerVNC/tigervnc/releases http://tigervnc.bphinz.com/nightly/ # archlinux pacman -S tigervnc # vncserver # dell desktop vncserver -geometry 1350x670 -dpi 96 -depth 32 :1 vncserver -geometry 1364x768 -dpi 96 -depth 32 :1 vncserver -kill :1 #kill 后面有空格!!! vncviewer 192.168.2.228:1 #edis config file .vnc/xstartup #!/bin/sh startxfce4 exit full screen ctrl+alt+shift+F vncviewer: disable allow jpeg https://unix.stackexchange.com/questions/67096/xterm-warning-tried-to-connect-to-session-manager centos yum -y install tigervnc-server yum -y install tigervnc install xorg start xorg install xfce4 ...

2015-12-25 · 1 min · 74 words · -

LVM

LVM commands # lvreduce, 用于减小 LVM 逻辑卷(Logical Volume)的大小 # -r, 同时调整(resize)文件系统的大小(调用 resize2fs xfs_growfs 等) # -L -40G 减小逻辑卷的大小 40GB(注意 - 表示减小) # /dev/ubuntu-vg/root 要调整的逻辑卷路径(通常是根分区) sudo lvreduce -r -L -40G /dev/ubuntu-vg/root LVM 的基本概念 通过 LVM 技术,可以屏蔽掉磁盘分区的底层差异,在逻辑上给文件系统提供了一个卷的概念,然后在这些卷上建立相应的文件系统。下面是 LVM 中主要涉及的一些概念。 PM 物理存储设备 (Physical Media): 指系统的存储设备文件,比如 某一块硬盘, /dev/sda、/dev/sdb 等。 或者 设备映射器(Device Mapper)管理的加密分区. /dev/mapper/nvme0n1p8_crypt PV (物理卷 Physical Volume): PV 可以看做是硬盘上的分区, 指硬盘分区或者从逻辑上看起来和硬盘分区类似的设备 (比如 RAID 设备)。 PE (Physical Extent):PV(物理卷)中可以分配的最小存储单元称为 PE,PE 的大小是可以指定的。 VG (卷组, Volume Group): 卷组: 物理卷的组合. 类似于非 LVM 系统中的物理硬盘,一个 LVM 卷组由一个或者多个 PV(物理卷) 组成。 卷组是 LVM 的中间层,VG 将多个物理卷(Physical Volumes, PV)组合在一起, 以便在其上创建逻辑卷(Logical Volumes, LV)。 ...

2015-10-12 · 3 min · 635 words · -

GPU

GPU # AMD 显卡 查看 显存等信息, 显存使用率 sudo apt install radeontop radeontop

2015-09-22 · 1 min · 12 words · -

PostgreSQL execution plan, explain, 执行计划

PostgreSQL execution plan, explain, 执行计划 -- 查看执行计划 EXPLAIN select * from table_0 where id < 1000; -- EXPLAIN ANALYZE - 查看实际执行情况(推荐) EXPLAIN ANALYZE select * from table_0 where id < 1000; -- 更详细的执行计划 EXPLAIN (ANALYZE, BUFFERS, VERBOSE, FORMAT TEXT) select * from table_0 where id < 1000; Seq Scan, 全表扫描,顺序扫描 全表扫描,也叫顺序扫描,扫描时把表中所有的数据块从头到尾遍历一边,找到复合条件的数据块。全表扫描在在explain中使用Seq Scan表示 IndexOnly Scan IndexOnly Scan 是覆盖索引扫描,所需的返回结果能被所扫描的索引全部覆盖 https://www.jianshu.com/p/682d798aee1f 了解 PostgreSQL 执行计划对于开发人员来说是一项关键技能,执行计划是我们优化查询,验证我们的优化查询是否确实按照我们期望的方式运行的重要方式。 PostgreSQL 数据库中的查询生命周期 每个查询都会经历不同的阶段,了解每个阶段对数据库的意义很重要。 查询生命周期 第一阶段是通过 Postgres 的客户端连接到数据库。 ...

2015-09-17 · 4 min · 829 words · -