Customize Super + N Behavior

I’m running Ubuntu 18.04 with GNOME. When I hit Super + 1, the first program in my left favorites bar (in my case, Firefox) starts up. If I hit Super + 1 again, it switches to the existing Firefox instance. I would like it to start a new Firefox process instead.

I followed the instructions in this question, which works if I go into the launcher by hand, but it doesn’t work for the keyboard shortcuts Super + 1, etc. Also, it seems that Super + 1 is not listed as a keyboard shortcut in the settings, so I can’t simply override the binding myself. How can I get a new process to start when I hit Super + N, for N from 1 to 9?

SignalR like behavior which integrates into C#

We want to create a software, where incoming messages should be manipulated and forwareded to a number of subscribers. The receiving end of this service should be hard-coded, because it can only be accessed by a controlled circle of programs. Clients on the sending end of this service should easily be able to connect to the server. They should only receive specific messages, controlled by a login method, credentials or something similar and a group/role based system.

The software is meant as a 1-to-n bridge to transmit events between multiple bussiness processes and systems. If a data change/Manipulation occurs somewhere, it should be delivered only to this central point. From there, it should be broadcasted to any subscriber. Any client should be able to subscribe to this broadcast and then get messages delivered. This could be anything from a very complex software to a simple IoT display.

So, for example, there could be a channel “orders”. If any system creates an order, it must inform this service about it. Now, there could be a display somewhere, which displays the newly placed orders on this day. Without that service, we would hard-code a call from the ERP system to that display. If another tool would need that information, too, we would need to add that code to the ERP again. With the new software in place, the ERP should only call the new software and anyone who is interested in this information “new order” could subscribe to that via a web socket or something similar. And with anyone, I mean with the exception of a role or right based system, where a subscriber must log into the service first. The server then decided, if the subscriber is allowed to receive this message.

SignalR is pretty much what we are looking for, but as far as I’m concerned, this is very specifically tailored towards web browsers. So is there something similar for the C# world? Maybe something on the basis of WCF, or a SignalR implementation for C#? It is vital, that we can restrict the circle of receivers from the server side, pretty much like the Client.Group or Client.Groups methods which we know from SignalR. I already looked into bi-directional WCF services, but it looks like they are not very dynamic and you also cannot group the clients.

Can you please give me some ideas, which tools or libraries would be appropriate for such a project?

Magento 1 programmatically creating a credit memo has incorrect behavior

The question of how to create a credit memo in Magento 1 has been asked several times and answered in a few different ways.

With each one, I’m yielded slightly different results but ultimately each has the same result:

A credit memo for $ 0 with no items listed in the “Items Refunded” section, or the full quantity of items ordered being refunded, and the quantities are ignored.

In this case, $ rma is a single RMA object from getCollection(), and the result of the below code is that all items are refunded even though the qty_authorized is 1.

$  order = $  rma->getOrder(); $  service = Mage::getModel('sales/service_order', $  order); $  rmaItems = $  rma->getItemsForDisplay();  $  data = array(     'items' => array() );   foreach($  rmaItems as $  rmaItem){     $  data["items"][strval($  rmaItem->getId())] = ['qty'=>$  rmaItem->getData('qty_authorized')]; }  $  data['shipping_amount'] = 0;  $  creditMemo = $  service->prepareCreditmemo($  data)->register(); Mage::getModel('core/resource_transaction')->addObject($  creditMemo)->addObject($  order)->save();  $  rma->close(); 

The above example is passing in items, and yields the following structure for the data variable:

array(2) {   ["items"]=>   array(1) {     [2300]=>     array(1) {       ["qty"]=>       string(6) "1.0000"     }   }   ["shipping_amount"]=>   int(0) } 

Switching the variable from items to qtys as in most answers yields the same structure but instead gives the result where no items are returned.

This is all very much beta code, and there’s bound to be errors in other parts of it as so far I’m working on just getting a proper credit memo in, so any comments on any part of it are much appreciated.

Kleene Star regex question, sed behavior?

Kleene Star with ‘sed’ is behaving as expected for me, with exception of a case where the input pattern is “ab” and the regex is “b*”. Does anyone know why this regex is not being matched against the pattern space?

This is the failure case:

$   printf "ab\n" | sed -En 's/b*// p' | od -t c 0000000   a   b  \n 0000003 

This case, without Kleene Star, behaves as expected:

$   printf "ab\n" | sed -En 's/b// p' | od -t c 0000000   a  \n 0000002 

I’m trying to match the ‘b’ and replace it with nothing.

The pattern space is ‘ab’, beginning of line is unspecified, so I’m confused why /b*/ would not match a pattern of zero or more ‘b’s, in this case ‘b’.

Oddly, this case works with the ‘.’ prepended to the ‘*’:

# fails to match $   printf "abb\n" | sed -En 's/b*// p' | od -t c 0000000   a   b   b  \n 0000004 # matches with .* ! $   printf "abb\n" | sed -En 's/b.*// p' | od -t c 0000000   a  \n 0000002 

Kleene Star matches zero or more occurrences of the preceding alphabet (in this case a single character).

By definition:

$ V^0 = \{\epsilon\}$

$ V^1 = V$

$ \forall i ( (i \gt 0) \land (V^{i + 1} = \{ wv : w \in V^i \land v \in V )\} $

Therefore $ V^0 = \{ \epsilon\}$ , $ V^1 = \{ \epsilon \cdot b\}$ , $ V^2 = \{ \epsilon \cdot b \cdot b\}$ .

$ V^* = \bigcup\limits_{i\ge0} V^i = V^0 \cup V^1 \cup …$ which I have specified by /b*/.

The following cases agree with my understanding of sed and Kleene Star:

# * : matches 0 or more occurances # no match $   printf "a\n" | sed -En 's/b*// p' | od -t c 0000000   a  \n 0000002  # match a printf "a\n" | sed -En 's/a*// p' | od -t c 0000000  \n 0000001  # match a printf "ab\n" | sed -En 's/a*// p' | od -t c 0000000   b  \n 0000002  # match aa printf "aab\n" | sed -En 's/a*// p' | od -t c 0000000   b  \n 0000002 

I tested using BSD and GNU sed, both have the same results.

Thanks!

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that “feels” wrong, but I can’t quite articulate what is wrong about it. Or maybe it’s just my prejudice. Here goes:

A developer defines a method with a boolean as one of its parameters, and that method calls another, and so on, and eventually that boolean is used, solely to determine whether or not to take a certain action. This might be used, for example, to allow the action only if the user has certain rights, or perhaps if we are (or aren’t) in test mode or batch mode or live mode, or perhaps only when the system is in a certain state.

Well there is always another way to do it, whether by querying when it is time to take the action (rather than passing the parameter), or by having multiple versions of the method, or multiple implementations of the class, etc. My question isn’t so much how to improve this, but rather whether or not it really is wrong (as I suspect), and if it is, what is wrong about it.

Is it wrong to use a boolean parameter to determine behavior?

I have seen a practice from time to time that “feels” wrong, but I can’t quite articulate what is wrong about it. Or maybe it’s just my prejudice. Here goes:

A developer defines a method with a boolean as one of its parameters, and that method calls another, and so on, and eventually that boolean is used, solely to determine whether or not to take a certain action. This might be used, for example, to allow the action only if the user has certain rights, or perhaps if we are (or aren’t) in test mode or batch mode or live mode, or perhaps only when the system is in a certain state.

Well there is always another way to do it, whether by querying when it is time to take the action (rather than passing the parameter), or by having multiple versions of the method, or multiple implementations of the class, etc. My question isn’t so much how to improve this, but rather whether or not it really is wrong (as I suspect), and if it is, what is wrong about it.

Seeing a weird navigation behavior in modern team site linked to hubsite

I am working with SP Online in modern experience and many team sites created and linked to HubSite “Home”, the hub navigation shows perfectly fine.

Since last couple of days, I am seeing another row of weird navigation in a row below hub nav and I have no idea where this comes from. enter image description here

Can’t enable publishing features on team site modern, so navigation option is not even showing up under site settings, so how can it appear all of a sudden, was not showing up before at all.

Can someone please assist, thanks in advance.

A group with a relative behavior mimicking the group of integers

Let $ G$ be a group having a subgroup $ H$ such that the interval $ [H,G]$ in $ \mathcal{L}(G)$ has the maximal condition. Let $ (K_i)_{i \in I}$ be the coatoms of $ [H,G]$ .

Assume $ I$ infinite countable and for every finite subset $ J \subset I$ we have $ \bigcap_{j \in J} (G \setminus K_j) \neq \emptyset$ .

Question: Is it true that $ \bigcap_{i \in I} (G \setminus K_i) \neq \emptyset$ ?

Remark: if $ G = \mathbb{Z}$ and $ H = \{0\}$ , the maximal condition is satisfied, the coatoms are $ (p\mathbb{Z})_{p \in \mathbb{P}}$ and $ \bigcap_{p \in \mathbb{P}} (\mathbb{Z} \setminus p\mathbb{Z}) = \{-1,1 \}$ .

Strange sysctl behavior on Ubuntu Server 18.04

Let’s say I have an Ubuntu bionic server that I wish to disable IPv6 on. (Important: This is not an XY Problem, please don’t guess at what I’m trying to achieve or ask me why I want to do this. I know how great and wonderful IPv6 is, no need to preach to the choir.) One way to do this is to set the following sysctls:

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 

When sysctl is run manually with the settings above, this disables all IPv6 networking on the host:

# ip -6 a # 

Great, but that doesn’t persist through a reboot. The recommended way to make sysctls persist is to put them in /etc/sysctl.conf, or a file in /etc/sysctl.d. I did that, but after a reboot, IPv6 is still there:

# ip -6 addr 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000     inet6 <censored>/64 scope global dynamic mngtmpaddr noprefixroute         valid_lft 2591985sec preferred_lft 604785sec     inet6 fe80::250:56ff:feae:c158/64 scope link         valid_lft forever preferred_lft forever 

And yet, the sysctls appear to be correctly set:

# sysctl net.ipv6.conf.all.disable_ipv6 net.ipv6.conf.default.disable_ipv6 net.ipv6.conf.lo.disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 

However when I set them on the command line, to the same value, suddenly IPv6 is actually disabled:

# sysctl -w net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 # ip -6 addr #  

So my question, then, is: Why does setting sysctls to specific non-default values in /etc/sysctl.d/ appear to be doing something according to the output of sysctl itself, and yet not actually affecting the kernel’s behavior? Is there some subtle difference between setting a sysctl and having it take effect?

I know that sysctl is an interface for /proc/sys but I am seeing the same thing there as well:

# cat /proc/sys/net/ipv6/conf/all/disable_ipv6  1 # ip -6 a 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000     inet6 <censored>/64 scope global dynamic mngtmpaddr noprefixroute         valid_lft 2591945sec preferred_lft 604745sec     inet6 fe80::250:56ff:feae:c158/64 scope link         valid_lft forever preferred_lft forever # echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 # ip -6 a # 

Also, I have done significant research into this, this question is NOT a dupe of any of these:

  • How to disable IPv6 permanently?
  • Disable IPv6 on Ubuntu 17.10 (Netplan)
  • /etc/sysctl.conf doesn't persist after reboot
  • /etc/sysctl.conf settings do not last after reboot
  • Ubuntu 12.04, why service procps start doesn't start procps?

The optimal asymptotic behavior of the coefficient in the Hardy-Littlewood maximal inequality

It is well-known that for $ f \in L^1(\mathbb{R^n})$ ,$ \mu(x \in \mathbb{R^n} | Mf(x) > \lambda) \le \frac{C_n}{\lambda} \int_{\mathbb{R^n}} |f| \mathrm{d\mu}$ , where $ C_n$ is a constant only depends on $ n$ .

It is easy to see $ C_n \le 2^n$ , but how to determine its optimal asymptotic behavior? For example, does $ C_n$ bounded in $ n$ ? Is $ C_n$ bounded by polynomial in $ n$ ?