💡root is another user, need extra configurations.
1.install it.
1 | pip install --user git+git://github.com/powerline/powerline |
2.run pip show powerline-status
to show where the package is.
3.add its launch script to ~/.bashrc.
💡 e.g. the location of the script on my computer is ~/.local/lib/python3.7/site-packages/powerline/bindings/bash/powerline.sh
goto my vimrc.
there are a few onedrive tools on Linux platform, but most of them, for example onedrive-d
just support personal onedrive account, onedrive 365 as well as onedrive business are not supported. Someone recommended GoodSync
, unfortunately I didn't figure out how on earth do I use it 😢. Good news is I find a thing called onedrive (what a confusing name), which support personal account and onedrive 365 and even onedrive business!
goto abraunegg/onedrive for instructions.
the guide is clear enough! 👍
🔗related question on Stack Exchange
1.install dconf-editor
1 | sudo apt install dconf-editor |
2.open the app and Navigate to org > gnome > shell > extensions > dash-to-dock and check isolate-workspaces
]]>Recently I am working on A Formula E car, trying to do something with data in the car's CAN Bus. The very basic idea is first transmit data into a RaspberryPi.
Reference:
https://www.cowfishstudios.com/blog/canned-pi-part1
https://zhuanlan.zhihu.com/p/30657287 https://zhuanlan.zhihu.com/p/30247549
https://www.gridconnect.com/collections/can-pc-interfaces https://www.raspberrypi.org/forums/viewtopic.php?t=141052 https://www.raspberrypi.org/forums/viewtopic.php?p=524910 https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=7027 https://www.raspberrypi.org/forums/viewtopic.php?p=444938
]]>Here is a tutorial for configuration of VSCode to run C/C++ programs on Windows. Mainly I wrote it for my C/C++ Extension Pack 🎉
Actually how can we run C/C++ code in VSCode has been described clearly in the C++ part of VSCode document, here is just my personal understanding of this work and I suppose my description is more friendly with beginners 😄
VSCode itself is just a editor, can not do things like compilation, even we add VSCode's official extension for C/C++ called cpptools, it does not install a compiler for us.
So undoubtedly, our first step is to install a compiler. There are a few choices, the one recommended by VSCode's document on Windows platform is MinGW-w64.
⚠ we have to notice that there is another thing called MinGW which is different from MinGW-w64. Although MinGW also works, but this project hasn't update for a while and we need more steps to install it. In addition, there should be a reason that VSCode document does not recommend it but MinGW-w64.
after downloaded the installer we are good to start installation, there are mainly two options we have to change and leave the other options as the default:
Architecture
, set it to x86_64 if your computer is 64-bit, set it to i386 if your computer is 32-bit.After the installation we have to add our compiler to the Path so that it can be called from the command line / powershell. (this is actually how VSCode calls the compiler)
But what path to add?
The path add to the Path is actually the folder path of the executable file of the application we want to call. For example I installed MinGW-w64 to D:-w6486_64-8.1.0-posix-seh-rt_v6-rev0, then I should add D:-w6486_64-8.1.0-posix-seh-rt_v6-rev064* to the Path**. You can see the two applications we are going to call, gcc.exe
and gdb.exe
are exactly there ✌
🔗 If you are no sure how to add something to the Path, this may helps you 👍
Now! We can test if we successfully add the compiler to the Path by typing gcc
in the cmd.
✔ What we should see is:
1 | C:\Users\LeoJh>gcc |
❌ What we should not see is:
1 | `gcc`is not recognized as an internal or external command, |
Which means you may have added wrong path to Path.
We are not far from completion as we have successfully get our compiler ready :smile: Actually we are now able to develop C/C++ code! (Although it may seems hardcore) Don't believe? Open cmd and get into te folder where you have a piece of C/C++ code to test, type gcc test.c
or gcc test.cpp
and you will find a a.exe is generated in the current folder. This is exactly the executable file we just compiled!
But this does not feels good, so we use extensions in VSCode to improve the situation.
I recommend my C/C++ Extension Pack since it includes only a few but really useful tools.
In some tutorials it is said that we have to generate c_cpp_properties.json
, tasks.json
, launch.json
three files, but the situation has changed! :tada: c_cpp_properties.json
has been totally replaced by settings in settings.json
. The advantage is that we can set different values for different workspace. Also, you will later see that configuring tasks.json
and launch.json
becomes REALLY easy too!
:link: click here to learn more about what has been replaced by settings.json
in c_cpp_properties.json
.
:link: click here to learn more about what could have been set in c_cpp_properties.json
.
⚠ the following configuration uses my settings as an example.
As mentioned above, we are able to develop C/C++ without VSCode, so, from my point of view, IntelliSense which provides us with smart suggestions is a very important part of language support for C/C++ in VSCode. We could configure the IntelliSense by editing settings.json
. The most useful ones are:
1 | "C_Cpp.autocomplete": "Default", |
the segments C_Cpp.clang_format_style and C_Cpp.clang_format_fallbackStyle specify the format style of how VSC format C/C++ code. The above value makes a code style similar to C/C++ code style in Visual Studio. If you prefer Google Style, the following piece is what you need.
1 | "C_Cpp.clang_format_style": "{BasedOnStyleStyle: Google, IndentWidth: 4}", |
🌟 In latest VSC, things becomes REALLY easy. You can learn how to generate tasks.json
and launch.json
simply by this gif 👇
💡 This gif is recorded under Linux system (Ubuntu).
Following are some explanations of tasks.json
and launch.json
.
Then we generate the tasks.json
to help us compile the code.
✔️ tasks.json
and launch.json
are prepared for specific piece of code as different programs may require different configurations. But if most of your code shares the same configuration, you can put your tasks.json
and launch.json
in the parent folder of all the programs. If a few programs among them require specific configuration, you can generate another tasks.json
and launch.json
in its folder.
After you have generate a tasks.json
following the instruction in VSCode's document, add the following task to the tasks list:
1 | { |
label
is the name of this task, it will be used later.
From this we can see that every time we call this task it actually inputs the following command to shell:
1 | gcc ${file} -o ${fileDirname}/${fileBasenameNoExtension}.exe -g -Wall -std=c++17 |
Things like ${file}, ${fileDirname} are actually variables defined by VSCode.
And the -o
option allows us to specify the name of output file.
The settings about group allow us to call this task by shortcut Ctrl+shift+B
. check this for more details.
So in total my tasks.json
looks like this:
1 | { |
The last thing we need is launch.json
. This is actually a easy task since VSCode provide us with a lot of templates, (normally I use the template (gdb) Launch) only a few options need modification:
1 | "program": "${workspaceFolder}/a.exe" |
program
means the program we want to debug. If not specified, the name of the output file will be a.exe, so the program name is the above one. But if you have specified the name of output file just like what I did in the tasks.json
, you should use this:
1 | "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe" |
Set your debugger path simply by this:
1 | "miDebuggerPath": "gdb.exe" |
And we can easliy find out that gdb will output something useless first every time evoked. We could use option -q
to disable this:
1 | "miDebuggerArgs": "-q" |
If you always forget to compile the modified code before debugging, VSCode provides a very useful option: preLaunchTask. We can specific this task to our task named Compile, so our code will be compiled first every time we start debugging 👍
1 | "preLaunchTask": "Compile" |
So in total my launch.json
look like this:
1 | { |
Congratulations! 🎉 You are now able to develop C/C++ code with VSCode and hope you enjoy it!
]]>This extension includes nearly everything you need for Markdown, the only extra stuff you need are Reflow Markdown and Markdown Emoji.
This extension seems really powerful that it can do nearly everything you can imagine of about Markdown. Unfortunately it seems that it don't support emojis by itself in preview tab either. I have not tried this extension since I have got Markdown All in One
This extension help you to do word-wrap very smartly by simply press Alt+Q
😍😍😍
I LOVE THIS ONE!
This blog site is powered by Hexo, the theme is NexT, the scheme is Pisces
. After I started building my blog with Hexo, I found that actually there are some more Static Site Generators which are considered better than Hexo. You can find a ranking list of the Static Site Generators here. (But if you have already get started with Hexo, it is O.K. At least I think it is good enough)
⚠ the generator named Next in the list is a different thing from the theme of Hexo I use.
Here I want to share about the problems I meet and my custom settings.
This problem is very likely to occur if you simply commit your whole Hexo instance to your master branch.
In fact, only a few themes are supported by GitHub Pages and NexT or any Hexo theme is not included 🤦♂But here is a little trick: the files are rendered at your desktop, simple HTML pages are uploaded to the master branch as the source code of your site. In this way, anytheme can be applied to your blog😄
Therefore, you can not simply commit your Hexo instance to the master branch, what I did is to publish a new branch Root
to store my Hexo instance and use the hexo-deployer-git extension to deploy my site to the master branch.
:warning:your GitHub Pages can only published from the master branch if your repository is named username.github.io
If you haven't installed this plugin, use the following command at the root of your hexo instance.
1 | npm install hexo-deployer-git --save |
check here for the configuration.
Therefore you cannot backup your theme simply committing it to github since it is a subproject. Although a cool solution is provided in #328
, it cannot solve my problem since I did further customization. But I did not try the solution fork+submodule mentioned in #932
. I simply deleted files declaring its identity of a subproject so the theme folder becomes totally a part of my hexo instance.🤦♂ You just need to left these files:
1 | . |
You can also change the theme's name from next
to whatever else, for example LeoJhonSong
:smile:. According to Hexo, you have to then modify the theme setting in your site’s _config.yml
, assigning the name of your theme folder to it.
the issue could be separated in to two situations.
the reason may be:
hexo clean
to delete the cache file (db.json)check if the attributes you changed is valid by Chrome DevTools. The invalid attributes will look like this: color: #fff
color: #fff !important
. It is often not recommanded since it ruins existing CSS and may cause difficulty when debugging. In addition, there is still a low risk it is not raised to first priority 😅 as examples are given hereThe reason could be:
The solution could be:
Ctrl + F5
or Ctrl + Fn + F5
to force the browser to refresh the pagehexo s
to run the site locally to see if something goes wrongadd hexo-filter-github-emojis and then you can use Emojis as you want just like me.✌
if you want to type a emoji but you have no idea what its shortcut is, you could go to emojipedia for help.
Actually this issue is mentioned in github.
this happened to me because I uninstalled hexo-renderer-marked
and installed hexo-renderer-markdown-it
since the markdown-it markdown parser has plenty of plugins🤦♂.
Google Search Console may tells you that there is errors in your site if you did not changed your site's url from http://yoursite.com
to your own root url
in your site's _config.yml
...
It had been mentioned here.
I enabled word count provided by Hexo but the count is definitely larger than it should be. But that is not a problem, it can be seen as a decoration 🙈
I am proud of some settings because I tried and achieved it by myself, despite from simply copying others' code. 😝
Unfortunately, Baidu crawler is blocked by GitHub because Baidu has been used to attack GitHub. Actually poor Baidu did not mean to do this... But to be honest, Baidu is not a lovely search engine since it puts plenty of ads in its search results🙄. So I won't bother solving the issue that Baidu con not find my blog. Besides, this blog is mainly wrote for myself✌.
install hexo-generator-sitemap
go to Google Search Console and add your site.verify it by HTML tag
. There you get a <meta> tag like this:
1 | <meta name="google-site-verification" content="blablablablablabla" /> |
the content
is your verification code.
add following code to your site's _config.yml
:
1 | sitemap: |
run the following code:
1 | hexo d -g |
now your site should have be added the verification tag.
go back to google search console and commit your sitemap. Your sitemap should be named sitemap.xml
.
DONE!
This part! Guys, this is my proud since I worked out my own solution. My work is based on this and this
It is described very clearly in Keep Velocity High's post that a multilingual blog implemented with current tools is not good enough. He's idea of running two isolated blog is a good try and thanks to his great work I don't have to do those works again. But just as the second post pointed out, it becomes too hassle that we have to run two independent site if we just want our site could be shown in more than one language. As a individual blogger I do not have that much time to maintain my blog. I have to run three sites, if I want it can be shown in Chinese, English and Japanese! In addition, if we want to change the style of the blog, we have to repeat the work for each language😨.
The solution mentioned in the second post is also very smart, but there is still some problems.
His idea of deploy two site to one repository is impossible since a repository can only have one home page.
In addition, you need a repository named zh-CN
if you want your chinese site's root url is https://yourname.github.io/zh-CN
it definitely waste a lot of time if we have to copy the markdown files to the source folder every time we generate the public folder.
As we can see, most multilingual site will give each site a different root url. Therefore, I decided to use https://leojhonsong.github.io to be the home of my english site and https://leojhonsong.github.io/zh-CN for Chinese site. That is to say, I need a repository called leojhonsong.github.io and a repository called zh-CN for my blog.
Things are simple until now, but here is the trick: since hexo allows us to add alternate config, we use the site's _config.yml
for settings of the english site as well as the basic settings of the blog and create _config.zh-CN.yml
for settings of Chinese site that differs from english site to override settings in _config.yml
. There, we are able to set different source folder path, public folder path for each language and even different repository to deploy the site😄
The following code are my settings.
in _config.yml
:
1 | # Site |
in _config.zh-CN.yml
:
1 | # Site |
Then after generation your directory should look like this:
1 | . |
By this method, you can easily set up a multilingual blog!
:warning: notice that db.json
is the cache file for generation, that is to say, if you generate the files for Chinese site right after generating files for English site, the English files will be mixed into public/zh-CN, which is annoying. So you should run hexo clean
to delete db.json
every time before generating files for different language.
We can also write a batch script and python script to shorten the commands.
put a.bat
in the root directory:
1 | @echo off |
put multi-language.py
in the root directory:
1 | # -*- coding: UTF-8 -*- |
These will make things much easier. You just need to put these two file in the root of your hexo instance and you are good to go. %1, %2 in the code are the parameters passed to the batch. For example, you can type a c g
in cmd in the root of your hexo instance to generate the Chinese files. a is te name of my batch file as I named it a.bat but of course you can change it to want ever you want. By the way, the file name is also a parameter passed to the batch file, %0. c is the second parameter (%1) passed to the batch and g is %2. It is interesting that the parameter's value could be null, that is to say, if you simply type a
, the English files will be generated and deployed then Chinese files will be generated and deployed. The commands a ne
, a nc
, a na
are used to generate new post.But the best part is that the command a na
will call the multi-language.py to write HTML code to link the Chinese post and the corresponding English post. For example, if you want to new a English post named Hello World and its Chinese version 你好世界, the command should be a na 'Hello World' '你好世界'
Reference here
install the dependencies hexo-generator-searchdb and hexo-generator-search by:
1 | npm install hexo-generator-search --save |
configure settings for hexo-generator-search in site's _config.yml
:
1 | search: |
configure settings for hexo-generator-searchdb in theme's _config.yml
:
1 | local_search: |
In themes/next/source/css/_custom/custom.styl
:
1 | @media (max-width: 425px){ |
To customize the background colors of your site, I recommend this site to you as it provides a lot of cool colors.
Things could be quite simply as most colors can be reset using variables in themes/next/css/_variables/base.styl
and themes/next/css/_variables/YourScheme.styl
. You can preview your custom settings utilizing developer tools of your browser. (Here is how we do this in Chrome DevTools.) After decided your custom settings, you reassign the variables which had been defined in the two yml files mentioned above in themes/next/css/_variables/custom.styl
.
:warning: you have to notice that only if your reassignments are in themes/next/css/_variables/custom.styl
will they take effect. They are invalid if they are put in themes/next/source/css/_custom/custom.styl
. Similarly, any other setting not related to the variables should be written in themes/next/source/css/_custom/custom.styl
.
you could find my custom.styl at the end.
As I see it, the single color font icons used by NexT are a little bit dual. In addition, fontawsome does not have some icons I want.
So I use icons from iconfont instead. This site even provides colorful font icons!
in themes/next/layout/_macro/sidebar.swig
:
1 | {% set sidebarIcon = '<i class="fa fa-fw fa-' + link.split('||')[1] | trim | default('globe') + '"></i>' %} |
comment out but not delete line 108
(the line above) by replacing it with the following line, in case one day you want it back. Then we add a line to use font icons from iconfont.
1 | {# % set sidebarIcon = '<i class="fa fa-fw fa-' + link.split('||')[1] | trim | default('globe') + '"></i>' % #} |
Then add a line after line 100
to import the source code of the icons:
1 | <script src="https:{{ theme.social_icons.source }}"></script> |
create a project in iconfont to collect icons you want to use in your blog.
here is the tutorial of iconfont.
You can log in with GitHub. After added icons you like to your project, choose quote as symbol
and View the Online Link
, copy it and put it in your theme's_config.yml
under the social_icons settings like this:
1 | social_icons: |
simply put the code of your icons after your social links in your theme's _config.yml
like this:
1 | social: |
😆 quite easy right?
find busuanzi_count
in your theme's _config.yml
and enable it.
Reference can be found here
Now suppose there is a image wow.jpg in the asset folder of a post named Hello. We could to use ![wow](wow.jpg)
to insert this image. But the annoying problem is that the image won't show up in your markdown preview unless you use ![wow](Hello/wow.jpg)
. But... the image won't show up on your server if Hello/wow.jpg
is used🤦♂
This is because hexo will put the HTML page index.html of the post Hello and the image wow.jpg into the same folder Hello in public folder.
So I modified following file to create a subfolder of the same name of the post in the folder where the post's index.html is put.
in node_modules/hexo/lib/models/post_asset.js
1 | return pathFn.join(post.path.replace(/\.html?$/, ''), this.slug); |
change line23
from ⬆ to ⬇
1 | return pathFn.join(post.path.replace(/\.html?$/, ''), post.path.replace(/\.html?$/, ''), this.slug); |
Unfortunately, according to my test, the tag method to insert images provided by Hexo does not work as it supposed to anymore after modifying the post_asset.js🤦♂. Since I would use anything but the tags so this doesn't bothers me😁. But if you want to improve this situation, I suppose you should modify **node_modules_img.js**
Search for Valine in your theme's _config.yml
then you just need to follow instructions here.
Although as I mentioned here, some settings only take effet if is put in themes/next/source/css/_custom/custom.styl
while some other should be put in themes/next/source/css/_variables/custom.styl
, but it is a little bit annoying that I have to decide where do I put my settings. So I simply put all the settings in both styl custom.styl😆.
1 | // Custom styles. |
]]>Thank you for reading!
OK. Finally, I build my own sweet little blog independent from annoy Chinese blog sites. It looks far much better don't it?
I plan to 1⃣ log my study experience (I found posting my schedule could force me doing things which I intend to do but not do at last because of laziness) and maybe some casual essay if I have the mood. It is really a good way to arrange your knowledge since there are too many small pieces of knowledge nowadays. Besides, a most important reason is that I want to 2⃣ share the cool things I found as I find it tastes the same with taking drug.
I hope the future me won't forget this.
]]>