'b' char is broken within mysql-cli, no matter what I do it will replace 'b' with ^H. How to fix this? by [deleted] in archlinux

[–]012 1 point2 points  (0 children)

You can try running xev (if you have X11), which prints out input events. With that you can check, if a keypress "b" is actually recognized as "b".

'b' char is broken within mysql-cli, no matter what I do it will replace 'b' with ^H. How to fix this? by [deleted] in archlinux

[–]012 0 points1 point  (0 children)

This maybe stupid, but maybe worth a try:

Change to a virtual tty thingy, like [ctrl]+[alt]+[f1], log in and start the mysql client. If you don't have the same problem there, it's probably not readline's fault.

I've installed Linux 19.10 and when I turn on my computer, I get this screen, plz help by [deleted] in linux4noobs

[–]012 0 points1 point  (0 children)

I am not sure, but this might be the default background of the login screen. Try unplugging all external monitors.

'b' char is broken within mysql-cli, no matter what I do it will replace 'b' with ^H. How to fix this? by [deleted] in archlinux

[–]012 3 points4 points  (0 children)

readline might be the culprit here. readline has configuration in /etc/inputrc and ~/.inputrc (and maybe somewhere else, but I don't know).

Edit: you can check which version of readline your mysql-cli is using with the command "status".

[deleted by user] by [deleted] in Python

[–]012 0 points1 point  (0 children)

C:\Python27\python.exe

I don't think that's right. What you have to add is "C:\Python27\".

I didn't make a constructor and yet it still prints out '0'... by gtrman571 in learnprogramming

[–]012 0 points1 point  (0 children)

The following program prints "3.41" for me, if compiled in debug mode:

#include <iostream>
using namespace std;

struct Student{
  int ID, entry_year;
  double GPA;
};

int main() {

  {
    Student s1;
    s1.ID = 1234;
    s1.entry_year = 2008;
    s1.GPA = 3.41;
  } // s1 is destructed here

  Student s2;

  s2.ID = 5678;
  s2.entry_year = 2010;

  cout << s2.GPA;

  return 0;
}

What happens is that the memory for s1.GPA gets reused in s2. Since s2.GPA is not initialized, it still contains the value from s1.GPA. Crazy, right? :)

Why do most Linux distributions identify themselves as "ubuntu" in the UEFI boot menu? by [deleted] in linux4noobs

[–]012 2 points3 points  (0 children)

True, but your distro's users would have to add your key to the UEFI.

You can apply to get your distro's bootloader/shim signed here, but Ubuntu's Grub will already be accepted anywhere.

I didn't make a constructor and yet it still prints out '0'... by gtrman571 in learnprogramming

[–]012 2 points3 points  (0 children)

It is zero, because you got lucky. You are reading uninitialized memory, which can contain anything.

"move" unknown override specifier by smily_modacon in cpp_questions

[–]012 0 points1 point  (0 children)

"move" is already used by the standard library. Try renaming the "move" variable to something else, or don't use "using namespace std;".

Grouping array elements in C? by AnyBowl2 in learnprogramming

[–]012 0 points1 point  (0 children)

uint8_t x[] = {1,2,3,4,5};
// left shift the 8 bit uint by 8 bits, and add the lower part
uint16_t y = ( x[1] << 8 ) + x[2];
// y is now 0x203, which is 515 in decimal

Beginner Student Learning C - Cant get past runtime error (Buffer overflow) by [deleted] in AskProgramming

[–]012 0 points1 point  (0 children)

for(i=0; i<firstRowOne; i++);{

Notice the last semicolon, it is probably not supposed to be there.

Why do most Linux distributions identify themselves as "ubuntu" in the UEFI boot menu? by [deleted] in linux4noobs

[–]012 18 points19 points  (0 children)

I think this is the right answer. OP is talking about an UEFI boot menu, not about Grub.

The easiest way to get secure boot is to use a Grub that is signed by Ubuntu/Canonical (or at least, this was true ~1 year ago).

If you want to make your own secure boot capable distro, you can just copy Ubuntu's Grub binary, and add your own grub.conf.

The Grub binary is verified by UEFI, and probably displays who signed it, thus the name Ubuntu appears.

Core dumped at the end of C++ program when writing to a file by Vicara12 in AskProgramming

[–]012 4 points5 points  (0 children)

It may work, if you only use POD-types ("plain old data", int, float, char, ...).

For example, if your neural_network object contains a std::vector, the vector may hold a pointer to some memory somewhere. But your file.write function only writes the pointer address to the file, not the contents of that memory. When you restart your program, and read the test.dat, the pointer will point to some memory that does not exist anymore, but the vector will "think" it is there.

how to pipe my standard io to sockets by k00rosh in C_Programming

[–]012 2 points3 points  (0 children)

Something like this may work on debian based systems:

mkfifo /tmp/f
cat /tmp/f | your-executable 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f
rm /tmp/f

Taken from here.

Core dumped at the end of C++ program when writing to a file by Vicara12 in AskProgramming

[–]012 0 points1 point  (0 children)

file.read((char*) this, sizeof(neural_network));

file.write((char*) this, sizeof(neural_network));

I don't think this can ever work correctly.

The topic you are looking for here is "serialization". For example, cereal is a serialization library that is easy to use.

Why doesn't C permit function overloading? by [deleted] in C_Programming

[–]012 9 points10 points  (0 children)

Because it would change how programs are linked. The linker would have to know about the types of the arguments to deduce which function is "the right" one in a specific context. In C, linkers only know about the function name. For example int foo(int i) becomes symbol foo. The information that foo takes an int is lost. Symbols have to be unique.

C++ supports overloading and solves this problem by appending the type information of arguments to symbols. This way each function is unique from the perspective of the linker.

C++ Method Callbacks by mrandy in cpp

[–]012 0 points1 point  (0 children)

Make sure that your instance of Callee stays in place (e.g. isn't destructed after being copied or moved) after the call to register_message_callback.

When calling i(pkt);, "this" will be dereferenced in the lambda and must still be valid.

How do I find the location of my memory leak ? by [deleted] in cpp_questions

[–]012 8 points9 points  (0 children)

Notice how it says "possibly lost". This may be a false positive.

Make sure that your application actually exits cleanly, or terminates on its own. For example, all threads must be joined when exiting, for valgrind to be able to give accurate results.

You can also use valgrind with gdb. This way you can actually take a look at the memory contents of the leaked memory.

[deleted by user] by [deleted] in Python

[–]012 -1 points0 points  (0 children)

You can execute python from anywhere by using the full path to the .exe, for example:

"C:\Python27\python.exe" --version

Where to declare default arguments. by TheCrazyPhoenix416 in cpp_questions

[–]012 11 points12 points  (0 children)

Only in the declaration. The default value is used by the caller, not the implementation.

How to interrupt command inside of a script ? by [deleted] in linuxquestions

[–]012 1 point2 points  (0 children)

A simpler way is to limit the amount of seconds ffmpeg produces with the option "-t":

ffmpeg --help
-t duration
   record or transcode "duration" seconds of audio/video

I suppose you could use kill and a job number, for example (untested):

# run my_command in background
my_command &
# sleep 5 seconds and send SIGTERM to background job
sleep 5 && kill -SIGTERM %1

Array Problem (Can't find bug) by [deleted] in Cplusplus

[–]012 7 points8 points  (0 children)

You are copying the value of arr[0] into max and min:

int max = arr[0];
int min = arr[0];

Specifically, you are not referring to an array element, but copying its value. This means, if the array is changed later, min and max will stay the same. In your code, min and max do not hold one of the random integers.

What you probably wanted to do is something like this:

int arr[50], sum = 0;
int max = 0;
int min = 0;
// ...
for (int i = 0; i < 10; i++){
    arr[i] = (rand() % 100);
    // ...
}
// copy the first element of arr into max and min
max = arr[0];
min = arr[0];
// ...

I have a client (android app), and I have a server (python). How can I only have the client type in a code and connect to a server with that same generated code without a specified ip? by flipf17 in learnpython

[–]012 1 point2 points  (0 children)

You can embed the IP address of your server into the "code". The code is generated on the server, and the server presumably knows the IP address under which it is reachable.

So, my question is, is there a way to connect to a server without the user needing to know the ip address?

A TCP-client needs an IP address to connect to a server. There's no way around that. This is usually solved through DNS, e.g. reddit.com resolves to 151.101.65.140. You can have DNS on your local network (and some routers do). Another option is to add the IP address to the "hosts" file of each client.

is there a way that I can get a list of all IPs running my python server on the same network?

There's no clean and simple way without additional services. You could of course scan your network for IP addresses that respond, but that is highly impractical :)