参考主页:http://jekyll.com.cn/
gem install jekyll
ERROR: Error installing jekyll: liquid requires Ruby version >= 2.1.0.
查看ruby版本
1
ruby —version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
升级ruby
使用RVM也就是Ruby Version Manager,Ruby版本管理器来升级ruby,RVM包含了Ruby的版本管理和Gem库管理(gemset)。
curl -L get.rvm.io | bash -s stable
会在~/.profile文件中配置环境变量
Add RVM to PATH for scripting. Make sure this is the last PATH variable change. export PATH=”$PATH:$HOME/.rvm/bin”
[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm” # Load RVM into a shell session as a function
测试是否安装正常
rvm -v
rvm 1.29.2 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]
列出已知ruby的版本
rvm list known
安装ruby2.4.1
rvm install ruby-2.4.1
中间报错:
and make sure brew update works before continuing.\n’ Failed to update Homebrew, follow instructions here: https://github.com/Homebrew/homebrew/wiki/Common-Issues
重新安装homebrew(官网:https://brew.sh/index_zh-cn.html)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Fatal: unable to access ‘https://github.com/Homebrew/brew/’: Failed to connect to github.com port 443: Operation timed out Failed during: git fetch origin master:refs/remotes/origin/master –tags –force –depth=1
发现是由于绑定了host所致。。。解除绑定安装成功:
==> Cleaning up /Library/Caches/Homebrew…
==> Migrating /Library/Caches/Homebrew to /Users/Ian/Library/Caches/Homebrew…
==> Deleting /Library/Caches/Homebrew…
Already up-to-date.
==> Installation successful!
rvm install ruby-2.4.1
Install of ruby-2.4.1 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri
gem install jekyll
Done installing documentation for public_suffix, addressable, colorator, sass, jekyll-sass- converter, rb-fsevent, ffi, rb-inotify, listen, jekyll-watch, kramdown, liquid, mercenary, forwardable-extended, pathutil, rouge, safe_yaml, jekyll after 32 seconds 18 gems installed
jekyll
/Users/Ian/.rvm/rubies/ruby- 2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in require: cannot load such file – bundler (LoadError)
gem install bundler
one installing documentation for bundler after 4 seconds 1 gem installed
jekyll
Could not find proper version of jekyll (3.1.1) in any of the sources Run bundle install to install missing gems.
bundle install
Bundle complete! 3 Gemfile dependencies, 17 gems now installed. Use “bundle info [gemname]” to see where a bundled gem is installed.
jekyll server
Configuration file: /Users/Ian/jekyll-blog/_config.yml Dependency Error: Yikes! It looks like you don’t have jekyll-sitemap or one of its dependencies installed. In order to use Jekyll as currently configured, you’ll need to install this gem. The full error message from Ruby is: ‘cannot load such file – jekyll-sitemap’ If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/! jekyll 3.1.1 | Error: jekyll-sitemap
bundle update jekyll
Using jekyll 3.5.0 (was 3.1.1) Bundle updated!
jekyll server
Configuration file: /Users/Ian/jekyll-blog/_config.yml Deprecation: The ‘gems’ configuration option has been renamed to ‘plugins’. Please update your config file accordingly. Dependency Error: Yikes! It looks like you don’t have jekyll-sitemap or one of its dependencies installed. In order to use Jekyll as currently configured, you’ll need to install this gem. The full error message from Ruby is: ‘cannot load such file – jekyll-sitemap’ If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
修改_config.yml,去掉jekyll-sitemap
#container {
float: left;
margin: 0 -240px 0 0;
width: 100%;
}
# 读取文件内容
def fread(self):
# 如果指针位置大于文件大小,说明是更换了文件
self.filename = self.getLogPath()
if not os.path.isfile(self.filename):
while not self.checkfile() :
time.sleep(5)
self.filename = self.getLogPath()
self.fclose()
self.fopen()
self.pos = 0
self.hd.seek(self.pos,0)
fline = self.hd.readline()
self.pos = self.hd.tell()
return fline.replace("\n","")
# 将文件指针定位到文件尾部
def feof(self):
self.fopen()
# 定位到文件末尾
self.hd.seek(0,2)
#设置指针位置
self.pos = self.hd.tell()
关于写倒计时大家可能都都比较熟悉,使用 setTimeout 或 setInterval 就可以搞定。几秒钟或者几分钟的倒计时这样写没有问题,但是如果是长时间的倒计时,这样写就会不准确。如果用户修改了他的设备时间,这样的倒计时就没有意义了。今天就说说写一个精确的倒计时的方法。
本文将介绍如何使用 JavaScript 创建文件,并自动/手动将文件下载。这在导出原始数据时会比较方便。
/**
* 创建并下载文件
* @param {String} fileName 文件名
* @param {String} content 文件内容
*/
function createAndDownloadFile(fileName, content) {
var aTag = document.createElement('a');
var blob = new Blob([content]);
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
很简单对吧,直接调用这个方法,传入文件名和文件内容,程序新建 a 标签,新建 Blob 对象,将文件名赋给 a 标签,同时将 Blob 对象作为 Url 也赋给 a 标签,模拟点击事件,自动下载成功,最后再回收内存。下面我们来看看具体是怎么操作的。
简单来说 Fisher–Yates shuffle 算法是一个用来将一个有限集合生成一个随机排列的算法(数组随机排序)。这个算法生成的随机排列是等概率的。同时这个算法非常高效。
本文主要介绍这个算法的来源、演变、原理。并举出一个例子为大家清晰的描述每次迭代过程。最后使用 JavaScript 代码将算法实现。
我们每次使用命令
git clone git@gitlab.xxx.com:xxxxx.git
默认 clone 的是这个仓库的 master 分支。如果最新的代码不在 master 分支上,该如何拿到呢?如下图所示,最新的代码可能在daily/1.4.1
分支上,我们希望拿到这个分支上的代码。