Incrementing one to a variable in IA32 Linux Assembly

Question: I'm trying to increment 1 to a variable in IA32 Assembly in Linux
section .data
num:    dd  0x1

section .text
global _start

_start:

   add    dword [num], 1

   mov    edx, 1
   mov    ecx, [num]
   mov    ebx,1
   mov    eax,4
   int    0x80

   mov    eax,1
   int    0x80

Not sure if it's possible to do.
In another literature I saw the follow code:
mov eax, num
inc eax
mov num, eax

Is it possible to increment a value to a var without moving to a register?
If so, do I have any advantage moving the value to a register?
Comment: Your actual bug is that the `write` system call wants a pointer to its data in `ecx`, not the data itself.  So that should be `mov ecx, num`.  And a dword is 4 bytes, not 1, and this will write it out as raw binary, not human-readable decimal or hex; you could pipe the output into `hexdump` if you want to see it.  Otherwise you get to write a binary-to-decimal conversion routine, which will about triple the length of your program.
Comment: Oh I see, thanks @NateEldredge
Answer:
Is it possible to increment a value to a var without moving to a register?

Certainly: inc dword [num].
Like practically all x86 instructions, inc can take either a register or memory operand.  See the instruction description at http://felixcloutier.com/x86/inc; the form inc r/m32 indicates that you can give an operand which is either a 32-bit register or 32-bit memory operand (effective address).
If you're interested in micro-optimizations,  it turns out that add dword [num], 1 may still be somewhat faster, though one byte larger, on certain CPUs.  The specifics are pretty complicated and you can find a very extensive discussion at INC instruction vs ADD 1: Does it matter?.  This is partly related to the slight difference in effect between the two, which is that add will set or clear the carry flag according to whether a carry occurs, while inc always leaves the carry flag unchanged.

If so, do I have any advantage moving the value to a register?

No.  That would make your code larger and probably slower.
Comment: @BrunoCriado: The usual reason for load / inc / store is if you also want the value again later, you still have it in a register.  i.e. to avoid `mov    ecx, [num]`, you'd do the increment in ECX.
 (Except that's not how to use `write(int fd, void *, size_t)`, but if it had been a printf call or something then you would want the value, not just its address.)
Comment: Great! Thank you again, @NateEldredge
Comment: Yeah, makes sense. Thanks @PeterCordes


How does one export Minecraft "Better Together" to Remix 3D?

Question: Recently, Remix 3D welcomed Minecraft creators to their site.  The welcome blog post starts in the middle:

So, you've found yourself here and you've exported a Minecraft structure.

Wait.  How do I actually export a Minecraft structure?  I don't see an export option in any of the in-game menus or commands on the edition I'm using (Windows 10 edition, "Better Together" update v1.2.0).
Which versions/editions of Minecraft have added this new export capability, and how does one actually cause the export to happen from the game?
Please post a screenshot of the game's UI doing this if you can (even if it's not the same edition that I have, I'm curious to see how the game's UI works for this).  Thanks!
Comment: I have no experience with minecraft other than the java edition, but in the java edition, there is a block called "structure block", which saves the blocks within a user defined area to the harddrive as a file. could that be the sort of structure that you're looking for?
Comment: The next sentence on that page is: "Why don't you try sharing your creation on Facebook, Twitter, Tumblr or your favourite social media channel?" I think that means that the export isn't a step in Minecraft in preparation to getting it into Remix3D, but rather the last step in Remix3D to save it to a file. Is this meant to be a 3D printing program for Minecraft structures? Or could it maybe just be a 3D painting program that contains Minecraft textures amongst others?
Comment: I'm not looking for the social media side as much, I'm trying to figure out if Minecraft can really export to GLTF (*.glb) format or any 3D model file format.  I know that Remix3D stuff can be downloaded into Paint3D and then saved to a variety of 3D formats, which makes it a possibility.  I'm interested in any sort of in-game partial-world export capability, and how it is accessed.  The "structure block" sounds very interesting, but I don't see that in the Win10 edition.
Comment: @emackey In that case, the structure block is not what you are looking for. The resulting file doesn't contain vertex data and such... It's basically just a list of all the blocks in an area, saved in such way that the structure can be copied into any minecraft world.
Comment: Actually, looks like structure blocks are exactly it!  In the Win 10 edition at least, saving a section of your world from a structure block does indeed create a *.glb file, which can be loaded in ThreeJS, BabylonJS, and can even be previewed in 3D on OneDrive's online viewer.
Answer: For anyone else trying to export 3D models of their Minecraft world, this is what I know now:

In January 2020, "Remix 3D" will be shut down, and as of now the option to upload from Minecraft to Remix 3D is gone from the game.  This shutdown has not hampered the ability to export to a file locally.
The option to export 3D models to *.glb files (glTF 2.0 format) exists in the Windows 10 edition, but does not appear available in the Java or mobile versions.
You need to be in a "Creative" mode game with "Operator" status (the gold crown icon in the player list).
In that game, the command is /give @s structure_block.  The @s means "self" and can be substituted with any player name.  The player will need a free slot in their hotbar to receive the structure block.
Place the Structure Block into the Minecraft world, and right-click to active it.  This opens a UI for choosing a nearby area to export, up to 32 x 32 x 32 in size.
Fill out the blank name field, and adjust the size & offsets to taste, then click the Export button to produce the GLB file.

The resulting file can then be loaded or imported into most applications that load glTF, including Blender 2.80.
Answer: I just figured it out! It does indeed use Structure Blocks. You must use the /give command to get one, switch to creative mode, place it, activate it, and then you can set coordinates. The structure block only works as an export mechanism, but there's a nice UI with a preview to see exactly what you'll get, and then it exports a GLB file that can be viewed.


Understanding the code of _.bind

Question: This is the code for _.bind, taken from the Underscore library. I don't understand the business of taking the empty function, changing it's prototype, etc.
  var ctor = function(){};

  _.bind = function bind(func, context) {
    var bound, args;
    if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
    if (!_.isFunction(func)) throw new TypeError;
    args = slice.call(arguments, 2);
    return bound = function() {
      if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
      ctor.prototype = func.prototype;
      var self = new ctor;
      var result = func.apply(self, args.concat(slice.call(arguments)));
      if (Object(result) === result) return result;
      return self;
    };
  };

Comment: I don't see a real question here.
Answer: It basically is there so that if you call new bound(), you're able to bind arguments for the new call. E.g.:
var func = function(a, b) {
    this.a = a;
    this.b = b;
};

// context does not matter, use e.g. `null`
var bound = _.bind(func, null, 1);

new bound(2); // a = 1, b = 2

I tried to explain the code a bit.
var ctor = function(){};

_.bind = function bind(func, context) {
    var bound, args;

    // use native .bind if available
    if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));

    // abort if not called with a function
    if (!_.isFunction(func)) throw new TypeError;

    // you can also bind arguments, which come after the function and context (so .slice(2))
    args = slice.call(arguments, 2);

    // return the bound function
    return bound = function() {

        // if you simply do bound(), then `this` is the global object.
        // This means the original function should be called with the
        // bound `this` value and arguments. Arguments you pass to the
        // bound function are concatenated to the bound arguments.
        if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));

        // otherwise, you're calling like `new bound()`, because `this instanceof bound`.
        // In that case, `this` should not be passed, but only the arguments. So, you
        // create a function of which the prototype is the original function's prototype,
        // and create an instance of it (to mimic `new func`).
        ctor.prototype = func.prototype;

        var self = new ctor; // won't execute anything since ctor's body is empty.
                             // Just creates an instance

        // then, you call the original function with the `this` value of the instance,
        // with bound arguments and new arguments concatenated. This way, the constructor
        // (func) is executed on the instance.
        var result = func.apply(self, args.concat(slice.call(arguments)));

        // finally, return the result if it's an object (the specs say `new xxx` should
        // return an object), otherwise return the instance (like you would with `new func`)
        if (Object(result) === result) return result;
        return self;
    };
};

Understanding the code of _.bind


Concatenate in JavaScript with + gives extra comma if value is null

Question: Here when I concatenate three different value with comma separator then if value is null then  comma is concatenate. How can I avoid extra comma if the value is null?
Below is the code I've tried.
var forecast = (is_forecast_checked()) ? 'f' : '';

var contract_volume = (is_contract_volume_checked()) ? 'd' : '';

var actual_volume = (is_actual_volume_checked()) ? 'a' : '';

var volume_type = forecast + ',' + contract_volume + ',' + actual_volume ;

Comment: Computers do what you tell them. You're telling it to do this. Use an `if` statement and tell it to do something else.
Answer: Very simple
var forecast = (is_forecast_checked() ? 'f' : ''),
// add the comma here if its not null
    contract_volume = (is_contract_volume_checked() ? ',d' : ''),
// same here
    actual_volume = (is_actual_volume_checked() ? ',a' : ''),
// remove the comma concatenation
// replace unwanted, double commas, preceding or ending commas
    volume_type = (forecast + contract_volume + actual_volume).replace(/$,|^,|\B,/g,'');

Comment: This isn't going to work. If they are all true then you get "f,,d,,a"
Comment: First is true so I get an "f". Then because it wasn't null I "add the comma here" which gives "f," . Then I add a ",d" which gives "f,,d" etc
Answer: What about this:
var array = [];

is_forecast_checked() && array.push("f");
is_contract_volume_checked() && array.push("d");
is_actual_volume_checked() && array.push("a");

volume_type = array.join(",");

Comment: this is clearly overkill... your adding 4 extra function calls here and that would only make sense if it was in a loop


What is the part called that holds the upper pulley on an extension spring garage door?

Question: I have an extension spring garage door that doesn't open and close smoothly, and many times it doesn't complete a cycle before jamming up. I recently discovered why - the stationary pulley is quite literally eating the piece it's mounted to.

Full imgur album here: https://i.stack.imgur.com/36Veg.jpg (First two images are closeups of the pulley that's eating its mounting piece and second is a wider shot of the matching piece on the other side)
I can't figure out what the piece the pulley mounts to is called. It's not the flag bracket, that's the vertical piece bolted to the wall that supports the pulley piece and the vertical track, and it's not part of the horizontal track either.
As an alternative to this exact part, since it may not exist, could I replace it with a piece of C-channel, unistrut, or even that right-angle hole punched stuff that holds up the opener and track ends?
As for make and model, I know the door is an old Raynor model but I haven't been able to find any information on something that old, and Raynor is more interested in selling me a new door than providing support for their old stuff.
Comment: Bearing in the pulley probably shot.  Will need a new new pulley and bolt.  Bracket might be okay(does not look too bad) or can bolt a piece of steel to the inside to stiffen.  Decent hardware store should have a pulley that will work.
Comment: Looks like you only need a new bearing on that pully and replacement angle iron.  My two doors are 25+ years old ( also helped a couple neighbors) and never saw a failure like that.
Comment: I'm replacing pretty much every moving part on this thing since it could be up to 30+ years old, and lead times for new garage doors are out to Februaryish in my area. I have a shopping cart lined up for purchase once I figure out how much the door weighs and what to replace the part in question with.
Comment: I believe that's called a cable drum.
Comment: Yeah... you don't need a new door and so on. You need to replace the pulley and bolt. About $5 from Home Depot. You can also get a length of "punched" angle iron for less than $20.
Answer: I would suggest that a decent piece of angle iron would be sufficient to mount a new pulley to. You could get either solid angle iron and drill the holes precisely where you need them, or get the perforated stuff and hope the holes line up.
Drilling holes in steel isn't all that hard. It just takes patience and some sort of lubricating fluid to keep the metal and the bit from overheating.


How encode strings using python

Question: I have lists with element
[u'\xd0\xbc\xd1\x82\xd1\x81 \xd0\xbe\xd1\x84\xd0\xb8\xd1\x86\xd0\xb8\xd0\xb0\xd0\xbb\xd1\x8c\xd0\xbd\xd1\x8b\xd0\xb9 \xd1\x81\xd0\xb0\xd0\xb9\xd1\x82']
[u'\xd0\xbc\xd1\x82\xd1\x81 \xd0\xbe\xd1\x84\xd0\xb8\xd1\x86\xd0\xb8\xd0\xb0\xd0\xbb\xd1\x8c\xd0\xbd\xd1\x8b\xd0\xb9 \xd1\x81\xd0\xb0\xd0\xb9\xd1\x82']

I try to convert it using
val[0].encode('utf-8')

And got after it
мÑÑ Ð¾ÑиÑиалÑнÑй ÑайÑ
мÑÑ Ð¾ÑиÑиалÑнÑй ÑайÑ

What I do wrong?
Comment: What are you trying to do?
Comment: Do those lists contain UTF-8 bytes?  If so, how/why are they stored in `unicode` objects?
Comment: @SLaks, I write it in my question. Usually I use `encode('utf-8')`, and I try `val[0].decode('latin1').decode('cp1251')`, but it doesn't help in my problem
Comment: @jwodder, I took url like `https://yandex.ru/touchsearch?clid=1906591&text=%D0%BC%D0%B0%D1%82%D1%87%20%D0%B8%D1%82%D0%B0%D0%BB%D0%B8%D1%8F%20-%20%D0%B8%D1%81%D0%BF%D0%B0%D0%BD%D0%B8%D1%8F%20%D0%B5%D0%B2%D1%80%D0%BE%202012&lr=213&redircnt=1465849826.1` and next `get2 = urlparse(url)
            dict2 = parse_qs(get2[4])
            val = dict2['text']`, I get search request from url and I want to decode that
Comment: `dict2['text']` gives you the byte string `'\xd0\xbc\xd0\xb0\xd1\x82\xd1\x87...'`, not a Unicode string as above. To turn that into `u'\xd0\xbc\xd0\xb0\xd1\x82\xd1\x87...'` you must have decoded using a Latin-1 encoding (ISO-8859-1 or Windows code page 1252), instead of UTF-8.
Answer: You have a Mojibake; text decoded using the wrong codec.
You have what looks like it was decoded or Latin-1 or Windows codepage 1252, while it should have been decoded as UTF-8 instead.
Either reverse the encoding manually, or use the excellent ftfy package to do it for you:
>>> import ftfy
>>> data = [u'\xd0\xbc\xd1\x82\xd1\x81 \xd0\xbe\xd1\x84\xd0\xb8\xd1\x86\xd0\xb8\xd0\xb0\xd0\xbb\xd1\x8c\xd0\xbd\xd1\x8b\xd0\xb9 \xd1\x81\xd0\xb0\xd0\xb9\xd1\x82']
>>> ftfy.ftfy(data[0])
u'\u043c\u0442\u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442'
>>> print ftfy.ftfy(data[0])
мтс официальный сайт

Manually, you'd re-encode as Latin-1:
>>> data[0].encode('latin1')
'\xd0\xbc\xd1\x82\xd1\x81 \xd0\xbe\xd1\x84\xd0\xb8\xd1\x86\xd0\xb8\xd0\xb0\xd0\xbb\xd1\x8c\xd0\xbd\xd1\x8b\xd0\xb9 \xd1\x81\xd0\xb0\xd0\xb9\xd1\x82'
>>> data[0].encode('latin1').decode('utf8')
u'\u043c\u0442\u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442'
>>> print data[0].encode('latin1').decode('utf8')
мтс официальный сайт

Note that you have a list with one unicode object in it. You may want to study up on Python and Unicode; I recommend the following documents:

Pragmatic Unicode by Ned Batchelder
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) by Joel Spolsky
The Python Unicode HOWTO

These will help you understand when to encode and when to decode, and what codec to use.
Comment: Thank you for detailed explanation!

How encode strings using python


Highcharts.SVGRenderer not working properly with Drill Down

Question: I have a Highcharts column graph in my application and it has a drill down behavior. Initially, it shows the Yearly wise count of something and then upon clicking on a year it shows the monthly view of that Year. Also, that Monthly View shows from December to Last Year December so that I have another requirement like need to separate two years. This Year wise separation should come in monthly view only. Something similar to the following image. But the problem is If I call the Separator adding method inside Drilldown event on Highcharts it doesn't add the separator as intended. What I want is something like following.

If I click on 2018 graph should be something like following.
Answer: You can use drilldown event only to save the right year in the chart:
<code>function renderSeparator(xVal, chart, year) {
  var xAxis = chart.xAxis[0],
    pxVal = xAxis.toPixels(xVal + 0.5);

  chart.additionalLabels.push(chart.renderer.path([
    'M', pxVal, chart.plotTop,
    'L', pxVal, chart.plotTop + chart.plotHeight
  ]).attr({
    stroke: 'black',
    'stroke-width': 1
  }).add());

  chart.additionalLabels.push(chart.renderer.text(
    year, pxVal + 10, 70
  ).css({
    color: 'black',
    fontSize: 20
  }).attr({
    zIndex: 6
  }).add());
}

// Create the chart
Highcharts.chart('container', {
  chart: {
    events: {
      drilldown: function(e) {

        e.target.drilldownYear = e.point.name;
      },
      render: function() {
        var chart = this,
          xAxis = chart.xAxis[0],
          additionalLabels,
          year = Number(chart.drilldownYear);

        if (!chart.additionalLabels) {
          chart.additionalLabels = [];
        }

        if (chart.additionalLabels.length) {
          Highcharts.each(chart.additionalLabels, function(label) {
            label.destroy();
          });
          chart.additionalLabels = [];
        }

        Highcharts.each(xAxis.names, function(el, i) {
          if (el === "December") {

            if (!chart.additionalLabels.length) {
              chart.additionalLabels.push(chart.renderer.text(year, chart.plotLeft + 10, 70)
                .css({
                  color: 'black',
                  fontSize: 20
                })
                .attr({
                  zIndex: 6
                })
                .add());

              year++;
            }

            renderSeparator(i, chart, year);
            year++;
          }
        });
      }
    },
    type: 'column'
  },

  ...

});
</code>
Live demo: https://jsfiddle.net/BlackLabel/qtr5x1po/
Similar topic: Add Custom Labels to Axes in Highcharts
Comment: Thanks it worked


What is the largest value for Dimension Im(T)?

Question: Here's a problem I have. Consider having 4 vectors in $R^5$ such that $3\vec{v_{1}}+\vec{v_{2}}=4\vec{v_{4}}$. Let $T$ be a linear transformation from $R^4$ to $R^5$ such that $T(e_{j})=v_{j}$ where $e$ is a normal vector.
(a) Find a nonzero vector in kernel of $T$ -- this I solved as $\begin{bmatrix}
3\\
1\\
0\\
-4
\end{bmatrix}$
(b) What is the largest possible dimension for $Im(T)$? -- This is the question I am having trouble with. So the matrix for t is clearly 5 by 4, and it has four vectors, relationship between three of which is given to me. By rank-nullity theorem, the dimension of the image is 4 minus the number of dependent columns/free variables. However, I am struggling to understand how many dependent columns/free variables I have from $3\vec{v_{1}}+\vec{v_{2}}-4\vec{v_{4}}=0$ -- clearly, I am given a relationship between three vectors, but does it mean that one of them is dependent on the other two, hence two free variables, or 1 dependent column?! I guess I am just confused by the connection -- I know the number of free variables and dependent columns should be the same, so I would appreciate if someone could clarify how to get both from the equation I am given (I realize that the third vector is not defined, so it could or could not be dependent).
Answer: The Rank-Nullity Theorem tells you that if you have a linear transformation $T\colon \mathbf{V}\to\mathbf{W}$, then the dimension of the kernel of $T$ plus the dimension of the image of $T$ equals the dimension of $\mathbf{V}$. In this case, since your $T$ maps $\mathbb{R}^4$ to $\mathbb{R}^5$, you know that the dimension of the kernel of $T$ plus the dimension of $\mathrm{Im}(T)$ equals $4$ (the dimension of $\mathbb{R}^4$). Since you know that $\dim(\mathrm{ker}(T))\geq 1$ (you already produced at least one nonzero element in the kernel), that tells you that $\dim(\mathrm{Im}(T))\leq \cdots$.
Comment: Thanks Arturo, I see how having at least one non-trivial element in Kernel makes my Image's dimension $\leq$ 3. I was just wondering if there was a way to deduce from the equation that I was given (or any other equation of this type) if there is more than one dependent column.
Comment: @user5157: No, because while you are told that the relation $3\mathbf{v}_1 + \mathbf{v}_2 = 4\mathbf{v}_4$ holds, you are *not* told whether *any other* relations hold. So you aren't really given enough information to figure out the dimension of $\mathrm{ker}(T)$.


No line break in html dd-element

Question: I am trying to get the image caption which is a dd-element to break so it is as wide as it's dt-element. I don't want to use a width and using display: inline and float: left do not work. I have code and example here: http://jsfiddle.net/PnyHs/11/. I'm using Firefox 9 to test.
The only solution I can come up with right now is to use javascript to measure the dt-element and set that width to the dd-element.
Thanks in advance for any help and suggestions.
Comment: This is more difficult that it looks. Do you need to support IE7?
Comment: Yes, IE7 support is required and you are right, it is more difficult than it looks. I have solved my problem with a little javascript as I see know other solution without changing the html.
Answer: If you want to keep the structure of your HTML and not use max-width, I dare to say this is impossible, and here is why:
You are expecting the img object to constrain the dd element. However both elements are siblings and can only be constrained in terms of width by their parent (alternatively an element can be stretched out by its children). Hence, the dd will expand as much as it wants because the parent element is not limiting it.
Of course this could be solved by setting the width of the parent element, however you've mentioned that you don't want to do that since the pictures will have different sizes.
So unfortunately unless you change your HTML structure this won't be possible without JavaScript (unless I'm missing something obvious here).
Comment: Thanks. I've given this answer the heads up because it's congruent with my thoughts and findings. I have in fact solved the issue with javascript.
Answer: Using dl markup for an image and a caption is artificial and doesn't make styling any easier. The only approach to the problem (making the caption as wide as the image) that does not need scripting or setting image width explicitly seems to be to use a single-cell table with a caption element, see fiddle and my page on image captions. Example:

Image Caption with a very very very very very long
     text

Comment: I want to solve this without changing the html. Thanks for the link, I'll hang on to that for next time.
Answer: Can you add a width to your dl element? The same width as your image like this http://jsfiddle.net/PnyHs/12/
Comment: The image width can vary so I don't want to use a width. I'm not sure if this is possible though. As mentioned above, my last resort is to set the width as you did in your example but with javascript dynamically.
Comment: I see. As you say, unless you know the width I don't think this is possible with just html/css unfortunately.
Comment: Just thought, how about a compromise by adding a `max-width` of say 200px?

No line break in html dd-element


Is there a correct orientation for hurricane clips?

Question: When installing hurricane clips to joists where it crosses a beam, is there a preference to mounting the clips on the inside or the outside of the beam? And should the ears on the clips point inward over the beam or outward? (Does it matter?)
Answer: It is always best to consult the manufacturer's manuals and catalogs on this. Simpson Strong-Tie is one brand that is very extensively documented. If you're talking about the diamond plate type, they belong on the outside of the building, and tie the double top plate strongly to the rafter. If you use them on the inside, they only catch the lower truss joist across the join and don't properly attach anything together.
http://www.strongtie.com/products/connectors/h.asp
Since it's under copyright, I'm not sure if they'd consider a clip to be fair use, so here's a link directly into their PDF Installation notes on installing these things for Rafter and Truss construction. Scroll up or down for other Hurricane Clip and Earthquake ties.
http://www.strongtie.com/ftp/catalogs/S-INSTALL09.pdf#page=21
Comment: I should have been a little more precise. My question relates to outdoor decks.
Comment: In the case of a deck, the hurricane clip should be just fine on the inside with the following caveat. What is really important is that the ears on the cross beam are being attached to a full width piece of material. With trusses, you have a steel plate joined wood joint on the inside of the top double plate as opposed to a full width 2x4 or 2x6 rafter on the outside. With the deck, as long as the plate and ears are both attaching to solid wood members, they should be tied together with the clip at their combined full strength.


Initialization process of WebApplicationContext

Question: I am learning spring MVC, Can someone tell me when WebApplicationCotext gets initialized? and who is responsible to initialize WebApplicationContext?
Comment: Please try googling something first otherwise it shows lack of effort

https://docs.spring.io/spring/docs/5.0.0.RC3/spring-framework-reference/web.html#spring-web
Comment: Is it a Spring Boot application?
Comment: No, Its Spring MVC.
Answer: i think it is initialized in the first time when the app runs, here is my log when spring webapp starts, the server container is reponsible to it?


Golang go1.14.7.linux-amd64.tar.gz checksum not matching

Question: https://golang.org/dl/ shows a different SHA256 checksum versus what I downloaded into my VPS:

go1.14.7.linux-amd64.tar.gz   Archive     Linux   x86-64  118MB   4a7fa60f323ee1416a4b1425aefc37ea359e9d64df19c326a58953a97ad41ea5

I'm getting different values:

sha256sum go1.14.7.linux-amd64.tar.gz
353f6c251ab323f7435d107577f1504d3c4f74af4ebb06fa2d3c71fc7560f4f3  go1.14.7.linux-amd64.tar.gz

I downloaded it using

curl -O https://golang.org/dl/go1.14.7.linux-amd64.tar.gz

What's going on here? Is it possible the golang.org values are not updated? Man-in-the-middle attack or similar?
Comment: Check the downloaded file, it's just a placeholder. you need to tell `curl` to follow redirects with `-L`
Comment: Thanks! Just submitted the option missing to the Digitalocean HOWTO
Answer: The problem that you're seeing is due to not using the -L option, which performs automatic redirects.  The link you use redirects to the real location and provides a stub HTML page to perform the redirection should you be using a browser that doesn't properly support the Location header.  As a result, the hash you're getting is of a small, incomplete HTML file, not the real Go archive.
If I don't use the -L option, I get the result you reported; if I do, then I get the expected result as listed on the download page.  Note that if you have a trusted, strong checksum or signature for an archive that you verify, it's always safe to use the -L option, since you're going to verify the archive manually and an attacker won't be able to tamper with it.
Comment: Thanks! Just submitted the option missing to the Digitalocean HOWTO


Unable to convert classes into dex format build error in Unity 5.3.4f1, when Google Play games plugin & Facebook plugins are added into the project

Question: In my game, after importing Google play games plugin and Facebook plugin, I cant build my Unity Project . It gives a build error, Unable to convert classes to dex format. The Unity version is 5.3.4f1. The google play games plugin version is 0.9.32. Facebook plugin version is 7.5.0. The error log that I'm getting is this:
<code>CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0_31\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="E:/Adt/adt-bundle-windows-x86_64-20140702/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/BuildConfig;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanMr2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorCompatHelper;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActionBarDrawerToggle;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActionBarDrawerToggle$1;

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at SDKMain.main(SDKMain.java:129)

Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
... 9 more
]
stdout[
processing archive F:\User\path1\path2\path3\Temp\StagingArea\android-libraries\MainLibProj\libs\.\play-games-plugin-support.jar...
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF
ignored resource com/
ignored resource com/google/
ignored resource com/google/games/
ignored resource com/google/games/bridge/
processing com/google/games/bridge/BuildConfig.class...
processing com/google/games/bridge/NativeBridgeActivity.class...
processing com/google/games/bridge/TokenFragment.class...
processing com/google/games/bridge/TokenFragment$1.class...
processing com/google/games/bridge/TokenFragment$2.class...
processing com/google/games/bridge/TokenFragment$3.class...
processing com/google/games/bridge/TokenFragment$TokenRequest.class...
processing com/google/games/bridge/TokenPendingResult.class...
processing com/google/games/bridge/TokenResult.class...
processing archive F:\User\path1\path2\path3\Temp\StagingArea\android-libraries\cardview-v7-23.2.1\bin\classes.jar...
processing android/support/v7/cardview/BuildConfig.class...
processing android/support/v7/widget/CardView.class...
processing android/support/v7/widget/CardViewApi21.class...
processing android/support/v7/widget/CardViewDelegate.class...
processing android/support/v7/widget/CardViewEclairMr1.class...
processing android/support/v7/widget/CardViewEclairMr1$1.class...
processing android/support/v7/widget/CardViewImpl.class...
processing android/support/v7/widget/CardViewJellybeanMr1.class...
processing android/support/v7/widget/CardViewJellybeanMr1$1.class...
processing android/support/v7/widget/RoundRectDrawable.class...
processing android/support/v7/widget/RoundRectDrawableWithShadow.class...
processing android/support/v7/widget/RoundRectDrawableWithShadow$RoundRectHelper.class...
processing archive F:\User\path1\path2\path3\Temp\StagingArea\android-libraries\facebook-android-sdk-4.11.0\bin\classes.jar...
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF
ignored resource android/
ignored resource android/support/
ignored resource android/support/v7/
ignored resource android/support/v7/cardview/
ignored resource com/
ignored resource com/facebook/
processing com/facebook/AccessToken.class...
processing com/facebook/AccessToken$1.class...
processing com/facebook/AccessToken$2.class...
processing com/facebook/AccessToken$AccessTokenCreationCallback.class...
processing com/facebook/AccessToken$AccessTokenRefreshCallback.class...
processing com/facebook/AccessTokenCache.class...
processing com/facebook/AccessTokenCache$SharedPreferencesTokenCachingStrategyFactory.class...
processing com/facebook/AccessTokenManager.class...
processing com/facebook/AccessTokenManager$1.class...
processing com/facebook/AccessTokenManager$2.class...
processing com/facebook/AccessTokenManager$3.class...
processing com/facebook/AccessTokenManager$4.class...
processing com/facebook/AccessTokenManager$RefreshResult.class...
processing com/facebook/AccessTokenSource.class...
processing com/facebook/AccessTokenTracker.class...
processing com/facebook/AccessTokenTracker$1.class...
processing com/facebook/AccessTokenTracker$CurrentAccessTokenBroadcastReceiver.class...
processing com/facebook/BuildConfig.class...
processing com/facebook/CallbackManager.class...
processing com/facebook/CallbackManager$Factory.class...
processing com/facebook/CustomTabActivity.class...
processing com/facebook/FacebookActivity.class...
processing com/facebook/FacebookAuthorizationException.class...
processing com/facebook/FacebookBroadcastReceiver.class...
processing com/facebook/FacebookButtonBase.class...
processing com/facebook/FacebookButtonBase$1.class...
processing com/facebook/FacebookCallback.class...
processing com/facebook/FacebookContentProvider.class...
processing com/facebook/FacebookDialog.class...
processing com/facebook/FacebookDialogException.class...
processing com/facebook/FacebookException.class...
processing com/facebook/FacebookGraphResponseException.class...
processing com/facebook/FacebookOperationCanceledException.class...
processing com/facebook/FacebookRequestError.class...
processing com/facebook/FacebookRequestError$1.class...
processing com/facebook/FacebookRequestError$Category.class...
processing com/facebook/FacebookRequestError$Range.class...
processing com/facebook/FacebookSdk.class...
processing com/facebook/FacebookSdk$1.class...
processing com/facebook/FacebookSdk$2.class...
processing com/facebook/FacebookSdk$3.class...
processing com/facebook/FacebookSdk$4.class...
processing com/facebook/FacebookSdk$InitializeCallback.class...
processing com/facebook/FacebookSdkNotInitializedException.class...
processing com/facebook/FacebookSdkVersion.class...
processing com/facebook/FacebookServiceException.class...
processing com/facebook/GraphRequest.class...
processing com/facebook/GraphRequest$1.class...
processing com/facebook/GraphRequest$2.class...
processing com/facebook/GraphRequest$3.class...
processing com/facebook/GraphRequest$4.class...
processing com/facebook/GraphRequest$5.class...
processing com/facebook/GraphRequest$6.class...
processing com/facebook/GraphRequest$7.class...
processing com/facebook/GraphRequest$Attachment.class...
processing com/facebook/GraphRequest$Callback.class...
processing com/facebook/GraphRequest$GraphJSONArrayCallback.class...
processing com/facebook/GraphRequest$GraphJSONObjectCallback.class...
processing com/facebook/GraphRequest$KeyValueSerializer.class...
processing com/facebook/GraphRequest$OnProgressCallback.class...
processing com/facebook/GraphRequest$ParcelableResourceWithMimeType.class...
processing com/facebook/GraphRequest$ParcelableResourceWithMimeType$1.class...
processing com/facebook/GraphRequest$Serializer.class...
processing com/facebook/GraphRequestAsyncTask.class...
processing com/facebook/GraphRequestBatch.class...
processing com/facebook/GraphRequestBatch$Callback.class...
processing com/facebook/GraphRequestBatch$OnProgressCallback.class...
processing com/facebook/GraphResponse.class...
processing com/facebook/GraphResponse$PagingDirection.class...
processing com/facebook/HttpMethod.class...
processing com/facebook/LegacyTokenHelper.class...
processing com/facebook/LoggingBehavior.class...
processing com/facebook/Profile.class...
processing com/facebook/Profile$1.class...
processing com/facebook/Profile$2.class...
processing com/facebook/ProfileCache.class...
processing com/facebook/ProfileManager.class...
processing com/facebook/ProfileTracker.class...
processing com/facebook/ProfileTracker$1.class...
processing com/facebook/ProfileTracker$ProfileBroadcastReceiver.class...
processing com/facebook/ProgressNoopOutputStream.class...
processing com/facebook/ProgressOutputStream.class...
processing com/facebook/ProgressOutputStream$1.class...
processing com/facebook/RequestOutputStream.class...
processing com/facebook/RequestProgress.class...
processing com/facebook/RequestProgress$1.class...
processing com/facebook/TestUserManager.class...
processing com/facebook/TestUserManager$Mode.class...
ignored resource com/facebook/appevents/
processing com/facebook/appevents/AppEventsConstants.class...
processing com/facebook/appevents/AppEventsLogger.class...
processing com/facebook/appevents/AppEventsLogger$1.class...
processing com/facebook/appevents/AppEventsLogger$2.class...
processing com/facebook/appevents/AppEventsLogger$3.class...
processing com/facebook/appevents/AppEventsLogger$4.class...
processing com/facebook/appevents/AppEventsLogger$5.class...
processing com/facebook/appevents/AppEventsLogger$6.class...
processing com/facebook/appevents/AppEventsLogger$7.class...
processing com/facebook/appevents/AppEventsLogger$AccessTokenAppIdPair.class...
processing com/facebook/appevents/AppEventsLogger$AccessTokenAppIdPair$SerializationProxyV1.class...
processing com/facebook/appevents/AppEventsLogger$AppEvent.class...
processing com/facebook/appevents/AppEventsLogger$AppEvent$SerializationProxyV1.class...
processing com/facebook/appevents/AppEventsLogger$FlushBehavior.class...
processing com/facebook/appevents/AppEventsLogger$FlushReason.class...
processing com/facebook/appevents/AppEventsLogger$FlushResult.class...
processing com/facebook/appevents/AppEventsLogger$FlushStatistics.class...
processing com/facebook/appevents/AppEventsLogger$PersistedAppSessionInfo.class...
processing com/facebook/appevents/AppEventsLogger$PersistedAppSessionInfo$1.class...
processing com/facebook/appevents/AppEventsLogger$PersistedEvents.class...
processing com/facebook/appevents/AppEventsLogger$SessionEventsState.class...
processing com/facebook/appevents/FacebookTimeSpentData.class...
processing com/facebook/appevents/FacebookTimeSpentData$1.class...
processing com/facebook/appevents/FacebookTimeSpentData$SerializationProxyV1.class...
processing com/facebook/appevents/FacebookTimeSpentData$SerializationProxyV2.class...
ignored resource com/facebook/appevents/internal/
processing com/facebook/appevents/internal/ActivityLifecycleTracker.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker$1.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker$2.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker$3.class...
processing  com/facebook/appevents/internal/ActivityLifecycleTracker$4.class...
processing com/facebook/appevents/internal/ActivityLifecycleTracker$4$1.class...
processing com/facebook/appevents/internal/Constants.class...
processing com/facebook/appevents/internal/SessionInfo.class...
processing com/facebook/appevents/internal/SessionLogger.class...
processing com/facebook/appevents/internal/SourceApplicationInfo.class...
processing com/facebook/appevents/internal/SourceApplicationInfo$1.class...
processing com/facebook/appevents/internal/SourceApplicationInfo$Factory.class...
ignored resource com/facebook/applinks/
processing com/facebook/applinks/AppLinkData.class...
processing com/facebook/applinks/AppLinkData$1.class...
processing com/facebook/applinks/AppLinkData$CompletionHandler.class...
processing com/facebook/applinks/FacebookAppLinkResolver.class...
processing com/facebook/applinks/FacebookAppLinkResolver$1.class...
processing com/facebook/applinks/FacebookAppLinkResolver$2.class...
ignored resource com/facebook/internal/
processing com/facebook/internal/AnalyticsEvents.class...
processing com/facebook/internal/AppCall.class...
processing com/facebook/internal/AppEventsLoggerUtility.class...
processing com/facebook/internal/AppEventsLoggerUtility$1.class...
processing com/facebook/internal/AppEventsLoggerUtility$GraphAPIActivityType.class...
processing com/facebook/internal/AttributionIdentifiers.class...
processing com/facebook/internal/AttributionIdentifiers$1.class...
processing com/facebook/internal/AttributionIdentifiers$GoogleAdInfo.class...
processing com/facebook/internal/AttributionIdentifiers$GoogleAdServiceConnection.class...
processing com/facebook/internal/BoltsMeasurementEventListener.class...
processing com/facebook/internal/BundleJSONConverter.class...
processing com/facebook/internal/BundleJSONConverter$1.class...
processing com/facebook/internal/BundleJSONConverter$2.class...
processing com/facebook/internal/BundleJSONConverter$3.class...
processing com/facebook/internal/BundleJSONConverter$4.class...
processing com/facebook/internal/BundleJSONConverter$5.class...
processing com/facebook/internal/BundleJSONConverter$6.class...
processing com/facebook/internal/BundleJSONConverter$7.class...
processing com/facebook/internal/BundleJSONConverter$Setter.class...
processing com/facebook/internal/CallbackManagerImpl.class...
processing com/facebook/internal/CallbackManagerImpl$Callback.class...
processing com/facebook/internal/CallbackManagerImpl$RequestCodeOffset.class...
processing com/facebook/internal/CollectionMapper.class...
processing com/facebook/internal/CollectionMapper$1.class...
processing com/facebook/internal/CollectionMapper$2.class...
processing com/facebook/internal/CollectionMapper$Collection.class...
processing com/facebook/internal/CollectionMapper$OnErrorListener.class...
processing com/facebook/internal/CollectionMapper$OnMapValueCompleteListener.class...
processing com/facebook/internal/CollectionMapper$OnMapperCompleteListener.class...
processing com/facebook/internal/CollectionMapper$ValueMapper.class...
processing com/facebook/internal/CustomTab.class...
processing com/facebook/internal/DialogFeature.class...
processing com/facebook/internal/DialogPresenter.class...
processing com/facebook/internal/DialogPresenter$ParameterProvider.class...
processing com/facebook/internal/FacebookDialogBase.class...
processing com/facebook/internal/FacebookDialogBase$ModeHandler.class...
processing com/facebook/internal/FacebookDialogFragment.class...
processing com/facebook/internal/FacebookDialogFragment$1.class...
processing com/facebook/internal/FacebookDialogFragment$2.class...
processing com/facebook/internal/FacebookRequestErrorClassification.class...
processing com/facebook/internal/FacebookRequestErrorClassification$1.class...
processing com/facebook/internal/FacebookRequestErrorClassification$2.class...
processing com/facebook/internal/FacebookRequestErrorClassification$3.class...
processing com/facebook/internal/FacebookWebFallbackDialog.class...
processing com/facebook/internal/FacebookWebFallbackDialog$1.class...
processing com/facebook/internal/FileLruCache.class...
processing com/facebook/internal/FileLruCache$1.class...
processing com/facebook/internal/FileLruCache$2.class...
processing com/facebook/interna<message truncated>
</code>
I guess it is due to the Support-v4 aar file. There are two copies of Support-v4 aar file in the project, when I had added google play games plugin and facebook sdk plugin. But when I try to remove any one of the aar file, the project is building successfully, but the plugins wont work at all. So is there any way to solve this issue.? Thanks in advance.
Answer: Go to Assets->FacebookSDK->Plugins->Android->libs then delete android-support-v4.jar. There is a conflict there because it contains a class from another jar or aar file.
This problem was solved here too. If that did not solve your problem, create an empty project, import the facebook, and google plugins. Then zip and upload the project.
Comment: Thanks. It solved it. But I'm getting another error when I try to view google play leader board:

DEBUG: Received UI callback: ERROR_NOT_AUTHORIZED

The leaderboard just shows in a flash and goes away. Do you know any solution to this issue?
Comment: @njnjnj I don't know about that but you should create a new post for that. Include your whole error message and the code you use for your leaderboard then I will see what I can do.
Comment: Can you please help me regarding this issue of mine.
http://stackoverflow.com/questions/36933159/google-play-leaderboard-not-showing-up-after-posting-score-to-leaderboard-in-uni
Answer: To solve this problem:

On your main Assets folder search on "support"
Check for double support-annotations and also support-V4
Look for older version
Uncheck "Android" and click "Apply"

Done.
Answer: I faced a similar problem. The general way for solving this is:

In Windows Explorer, navigate to [project]\Assets.
To list all the jar and aar files, in the top-right search box of Explorer, enter *.?ar
Right-click anywhere to View as Details, and Sort by Name.
Check for files with the same or similar names. Normally these are the same files, possibly of different versions.
Delete the files of the older version.

Done!
For my case, the conflicting errors arose from Google Mobile Ads and Facebook SDK. I needed to delete two files:
Assets\FacebookSDK\Plugins\Android\libs\support-annotations-23.4.0.jar (deleted)
Assets\FacebookSDK\Plugins\Android\libs\support-v4-23.4.0.aar (deleted)
Assets\Plugins\support-annotations-24.0.0.jar
Assets\Plugins\support-v4-24.0.0.aar
Answer: I did not find any duplicate plugins. Upgrading to JDK8 and pointing to it in Unity Preferences solved it for me.
Answer: I had the same problem and resolved it by deleting the duplicate files with the older version in Google Play folder. You can see it in the image. I think It would help you.


move in file- unix

Question: For example consider this dataset:
tomato     1kg
orange     2kg
Fruit      Quantity
I want my dataset to be as:
Fruit      Quantity
tomato     1kg
orange     2kg
How can I use commands?
Answer: You can use sed and its hold space to accomplish that:
sed -n -e '${p;x;s/^\n//;p}' -e 'H' yourfile

on the last line ($), print it then print the content of the hold space (i.e. all lines except the last one)

the s command is necessary because the H command adds a newline to the hold space, so the hold space starts with an empty newline

append to the hold space (H)
Answer: If you're reading from a file, this will do what you want:
(tail -1 myfile && head -n -1 myfile) > newfile

Put it in parentheses to combine the output from both processes.
If you're not reading from a file, it's more difficult. You may have to
send part of it to a temporary file.
Answer: When the order of the other rows are random, you can use
tac inputfile

move in file- unix


Ubuntu Server proper SSH etiquette

Question: I am using ubuntu server 20.04 on a Raspberry Pi 4 as a Web-Server and eventually Mail-Server. The default user is called ubuntu and I was wondering if that is the account I am meant to SSH in, or if I should rename it, delete it or create a new user with the name I want. Are there any security concerns related to actively using the ubuntu user for remote access? Also, if I set up an email address using this server as firstname.lastname@example.com and my SSH user is called johndoe, will that cause any problems since I will have to login for SSH using "ssh firstname.lastname@example.com"? Thanks! :)
Answer: User Accounts: You have an 'ubuntu' account simply because the root account is locked. You need some account to be able to login for the first time. There is nothing special about the 'ubuntu' account -- it's just like every other admin account. You can use it --or a different account that you create-- as you please.

Creating a new admin user to replace 'ubuntu' is very easy.
Advice: If you decide to use the Ubuntu account, CHANGE THE PASSWORD. Don't make an intruder happy by keeping the default password.

SSH: Our usual advice is to ALWAYS use key-based authentication for SSH connections across the internet. Never passwords. Automated attacks against password-protected ssh servers are just too easy.
Comment: AksUbuntu is poorly suited to follow-up questions in comments. This is not a thread-based or coversational venue. 1) Yes, you can...after you create another user. 2) No, you didn't. A root prompt is not a root login.
Comment: So can I just disable the ubuntu account outright? Also, when I do "sudo -i" it logs me in as root. Does that mean that I enabled root accidentally? Thank you for your help!

Ubuntu Server proper SSH etiquette


number of permutations whose cycles all have odd length

Question: I found the number of permutations whose cycles all have odd length by using exponential generating function and found that it's
n![1-sum(C(i-1)/2^(2i-1))]
where the sum is 1<=i<=n/2
and C is catalan number.
Now i wonder if i can find this number directly without using generating function but combinatorical way.
Answer: What follows is more of a comment.
By classifying the odd-cycles  only permutations according to the size
of the cycle that $n+1$ is on we get the recurrence
$$Q_{n+1} = \sum_{k=0}^{\lfloor n/2\rfloor}
{n\choose 2k}\times (2k)!\times Q_{n-2k}$$
where $Q_0=1.$ We get the factor $(2k)!$ because placement of $n+1$ on the cycle transforms it into a sequence.
However as we solve this recurrence which is not difficult we invariably encounter the generating function of the species $\mathfrak{P}(\mathfrak{C}_{\mathrm{odd}}(\mathcal{Z}))$
$$G(z) = \exp\left(\sum_{q\ge 1} \frac{z^{2q+1}}{2q+1}\right)
= \exp\left(\sum_{q\ge 1} \frac{z^{q}}{q}
- \sum_{q\ge 1} \frac{z^{2q}}{2q}\right)
\\ = \frac{1}{1-z} \left(\frac{1}{1-z^2}\right)^{-1/2}
= \frac{1}{1-z} \sqrt{1-z^2}$$
or one of its guises. The closed form then follows by inspection using the generating function of the Catalan numbers.
For example, we may solve the recurrence by considering the exponential generating function $\sum_{n\ge 0}\frac{Q_n}{n!} z^n$  and transforming it into a differential equation but this EGF is precisely $G(z)$ which we may not use.
Comment: thanks Marko, that was very helpful.
Comment: hey. could you please explain me how did you get this recurrence and how you can solve it with no generating function?


View message in website to mobile Browsers

Question: How to display a message on website to mobile Browsers that disappears after a short time use jquery-mobile
Such as gmail show when you perform the download of attachment
Answer: hm.. quickshot:
var shortTime = 5; // for 5 seconds
$('body').on("yourevent",function(e) {
    $('body').append($("
Starting download
"));
    setTimeout(function(e) {
        $('body').remove($("#startDl"));
    }, shortTime);
});

there are still better ways.. e.g. remove the element after callback of your function startDownload() or whatever..
Comment: @lealam could i help you?


How and when are interrupt key combination,such as CTRL-C, translated to signals?

Question: Using a Linux OS, I need to transparently pass all keystrokes from remote connections to local hardware connections. This is fairly straight forward for everything but signals. I know I can register handlers for each signal that capture and pass the keystroke, but this seems like a hack that might not work for edge cases (what if someone changes the interrupt key combo mapping, would I be double passing the keystrokes, etc.).
In order to come up with a better solution, I really need to know more about how the key combos, IE: CTRL-C, become signals, IE: SIGINT.

How does the keycombo become a Signal (in the kernel, client application, runtime)?
Is the keystroke still passed? If CTRL-C has a null handler, does STDIN still get CTRL-C?
What is the best way to not interpret any keystroke as a signal combination? Can this be done in TTY or Environment settings?
Comment: In short:a signal is not a keystroke.  They are unrelated.
Comment: You want **tcsetattr** (`man 3 termios`) to set the terminal into raw mode.
Answer:
The key combo is turned into a signal by the terminal's line discipline, a layer in the TTY subsystem. Here's the description from Wikipedia:

For example, the standard line discipline processes the data it receives from the hardware driver and from applications writing to the device according to the requirements of a terminal on a Unix-like system. On input, it handles special characters such as the interrupt character (typically Control-C) and the erase and kill characters (typically backspace or delete, and Control-U, respectively) and, on output, it replaces all the LF characters with a CR/LF sequence.

The keypress is not passed, it's suppressed when the signal is raised. If the process has no SIGINT handler, the kernel will terminate it.
You can obviously override this: that's how tools like ssh work. You can easily do this by setting the terminal to "raw" mode, e.g. with the shell command stty raw. If you then run cat -vE you can hit any keys you want and see them printed in caret notation. Make sure to plan on a way to close the terminal because you can obviously not Ctrl-C/Z/D out of it anymore.
Answer:
How does the keycombo become a Signal (in the kernel, client application, runtime)?

This translation is performed as part of the kernel's TTY line discipline. There are a number of other translations performed as part of this process, like end-of-file (^D), stop signalling (^Z), character echo, basic line editing (backspace, ^U, etc), and DEL/BS and CR/CRLF translation.

Is the keystroke still passed? If CTRL-C has a null handler, does STDIN still get CTRL-C?

No. Control characters which are handled by the line discipline are not passed to the foreground process.

What is the best way to not interpret any keystroke as a signal combination? Can this be done in TTY or Environment settings?

Use tcgetattr() and tcsetattr() to change the terminal attributes. The c_cc element of struct termios contains settings for control characters; you can disable some or all elements by setting them to _POSIX_VDISABLE.
(You can also use cfmakeraw() -- documented at the same page as above -- to clear most elements of a struct termios, giving you a mostly "raw" terminal. However, this may disable more terminal behaviors than you expect.)


To generalize of Fermat's Last Theorem, to find the solution of $a^n+b^n+c^n = d^n$

Question: The Fermat's Last Theorem was proved by Andrew Wiles in 1995. It states that no three positive integers $x$, $y$, and $z$ can satisfy the equation  $x^n+y^n= z^n$ for any integer value of $n$ greater than two.
I wonder if there is general solution for $a^n+b^n+c^n = d^n$  , $n>4$ or not?
$a,b,c,d,n$ are positive integers
$$a^n+b^n+c^n = d^n$$
For $n=2$, there is a solution
$$1^2+2^2+2^2=3^2$$
For $n=3$, there is a solution
$$3^3+4^3+5^3=6^3$$
I saw somewhere that
For $n=4$, there is a solution
$$95800^4 + 217519^4 + 414560^4 = 422481^4$$
Is there proof for the general problem that there is no solution for $n>4$?
Do you know counterexamples to disprove the generalization for $n>4$?
Thanks for answers
Answer: From the second edition of Unsolved Problems in Number Theory by Richard K. Guy, section D1, Euler conjectured that your equation should be impossible for $n \geq 4.$ For $n=4,$ the first counterexample was by Noam Elkies, a parametric solution was given by Dem'janenko, and your solution above was found by Roger Frye. No explicit reference for Frye...There is a third edition, there it starts on page 209. I don't think anyone has any solutions for $n>4.$
To be specific, Euler thought that you needed four fourth powers to add up to another fourth power, five fifth powers to add up to another fifth power, and so on.
OK, we have
$$ 27^5 + 84^5 + 110^5 + 133^5 = 144^5,  $$
by Lander and Parkin (1966). I don't think three fifth powers is going to work. Might try six or five or four sixth powers, or seven or six or five seventh powers if you want to stick with prime exponents. Note that, by Fermat's little theorem, for sixth powers , all but one of the summands will need to be divisible by 7. That is, if some $a \neq 0 \pmod 7$ then $a^6 \equiv 1 \pmod 7.$ You have fewer than seven summands, so the left hand side will not be divisible by 7, so the right hand side will be exactly $1 \pmod 7.$ Something of a timesaver. To compare, look at the solution in the original question for $n=4,$ two out of three numbers on the left hand side are divisible by 5.
Alright, as of the second edition (1994) there were no known solutions for $n$ $n$th powers adding up to another $n$th power for $n \geq 6.$ So, even what Euler had intended as the problem had no known solutions. Of course, computers are much faster now...
Comment: @WillJagy, Actually, for $n$ $n$th powers equal to an $n$th power, while there is none for $n=6$, there is for $n=8$. See [Eight Powers](http://mathworld.wolfram.com/DiophantineEquation8thPowers.html). If we allow negative integers, then there are for $n=7,9$ as well.
Comment: Thanks a lot for the references. I have been using them while searching the subject. I wonder why the method that Wiles used to prove for  Fermat's Last Theorem does not work for the problem I asked. If you know the proof of Fermat's Last Theorem, could you please advice about difficulties and differences of the problem I asked from FLT? Thanks
Comment: @Mathlover, my advice would be for you to find good presentations of the proof of FLT for exponent 5, begin with list at http://en.wikipedia.org/wiki/Proof_of_Fermat%27s_Last_Theorem_for_specific_exponents#n.C2.A0.3D.C2.A05 and see how things go when trying to prove that the sum of three fifth powers cannot be another fifth power. At the same time, you could run a computer search to find such an equation.
Comment: @Mathlover, $n=6$ is likely to be easier to deal with, http://en.wikipedia.org/wiki/Proof_of_Fermat%27s_Last_Theorem_for_specific_exponents#n.C2.A0.3D.C2.A06.2C_10.2C_and_14
Comment: If I discover one solution for $n$ $n$th powers adding up to another $n$th power for some $n\geq 6$, or one solution for $a^n+b^n+c^n=d^n$ for $n\geq 4$, would that be a publishable result?
Comment: @rhombidodecahedron: Of course. To lengthen the paper, you can give a summary of known results, a description of the method used, suggestions for further work or improvements to the method, etc, etc.


$\{u_1, u_2, . . . , u_n\}$ independent $\Longrightarrow \{Bu_1, Bu_2, . . . , Bu_n\}$ independent

Question: I have no idea how to prove this:
Let
$S = \{u_1, u_2, . . . , u_n\}$,
be a linearly independent subset of $\mathbb{R}^m$ and $B \in M_{(m\times m)}(\mathbb{R})$ is invertible. Prove that the set
$L_B(S) = \{Bu_1, Bu_2, . . . , Bu_n\}$
is also linearly independent
Comment: A simpler question: do you know what "invertible" and "linearly independent" mean?
Comment: It is an isomorphism.
Answer: Suppose that $\{Bu_1, Bu_2, \ldots, Bu_n\}$ is not linearly independent. Then some vector in $\{Bu_1, Bu_2, \ldots, Bu_n\}$ is a linear combination of the others. Without loss of generality, say
$$
Bu_1 = c_2 Bu_2 + c_3 Bu_3 + \cdots + c_n Bu_n
$$
Multiplying both sides by $B^{-1}$ gives
$$
u_1 = c_2 u_2 + c_3 u_3 + \cdots + c_n u_n
$$
Which means $\{u_1, u_2, \ldots, u_n\}$ is linearly dependent, a contradiction. Therefore, $\{Bu_1, Bu_2, \ldots, Bu_n\}$ is linearly independent.
Comment: Thank you! I appreciate it.
Answer: The first two steps of most exercise-proofs are the same.

Suppose $u_1,\ldots,u_n$ are linearly independent. By the definition of "linearly independent", for all $k_1, \ldots, k_n$ that are not all zero, $k_1u_1 + \cdots + k_nu_n \neq 0$.
We wish to show $Bu_1, \ldots, Bu_n$ are linearly independent. By the definition of linearly independent, for any $c_1, \ldots, c_n$ not all zero, we must show $c_1Bu_1 + \cdots + c_nBu_n \neq 0$.

Can you go from there?
Answer: Matrices and linear transformation can be seen as interchangeable. Thus an invertible matrix is a 1-1 linear transformation. That is, a bijective linear transformation (onto its range). This is a vector space isomorphism and LI sets being described in the language of vector spaces are preserved by isomorphism.


ls: cannot access .gvfs: Permission denied

Question: Whenever I run an application in terminal as root (such as sudo gedit  /etc/default/varnish) , subsequently when I open another terminal I get "ls: cannot access .gvfs: Permission denied" error at top line of terminal.
I found a solution on the net
  umount /path/to/.gvfs
  rm -rf .gvfs

but it only fixes problem temporarily.
It appears that I have two mounted instances of gvfs in my system
  $ sudo mount |grep gvfs
    gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=33)
    gvfsd-fuse on /home/****/.gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0)

I don't know if it's related to, a few months ago I had to change permission in my home folder like
  sudo chown -R $USER:www-data

Would you please help me fix it?
EDIT:
After I unmount /run/user/1000/gvfs I don't get that error.
Comment: And that's one of the reasons why you shouldn't run `sudo` with graphical programs.
Comment: I suspect this particular situation may actually *not* be related to [running graphical programs with straight sudo](http://askubuntu.com/questions/270006/why-user-should-never-use-normal-sudo-to-start-graphical-application). Permissions/access on users `.gvfs` folders [have always been interesting and (to some of us) surprising](http://unix.stackexchange.com/a/77592/11938).
Comment: possible duplicate of [Why user should never use normal sudo to start graphical application?](http://askubuntu.com/questions/270006/why-user-should-never-use-normal-sudo-to-start-graphical-application)
Comment: @muru
Thank you for the link, it explains well why I should not run sudo to open graphical applications. But I still wonder why I began to get that error message
Comment: Quoting the top answer in the linked question: "This will sometimes result in the configuration files being owned by root and thus inaccessible to you (when you later run the program as yourself and not as root)."
Comment: Unmounting fixed this issue for me too!
Answer: Running graphical applications with sudo can sometimes lead to problems like this.
Explanation
sudo runs the program with superuser privileges (like running as root), but the program still sees the current home directory as your home directory.
So, when the software writes its configuration files, it'll end up creating files in your home directory that are owned by the root user.  You end up with files you yourself cannot edit or delete, and software running as you won't be able to modify it either, leading to more problems.
What is the best solution?
There is an alternative: gksudo.
This variant of sudo will set up environment variables, such as the home directory, in such a way that makes running graphical applications as root a lot safer and won't confuse programs into creating root-owned files in your home directory.
Why does this affect graphical applications?
This doesn't just affect graphical applications, nor does it affect all graphical applications.  It affects applications that store configuration inside the current user's home directory.  This is just more common among graphical applications.
Sometimes applications will be able to detect if they're run with sudo and adjust their behaviour accordingly, but this is not common with graphical applications which are usually not expected to be run with sudo.
How do I fix the problem?
You'll need to find root-owned files and directories within your home directory and remove them.  It's better to remove them than change their ownership in my opinion, as they were not intended for your user, but the root user, so there may be unexpected effects if you simply change ownership.  You can of course back them up in case you decide there's something you want in them later.
To find root-owned files in your home directory:
find ~ -user root

If you are still having problems with some applications (run as your user), try rebooting to clear out /tmp and anything still running.  Occasionally some applications might have corrupted their existing config files and need you to remove all their configuration in your home directory, but hopefully this won't be the case for many.
Comment: By using `gksudo` instead of `sudo` when running graphical programs.
Comment: Yes, other than the possibility you now have root-owned files in your home directory that shouldn't be root-owned.
Comment: Thank you for explanation. How can I fix it? Or everybody has the same issue as me?
Comment: So there is nothing wrong in my system.
Answer: Just give the user permissions to the .gvfs/ and it should fix it.
sudo chown -R $USER:$USER ~/.gvfs/

Comment: All these years... the answer was right in front of me. Thanks. Is there any downside at all to opening up the permissions in this way?


How to test the Elixir GenStage Consumer?

Question: I found some resources on how to test the producer, however there is nothing I could find which shows how to test the Consumer.
In producer, I create a dummy consumer and everything works fine, however in consumer I am struggling with testing.
defmodule DataProducer do
      use GenStage

      def start_link([]) do
        GenStage.start_link(__MODULE__, 0, name: __MODULE__)
      end

      # {:queue.new, demand, size}
      def init(counter) do
        {:producer, counter, dispatcher: GenStage.BroadcastDispatcher}
      end

      def handle_demand(demand, state) do
        events = Enum.to_list(state..state + demand + 1)
        # Logger.info "demand is: #{inspect(demand)}, state is #{inspect(state)}"
        {:noreply, events, (state + demand)}
      end
    end

Producer Test:
 defmodule DataProducerTest do
      use ExUnit.Case

      test "check the results" do
        {:ok, stage} = DataProducer.start_link([])
        {:ok, _cons} = TestConsumer.start_link(stage)
        assert_receive {:received, events}
        GenStage.stop(stage)
      end

    end

    defmodule TestConsumer do
      def start_link(producer) do
        GenStage.start_link(__MODULE__, {producer, self()})
      end
      def init({producer, owner}) do
        {:consumer, owner, subscribe_to: [producer]}
      end
      def handle_events(events, _from, owner) do
        send(owner, {:received, events})
        {:noreply, [], owner}
      end
    end

And consumer:
defmodule DataConsumer do
  use GenStage
  def start_link([]) do
    GenStage.start_link(__MODULE__, :any_state)
  end
  def init(state) do
    {:consumer, state, subscribe_to: [{DataProducer, selector: fn n -> n > 50 && n < 100 end, max_demand: 10}]}
  end
  def handle_events(events, _from, state) do
    for event <- events do
      # :timer.sleep(250)
      Logger.info inspect( {self(), event, state} )
    end
    {:noreply, [], state}
  end
end

Thank you in advanced.
Comment: You can either mock DataProducer using ex_mock, or make producer module parametric to initialize consumer with your own custom test producer.
Answer: No reason to use ex_mock here. It would much easier if you made the producer your consumer is subscribing to an argument like so:
defmodule DataConsumer do
  use GenStage

  def start_link(producer) do
    GenStage.start_link(__MODULE__, producer)
  end

  def init(producer) do
    {:consumer, state, subscribe_to: [{producer, selector: fn n -> n > 50 && n < 100 end, max_demand: 10}]}
  end
end

Then you could have a TestProducer:
defmodule TestProducer
  use GenStage

  def notify(pid, event) do
    GenServer.cast(pid, {:notify, event})
  end

  def start_link do
    GenStage.start_link(__MODULE__, :ok)
  end

  def init(:ok) do
    {:producer, :ok, dispatcher: GenStage.BroadcastDispatcher}
  end

  def handle_demand(_demand, state) do
    {:noreply, [], state}
  end

  def handle_cast({:notify, event}, state) do
    {:noreply, [event], state}
  end
end

And subscribe to it in your test and assert on the expected outcome:
defmodule DataConsumerTest do
  use ExUnit.Case

  test "consumes events" do
    {:ok, pid} = TestProducer.start_link()
    DataConsumer.start_link(pid)
    TestProducer.notify(%{data: :event_data})

    # assert thing you expected to happen happens
  end
end

TLDR; If you're working with a lot of different consumers in your codebase, a manual/test event producer is a must. A consumer does not really care what a producer does to produce events, just that it can subscribe to and consume them. So your tests just need to make sure the consumer is able to receive events from any producer and you can send them the correct events its looking for in the tests.
Comment: Thank you for the respond. Can you please put an example for `# assert thing you expected to happen happens` ? Thanks
Comment: from your implementation, how can you get the demand requested by consumer? Sorry I can't see how this test would work. You mentioned `So your tests just need to make sure the consumer is able to receive events` How do you test that, when consumer doesn't return event in the state, so one should test if Producer receives new demands. Is that correct?
Comment: @MrH For example I would test that a record was created or whatever my consumer was doing was executed. Also, for the test, we ignore the demand requested by the consumer and just generate the events manually. `handle_cast({:notify, event}, state)` will dispatch those events to your consumer always. **TLDR;** the demand loop is there so that you can respond to demand as the consumer is free to accept new events. If you don't care about demand (which we don't in this test case) you can ignore it and dispatch events to consumers whenever you want.
Answer: In the test for the consumer:
 test "should behave like consumer" do
    {:ok, producer} = DummyProducer.start_link(1)
    {:ok, consumer} = Consumer.start_link(producer)
    Process.register self, :test
    assert_receive {:called_back, 10}
  end

Now DummyProducer
defmodule DummyProducer do
  use GenStage

  def start_link(demand) do
    GenStage.start_link(__MODULE__, demand)
  end

  def init(demand) do
    {:producer, demand}
  end

  def handle_demand(demand, counter) when demand > 0 do
    events = Enum.to_list(counter..counter+demand-1)
    Process.send_after(self(), {:stop, demand}, 1)
    {:noreply, events, demand + counter}
  end

  def handle_info({:stop, demand}, state) do
    send :test, {:called_back, demand}
    {:stop, :normal, demand}
  end
end

I think,
The point of Testing the consumer is checking if consumer can send the demand and stick with max demand allocated in the subscription.


Unable to create a table with foreign key. Error: ORA-00904: : invalid identifier

Question: I am trying to create a table that has a foreign key in a table called 'country' which looks as follows:
CREATE TABLE country (
   name varchar2(50),
   region varchar2(60),
   area number(10,0),
   population number(11,0),
   gdp number,
   CONSTRAINT country_PK primary key (name)
 );

Every time I try to reference the 'country' in my 'City' create table I get this error ORA-00904: : invalid identifier.  Can someone please tell me what I am doing wrong? Thank you.
CREATE TABLE City(
CityName varchar2(50) not null,
CityCountry varchar2(60),
CityPopulation number(11,0),
IsCapital char(1),
CONSTRAINT CityName_pk PRIMARY KEY (CityName),
CONSTRAINT CityCountry_fk FOREIGN KEY (CityCountry) REFERENCES country (name),
);

Comment: The invalid identifier is the superfluous `,` at the end of your foreign key constraint. Omit it and your foreign key will work.
Comment: in `country` table your PK is `name varchar2(50)` and in `City` table your FK is `CityCountry varchar2(60)` - try having 50 or 60 in both - even if this is not what causes problem its not a good idea to have as different type size columns
Answer: Remove the trailing comma , from your last line of Country table DDL
CONSTRAINT CityCountry_fk FOREIGN KEY (CityCountry) REFERENCES country (name),

should become:
CONSTRAINT CityCountry_fk FOREIGN KEY (CityCountry) REFERENCES country (name)


*ngFor doesnt update on Value Change

Question: My *ngFor doesnt update on Value Change. My relevant code:
chat.component.html

    {{contact.name}}

chat.component.ts
export class ChatComponent implements OnInit {
    public selectedTeamId: string;
    constructor(
        private apiClientService :ApiClientService,
        private teamService: SetTeamService
    ){
         this.teamService.teamIdChange.subscribe(value => {
            this.selectedTeamId = value;
            this.apiClientService.getAPIObject(param, "chat-room-list").then((data) => {
                 this.contactList = data.response_payload.contacs;
            });
        });
     }
 }

setTeam.service.ts
export class SetTeamService {
    public teamId:string = '';
    teamIdChange: Subject<string> = new Subject<string>();
    constructor( ) {
        this.teamIdChange.subscribe((value) => {
            this.teamId = value;
            sessionStorage.setItem('teamId',value);
        });
    }

    setTeamId(teamId){
       this.teamIdChange.next(teamId);
    }
}

The following steps should happen:

The Set Team ID function get called with a new value
The Subscribe in the constructer should get notified
The component starts an GET Api Call with new param
The *ngFor in the Template should iterate over the new Value in contactList

Step 1, 2 and 3 are working. I get the value from my API and the contactList updates.
Sadly Step 4 doesnt work. the Template doesnt react or rerender on the value change. Usually im doing this stuff on the NgOnInit and it works this way. But this time i need a subscribe on a service Value.
EDIT:
Value from the API Response:
{
    "status": {
        "statusCode": 0,
        "statusMessage": "OK"
    },
    "response_payload": {
        "contacs": [
            {
                "id": "0c9d8efc-fc8a-42fc-80d8-64532679df48",
                "crm_account": "d9eec698-80d2-4976-8b79-9a900737848a",
                "name": "XXX",
                "email": "XXX",
                "deleted": "0",
                "update_date": "2019-07-25 05:05:48",
                "create_date": "2019-07-25 05:05:48",
                "hasChat": false
            },
            {
                "id": "885c2c11-cd5b-461c-b6dd-efdf4e21966d",
                "crm_account": "6615b728-c484-4f94-bc74-b214fab2a9e3",
                "name": "YYY",
                "email": "YYY",
                "deleted": "0",
                "update_date": "2019-08-02 15:02:15",
                "create_date": "2019-08-02 15:02:15",
                "hasChat": "1234"
            }
        ]
    }
}

navbar.component.html

navbar.component.ts
setTeamId(team) {
  let teamId = team['team_id'];
  this.teamService.setTeamId(teamId);
}

Comment: Looks like your navcomponent calls setTimeId method before the component subscribe to the service' subject. Because of the nature of the Subject, it emits the values to all subscribers if value is smitten after the subscription. Can you try changing the Subject to BehaviorSubject.
Comment: @VivekDoshi Nice catch, but thats not the Problem. I have a typo in my Rest API response where its `contacs`, instead of `contacts`. Need to Fix it on my next backend Deploy, but here it doesnt matter
Comment: please confirm that you are getting updated response ` this.contactList = data.response_payload.contacs;` with console log and its diffrent then what you are seeing in your html.
Comment: your code looks good, it should be working, but I think its typo `data.response_payload.contacs` in here,may be it should be `data.response_payload.contacts`
Comment: please provide the output of `data.response_payload.contacs`, what are you getting there?
Comment: @VivekDoshi added the Response
Comment: @VivekDoshi i can confirm this
Comment: in that case your code must be working, there is no issue, please try to make sample on stackblitz, then I will be able to help you.
Comment: @sHamann Can you please let us know who/how `setTeamId` method of `SetTeamService` is called? Also `this.apiClientService.getAPIObject(param, "chat-room-list")` call returns a Promise or an Observable?
Comment: @user2216584 I added my navbar component which triggers the setTeamId. The `getAPIObject` returns an Promise
Comment: Could you try to track the *ngFor by yourselfe. Change your loop to *ngFor="let contact of contactList; let i = index;trackBy: tracker" and in your component.ts add the tracker tracker = (i, e) => {
    console.log('render');
    return e;
  }; and check if the tracker fires up. Sorry, i have no idea how to format code in the comments :D
Comment: Your are also not declaring this.contactList in your components.ts. This should still work, but maybe it's causing trouble somehow.
Comment: Do you receive the mandanten as an component input?
Comment: @SebastianMünster The tracker doesnt trigger on the value Change
Comment: @sagat the mandanten value is set at `ngOnInit` from the Navbar component
Comment: maybe its not updating the mandanten, did u evaluate that?
Comment: The code as you have it here works fine: https://angular-w9nfkn.stackblitz.io , can you show the implementation of `getAPIObject`?
Comment: The call to `getAPIObject` does not seem to take into account the new team id. What makes the api response to be different ? Where is `param` defined ?
Answer: A lot of good questions in the comment Section and as a lot of people have suggested the code should work. And Yes it did.
But someone of my coworker changed the ChangeDetectionStrategy to onPush ...
https://angular.io/api/core/ChangeDetectionStrategy

*ngFor doesnt update on Value Change


Strangely defined ball compact in $L^p(I)$ or not?

Question: Let $I = (0, 1)$ and $1 \le p \le \infty$. Set$$B_p = \{u \in W^{1, p}(I) : \|u\|_{L^p(I)} + \|u'\|_{L^p(I)} \le 1\}.$$When $1 < p \le \infty$, does it necessarily follow that $B_p$ is compact in $L^p(I)$?
Comment: Do you know the Ascoli-Arzelà theorem? This is very similar.
Comment: The ball is not really strange, it is the unit ball in (one of the variants of) the $W^{1,p}$ norm. Thus the title should be $W^{1,p}$ unit ball compact in $L^p=W^{0,p}$. Which is equivalent to the embedding operator $W^{1,p}\to L^p$ being compact.
Answer: Note that
$B_p$ compact in $L^p$ $\Rightarrow$ $B_p$ closed in $L^p$ $\Rightarrow$ $B_p$ complete in $L^p$ $\Rightarrow$ $W^{1,p}(I)$ complete w.r.t. $\|\cdot\|_{L^p}$
So, $B_p$ isn't compact in $L^p$.
However, $B_p$ is relatively compact in $L^p$.


run C++ compiler via batch file

Question: I want to start learning C so started reading "C for dummies". It asked me to create a batch file that runs the gcc command that runs the compiler (Dev-C++).
I managed to create a gcc.bat file in c:\windows using the command "copy con gcc.bat". In this file I inserted the path name and details as in the book using the terminal, which is "@c:\Dev-C++\bin\gcc %1 %2 %3 %4 %5 %6"
(I made sure the pathname is similar to the path in which Dev-C++ is installed)
Now to check if it is installed properly I went to another folder and typed "gcc -v",
however it returns "the system cannot find the path specified".
Can you help me what I did wrong?
Many thanks :)
Comment: You already know the path to GCC, so use it like this, `@"C:\Dev-C++\bin\gcc" -v`. Alternatively, change directory to `"C:\Dev-C++\bin"`, or add it to your `%PATH%` location and use it directly.
Comment: If you are on Windows the DOS tag is *inappropriate*
Answer: Dev-C++ is old. I used it myself many years ago, but then I discovered Code::Blocks (http://codeblocks.org/) which I still use today.
As for gcc running in the Command Prompt, you could just run this as the first command:
<code>SET PATH=C:\Dev-C++\bin;%PATH%
</code>
After that you can just run gcc in the prompt.
A more recent version of GCC for Windows is available at http://winlibs.com/. Instructions on how to use it from console and Code::Blocks are on the website.

run C++ compiler via batch file


How do I output a scoreboard value or a selector to chat in Bedrock Edition?

Question: JSON text format in Bedrock Edition is very different from that in Java Edition.
The possible elements to go in the {"rawtext":[]} component are:

text
translate
with
(args)

As you can see it is a very limited selection. This also means that there is no way to output a scoreboard score or a target selector's result to the chat. Is that right, or is there an alternate way to output these?
Answer: As of November 17, 2020, this has been made possible with the 1.16.100 update. This update includes changes to command format, including the addition of selectors and scores to the Bedrock Edition /tellraw command. These act the same as their Java Edition counterparts, meaning the commands that you know and love in Java Edition will be the same when they are added to Bedrock Edition.
Note that you need to change the raw JSON text format to be in BE syntax:

tellraw @a {"rawtext":[{"selector":"@p"},{"text":" has won the game!"}]}

tellraw @a {"rawtext":[{"text":"You have "},{"score":{"name":"*","objective":"lives"}},{"text":"lives left."}]}

Remember, while these new JSON features have been added to Bedrock Edition to make it more like Java Edition's ways, they are still not the same. The following items will still be different:

Text formatting: Instead of using raw JSON text, use the section sign § with formatting codes. For example:
{"text":"Test","bold":true} → {"text":"§lTest"}
No further changes have been made to allow NBT support. So unfortunately, you may not use raw JSON text in NBT tags, like items' custom names and lores, though you can mimic the /give command through a little extra work.
Answer: what about /tellraw @p {"rawtext":[{"score":{"name":"@s","objective":"obj_name","value":"?"}}]}?
Answer: if you're still looking
/tellraw @a ["",{"text":"Your score: "},{"score":{"name":"@a","objective":"your score name"}}]


Enter special characters in Excel VBA

Question: How do I enter special characters in Excel VBA? For example if I want "●" (large interpunct) in some strings, they all appear as "?". I tried to substitute all "●" with ● in VBA but it didn't work, simply displayed ● in the string.
Comment: Try `"This is a strong bullet - " & ChrW(9679)`. Note that not all GUI components can display unicode; the Immediate window will just show `?`.
Answer: Reference Website  - Unicode and VBA's ChrW() and AscW() functions
Here the code for bullet et strong bullet. Use hexadecimal in lieu of long.
Sub DisplayBullet()
Cells(1, 1).Value = "This is a bullet - " & ChrW(8226)

Cells(2, 1).Value = "This is a strong bullet - " & ChrW(&H25CF)

End Sub

Important: If you try to display in a MsgBox it's not working.

Enter special characters in Excel VBA


Changing Light Switch - all three wires the same color

Question: How do I change a light switch when I took switch out and it has three wires all the same color - red?
Which wire is which??
Comment: You move the wires from the old switch to the new switch one at a time so that you don't mix them up.
Comment: Is it a 3-way switch? That is, is it one of a pair of switches which operates one light or one set of lights which go on and off together?
Comment: @RickKapsch Take a picture and post it here . That way we know if it is a 3 way or what kind of switch we are assuming you mean a wall switch for a light. Please clarify - pictures are better..
Answer: While annoying, it is entirely legal in the USA to use all same-color wires for a 3-way switch setup.   This implies wires in conduit, where any wire color can be chosen... rather than multiconductor cable, where the factory decides the colors and they'd never put 2 reds in a cable.
Two of the screws are the same color.  These are the messengers.   One screw is a different color.  This is the common.   If the screws are not different colors, look at the markings on the switch to figure out which is which.
The wires enter the box in one or more cables or conduits.  The messengers will always be together.  Depending on topology, there's probably a 70% chance that the messengers exit via a different conduit than the common. The fact that the installer used the same colors makes this even more likely... if they were all in the same conduit, he'd confuse himself! So most likely the common goes into a different conduit/destination, and the installer used the same color because it was in his hand.
Assuming we're dealing with a 3-way switch, there is no harm in trial and error; worst case the circuit won't work fully.  However, do not connect a ground wire anywhere except the ground terminal.
Comment: @CarlWitthoft I edited my answer to address your concerns,
Comment: Your suggested approach doesn't work if the OP didn't mark the wires to begin with.  We don't even know (not your fault) whether it's a 3-way or just controls two separate fixtures.
Comment: I for one reserve downvoting for answers which are seriously or dangerously wrong.  @CarlWitthoft good point.  I had earlier thought of adding what I now added, but thought it would be confusing or redundant.  Also, you can often figure out where the wires went based on how they are bent/fall in the box. I added some methods to detect the wires.
Comment: SInce the intent of up and down votes is to distinguish helpful and valuable answers from everything else,  I believe it's not only allowable but beneficial to the site as a whole to downvote incomplete or inaccurate answers.


getTabHost() is returning null

Question: I am following the directions for a TabLayout.  Everything is pretty much an exact copy from that page.
public class DashboardActivity extends TabActivity {

the problem is that in this line TabHost tabHost = getTabHost();, tabHost is always null, which causes a null pointer exception in the TabActivity base class.
Is there something I am missing?
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    profile = Controller.getProfile();

    this.setContentView(R.layout.test);

    buildTabs();
}

private void buildTabs()
{
    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost();// The activity TabHost

    if(tabHost != null)
    {
        // Initialize a TabSpec for each tab and add it to the TabHost
        TabSpec statementSpec = tabHost.newTabSpec("statements").setIndicator("Statements (" + profile.Statements.length + ")",
                          res.getDrawable(R.drawable.ic_tabs_statements))
                      .setContent(new Intent().setClass(DashboardActivity.this, SplashActivity.class));
        tabHost.addTab(statementSpec);

        TabSpec paymentSpec = tabHost.newTabSpec("payments").setIndicator("Payments (" + profile.Items.length + ")",
                          res.getDrawable(R.drawable.ic_tabs_payments))
                      .setContent(new Intent().setClass(DashboardActivity.this, SplashActivity.class));
        tabHost.addTab(paymentSpec);

        tabHost.setCurrentTab(0);
    }
}

Layout
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>

state-list drawable
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/ic_tab_active"
          android:state_selected="true" />

    <item android:drawable="@drawable/ic_tab_suspended" />
</selector>

I even tried moving the images in the state-list drawable from /rex/drawable to /res/drawable-hdpi.  I always get the same error.
05-31 21:22:23.753: ERROR/AndroidRuntime(647): FATAL EXCEPTION: main
05-31 21:22:23.753: ERROR/AndroidRuntime(647): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ftni.consumer/com.ftni.consumer.ui.DashboardActivity}: java.lang.NullPointerException
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.os.Looper.loop(Looper.java:123)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.ActivityThread.main(ActivityThread.java:3647)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at java.lang.reflect.Method.invokeNative(Native Method)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at java.lang.reflect.Method.invoke(Method.java:507)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at dalvik.system.NativeStart.main(Native Method)
05-31 21:22:23.753: ERROR/AndroidRuntime(647): Caused by: java.lang.NullPointerException
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.TabActivity.onPostCreate(TabActivity.java:79)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1108)
05-31 21:22:23.753: ERROR/AndroidRuntime(647):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1605)

Has anyone else had problems implementing the standard tab activity?  Any pointers on what I am doing wrong?
Comment: Have you tried putting all of the code for the buildTabs() method in your onCreate() method? Let me know if that fixes it.
Comment: Glad it helped man. I actually had a ton of problems with this kind of "context" passing between different methods. Honestly the easiest way is to just avoid referring to your activity's resources outside of your onCreate() method.
Comment: The exception is in class TabActivity and not your class. This tells me something else is wrong with your app. Have you tried rolling back to what used to work from the that link until seeing what breaks?
Comment: Vinay, I moved the code into the oncreate and now it works.  I'm not sure why it doesn't work to put in a method that is called from the same spot in `onCreate`.  If you post an answer, I will mark it correct.
Answer: Try putting all of the code for buildTabs() in your onCreate() method.
Answer: Write
tabHost.setup();

instead of:
 tabHost = getTabHost();

This should solve the problem.

getTabHost() is returning null