Skip to content

Instantly share code, notes, and snippets.

View simlei's full-sized avatar

Simon Leischnig simlei

View GitHub Profile
@simlei
simlei / bt_conn_up.expect
Last active October 22, 2022 07:22
Reconnect bluetooth on raspbian, using PulseAudio pactl and expect
#!/usr/bin/expect -f
# from: https://gist.github.com/RamonGilabert/046727b302b4d9fb0055
set prompt "#"
set address [lindex $argv 0]
set timeout 20
spawn sudo bluetoothctl
# expect -re $prompt
send "connect $address\r"
@simlei
simlei / bt-from-win
Last active April 11, 2020 23:46
copy bluetooth pairing keys from windows for dual boot -- bash script
#!/usr/bin/env bash
#credits \& original idea: https://unix.stackexchange.com/a/255510
if [[ "$1" == "--help" ]]; then
echo usage: $0 "<WindowsPartition>/Windows/System32/config"
echo if youre already in that directory, you will still have to provide that directory. However, you may then just use \$PWD in its stead.
echo this script will read out all your paired bluetooth device keys from the windows registry and show them to you. optionally, it will drop you into VIM at the approximate location at where you will want to edit stuff. This saves you the hassle of browsing the registry by hand with the chntpw command. However, it may be a good idea to read the original stackexchange post \(see below\). This script is written for ubuntu but may work for other distributions. Good luck!
echo
echo Pain points:
@simlei
simlei / bind.bash
Created April 26, 2019 20:23
bash code that handles binds
#TODO: these depend on fzf re-bindings to be present; rip them out and have that code here!
# bind '"\ec": "\C-x\C-addi`__fzf_cd__`\C-x\C-e\C-x\C-r\C-m"'
# bind -m vi-command '"\ec": "ddi`__fzf_cd__`\C-x\C-e\C-x\C-r\C-m"'
bindCmdVi() { #{{{
local binding="$1"
shift
local cmd="$*"
local argNormal="$(printf '"%s": "\C-x\C-addi%s\C-x\C-e\C-x\C-r\C-m"' "$binding" "$cmd")"
local argCmd="$(printf '"%s": "ddi%s\C-x\C-e\C-x\C-r\C-m"' "$binding" "$cmd")"
bind "$argNormal"
@simlei
simlei / YCMToggleLogs
Created May 19, 2018 15:48
YCMToggleLogs with verdin omnifunc - 3 files in one, search for '====' for separators between them with filename
====/tmp/ycm_syhzufb7
2018-05-19 17:44:11,798 - ERROR - Unable to connect to server
Traceback (most recent call last):
File "/home/simon/touchstone/modules/vim/vim-plugins/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/connection.py", line 137, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/simon/touchstone/modules/vim/vim-plugins/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 91, in create_connection
raise err
File "/home/simon/touchstone/modules/vim/vim-plugins/YouCompleteMe/third_party/ycmd/third_party/requests/requests/packages/urllib3/util/connection.py", line 81, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
2018-04-24 23:54:54,957 - DEBUG - No global extra conf, not calling method YcmCorePreload
2018-04-24 23:54:55,081 - INFO - Received ready request
2018-04-24 23:54:55,086 - INFO - Received event notification
2018-04-24 23:54:55,087 - DEBUG - Event name: BufferVisit
2018-04-24 23:54:55,088 - INFO - Starting JediHTTP server
2018-04-24 23:54:55,095 - INFO - Received event notification
2018-04-24 23:54:55,096 - INFO - using port 36010
2018-04-24 23:54:55,096 - DEBUG - Event name: FileReadyToParse
2018-04-24 23:54:55,096 - INFO - Adding buffer identifiers for file: /home/simon/resources.bash/abc.py
2018-04-24 23:54:55,193 - INFO - Received filetype completion available request
2018-04-24 19:59:11,262 - ERROR - Exception in unsafe thread pool executor
Traceback (most recent call last):
File "/home/simon/.vim/plugged/YouCompleteMe/autoload/../python/ycm/unsafe_thread_pool_executor.py", line 43, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 437, in send
raise ConnectionError(e, request=request)
@simlei
simlei / gist:3be3191e5fa03dd1817c0ca04efe7618
Created April 24, 2018 17:58
extra lines after CXX compilation
Collecting regex==2018.02.21
/home/simon/.pyenv/versions/2.7/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/home/simon/.pyenv/versions/2.7/lib/python2.7/site-packages/pip/_vendor/urllib3/util/ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
/home/simon/.pye
2018-04-24 19:40:27,215 - ERROR - Exception in unsafe thread pool executor
Traceback (most recent call last):
File "/home/simon/.vim/plugged/YouCompleteMe/autoload/../python/ycm/unsafe_thread_pool_executor.py", line 43, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/requests/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/requests/requests/adapters.py", line 376, in send
timeout=timeout
simon@UbuntuSP3:~/.vim/plugged/YouCompleteMe$ ./install.py
Searching Python 2.7 libraries...
Found Python library: /home/simon/.pyenv/versions/2.7/lib/libpython2.7.so
Found Python headers folder: /home/simon/.pyenv/versions/2.7/include/python2.7
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
2018-04-24 18:57:12,803 - ERROR - Error while handling server response
Traceback (most recent call last):
File "/home/simon/.vim/plugged/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 79, in HandleFuture
return _JsonFromFuture( future )
File "/home/simon/.vim/plugged/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 239, in _JsonFromFuture
response = future.result()
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
return self.__get_result()
File "/home/simon/.vim/plugged/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
raise self._exception