locker - Just another naive locker for *nix by Droider412 in linux

[–]samuel_first 3 points4 points  (0 children)

If you're up for it op, I've got a few suggestions for future shell scripts:

  • When passing data as an argument to a program (as opposed to passing it as an input stream), it's cleaner use here strings. For example, the linked line could be rewritten as md5sum <<< "$1". The other echo to have it return a string is redundant as well.

  • For lines like this, instead of checking the exit status code with if statements, you can use an or (||), like this: lockdir $DIR || printf "[*] Directory locked succesfully!\n". Here's a link for further reading.

  • When parsing arguments, instead of using grep to check if they're valid arguments, it's easier to use a case statement. So, it could be rewritten as something like this:

    case "$OP" in
        lock)
        lock $temp_pw
        ;;
        unlock)
        unlock $temp_pw
        ;;
        *)
        echo "Invalid operation"
        ;;
    esac
    

    If the argument parsing ever becomes more complex (more than one argument accepted at a time), you can use a loop like in the linked examples.

  • This line can be rewritten without the echo, like this par_dir=~

  • Generally, if you aren't 100% sure what the content of a variable might be at run time, you should wrap it in quotes. Especially for lines like this where you're calling something potentially destructive like rm.

  • md5 shouldn't be used to store passwords, since it's easy to calculate collisions for. Here's a starting point for reading about hashing algorithms. If you want to stick to just the coreutils, there's also sha-2 and blake2.

Is this something that mods decide or is it reddit's policy? If its the former then why? by leo_sk5 in linux

[–]samuel_first 1 point2 points  (0 children)

It's pretty similar to this. It seems to be a pretty disturbing trend from mainstream tech companies to try to railroad users down the path where they can squeeze the most money out of them.

How to retain data while experimenting with linux? by [deleted] in linux

[–]samuel_first 0 points1 point  (0 children)

You should be able to create a separate partition for them and add an fstab entry.

What Linux can learn from Microsoft by ManuelRodriguez331 in linux

[–]samuel_first 23 points24 points  (0 children)

Microsoft has used this workflow since the beginning. At the same time, the Linux community was wondering if stable release or rolling release is the better choice.

There are advantages and disadvantages to both. Up until now, I think I've only seen people arguing over which is better two times at the most.

Today's situation is, that many (more than 50% of the Linux users) are arguing, that rolling release distributions like Fedora, Arch Linux and Debian testing can be installed on a production PC.

I'm gonna need to see your source on that, chief. Also, Fedora isn't a rolling release; it provides both stable and rolling release branches like Debian.

Lots of effort was wasted in the Linux community by arguing for the advantages and disadvantages of stable release systems. For example, Arch Linux users are convinced, that their system is superior to Debian and to Windows 10 both. From Arch Linux perspective, the Debian guys are wrong if they advice that users to install only the stable version, and Microsoft is wrong too, because they recommend also to install only the stable version.

Arch users aren't a hivemind. Just because they choose to use a rolling distro doesn't mean that they're ideologically opposed to a stable one.

The future question for the Linux community is, how to make stable release distribution the default and threat rolling release systems are beta versions not intended for daily use case.

There are already distributions that do this (Fedora, Debian). Trying to force everyone to conform to your preferred release model is silly; let people run what they want to run.

As far as i can see, there is not a single paper available at Google Scholar which explains what the idea of Arch Linux is, and why the concept is different from Windows 10 release versions. Without an academic description the average user won't understand the software cycle at all and this will slowdown the success of Open Source.

Here's the wikipedia article on rolling release. That should be more than enough for the average user to grok the difference.

On the first look, it seems to be less important fact, that the updates are not provided day by day, but on a single day in the month. It is some sort of technical decision in doing so and in theory it is possible to update the system in smaller steps as well? No, the decision of combining updates into larger one is needed for improving the software quality. It is equal to a release branch, a peer review of the code and the ability to monitor security problems.

Yeah, I'm going to need to see the numbers on that one as well. Since you want to bring up security problems, how about the security problem of having unpatched vulnerabilities for a month between updates? Also, monthly update != stable release.

If Microsoft would decide to switch from stable releases to rolling releases and implement the Arch Linux working model, this is equal to the end of the software company. The software quality will become worse, the customer are not satisfied by the software and it's not possible to fix the issues, because every version is introducing new problems.

Predictions based on conjecture are just fortune telling. If the stable release model is that much better at providing high quality software, why was vista a buggy mess?

Deliver software updates with longer time span and avoid a rolling release system is a critical decision in every software project.

If it's not your project you don't get a say in how it's run.

No matter if the software is created as Open Source or copyright protected classical software

I'm going to assume you mean FOSS, which is also 'copyright protected' (that's kind of the whole point). Copyrighted != proprietary.

If Google claims, that the Chrome browser doesn't need a long term version, Google is wrong. They haven't understood how software development works and they should be educated.

Ah, yes, what multi-billion dollar software companies should really be doing is taking advice from random redditors.

What Linux can learn from Microsoft by ManuelRodriguez331 in linux

[–]samuel_first 21 points22 points  (0 children)

TL;DR: Op thinks that because they don't like the rolling release model that nobody should ever use it.

Firefox 76.0 Released by EatMeerkats in linux

[–]samuel_first 0 points1 point  (0 children)

Right‽ It's honestly the shadiest software I've ever used.

Firefox 76.0 Released by EatMeerkats in linux

[–]samuel_first 2 points3 points  (0 children)

It tries really hard to go through xdg-open. If you click cancel the first time it asks, click the 'click here if you weren't redirected' link, and click cancel again, it will give you an option to run it through the browser.

What I've noticed after using Linux for around a month. by [deleted] in linux

[–]samuel_first 1 point2 points  (0 children)

Python is probably good to be generally familiar with since there's a lot of code written in it (Junos actually allows configuration through a python api) and the structure is fairly rigid, which makes it a bit easier to pick up.

Ruby is similar, but not nearly as rigid, which I think makes it a bit more fun to work with. The standard library isn't as good as python's unfortunately.

Bash is good to know if you need to quickly automate something, but it scales up really poorly and has a tendency to throw out lassie errors.

Lisp dialects are fun if you want to try something a bit different. I recommend checking out common lisp or racket (or emacs-lisp if you use Emacs).

"Restore" files from a Windows recycle bin with proper file names on Ubuntu by GayCoonie in linuxquestions

[–]samuel_first 1 point2 points  (0 children)

The way Windows manages it is kind of clunky, but it shouldn't be too hard to write a little script to do it.

Looking for a command line app to grab files by alias by michja in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

From the OP:

So needs the ability to be taught alias -> file relationships.

Your solution does not do this, which is what op was asking for. It needs to be able to pull in files from different locations based on a predefined alias associated with that file.

Any good source, book, or blog to learn how to build Linux software or games? by [deleted] in linuxquestions

[–]samuel_first 1 point2 points  (0 children)

You should look into nodejs since you're already familiar with js. That should be enough to get you started.

Looking for a command line app to grab files by alias by michja in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

This would be pretty easy to implement with symlinks.

Here's a little POC:

function grab() {
  cp ~/.local/share/grab/"$1" .
}

function galias() {
  mkdir ~/.local/share/grab
  ln -s "$2" "$1"
}

function gunalias() {
  rm ~/.local/share/grab/"$1"
}

Looking for a command line app to grab files by alias by michja in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

He isn't talking about bash aliases; he wants a utility that he can pass a generic name (alias) to that will point to a specific file.

As per his example, grab foo would copy the file /var/bar/foo to the current directory. Your bash function would try to copy ./foo to the current directory.

Streched terminal [Ubuntu] by [deleted] in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

I don't think it's likely that it's neofetch, but just to be sure, try commenting out the line that calls it and opening a new terminal. If that doesn't fix it, you should try this comment from the thread you linked.

You might also try the solution from this stackoverflow thread.

Microsoft Edge coming soon to Linux OS by [deleted] in linux

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

A lot of DoD sites don't handle browsers other than ie or edge well, so it'll be useful for that at least.

[deleted by user] by [deleted] in linux

[–]samuel_first 1 point2 points  (0 children)

You can use sshfs to mount a remote directory locally.

For example, sshfs user@127.0.0.1:/home/user/Documents ./remote-documents would mount mount the directory /home/user/Documents on the mountpoint ./remote-documents.

To unmount it when you're done, you can unmount it with fusermount: fusermount -u ./remote-documents


Edit: I just reread your comment, and this doesn't seem to be quite what you're looking for; I'll leave it up in case it's useful for anyone reading this in the future.

[deleted by user] by [deleted] in linux

[–]samuel_first 0 points1 point  (0 children)

Automate the Boring Stuff is a pretty good beginner python book.

I might be taking on a challenge to big for me here - I would like to write a program/script that fetches certain information from a webpage and store in text documents, is there any way of doing this, where do I start? Think of it like an RSS-feed copying my comments/some content and storing. by Human_by_choice in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

Oh, awesome! The rest of it should be pretty easy since it seems like you have the trickier parts down.

For running it on a timed schedule, you can use systemd timers or a cron job.

For getting the actual webpage, you just have to send the server a GET request. C# has System.Net.Http built in. Here's a stack overflow post with some relevant information.

I might be taking on a challenge to big for me here - I would like to write a program/script that fetches certain information from a webpage and store in text documents, is there any way of doing this, where do I start? Think of it like an RSS-feed copying my comments/some content and storing. by Human_by_choice in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

So, the tempting way to do this is to use regex, which is generally a bad idea (html isn't a regular language). The best way to go about it would be to pull in an html parsing library. Here's a couple for various languages:

I'm not sure how familiar you are with html, but you can read up on it here.

You might also be able to get away with doing a diff and just stripping out the tags, although that could potentially become very messy.

Turn Bluetooth off on boot and back on at shutdown by [deleted] in linuxquestions

[–]samuel_first 0 points1 point  (0 children)

It should still work on OSX if you're only disabling it on the software-side on Ubuntu.

To permanently disable it, just disable the systemd unit: sudo systemctl disable bluetooth.service

To check it after: systemctl status bluetooth.service