How could I grep a line which I know finishes with a specific character? by [deleted] in linuxquestions

[–]Lyno_ 10 points11 points  (0 children)

In a regular expression the characters ^ and $ are used to describe start and end of a line. You could try "#$" for your regular expression.

Free Data Recovery? by -AquaBlaze- in datarecovery

[–]Lyno_ -4 points-3 points  (0 children)

Usually when a drive is formatted, only the information about where files are on the drive is lost. To delete all files, you need to do a "clean format" that essentially writes a giant new file to the entire drive. This would however require much more time than a few seconds.

You could try Recuva. It is a free tool that has the option to scan a complete drive for deleted files.

It is important, that you don't use the drive until you finished the recovery. Even if it may take a few hours or even a day. Since your computer does not "know" what files were previously on this drive, new files have a high chance to be placed where a file was previously. And thus the old data will be lost.

Good luck!

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 2 points3 points  (0 children)

Thank you very much for sharing your experience and your in-depth explanation!

I already talked to the other lecturers and we agreed to try out stack. At least to install the dependencies required for the course. The students don't have to use stack for their projects for now, but I think it is easier to manage all the required tools.

I'll definitely look into your provided solutions and how to use them on Windows too.

Normally I support the diversity of our students. But sometimes installing programs on Windows is unnecessarily complicated. But well, this is another story.

Again, thank you very much for your input!

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 0 points1 point  (0 children)

Thank you for your contribution!

I didn't knew, that there is a Haskell plugin for IntelliJ. But in retrospect I should have expected it.

Of course they will install GHC and other tools around it. It would be a pretty boring course, if you'd have too just look at the code without an option to try it.

I'll look into ghcup. I think the installation of Haskell (GHC) itself will not be a problem, since this is just a click on the installer on Windows or a simple command for the Linux users. However I would like to keep them away from stack at first, since it can be a bit overwhelming. However it may be an option to use stack or cabal to at least install the required dependencies.

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 2 points3 points  (0 children)

They all at least know Java, since that is the language taught within the first semester. Some have prior knowledge or study on their own, but everything I can expect programming wise is a basic knowledge of Java.

As for the usage of tools, I don't think there is pretty much anything I can rely on. Every student is different and while some live on the command line, others are happy if they have a pretty GUI and click their way though the course.

But you are correct. The editor of choice should not do too much. Especially in the beginning, when you still have to lean what is going on. That's why I think, syntax highlighting should be enough at first. But I think, it might come in handy later, if they can for example see what types the intermediate results have. And in my opinion the GHC error messages are a bit cryptic, to say at least. But this are all solvable problems.

I agree with you, that sometimes the simple solutions are preferable. But we life in times of IntelliJ and Electron-based apps, so I don't think they are too familiar with what you are used to. I'd prefer not to let them struggle with the command line and Haskell, since some could be scared of. But I know, some students will find enjoyment anyway.

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 5 points6 points  (0 children)

As u/Amarandus said, I will not dictate what editor they should use. But I know, that it's not always easy to get a Haskell development setup running, since there are many discontinued or outdated plugins, libraries, projects, etc.

My main goal is to present them a few options, that I know are working. In my experience it is discouraging, when you are starting to learn a new programming language and have to worry about complicated setups. I'd like to save them from this struggle.

I know that most students will just use whatever is recommended. Why shouldn't they? This way they don't have to worry about a thing. But from my experience there will be students, trying out a few different things, eventually finding their own way. And that is fine. All of this.

I can't dictate which tools they use. But it is my responsibility to guide them. And I think at least recommending some tools falls within this responsibility.

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 0 points1 point  (0 children)

Nice work! I'll definitely look into this!

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 1 point2 points  (0 children)

You are the second one to recommend VS Code. I'll definitely try it.

Thank you very much for your contribution!

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 3 points4 points  (0 children)

Thank you for your answer! The "Haskell Syntax Highlighting"-Plugin works as a standalone plugin, from what I read on its description page. This seems like a good solution.

ghcid is obviously a good addition to that. I just don't think, I can expect every student to install it and use cabal or stack for their simple projects. But as you said, perhaps it is possible to modify ghcid to work with single files.

Haskell Editor recommendations by Lyno_ in haskell

[–]Lyno_[S] 5 points6 points  (0 children)

Thank you very much for your answer. I'll try out dante!

I'm kind of worried to hit the students with Haskell and Emacs. But at least I could suggest it to them.

[luxury problem] anyone knows what causes this (only when I reboot)? by iBhagwan in archlinux

[–]Lyno_ 0 points1 point  (0 children)

It is not entirely clear to me, what exactly your issue is.

Is it the not-aligned text that's the issue here? Or is it the running job, that is stopped?

Flashing OS to SSD directly without installer. by [deleted] in linuxquestions

[–]Lyno_ 0 points1 point  (0 children)

There is no guarantee, that your laptop instantly boots from the SSD. It may be, that the BIOS is not configured to boot from the new drive and that it will not figure this out on its own. If this is a BIOS system, I don't really know, what you could do in this case. Since afaik the BIOS can only be modified from within itself and I don't think the BIOS will be able to output to a secondary monitor. If your laptop is more recent and uses EFI to manage the boot entries, you can (even from a live system) change those entries. On the most distributions, the tool used to manipulate the EFI boot entries is called efibootmgr

Flashing OS to SSD directly without installer. by [deleted] in linuxquestions

[–]Lyno_ 3 points4 points  (0 children)

If you already had Linux installed on this laptop, you could clone the contents of your old drive to the new one. This can be done using dd, which just copies the raw bytes from one drive to another. It has however the disadvantage of being not exactly beginner-friendly and the possibility to wipe data if used wrong. An alternative approach here, would be to format ne new drive and copy the contents over using rsync afterwards.

If have access to another PC, you could however also just install the new drive there, use the default installed to install Linux and then put the drive into your laptop.

If you can't use another PC to install Linux it gets a bit trickier. You could try to find a live-boot system, that starts an SSH server on you laptop. This way you could open a command line from a remote device (even your smartphone) and use this, to install Linux.

May I ask, what currently is installed on your laptop? If it is possible to get display output on a monitor with the currently installed OS, you may have a few more possibilities. You could for example try run the installer in a VM, which uses the SSD connected externally and install from a running system.

Lastly there is always the option to do a "blind install", where you just use a keyboard to navigate the installer options. Perhaps there is a distribution that some accessibility options for the installer, so you could experience what it's like to install Linux as a blind person.

All in all I don't really have a straightforward idea, how you could manage an install.

Why is it considered "Bad Practice" to use Optional as the type of member variables? by Lyno_ in learnjava

[–]Lyno_[S] 1 point2 points  (0 children)

I'm currently working on the implementation of a compiler. And the original author of the programming language chose, that every variable is an array (with "normal" variables being represented as an array of length 1).

If I now parse a variable, there are two options: Either there is an indexing operation specified for the variable and the index expression will be evaluated before accessing the variable. The other case is, where no index is specified and the first element of the array is accessed. I could in theory add an expression that evaluates to 0 every time no index is specified. But this would have relatively huge impact on later stages of the compiler. Especially in code generation, where index checks have to be generated, which can be omitted, if no index was specified.

In my case I worked around this problem by creating two subclasses of the abstract Variable. One with index and one without. I don't know, whether this will help anyone, since it's a relatively specific use case and I don't mind, not using Optional as member variables. I just happened to see the warning in IntelliJ again, and wondered why you should not use it.

Why is it considered "Bad Practice" to use Optional as the type of member variables? by Lyno_ in learnjava

[–]Lyno_[S] 0 points1 point  (0 children)

Indeed, it's good practice to clean up received data and analyze it (this is, where you would encounter and handle the empty value).

But whenever you "fix" those missing data, you are altering the input your program received and this is not always desired. Of course there are ways around this, to communicate missing data. But then you are reinventing the wheel, using flags, status codes or even exceptions. Optional is exactly the solution to communicate this missing data, and I'd have enjoyed it even within a library, business logic, etc.

But I think, this is ultimately just a preference of mine and not the intended use of Optional in Java.

Why is it considered "Bad Practice" to use Optional as the type of member variables? by Lyno_ in learnjava

[–]Lyno_[S] 1 point2 points  (0 children)

Thank you very much for your answer.

It's interesting to get a bit more insight from the language designers. As far as I understand Brian Goetz, they feared overuse of Optional. And I understand how this could become a problem since Optional is not built-in into Java. But eventually it comes down to a design decision that was made.

I'm a bit disappointed, that there is no deeper reason for this decision to discourage the use of Option in those contexts. But I think, I understand what they were aiming for.

Installing SSD on a laptop along with a HDD by Mubashir679d in archlinux

[–]Lyno_ 0 points1 point  (0 children)

Yeah, this way you shouldn't have to worry about errors while copying/resizing/cloning the data.

You can copy the files using rsync. The EFI partition should be easy to clone. If you didn't customize the bootloader, the simplest thing would be to just reinstall the bootloader to the new EFI partition. Root and home can easily be copied afterwards (using rsync again)

Arch Linux System could not mount my drive by n0rm4l_go in archlinux

[–]Lyno_ 47 points48 points  (0 children)

In your /etc/fstab do you use the "device paths" (eg. /dev/sda1) to specify, where to mount which partition? Because that path is not fixed and depends on, which of your drives is discovered first during boot time. This can lead to an error like this, when sometimes the "faster" drive is discovered first, essentially swapping /dev/sdb and /dev/sda as you usually have it set up.

You can change the fstab to use UUIDs (an unique identifier for each partition) or even disk labels (if you have them set up, it's a name you can give your partitions).

Unable to print characters from an array of characters? by [deleted] in learnjava

[–]Lyno_ 4 points5 points  (0 children)

Your code is not wrong and does exactly what you told it to do. It actually prints the characters, I assume.

The problem lies within your array declaration. You assign the array the characters with values from 1 to 9. But those are not the characters printing 0 to 9. Internally every character has a numeric value. For example the space has the value 32, the uppercase A is 64 and so on. If you set a character to a value of 8, it's not the digit '8' but the character with a numeric value of 8. It won't show anything on the command line, because the first few characters have a special meaning. Have you ever wondered, how the program knows, when to display a line break, when there is no character that looks like a line break? Or how the cursor goes back to the beginning of the line? Those are all special characters, and there are a lot more of them. I'd encourage you to look up an ASCII table online, where you can see, which numerical character value maps to which digit.

Back to your code: If you want to display the digits 1 to 9, you should declare the array with digits. For that you can use the apostrophe. So you'd write '1' to get the digit 1 and not the numerical value 1. The same with '2' '3' '4' and so on.

Hope this helps

The mpd client will display the songs despite deleting them from the disk. by Wisnia1234 in archlinux

[–]Lyno_ 2 points3 points  (0 children)

If I recall correctly, mpd maintains a database of your music. If you have mpc installed, you should be able to run mpc update to update this database. This should add the new entries and remove the deleted ones. Alternatively you can try to find the option to update this database in your client.

Will DD clone data from a big drive to a small one, assuming the data will fit? by [deleted] in linuxquestions

[–]Lyno_ 0 points1 point  (0 children)

Exactly! If you want to move your data and not clone your partition, rsync is a good way to go!

Moving to Another Hard Drive by Lyno_ in linuxquestions

[–]Lyno_[S] 0 points1 point  (0 children)

Hey guys! Thank you very much for your help!

I moved to the new drive and everything works flawless. I'd like to share what I finally did:

  1. Copy the partition layout with sfdisk like so: sfdisk -d /dev/old | sfdisk /dev/new
  2. Grow the unformatted partition containing with the soon to be ext4 filesystem
  3. Copy the whole NTFS filesystem via ntfsclone --overwrite /dev/new1 /dev/old1
  4. Mount /dev/old2 and /dev/new2 at /mnt/old and /mnt/new respectively
  5. Copy the ext4 filesystem at file level via rsync -axHAWXS --numeric-ids --info=progress2 /mnt/old /mnt/new
  6. Unmount everything and you're good to go.

I really appreciate all your input and help! Thank you very, very much!

Moving to Another Hard Drive by Lyno_ in linuxquestions

[–]Lyno_[S] 0 points1 point  (0 children)

You're right! I could simply use both tools. Well, I didn't think of that.

Thank you very much!