linux – new to bash scripting and coding in general looking form some feedback and constructive criticism

Just looking for some feedback and constructive criticism. This is the second script I ever made. Just recently started learning the basics. Anyway just wanted to post the script and see if maybe I can get some input on where I can maybe do things better. The script is for extracting the compressed file types you run into the most on Linux. I added the option to extract to a directory of the users choosing and not just keep it limited to only the working directory. I feel like I have to many if then statements and they can somehow be better but Im not sure. And not sure if I Implemented the exits the right way. Some of you are probably gonna cringe when you see this lol! Anyway if you can help thanks.

#!/bin/bash

error() {
    echo "For help, type: nzip -h"
}

usage() {
    echo "Usage: nzip (FILE)..."
    echo "By default file(s) will be extracted to the working directory."
    echo
    echo "OPTIONS.."
    echo
    echo "-d, --directory, eg. nzip (file) (-d) (directory)"
    echo
    echo
}

if ( $# -eq 0 )
then
    error >&2
    exit 1
fi

if ( $# -eq 1 )
then
    case $1 in
        -h) usage
            exit 0
            ;;
        *.7z) 7z e "$1"
            ;;
        *.tar.bz2) tar xjvf "$1"
            ;;
        *.tar.gz) tar xzvf "$1"
            ;;
        *.rar) unrar e "$1"
            ;;
        *.tar) tar xvf "$1"
            ;;
        *.bz2) bunzip2 "$1"
            ;;
        *.tbz) tar xjvf "$1"
            ;;
        *.gz) gunzip "$1"
            ;;
        *.tgz) tar xzvf "$1"
            ;;
        *.jar) unzip "$1"
            ;;
        *.xz) tar xvf "$1"
            ;;
        *.zip) unzip "$1"
            ;;
        *.Z) uncompress "$1"
            ;;
        *) echo "No extraction option for $1" >&2
            exit 1
    esac
    exit 0
fi

if ( $# -eq 3 ) && ( "$2" = "-d" )
then
    case $1 in
        *.7z) 7z e "$1" -o"$3"
            ;;
        *.tar.bz2) tar xjvf "$1" -C "$3"
            ;;
        *.tar.gz) tar xzvf "$1" -C "$3"
            ;;
        *.rar) unrar e "$1" "$3"
            ;;
        *.tar) tar xvf "$1" -C "$3"
            ;;
        *.bz2) bunzip2 "$1" -c > "$3"
            ;;
        *.tbz) tar xjvf "$1" -C "$3"
            ;;
        *.gz) gunzip "$1" -c > "$3"
            ;;
        *.tgz) tar xzvf "$1" -C "$3"
            ;;
        *.jar) unzip "$1" -d "$3"
            ;;
        *.xz) tar xvf "$1" -C "$3"
            ;;
        *.zip) unzip "$1" -d "$3"
            ;;
        *.Z) uncompress "$1" -c > "$3"
            ;;
        *) echo "No extraction option for $1" >&2
            exit 1
    esac
else
    error >&2
    exit 1
fi
```

security – Am I really understanding how the “Trezor Model T”, and hardware wallets in general, work?

Getting increasingly paranoid about losing my coins, I’ve yet again (for probably the 20th time by now) went looking for hardware wallets. The only semi-reasonable one seems to be the two Trezors. All the others seem fishy/unreliable to me.

But as I read and watch and listen, it seems like even the “premium” Trezor Model T requires “OS support” and even to go to a webpage (not hosted on the device itself) to actually use it. Its operations are not at all self-contained in the device itself.

Up until now, I always had the idea that the Trezors (even the first model) is entirely self-contained, and only plugs into a computer in order to use its network capabilities to be able to send coins and update its data. (Of course, doing all the validations and verifications on the device, so it doesn’t have to trust the network or the computer it’s plugged in to.)

Actually, I vaguely had the idea that I would be able to buy one and then physically take it with me somewhere, without any computer around, and sort of “beam” any amount of my coins into another person’s Trezor or even other hardware wallet…

None of this seems to be the case. Even the expensive model with the touch screen appears to be entirely reliant on the “host computer” to do anything besides storing the coins. I bet the special Trezor “coin control panel” webpage doesn’t even support my browser (I don’t run spyware), and who knows how long that will stay online? I don’t want to rely on some company’s website, or require special “OS support” for my hardware wallet. That’s why it’s a hardware wallet! For it to be stand-alone.

Am I missing something fundamental? Are there no “actual” hardware Bitcoin wallets which can do everything by themselves: send and receive coins without any computer? I don’t even have wireless Internet at home, but most people apparently have, so I definitely expected it to be using “wifi” on its own, but this doesn’t seem to be the case?!

I really tried to find this out by myself before asking.

general topology – Showing that $(X,mathscr T)$ is a topological vector space.

Let $X$ be a vector space. Let $mathcal B$ be a collection of subsets of $X$ containing $0$ satisfying the following properties $:$

$(1)$ $mathcal U, mathcal V in mathcal B implies exists mathcal W in mathcal B$ such that $mathcal W subseteq mathcal U cap mathcal V.$

$(2)$ $x in mathcal U in mathcal B implies exists mathcal V in mathcal B$ such that $x + mathcal V subseteq mathcal U.$

$(3)$ $mathcal V in mathcal B, x in X implies exists 0 neq lambda in Bbb C (text {or} Bbb R)$ such that $lambda x in mathcal V.$

$(4)$ $mathcal U in mathcal B implies exists mathcal V in mathcal B$ such that $mathcal V + mathcal V subseteq mathcal U.$

$(5)$ $mathcal U in mathcal B implies lambda mathcal U subseteq mathcal U, forall lambda$ with $|lambda| lt 1.$

Then $mathcal B_1 = {x + mathcal U | mathcal U in mathcal B }$ is a base for a topology $mathscr T$ on $X$ which makes $X$ a topological vector space.

$textbf {Attempt} :$ First of all it is clear that $$bigcuplimits_{x in X, mathcal U in mathcal B} x + mathcal U = X.$$ Now let $x + mathcal U, y + mathcal V in mathcal B_1$ such that $(x + mathcal U) cap (y + mathcal V) neq varnothing.$ Let $z in (x + mathcal U) cap (y + mathcal V).$ Then $(z – x) in mathcal U$ and $(z – y) in mathcal V.$ So by property $(2)$ it follows that there exist $mathcal V_1,mathcal V_2 in mathcal B$ such that $(z – x) + mathcal V_1 subseteq mathcal U$ and $(z – y) + mathcal V_2 subseteq mathcal V.$ Let $V’ = mathcal V_1 cap mathcal V_2.$ Then by property $(1)$ there exists $mathcal W in mathcal B$ such that $mathcal W subseteq V’.$ Then $(z-x) + mathcal W subseteq (z – x) + mathcal V_1 subseteq U$ and $(z – y) + mathcal W subseteq (z – y) + mathcal V_2 subseteq mathcal V.$ In other words $z + mathcal W subseteq (x + mathcal U) cap (y + mathcal V).$ This shows that $mathcal B_1$ is a basis for a topology $mathscr T$ on $X.$

Now let $x,y in X.$ Take a basic open set $z + mathcal U$ containing $x + y,$ for some $z in X$ and $mathcal U in mathcal B.$ Then $(x + y – z) in mathcal U.$ So by property $(2)$ it follows that there exists $mathcal V in mathcal B$ such that $(x + y – z) + mathcal V subseteq U$ i.e. $(x + y) + mathcal V subseteq z + mathcal U.$ Now consider the open neighbourhood $(x + mathcal V) times (y + mathcal V) in V times V$ of $(x,y).$ Then $(x + mathcal V) + (y + mathcal V) = (x + y) + mathcal V subseteq z + mathcal U.$ This shows that the binary operation $(x,y) mapsto (x + y)$ is continuous with respect to the topology $mathscr T$ on $V.$

But I find difficulty to prove continuity of the scalar multiplication. I tried to proceed as follows $:$

Let $lambda in Bbb C$ and $x in X.$ Let $z + mathcal U in mathcal B_1$ be a basic open neighbourhood of $lambda x.$ It implies that $(lambda x – z) in mathcal U.$ Therefore by property $(2)$ there exists $mathcal V in mathcal B$ such that $(lambda x – z) + mathcal V subseteq mathcal U$ i.e. $lambda x + mathcal V subseteq z + mathcal U.$ Now I take $0 lt varepsilon leq 1.$ Then take the open set $B(lambda, varepsilon) times (x + mathcal V).$ Can we somehow say that for $lambda’ in B(lambda,varepsilon)$ we have $lambda’ x + lambda’ mathcal V subseteq lambda x + mathcal V $? What I know by property $(5)$ that $(lambda’ – lambda) mathcal V subseteq mathcal V.$ Does it help anyway? Also how do I show that this topological space is Hausdorff? Any help in this regard will be highly appreciated.

Thanks in advance.

How to optimize the structure of a general site?

I have very varied contents.

For each of these contents, a lot of information to classify.

There are two options :

  • create a single type of content, many fields (more than 100) and play on the presentation with field group or conditional fields, or
  • create different types of content (approximately 5), and the
    corresponding fields.

In the long term, what is the preferred option?
In terms of performance, maintainability?

Trying to ask the moderator a question but don’t have 20 rep to ping in general Chat. How do I PM the moderator?

The site doesn’t have any “private message” mechanism. This is very much by design. Luckily, site moderators are the one kinda-sorta exception: if you flag a post, one of your options is to send a message to a moderator. They can then initiate a private discussion with you.

That would not be the recommended solution to this situation, however.

Instead, you should learn a little bit more about who we are and what this site is about.

We don’t accept questions asking for interest in playing games here; that’s not what the site is about. We ban questions looking for groups, questions looking for GMs, and so on, too—in all cases, those just aren’t on-topic here. Questions can’t be open-ended like that, they have to be actual questions that can at least theoretically have actual answers. As in definitive, comprehensive, authoritative answers that can become a resource for future readers. Most of our site rules are geared towards encouraging these sorts of questions, and filtering out others which are better-handled on other sites. (By the way, we do have recommendations for discussion forums, which may be more interested in hosting discussions of a new game with the game’s creators.)

Links to your game are acceptable if and when it is appropriate content for an otherwise-valid question. We also expect those who are related to a product to disclaim that affiliation, just so readers know what they’re getting. And if your only reason for being here, and only content you contribute, is about your game, you might also get the cold shoulder for that.

For example, when I first joined this site, I was at the time a writer and designer for Rule of Cool, working on their game Legend. Like you, I had similar interests in getting the word out about the game. But the way I handled this was to start a meta discussion on the appropriateness of that, which is where the site agreed that the best solution was, as I said, to only allow such posts if they are legitimate content we would otherwise allow, and such affiliations are disclaimed. See wax eagle’s excellent answer, which remains the community consensus to this day:

Provided that asking/answering questions about Legend is not your only reason for being involved here, and is not the only contribution you are making. I think this is fine.

What I would advise is that you disclose your connection to Legend, probably at least in your answers.

Lastly, if you’re going to ask and self answer, please make sure the questions are actually good and not just vehicles for the answer you really want to write :).

We’re very happy to get coverage of small RPGs and as a contributer you qualify as an expert in Legend which is what we’re here for.

So please, join our merry band, take a look at other questions too, vote as you see fit, maybe answer a few. Self-answered Q&As are acceptable, but make sure they’re legitimately questions that real users might ask. In fact, the best way to handle it may be to point to your fans that this resource exists, and is a place where you’re answering questions—if they have actual questions for you, and you answer them, then those will make great answers and should be fairly well-received.

(Though don’t have your fans spam the site with every question they can think of just to give you an excuse to promote the game more—that would be very poorly received.)

audit – MySQL router making mysql general log not useful

I am running MySQL 5.7 on a 3 node cluster using InnodBCluster. It is making the user of the general_log quite challenging. The mysqlrouter check ins are being logged in the mysql general_log. These status updates are appearing in the log nearly every second for every router that is pointed at the cluster.

2808634 Query select I.mysql_server_uuid, I.endpoint, I.xendpoint, I.attributes from mysql_innodb_cluster_metadata.v2_instances I join mysql_innodb_cluster_metadata.v2_gr_clusters C on I.cluster_id = C.cluster_id where C.cluster_name = 'cluster' AND C.group_name = '7b6cc6c6-b4d6-11ea-bb3a-023d3853a38a'
2808634 Query COMMIT
2808634 Query show status like 'group_replication_primary_member'
2808634 Query SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM on_group_members WHERE channel_name = 'group_replication_applier'
    8 Query BEGIN
    8 Query COMMIT /* implicit, from Xid_log_event */
2808633 Quit  

I’m guessing this is how mysqlrouter is internally knowing where to route connections. Is there a to not write this to the general_log? Other than turning off the general_log?

I use the general_log to audit of who logs in and what they run. I have found there are tools to do this other than the general_log such as:

MySQL Enterprise Audit https://dev.mysql.com/doc/refman/5.7/en/audit-log.html

Percona Audit Log https://www.percona.com/doc/percona-server/5.7/management/audit_log_plugin.html

Which I may need to investigate further.

special functions – Clebsch Gordan Coefficients: General Expression Does Not Match Specific Expression

The expression ClebschGordan({2, 0}, {4, 0}, {2, 0}) yields the correct result of Sqrt(2/7).

However the expression ClebschGordan({2, 0}, {l2, 0}, {2, 0})/. l2 -> 4 yields Indeterminate. Indeed, ClebschGordan({2, 0}, {l2, 0}, {2, 0}) evaluates to an algebraic expression numerator/((-4 + l2) (2 - l2)!) where numerator/.l2 -> 4 evaluates to Sqrt(2/7). This is indeed indeterminate.

Interestingly, the expression ClebschGordan({l2, 0}, {2, 0}, {2, 0}) /. l2 -> 4 gives the correct result, and ClebschGordan({l2, 0}, {2, 0}, {2, 0}) leads to a different algebraic expression that has the same values for 0<=l2<4 and the correct value for l2->4.

This would appear to be a minor bug, as it violates the simplest symmetry of the Clebsch Gordan coefficients.

general topology – Set of Unit Ball’s Extreme Points is not always closed

I am trying to show that $text{Ext}B(X)$ does not have to be closed where $B(X)$ is closed unit ball of normed space $X$ and $text{Ext}B(X)$ is the set of extreme points of unit ball.

My definition for extreme point : $x in S(X)$ is an extreme point of $B(X)$ if $x$ cannot be written as aritmetic mean of distinct elementsof $B(X)$. ($S(X)$ is unit sphere)

I thought that $Bbb R^n$ can be an example for this and I tried to use $Bbb R^3$ but I could not find the proper sequence to show that $text{Ext}B(Bbb R^3)$ is not closed. I really stuck.

I appreicate any help.

Thank you

mysql – Relationship design for areas, managers and general manager

Given some specifications I need to design a database for an organization. One of the parts has to do with areas. In the organization there are different areas, each area has a boss, and there is also an employee as the boss of all areas. My question is about how I should indicate which employee is the boss of all areas.

    | employee_id |    name    |

    |      1      |    Mark    |

    |      2      |    Carol   |

    |      3      |    Adam    |

    |      4      |    Andy    |



    | area_id |    area_name    | manager |

    |    1    |    Chemistry    |    2    |

    |    2    |    Electronics  |    4    |

    |    3    |    Medicine     |    3    |

    |    4    |      ALL        |    1    |

enter image description here

At the moment what has occurred to me is to create an occurrence called “ALL” within the relation “AREA” to indicate the head of all areas, however I am not sure if it is the best way or the correct way to do it . Any other idea?

general topology – What is the point of disjoint union?

Disjoint union is seemingly ubiquitous in mathematical literature but it is rarely ever used properly. It is almost always the case that one forms $bigsqcup_{iin I} X_i$ and ends ups identifying $xin X_i$ with $(x,i)inbigsqcup_{iin I} X_i$. (Open any topology textbook and you will see this abuse.) Why not just assume that the $X_i$ are all pairwise disjoint and instead use ordinary union? Why bother with $X_itimes{i}$ when we don’t ever use the notation $(x,i)$?