Skip to content

Instantly share code, notes, and snippets.

View pansila's full-sized avatar

Lix Zhou pansila

View GitHub Profile
@pansila
pansila / gist:d9d084bf7090b5851bcdceb959a61b0f
Created April 2, 2018 09:29
Remove a file in the git database permanently
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch FILE_PATH' --prune-empty --tag-name-filter cat -- --all
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
@pansila
pansila / gist:f0b25c1fdaef400f43f4a65b5ac67f60
Created April 4, 2018 13:00
How do I relocate the docker images?
First, all images are stored in the Hyper-V drive
C:\Users\Public\Documents\Hyper-V\Virtual hard disks
In Windows 10,
Stop docker etc
Type “Hyper-V Manager” in task-bar search box and run it.
Select your PC in the left hand pane (Mine is called DESKTOP-CBP**)
Right click on the correct virtual machine (Mine is called MobyLinuxVM)
@pansila
pansila / cull_violation.py
Last active August 16, 2018 08:58
Cull violations against a patch set of git from a complete cpplint result file
#!/usr/bin/python
import sys, os
from sys import argv
from unidiff import PatchSet
import subprocess
def parse_log_line(line):
"""
parse a line from the cpplint results with --output=vs7
@pansila
pansila / cpplint-function-opening-brace.patch
Last active August 28, 2018 04:00
Patch of cpplint to filter whitespace/braces for opening brace of C function
diff --git a/cpplint.py b/cpplint.py
index 95c0c32..fc8f6ba 100755
--- a/cpplint.py
+++ b/cpplint.py
@@ -3897,6 +3897,8 @@ def CheckBraces(filename, clean_lines, linenum, error):
# within the 80 character limit of the preceding line.
prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
if (not Search(r'[,;:}{(]\s*$', prevline) and
+ # test a C function definition
+ not Search(r'(void\s*|\(\s*|\w+(\s+\**\w+)+(,\s*\w+(\s+\**\w+)+)*\s*)\)', prevline) and
@pansila
pansila / cpplint-mixture-indent.patch
Last active August 28, 2018 07:09
Patch of cpplint to detect mixture uses of tabs and spaces for indent
diff --git a/cpplint.py b/cpplint.py
index 95c0c32..b8cabad 100755
--- a/cpplint.py
+++ b/cpplint.py
@@ -4466,6 +4466,9 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
if line.find('\t') != -1:
error(filename, linenum, 'whitespace/tab', 1,
'Tab found; better to use spaces')
+ if Match('^\s* \t', line) or Match('^\s*\t ', line):
+ error(filename, linenum, 'whitespace/indent', 1,
diff --git a/cpplint.py b/cpplint.py
index b8cabad..769a61a 100755
--- a/cpplint.py
+++ b/cpplint.py
@@ -3564,7 +3564,7 @@ def CheckParenthesisSpacing(filename, clean_lines, linenum, error):
line = clean_lines.elided[linenum]
# No spaces after an if, while, switch, or for
- match = Search(r' (if\(|for\(|while\(|switch\()', line)
+ match = Search(r'\b(if\(|for\(|while\(|switch\()', line)
@pansila
pansila / c-macro-comment.py
Created September 11, 2018 02:58
Add comments to mark the start and stop position of C macro directives, including ifdef, else, endif, etc., to make them more legible
#!/bin/python
import sys, os
import argparse
class macro_directive(object):
def __init__(self, name, comment):
self.name = name[1:] if name[0] == "#" else name
self.comment = comment
self.path = True
@pansila
pansila / README.md
Last active December 14, 2018 14:19
An enhanced patch to enable support of markdown for robotframework
@pansila
pansila / xilinx-xc6v.cfg
Created January 28, 2019 09:17
bitfile download configuration for openocd
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME xc6v
}
set XC6_CFG_IN 0x05
set XC6_JSHUTDOWN 0x0d
set XC6_JPROGRAM 0x0b
set XC6_JSTART 0x0c
@pansila
pansila / my_configs.vim
Created April 15, 2019 07:42
my VIM config file
scriptencoding utf-8
set tabstop=4 " 设置制表符(tab键)的宽度
set softtabstop=4 " 设置软制表符的宽度
set shiftwidth=4 " (自动) 缩进使用的8个空格
set cindent " 使用 C/C++ 语言的自动缩进方式
set cinoptions={0,1s,t0,p2s,(03s,=.5s,>1s,=1s,:1s "设置C/C++语言的具体缩进方式
" set backspace=2 " 设置退格键可用
set undofile " Persistent undo even through restart
set undodir=$HOME/.vim/undo