星辰大海

My Conquest Is the Sea of Stars.

前言

本文讲述如何安装配置Shadowsocks Server,并支持通过代理方式(http/sock v4/5)连接因特网.

1531388960253

这里主要阐述服务端通过proxy连接的解决方案,shadowsocks server直连网络的方式比较简单,网上这块资料也比较齐全,不做过多描述

阅读全文 »

进入shell环境

1
2
docker ps
docker exec -it <container> bash

and run

1
2
apt-get update
apt-get install vim

!不要去改系统配置

正常运行的docker先保存一下docker的ID,之后不要去改下面的配置,否则docker会更新为新的那个,导致数据丢失

1529818594236

docker指令

1、启动docker

1
docker run -it --privileged=true -v /home/oracle/download:/usr/Downloads centos /bin/bash

2、查看当前docker运行

1
docker ps -a

3、提交docker

1
docker commit 9f73a02d5ef0[CONTAINER ID] docker.io/ubuntu[REPOSITORY]

4、查看容器的root用户密码

1
docker logs <容器名orID> 2>&1 | grep '^User: ' | tail -n1

因为docker容器启动时的root用户的密码是随机分配的。所以,通过这种方式就可以得到redmine容器的root用户的密码了。

5、查看容器日志

1
docker logs -f <容器名orID>

6、查看正在运行的容器

1
2
docker ps
docker ps -a为查看所有的容器,包括已经停止的。

7、删除所有容器

1
docker rm $(docker ps -a -q)

8、删除单个容器

1
docker rm <容器名orID>

9、停止、启动、杀死一个容器

1
2
3
4
5
docker stop <容器名orID>

docker start <容器名orID>

docker kill <容器名orID>

10、查看所有镜像

1
docker images

11、删除所有镜像

1
docker rmi $(docker images | grep none | awk '{print $3}' | sort -r)

12、运行一个新容器,同时为它命名、端口映射、文件夹映射。以redmine镜像为例

1
docker run --name redmine -p 9003:80 -p 9023:22 -d -v /var/redmine/files:/redmine/files -v   /var/redmine/mysql:/var/lib/mysql sameersbn/redmine

13、一个容器连接到另一个容器

1
docker run -i -t --name sonar -d -link mmysql:db  tpires/sonar-server

sonar容器连接到mmysql容器,并将mmysql容器重命名为db。这样,sonar容器就可以使用db的相关的环境变量了。

14、拉取镜像

1
docker pull <镜像名:tag>

如docker pull sameersbn/redmine:latest

当需要把一台机器上的镜像迁移到另一台机器的时候,需要保存镜像与加载镜像。

机器a

1
docker save busybox-1 > /home/save.tar

使用scp将save.tar拷到机器b上,然后:

1
docker load < /home/save.tar

15、构建自己的镜像

1
docker build -t <镜像名> <Dockerfile路径>

如Dockerfile在当前路径:docker build -t xx/gitlab .

安装Xmanager全家桶

使用前检查一下是否安装了Xshell、Xstart、Xmanager - Passive,正常安装Xmanager全家桶应该是全的

1529248519265

阅读全文 »

安装

Gitalk提供了两种方式:

  • 直接引入
1
2
3
4
5
6
7
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>

<!-- or -->

<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
  • npm安装
1
2
3
npm i --save gitalk
import 'gitalk/dist/gitalk.css'
import Gitalk from 'gitalk'

相对来说第一种会更简单。

使用

A GitHub Application is needed for authorization, if you don’t have one, Click here to register a new one.

Note: You must specify the website domain url in the Authorization callback URL field.

1
2
3
4
5
6
7
8
9
10
11
const gitalk = new Gitalk({
clientID: 'GitHub Application Client ID',
clientSecret: 'GitHub Application Client Secret',
repo: 'GitHub repo',
owner: 'GitHub repo owner',
admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'],
id: location.pathname, // Ensure uniqueness and length less than 50
distractionFreeMode: false // Facebook-like distraction free mode
})

gitalk.render('gitalk-container')

修改主题文件

不同的主题目录和模板引擎不同,可以自己修改, 修改next主题配置文件_config.yml,添加字段:

1
2
3
4
5
6
7
8
9
10
# Gitalk
# more info please open https://github.com/gitalk/gitalk
gitalk:
enable: false
clientID:
clientSecret:
repo:
owner:
admin: # support multiple admins split with comma, e.g. foo,bar
pagerDirection: first
  • 找到next/layout/_third-party/comments文件夹,新建gitalk.swig文件,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname %}
{% if theme.gitalk.enable %}
{% if page.comments %}
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script type="text/javascript">
const gitalk = new Gitalk({
clientID: '{{theme.gitalk.clientID}}',
clientSecret: '{{theme.gitalk.clientSecret}}',
repo: '{{theme.gitalk.repo}}',
owner: '{{theme.gitalk.owner}}',
admin: '{{theme.gitalk.admin}}'.split(','),
pagerDirection: '{{theme.gitalk.pagerDirection}}',
// facebook-like distraction free mode
distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
{% endif %}
{% endif %}
{% endif %}
  • 同目录下在index.swig文件末尾添加:
1
{% include 'gitalk.swig' %}
  • 下步搞起,next/layout/_partials文件夹下,找到comments.swig文件,添加代码:
1
2
3
{% elseif theme.gitalk.enable %}
<div id="gitalk-container"></div>
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">

因为github限制了issue的提交title长度不能超过50,可能会遇到Error: Validation Failed 按照这里的方案,使用MD5的方式降低长度即可

参考文档

  1. Hexo添加Gitalk评论插件
  2. Next 第三方服务集成
  3. 在hexo next主题上使用gitalk

前言

个人博客自从2016年10月21日搭建以来,迄今为止已经有49 篇日志了。虽然不是很多篇文章,但是搜索站内的内容已经力不从心了。

搜索了网上很多关于“Hexo 站内搜索”的内容,发现大部分都是使用Swiftype,但是发现Swiftype 搜索只有15 天的免费,之后就需要开始收费了。

因为只是为自己的个人博客 使用站内搜索,所以希望找一个类似与Swiftype 的,但是免费的站内搜索。最后找了Algolia 这个免费版本替代。

阅读全文 »

在Linux上编译 xmr-stak

Install Dependencies

AMD APP SDK 3.0 (only needed to use AMD GPUs)

Cuda 8.0+ (only needed to use NVIDIA GPUs)

GNU Compiler

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Ubuntu / Debian
sudo apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..
make install

# Arch
sudo pacman -S --needed base-devel hwloc openssl cmake libmicrohttpd
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..
make install

# Fedora
sudo dnf install gcc gcc-c++ hwloc-devel libmicrohttpd-devel libstdc++-static make openssl-devel cmake
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..
make install

# CentOS
sudo yum install centos-release-scl epel-release
sudo yum install cmake3 devtoolset-4-gcc* hwloc-devel libmicrohttpd-devel openssl-devel make
scl enable devtoolset-4 bash
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake3 ..
make install

# Ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-5 g++-5 make
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 1 --slave /usr/bin/g++ g++ /usr/bin/g++-5
curl -L http://www.cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xvzf - -C /tmp/
cd /tmp/cmake-3.4.1/ && ./configure && make && sudo make install && cd -
sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force
sudo apt install libmicrohttpd-dev libssl-dev libhwloc-dev
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
cmake ..
make install

# TinyCore Linux 8.x
# TinyCore is 32-bit only, but there is an x86-64 port, known as "Pure 64,"
# hosted on the TinyCore home page, and it works well.
# Beware that huge page support is not enabled in the kernel distributed
# with Pure 64. Consider http://wiki.tinycorelinux.net/wiki:custom_kernel
# Note that as of yet there are no distro packages for microhttpd or hwloc.
# hwloc is easy enough to install manually though, shown below.
# Also note that only CPU mining has been tested on this platform, thus the
# disabling of CUDA and OpenCL shown below.
tce-load -iw openssl-dev.tcz cmake.tcz make.tcz gcc.tcz git.tcz \
glibc_base-dev.tcz linux-4.8.1_api_headers.tcz \
glibc_add_lib.tcz
wget https://www.open-mpi.org/software/hwloc/v1.11/downloads/hwloc-1.11.8.tar.gz
tar xzvf hwloc-1.11.8.tar.gz
cd hwloc-1.11.8
./configure --prefix=/usr/local
make
sudo make install
cd ..
git clone http://github.com/fireice-uk/xmr-stak
cd xmr-stak
mkdir build
cd build
CC=gcc cmake .. -DCUDA_ENABLE=OFF \
-DOpenCL_ENABLE=OFF \
-DMICROHTTPD_ENABLE=OFF
make install
  • g++ version 5.1 or higher is required for full C++11 support.
    If you want to compile the binary without installing libraries / compiler or just compile binary for some other distribution, please check the build_xmr-stak_docker.sh script.

  • Some newer gcc versions are not supported by CUDA (e.g. Ubuntu 17.10). It will require installing gcc 5 but you can avoid changing defaults.

In that case you can force CUDA to use an older compiler in the following way:

1
cmake -DCUDA_HOST_COMPILER=/usr/bin/gcc-5 ..

To do a generic and static build for a system without gcc 5.1+

1
2
3
4
cmake -DCMAKE_LINK_STATIC=ON -DXMR-STAK_COMPILE=generic .
make install
cd bin\Release
copy C:\xmr-stak-dep\openssl\bin\* .

Note - cmake caches variables, so if you want to do a dynamic build later you need to specify ‘-DCMAKE_LINK_STATIC=OFF’

Reference xmr-stak

编者注:我们发现了比较有趣的系列文章《30 天学习 30 种新技术》,准备翻译,一天一篇更新,年终礼包。以下是译文,英文标题表示还未翻译,附原文链接;中文标题表示已翻译,附译文链接。

阅读全文 »

1、创建“分类”选项

1.1 生成“分类”页并添加tpye属性

打开命令行,进入博客所在文件夹。执行命令

1
$ hexo new page categories

成功后会提示:

1
INFO  Created: ~/Documents/blog/source/categories/index.md

根据上面的路径,找到index.md这个文件,打开后默认内容是这样的:

1
2
3
4
---
title: 文章分类
date: 2017-05-27 13:47:40
---

添加type: "categories"到内容中,添加后是这样的:

1
2
3
4
5
6
---
title: 文章分类
date: 2017-05-27 13:47:40
type: "categories"
comments: false
---

保存并关闭文件。

1.2 给文章添加“categories”属性

打开需要添加分类的文章,为其添加categories属性。下方的categories: web前端表示添加这篇文章到“web前端”这个分类。注意:hexo一篇文章只能属于一个分类,也就是说如果在“- web前端”下方添加“-xxx”,hexo不会产生两个分类,而是把分类嵌套(即该文章属于 “- web前端”下的 “-xxx ”分类)。

1
2
3
4
5
6
---
title: jQuery对表单的操作及更多应用
date: 2017-05-26 12:12:57
categories:
- web前端
---

至此,成功给文章添加分类,点击首页的“分类”可以看到该分类下的所有文章。当然,只有添加了categories: xxx的文章才会被收录到首页的“分类”中。

2、创建“标签”选项

2.1 生成“标签”页并添加tpye属性

打开命令行,进入博客所在文件夹。执行命令

1
$ hexo new page tags

成功后会提示:

1
INFO  Created: ~/Documents/blog/source/tags/index.md

根据上面的路径,找到index.md这个文件,打开后默认内容是这样的:

1
2
3
4
---
title: 标签
date: 2017-05-27 14:22:08
---

添加type: "tags"到内容中,添加后是这样的:

1
2
3
4
5
6
---
title: 文章分类
date: 2017-05-27 13:47:40
type: "tags"
comments: false
---

保存并关闭文件。

2.2 给文章添加“tags”属性

打开需要添加标签的文章,为其添加tags属性。下方的tags:下方的- jQuery - 表格
- 表单验证就是这篇文章的标签了

1
2
3
4
5
6
7
8
9
10
---
title: jQuery对表单的操作及更多应用
date: 2017-05-26 12:12:57
categories:
- web前端
tags:
- jQuery
- 表格
- 表单验证
---

至此,成功给文章添加分类,点击首页的“标签”可以看到该标签下的所有文章。当然,只有添加了tags: xxx的文章才会被收录到首页的“标签”中。

细心的朋友可能已经发现,这两个的设置几乎一模一样!是的,没错,思路都是一样的。所以我们可以打开scaffolds/post.md文件,在tages:上面加入categories:,保存后,之后执行hexo new 文章名命令生成的文件,页面里就有categories:项了。

scaffolds目录下,是新建页面的模板,执行新建命令时,是根据这里的模板页来完成的,所以可以在这里根据你自己的需求添加一些默认值。

0%