~$ sudo sqlite3 /var/lib/grafana/grafana.db ~$ update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'username'; ~$ .exit
functiontestHelloWorld() localret = testModule.helloWorld("world") luaUnit.assertEquals(type(ret), "string") luaUnit.assertEquals(ret, "Hello, world!") ret = testModule.helloWorld("ming") luaUnit.assertEquals(type(ret), "string") luaUnit.assertEquals(ret, "Hello, ming!") ret = testModule.helloWorld(integer) luaUnit.assertEquals(type(ret), "string") luaUnit.assertEquals(ret, "Hello, ming!") end os.exit(luaUnit.LuaUnit.run())
Run LuaUnit
1 2 3 4 5 6
~$ lua test_helloworld.lua -v Started on Mon Jul 8 15:06:09 2019 testHelloWorld ... Ok ========================================================= Ran 1 tests in 0.000 seconds, 1 success, 0 failures OK
localfunctionhelloWorld(name) -- assert(type(name) == "string", {message="name expects a string"}) iftype(name) ~= "string"then error({message="name expects a string"}) end
returnstring.format("Hello, %s!", name) end
functionmodule.HelloWorld(name) -- Error Handling -- Reference: https://blog.golang.org/error-handling-and-go local success, result = pcall(helloWorld, name) ifnot success then return"", result.message end
~$ lua test_helloworld.lua -v Started on Mon Jul 8 15:42:30 2019 testHelloWorld ... Ok testHelloWorldWrongCase ... Ok ========================================================= Ran 2 tests in 0.000 seconds, 2 successes, 0 failures OK
version=$(go version) regex="([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})" if [[ $version =~ $regex ]]; then echo ${BASH_REMATCH[1]} fi
1 2 3 4 5 6 7 8 9 10
function funcGoVersion { version=$(go version) regex="([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})" if [[ $version =~ $regex ]]; then echo ${BASH_REMATCH[1]} fi }
~$ sudo apt-get install gcin-qt5-immodule Reading package lists... Done Building dependency tree Reading state information... Done Starting pkgProblemResolver with broken count: 1 Starting 2 pkgProblemResolver with broken count: 1 Investigating (0) gcin-qt5-immodule [ amd64 ] < 2.8.6+eliu-0 > ( utils ) Broken gcin-qt5-immodule:amd64 Depends onqtbase-abi-5-5-1 [ amd64 ] < none -> > ( none ) Considering libqt5core5a:amd64 2904asa solution to gcin-qt5-immodule:amd64 10000 Considering libqt5core5a:amd64 2904asa solution to gcin-qt5-immodule:amd64 10000 Done Some packages could not be installed. This may mean that you have requested an impossible situation orif you are usingthe unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help toresolvethe situation:
The following packages have unmet dependencies: gcin-qt5-immodule : Depends: qtbase-abi-5-5-1 E: Unable to correct problems, you have held broken packages.
之前裝 LinuxMint 18 的時候有解過一次這個問題。
解決方法如下
1 2 3
sudo apt download gcin-qt5-immodule ar x gcin-qt5-immodule_2.8.6+eliu-0_amd64.deb vim control.tar.gz
~$ deb http://hyperrate.com/gcin-ubuntu1604 eliu release ~$ deb http://hyperrate.com/gcin-ubuntu1804 eliu release ~$ deb http://hyperrate.com/gcin-ubuntu2004 eliu release ~$ deb http://hyperrate.com/gcin-ubuntu2404 eliu release
Error detected while processing /home/ming/.vim/bundle/vim-copycat/plugin/copycat.vim: line23: E319: Sorry, the commandis not available in this version: python << EOF line24: E492: Not an editor command: import sys line25: E492: Not an editor command: import vim line26: E492: Not an editor command: sys.path.append(vim.eval('expand("<sfile>:p:h:h")')) line27: E492: Not an editor command: import copycat_plugin line28: E492: Not an editor command: EOF
Error detected while processing /home/ming/.vim/bundle/vim-copycat/plugin/copycat.vim: line 28: Traceback (most recent call last): File"<string>", line 4, in <module> File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 11, in <module> import copycat File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 73 print 'noreg {}'.format(name) ^ SyntaxError: invalid syntax
Error detected while processing function <SNR>36_push_into_clip: line 4: Traceback (most recent call last): File"<string>", line 1, in <module> File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 37, indeco result = func(*args, **kwargs) File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 53, incopy copycat.copy(name=name, value=value) File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 96, incopy value = smart_str(value) File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 20, in smart_str if not isinstance(s, basestring): NameError: name 'basestring' is not defined
Error detected while processing function <SNR>36_push_into_clip: line 4: Traceback (most recent call last): File"<string>", line 1, in <module> File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 37, indeco result = func(*args, **kwargs) File"/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line 53, incopy copycat.copy(name=name, value=value) File"/usr/local/lib/python3.6/dist-packages/copycat.py", line 100, incopy clipboard.copy(value) File"/usr/local/lib/python3.6/dist-packages/clipboard.py", line 31, incopy pipe.communicate(text) File"/usr/lib/python3.6/subprocess.py", line 828, in communicate self._stdin_write(input) File"/usr/lib/python3.6/subprocess.py", line 781, in _stdin_write self.stdin.write(input) TypeError: a bytes-like object is required, not 'str'
將 copycat.py 中的 copy 函數改成:
1 2 3 4 5 6 7 8
def copy(value=None, name=None): value = value or not sys.stdin.isatty() and sys.stdin.read()
#value = smart_str(value) with Storage() as storage: storage.save(value, name=name) if not name: clipboard.copy(value.encode('utf-8'))
copy 函數正常後,現在已經可以正常複製,接下來 paste 錯誤訊息:
1 2 3 4 5 6 7 8 9 10 11 12
Error detected while processing function<SNR>36_pop_from_clip: line3: Traceback (most recent calllast): File "<string>", line1, in <module> File "/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line39, in deco set_to_vim(result_reg, result) File "/home/ming/.vim/bundle/vim-copycat/copycat_plugin.py", line25, in set_to_vim if not isinstance(name, basestring): NameError: name 'basestring'is not defined line4: E121: Undefined variable: l:result E15: Invalid expression: l:result
將 copycat.py 中的 paste 函數修改為:
1 2 3 4 5 6 7 8 9
def paste(name=None): with Storage() as storage: if not name: data = clipboard.paste() or storage.get() else: data = storage.get(name) #data = smart_str(data) clipboard.copy(data) return data
打開 copycat_plugin.py 將 set_to_vim 函數改成:
1 2 3 4 5 6 7 8 9 10
defset_to_vim(name, value): #if not isinstance(name, basestring): # return False