Please following the core code or clone the project from Github
1 | def getPrice(country): |
Please following the core code or clone the project from Github
1 | def getPrice(country): |
Visual Studio Code
aka VSCode
Microsoft
clone Sublime
project to create a new editor. It’s different with Visual Studio
. VSCode
is more simple, quickly and friendly. I love this project that supports many extensions for improving the experience.
I don’t introduce how to install VSCode
and how to search extensions. I think it’s a easy job. I focus on how to use extensions and how to set up.
C/C++
I’m a embedded system engineer and telecommunication engineer. I often use C/C++
to implement the ideas and do my jobs. VSCode
also recommend this extension.
C++ Intellisense
I use this extensions to find the referneces in my code. It’s a powerful feature like as Source Insight
.
How to set up the environment. Just install global
.
$ brew install global
How to use it. Please go to your project folder and type gtags
$ gtags
Find references
Astyle
Must be formated your code all the time and talk your team to use the same code style.
How to set up the environment. Just install install
$ brew install astyle
You can try the following settings for formatting the code.
$ astyle –style=google -s2 -S -N -L -m0 -M40 –add-braces –delete-empty-lines –convert-tabs –suffix=none
Git History
and Git Blame
To use Git
to manage the project that is the best way. You can try to install Git History
and Git Blame
that provide a simple way to check out your commits.
vscode-icons
Nothing important. It provide VSCode
to display the icons for each file.
CMake
To use CMake
to compile your project that is more powerful than Makefile.
Git is a complex management system but powerful. Sometimes you need to figure out some weird problems. You can read the paragraph if you want to find someone broke the code.
bisect
to find the compiled error commitYou already knowed which committed was good and which committed was bad. That’s try to find out what the problem. Just type
$ git bisect start
$ git bisect good <good commit id>
$ git bisect bad <bad commit id>
Git will help you to checkout each commit for testing the code when you mark the commit is bad
$ make
gcc ... Error 1
$ git bisect bad
You can write the following script to help you find out the bad commit. If compiled error that the script response 1
and vice versa.
1 | #!/bin/sh |
bisect
Use git bisect run
for running the script.
$ git bisect start
$ git bisect good <good commit id>
$ git bisect bad <bad commit id>
$ git bisect run ./find_compile_error.sh
Now you can send the mail to someone, notice him/her to fix the problem.
If you want to exit bisect
, just type
$ git bisect reset
Install jekyll firstly https://pcjustin.github.io/2017/09/17/install-jekyll-on-mac.html
And following the simple way to create your own blog.
1 | $ jekyll new my-awesome-site |
1 | --- |
This file include many features what you want to.
1 | title: My blog |
1 | --- |
1 | $ git add _posts |
Many ways to support visitors counter and post views in your blog. Please following the simple way to support it.
Copy the ‘_includes’ and ‘_layouts’ to your blog. In Mac, you can use the command to find out the folder.
1 | $ open $(bundle show minima) |
1 | <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script> |
1 | <div class="footer-col footer-col-3"> |
1 | <p class="post-meta"> |
Now you can create the own blog or copy others into your blog.
If you want to learn how to use markdown for writing your post, you can following the link.
And you can find out more templates for improving the layout.
To follow this instructions that solve the compiled problem.
To create a cmake file named ‘cross_compile.cmake’
1 | set(CMAKE_SYSTEM_NAME Generic) |
Following the command for cross compiling
1 | $ mkdir build |
Remember that don’t forget the ‘CMakeLists.txt’.
That’s all. Hope it will be worked in your project. I will introduce CMake for next topic.
You don’t care memory size in PC but it is small in the embedded system. This post shows a couple of simple ways to reduce the wasted memory in your code.
Static variables use many memory sizes until the program exits. You should use dynamic allocation if you don’t use as the same as memory each time or you don’t use the variables again.
Compare the memory size with global variable and local variable. global variable use more memory size because the variable alives when the program begins.
global.c
1 | int size[10000]; |
local.c
1 | int main() |
You should refactor your code many times. You can find out many code that can use as the same as the function and variable.
Let’s talking more details about stack and heap and something else.
The stack area contains the program stack, a LIFO structure, typically located in the higher parts of memory. When call function, local variable will put into stack until the function exits. If you write a recursive function, it use many stacks.
Please following the code that use 40 bytes until function ‘run1’ exits.
1 | void run2() { |
The heap area commonly begins at the end of the .bss and .data segments and grows to larger addresses from there. The heap area is managed by malloc, calloc, realloc, and free, which may use the brk and sbrk system calls to adjust its size
Please following the code that use 10 bytes until free the variable ‘str’.
1 | void run3() { |
The BSS segment, also known as uninitialized data, is usually adjacent to the data segment. The BSS segment contains all global variables and static variables that are initialized to zero or do not have explicit initialization in source code.
The .data segment contains any global or static variables which have a pre-defined value and can be modified.
The code segment, also known as a text segment or simply as text, is where a portion of an object file or the corresponding section of the program’s virtual address space that contains executable instructions is stored and is generally read-only and fixed size.
I was writing Makefile and CMakefile and I was thinking how many defines in GCC and Clang. Please following the command to get the GCC defines and it’s compatible with Clang.
1 | $ gcc -E -dM - </dev/null |
1 | #define OBJC_NEW_PROPERTIES 1 |
It’s my fist post. The blog is talking technical, news, blah blah blah, something else.
這是我第一篇文章。此blog將會說些技術、新聞和一些有得沒有的事情。
Mosh is a replacement for SSH. Mosh runs the mosh-server remotely and connects to it over UDP.
Mac
1 | brew install mobile-shell |
Windows
Mosh haven’t native mosh client in Windows. You can install Chrome extensions or install mosh on cygwin.
Download Chrome Extensions
Install mosh on cygwin
1 | C:\setup.exe -q mobile-shell |
Use Chrome extensions to login the server
![](/images/mosh-chrome.jpg)
Create a private key for accessing the system. Recommend to set up passphrase for protecting private key.
1 | $ ssh-keygen -t rsa |
Copy public key to authorized_keys
1 | $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys |
Copy private key into mosh client.
1 | $ cat ~/.ssh/id_rsa |
Click ‘Add ssh key’ to insert private key.
![](/images/add-ssh-key.jpg)
1 | $ git clone https://github.com/pcjustin/pcjustin.github.io.git |
1 | $ git clone |
1 | $ git init new-repository |
1 | $ git add main.c |
1 | $ git commit -m "initial commit" |
1 | $ git remote add origin https://github.com/pcjustin/pcjustin.github.io.git |
1 | $ git push -u origin master |
Please following the Golden rules:
1 | $ git checkout dev |
HEAD~3 means how many commits do you want to combine
1 | $ git rebase -i HEAD~3 |
1 | $ git checkout dev |
Sometimes you need to solve some conflicts.
1 | $ git checkout sandbox/pcjustin/add_hello_world |
Many services support Git for code review. I prefer Gerrit to code reivew that is stable version.
1 | $ git checkout dev |
1 | $ git add main.c |
You need to solve local conflicts.
1 | $ git checkout dev |
1 | $ git-review -d <change id> |
1 | $ git remote prune origin |
To be continued