Skip to main content

· One min read
Hreniuc Cristian-Alexandru

Sometimes VSCodium search functionality for extensions doesn't work, or doesn't return the desired results. So to fix this I had to look for an alternative:

Download the extension from VSCode marketplace, it'll be a .vsix file, then do like the image below.

Source: https://github.com/microsoft/vscode/issues/108147#issuecomment-704723949

· One min read
Hreniuc Cristian-Alexandru

I got this error:

⬤ quotes_api ⑂chreniuc_351 ♦ git commit -m "added rule 2.1, 3.2"
error: inflate: data stream error (incorrect header check)
error: unable to unpack 2429559f950ba19b0ce5a9aeedd87820305f36b6 header
fatal: loose object 2429559f950ba19b0ce5a9aeedd87820305f36b6 (stored in .git/objects/24/29559f950ba19b0ce5a9aeedd87820305f36b6) is corrupt
[2]+ Done gitk --all
⬤ quotes_api ⑂chreniuc_351 ♦ git status

I ran git fsck --full and removed all objects that were corupted, but nothing seemed to work.

I've recloned the repository in a different folder and did the following:

$ cd ..
$ git clone someremote newsrc
$ cd src
$ mv .git /tmp/bad-git
$ mv ../newsrc/.git .
$ rm -rf ../newsrc

Explaination: I've used the .git folder of a valid git repository. The changes of the files that were not commited were not lost, they appeared as changed. And then I added them and created a commit.

Drawbacks:

  • you will lose all local branches, when you use the .git folder
  • you will lose all local commits that were on your current branch and were not pushed on the remote. The changes will remain, they will apear as changes that were not added to a commit.

Source

· One min read
Hreniuc Cristian-Alexandru

Get lines that contain the same pattern twice or X times(source):

grep -E "(string.*){2}" file.log

· 7 min read
Hreniuc Cristian-Alexandru

How much faster it is to have a vector of objects instead of pointers.

Compile the code from below and run it:

g++ -std=c++17 -O3 -g -o exe main.cpp

Ussage: ./exe iterations entries_per_vector no_tests [shared_ptr|object] [pre-allocated]

☰ dockerfile ⑂master_interactive* ♦ gcc --version
gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008

Not prealocated: - Storing a vector of objects is 2 times faster.

· One min read
Hreniuc Cristian-Alexandru

Source: https://stackoverflow.com/a/19537899

My server(started from qtcreator in Debug) was sending data to a client and the client crashed ungracefully(CTRL+C), this resulted in two things:

  • SIGPIPE signal was generated(which was handled in my code, but before getting to my code GDB was handleling it, and crashed my server)
  • The server crashed with SEGFAULT when I was running it in terminal with no GDB attached.

So, to investigate the SEGFAULT easier, inside QtCreator, I had to force GDB to ignore the first signal SIGPIPE, I did this by doing thse two steps:

  • uncheck the box "Show a message box when receiving a signal" in Tools -> Options... -> Debugger -> GDB.
  • If you want gdb not to catch a signal but pass it to your program, you need to give gdb a command like the following:handle SIGPIPE pass nostop noprint(see Window -> Views -> Debugger Log or Tools -> Options... -> Debugger -> GDB -> GDB startup script Debugging Helper Customization or Tools -> Options... -> Debugger -> GDB -> Locals & Expressions (like the image below for the SIGPIPE signal)).

· 3 min read
Pamparau Sebastian

This was tested on Debian 10, running KDE.

I bought the following headphones: Coocheer ANC8.

I wanted to use them on a desktop machine running Debian 10 with KDE. Here's what I did:

  1. Since my desktop environment had not bluetooth capabilities, I bought the following Bluetooth USB Adapter: TP-Link UB400. Inserting it in one of the USB ports of my machine, KDE detected it instantly and activated the bluetooth capability.

After this single step, I could see my headphones on the list of available bluetooth devices but got the following error when trying to connect to it (seen in journalctl)

a2dp-sink profile connect failed for 30:21:07:9D:72:05: Protocol not available

· One min read
Hreniuc Cristian-Alexandru

Source: https://stackoverflow.com/a/19271368

You can achieve it in two steps:

1) You need to start nc with a named pipe (fifo) as its input:

mkfifo /tmp/fifoIn; cat /tmp/fifoIn | nc localhost 2222 &

2) Send your data from file input.txt, line by line with 2 sec delay:

cat input.txt | while read line; do echo $line; sleep 2; done > /tmp/fifoIn

I've tested it with this "server" (I'm using openbsd netcat syntax):

nc -l localhost 2222

If you don't want the new-line char after every line use echo -n instead of echo.

· One min read
Hreniuc Cristian-Alexandru

Common flags for sanitizers, here

  1. Redirect report to specific file:
export TSAN_OPTIONS="log_path=tsan_output.log"
./executable

All options that can be set for thread sanitizer can be found here

· 2 min read
Hreniuc Cristian-Alexandru

GDB cheatsheet

Start gdb with coredump:

gdb ./executable coredump

Print all bracktrace:

bt full

Go to a specific frame:

frame 3

Content of an oject of a specific type from a specific address:

print *(class::client::client_data*)0x7f2a10000c50

Content of a variable:

print conn_ptr

Print the content of the object stored in a shared_ptr:

print *shared_ptr_obj._M_ptr

Print the content of std::string:

# 0x7fdaa000f690 is the address of the string.

print *(char**)0x7fdaa000f690

Print a specific element from a vector:

# A shared_ptr to a vector
print *((*vector_shared_ptr._M_ptr)._M_impl._M_start+0)

print *((vector_obj)._M_impl._M_start+0)

Print multiple elements from a vector(ex 9 elements):

# A shared_ptr to a vector
print *((*vector_shared_ptr._M_ptr)._M_impl._M_start)@9


print *((vector_obj)._M_impl._M_start)@9

Source: https://stackoverflow.com/questions/6261392/printing-all-global-variables-local-variables

Type info variables to list "All global and static variable names".

Type info locals to list "Local variables of current stack frame" (names and values), including static variables in that function.

Type info args to list "Arguments of the current stack frame" (names and values).


Print long string(more here):

set print elements 0
print string

Print variable value in a file(more here):

set logging on

print string

set logging off

# The content can be found in gdb.txt
# If you want to change the file run:
set logging file my_god_object.log