How to apply vertical-align inside inline-table

Question: As in the question :) I would like to verticaly center my text inside links. I tried to handle this problem without srcipt but my ideas doesn't work. Also, I don't want to lose my 100% height of "a" elements. Thank you in advance for any approach of my problem. I am using twitter bootstrap 3
        .navbar-wrapper {

            position: absolute;
            top: 0;
            right: 0;
            left: 0;
            z-index: 20;
        }

        .navbar .navbar-nav {

            display: block;
            float: none;
        }

        .navbar .navbar-nav > li {

            display: table-cell;
            float: none;
        }

        .navbar .navbar-nav > li > a {

            display: inline-table;
            height: 100%;
        }

        /*.navbar .navbar-nav > li > a > span {

            vertical-align: middle;

        } */

and html:

                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                            Toggle navigation

                        </button>
                        Project name

level 1 line 1
line 2

level 1

level 1 line 1
line 2

                                Dropdown

Action

Another action

Something else here

Separated link

One more separated link

Answer: Set display:block on the a element, instead of display: inline-table;
.navbar .navbar-nav > li > a {
   display: block;
   height: 100%;
}

Updated FIDDLE
Note: If, for some reason you need to set display: inline-table; on the a element, then
just make sure that the direct children of the table have the following rules:
1) display: table-cell;
2) vertical-align: middle;
In this case:
.navbar .navbar-nav > li > a span {
    display: table-cell;
    vertical-align: middle;
}

FIDDLE
Comment: I am sorry @Danield but I didn't write I am using twitter bootstrap 3.  BTW Both of solutions don't work. First doesn't stretch background-color of active element to 100% height of parrent. Second destroy my navigation a little :)


Comment template in VS2010

Question: I have inherited an API which doesn't have proper comments, and I am working on changing that.
Anyone know if there is some sort of mechanism to add a default XML comments to all the members of a class or an assembly?
(I remember seeing something like that on a webcast and I think he might have used PowerShell script to achieve that.)
This way I can avoid lots of repetitive steps, and have everything in place to go and start writing just the comments.
Anyone has any better suggestions?
Answer: GhostDoc is pretty fantastic for XML documentation, although you'll need to purchase a copy to generate automatic documentation for all classes/members. The free version allows you to right click (or use a hotkey) on class or member and it will generate the documentation.
Comment: @Ryan S: Do you have the licensed version? Anything in particular you like about it?
Comment: @Voodoo, Unfortunately no, I use the free version. You could try asking on the [GhostDoc forums](http://community.submain.com/forums/30/ShowForum.aspx) and see if you can get some opinions there.
Comment: @Ryan S: The pro version comes with 14 days trial so I guess I can try it out myself.
Answer: I've found GhostDoc to be pretty good.
Once you've run it over your code you then simply add details where required.
http://submain.com/products/ghostdoc.aspx

Comment template in VS2010


Using UK switches in Slovakia

Question: I have checked Wikipedia to compare electricity in the UK vs Slovakia, see:
<code>Country         PlugType    PlugStandard    Residential voltage Frequency   Comments
Slovakia        C, E        STN 34 4516                 230 V       50 Hz
United Kingdom  G[44]       BS 1363                 230 V[45]       50 Hz   Bathrooms may have shaver sockets
</code>
We can see the Frequency and the Voltage are the same. Obviously, I will not be using plugs as they are different.
Question: are the UK switches fully compatible with Slovakia?
More detail: the wiring is not in place yet, property is new built. I am planning to use dimmer switches for LED lights. The reason to use the UK products, they are surprisingly cheaper and have more varieties to choose from.
I have contacted the UK switch providers, and they keep saying there will be no warranty as they are not designed for EU. I am suspecting they are just playing safe not because products are not compatible.
I have also contacted Slovakia and the UK electricians, and cannot get a final answer, some say it is OK, some say it is not.
Any insight, suggestions?
Comment: I'm sure UK has some sort of trade agreement with Slovakia that says each must honor the other's technical certifications if they are reasonable... US has this with EU.  Otherwise trade agreements are worthless, as every foreign product could be  *coincidentally* rejected on technical grounds...  Rejecting a perfectly good UK switch is silly...
Comment: what about the electrical inspector? ... also, if you use UK components, and you have a fire, then the insurance company will probably not pay.
Comment: @jsotola Thanks that is a concern, too. I guess this will be covered by the Slovak electricians "sign-off" papers.
Answer: Electrically they should be safe and function well. Both are EU member states - so standards are theoretically harmonised.
The problems may be that UK light switches are designed for use in UK back-boxes and patresses. The dimensions of the box and the location and dimensions/threads of the fixing screws (which are always included with UK switches) may be different to those used in Slovakia.
Labelling of connections in UK switches may be unfamiliar to Slovakian electricians (e.g. "Com", "L1" and "L2") but that should be a minor issue.
Comment: Had to look up the word [pattress](https://en.wikipedia.org/wiki/Pattress)! Good point, before buying we will of course check if all the pieces fit together. My question was would it (as you put it) "Electrically" work, which you answered already. Thank you. I will wait couple of days, to see if anyone disagrees.
Comment: Regarding language, however minor, we will have English speakers on site to advise.

Using UK switches in Slovakia


Node res.write all data before res.end() is called

Question: Trying to write all files and then end response, but it somehow calls res.end before all writing is finished. How I can fix it, to do all the writing, and after that call res.end()?
Error msg atm: Error: write after end
app.get('/api/upload', function (req, res) {
  gfs.files.find({}).toArray(function (err, files) {

      if (files.length === 0) {
          return res.status(400).send({
              message: 'File not found'
          });
      }

      res.writeHead(200, {'Content-Type': files[0].contentType});

      var i = 0;

      async.each(files, function (file, next) {

        file.position = i;

        var readstream = gfs.createReadStream({
            filename: file.filename
        });

        readstream.on('data', function (data) {
            res.write(data);
        });

        readstream.on('error', function (err) {
            console.log('An error occurred!', err);
            throw err;
        });

        i++;

        next();

    }, function (err) {

        res.end();

    });

  });

});

Answer: You need to call next when readstream is done:
readstream.on('end', function () {
  next();
});


More efficient pandas python command to drop Nan rows?

Question: I have a DF called TI.  I want to drop rows where BookDate is NaN.  So I run:
TI = TI.dropna(subset=['#Book_Date'])

When I run this, the memory gets eaten up for some reason (I'm on a 100GB of RAM machine, and about 50% of the RAM is used to hold TI, when I run that dropna line, it goes to 100% usage and never finished executing the commmand).  Is it making a whole new copy?  TI is a 64 million row dataframe, so it needs to be more efficient.
Comment: almost all pandas operations create a new copy. You are operating with too limited memory to work with a frame of that size IN MEMORY. You need work on it with chunks.
Comment: okay okay -- what about something old school like awk? yeah i know it's not in python -- but sometimes preprocessing steps are easier in the command line
Comment: I think this begs to be asked: what's the RAM usage when you add the parameter `inplace=True`? Note that this means using `TI.dropna(subset=['#Book_Date'], inplace=True)` instead of assigning it to `TI`.
Comment: well, if you think about it you have to create a new array that is the same size as the existing one, then copy over the non-dropped rows. you don't a-priori know that you have rows to drop. Much easier with a large data set to keep it in HDF5. Then chunk write to a new store, dropping as you go. When you read it back it you are done.
Comment: @Metatron, same problem.  RAM immediately explodes to 100%.
Comment: This is a big problem, it also happens when I run:

TI = TI.drop(colnames[0:2], 1)
Comment: @Jeff,  that seems weird that to drop rows I have to create a copy and end up using 2x the RAM.
Comment: Ohhh so you mean DROP in chunks?  That might work.
Answer: By far the best way to do this is to do this is through employment that the column must be finite. You'll need numpy for this.
from pandas import *
import numpy

TI = TI[np.isfinite(TI['#Book_Date'])]

Comment: for me, this does not solve the problem in this use case
Answer: This can be done using query, but requires first removing the special character # from the column name.
TI = TI.rename(columns={"#Book_Date": "Book_Date"})  # remove the '#' symbol from column name
TI = TI.query("Book_Date.notnull()")  # memory-efficient dropna

Based on Memory-efficient filtering of `DataFrame` rows


'Unbalanced Curly Brackets' Error with this command block code, what am I doing wrong?

Question: I am trying to make a chest that is called 'I' that has another chest inside called 'II' that has another chest inside called 'III' that has another chest inside called 'IV' that has another chest called 'V' that has a piece of paper called 'An important message...' and it has a lore saying

自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。

I keep getting 'Unbalanced Curly Brackets' every time I try use this command. I checked with Notepad++, I'm pretty sure the curly brackets are right?
Here's the command below, but what am I doing wrong?
/setblock ~ ~ ~ chest 0 replace {Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"II"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"III"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"IV"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"V"},Items:[{id:339,Count:1,Slot:13,tag:{display:{Name:"An important message...",Lore:[自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。]}}}]}}}]}}}}],display:{Name:"I"}}}

Comment: Perhaps try the command of the piece of paper by itself?  And if that works, add the first chest, then the second, etc.
Answer: You're definitely missing brackets.

Note: While this question already has an answer with the fixed code, I think that it's worth knowing how to fix it yourself, especially for the people coming across this question later. So, I'm going to teach you a technique for finding these missing brackets easily.

Background
Let's talk about Minecraft commands, and why brackets are needed:
Minecraft commands are a very simple programming language. This language uses brackets to help it separate and interpret the different areas of code. It uses braces (curly brackets) { } to mark out items/objects, and square brackets [ ] to make lists of those items/objects,
Every open bracket, whether it be square [ or brace {, needs a corresponding closing bracket (}, ]) in the correct order, otherwise Minecraft gets confused when it tries to interpret them. The order is in reverse, or mirrored, from the appearance of the corresponding bracket.
For example: [ [ { } ] ], or { { [ { } ] } }

The Process
Now, to put this knowledge to the test: How does one find missing brackets easily, in command lines that are hundreds of characters long?
Answer? Space it out to make it easier to read. We add spaces between words, becausethisishardtointerpretwhatI'msayingright? So why not do the same with your command code?
First things first, Download and open up Notepad++

It's free and really useful for this sort of thing. Trust me, I use it every day, you'll never go back to regular Windows Notepad, which doesn't have the features we need for this thing:
Notepad++ will highlight the currently selected bracket and it's matching close bracket as the cursor runs over them..
It also gives you dotted vertical lines running down from brackets to help line up the closing bracket.

Now, onto the process:

In the Notepad++ window, paste your Minecraft Command line and start moving the cursor across using the keyboard arrows, character by character.
Every time you reach an opening bracket or a comma, Press Enter to move it (and the remaining code) to a new line.
Move one more space across (After the bracket), and add another new line and a Tab to shift the rest of the Minecraft Command across.
As you reach closing brackets, move them onto their own line as well, and use Shift-Tab to move it back into line with the opening one (removing the extra tab).

As you're doing this, you'll notice that Notepad++ adds dotted lines which link opening and closing brackets together. Use this as a guide to line them up.

Once you've spaced everything out, look for inconsistencies with the closing brackets. the closing brackets should all follow a straight line due to the tab-spacing, all the way down the page.
Note and fix up any missing or out of order brackets you see.

An Example
Using the broken code in the question as an example, I'm going to show you how to solve the problem hands-on. So here's the original Minecraft command:
/setblock ~ ~ ~ chest 0 replace {Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"II"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"III"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"IV"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"V"},Items:[{id:339,Count:1,Slot:13,tag:{display:{Name:"An important message...",Lore:[自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。]}}}]}}}]}}}}],display:{Name:"I"}}}

To save us some trouble, I've done Steps 2 to 4 (spacing & newlining) for you already, so you don't need to worry too much about it. Just copy the code broken down like this, and paste it in Notepad++:
/setblock ~ ~ ~ chest 0 replace
{
    Items:
    [
        {
            id:54,
            Count:1,
            Slot:13,
            tag:
            {
                display:
                {
                    Name:"II"
                },
                Items:
                [
                    {
                        id:54,
                        Count:1,
                        Slot:13,
                        tag:
                            {
                                display:
                                {
                                    Name:"III"
                                },
                                Items:
                                [
                                    {
                                        id:54,
                                        Count:1,
                                        Slot:13,
                                        tag:
                                        {
                                            display:
                                            {
                                                Name:"IV"
                                            },
                                            Items:
                                            [
                                                {
                                                    id:54,
                                                    Count:1,
                                                    Slot:13,
                                                    tag:
                                                    {
                                                        display:
                                                        {
                                                            Name:"V"
                                                        },
                                                        Items:
                                                        [
                                                            {
                                                                id:339,
                                                                Count:1,
                                                                Slot:13,
                                                                tag:
                                                                {
                                                                    display:
                                                                    {
                                                                        Name:"An important message...",
                                                                        Lore:
                                                                        [
                                                                            自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。
                                                                        ]
                                                                    }
                                                                }
                                                            }
                                                        ]
                                                    }
                                                }
                                        }
                                            ]
                                    }
                            }
                    }
            }
                                ],
                                display:
                                {
                                    Name:"I"
                                }
        }
}

Follow the dotted vertical lines down, and use the bracket highlighting to try and match and line up the brackets. Again, when writing code out like this with tab spaces and newlines, the closing brackets should all line up into a neat row. However, you will have noticed the discrepancies of stuff not quite lining up already. That's ok! Do the best you can to line them up properly, we're about to fix them:
1. First Square Bracket Missing:

To fix this, insert a closing square bracket after the curly brace on the line above (use Shift-Tab to move it into line with the opening bracket above:

You'll note that after inserting this, Notepad++ recognises that the lower square bracket is out of place. So go ahead and line up all the brackets again using tabs, and you'll quickly find:
2. Curly Bracket Missing:
You know the drill, insert a closing curly bracket to fix this one up as well:

Once again, after inserting the missing bracket, Notepad++ recognises that some are out of place. Re-tab the remaining brackets until they line up with the highlighted line.
3. Square Bracket Missing
You may have noticed that the 'display:' object, which was way out of place, before, is starting to move back into line with the rest of them:

Inserting a square bracket here, and it should look a lot more in-place after re-tabbing once more. You will also note that you now have an extra closing bracket that doesn't match up with anything. This is ok, just remove it entirely.
You've got the hang of it now. Continue on until everything is lined up and has a matching bracket.

Finalisation
You're done! You can even use Notepad++'s inbuilt replace function to remove the spaces and tabs. Access it using Ctrl+H. Use 'Extended' Mode, and use \n to remove newlines, and \t to remove tabs:

This should be it! You can now copy out your command and it should work fine.*
* Well, in terms of brackets at least. This is assuming you've coded it to do what you want it to do as well!
Comment: Great answer! I suggest setting the Language to Java/Javascript as well (even though Minecraft commands is neither). This will highlight some of the syntax and make auto-indentation work for the curly brackets (Haven't found any language that auto-indents the square brackets though)
Comment: @MrLemon - Agreed. Javascript will work best as the format of Minecraft Commands is pretty close to JSON syntax :)
Comment: @Robotnik Your answer is a great enhancement to this question. This helps future help seeking folks to solve their problems on their own.
Comment: @Robotnik, would a "TL:DR - every opening bracket needs a corresponding close bracket" be appropriate around the header? I feel this guide will be incredibly helpful for most users, but for some, the simple explanation of the reason should suffice. This is a lot more obvious for me, coming from a programming background.
Comment: @Timelord64 - I've added a 'Programming 101' section, and also fixed up a *ton* of the info whilst I was at it :)
Comment: For those interested in digging even deeper than this excellent post.  The arche-type "how to write a really long formula paper" is here: http://research.microsoft.com/en-us/um/people/lamport/pubs/lamport-howtowrite.pdf
Answer: I think there are some errors regarding your brackets (as well curly as square ones)
Try this block:
/setblock ~ ~ ~ chest 0 replace {Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"II"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"III"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"IV"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"V"},Items:[{id:339,Count:1,Slot:13,tag:{display:{Name:"An important message...",Lore:[自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。]}}}]}}]}}],display:{Name:"I"}}}]}}]}

Answer: You can do this manually and just make the first chest and then pick block it, now it will become +NBT in purple writing. You can keep on doing that as much as you require.


How to make a voice assistant in python that always listen for inputs?

Question: I am making a voice assistant in python following the tutorial on YouTube by "Code with harry". I have successfully added some more functionalities. The file is of extension .pyw so it runs in the background. The problem I am facing is that sometimes when I run the script it runs as I want it to i.e. always listening for inputs especially after executing a command but most of the time, when I run the script it stops listening after I give it a command. Let's say I asked it to open chrome and it opened it then it would stop listening until I close chrome. How do I fix this?
tutorial link - https://www.youtube.com/watch?v=Lp9Ftuq2sVI&t=1693s
Any help would be really appreciated. Just so you know I am not a pro in coding.
Comment: Have you got any example code that we can help you with?
Comment: it's impossible to answer the question as it is. the problem could be that the control cycle remains on the chrome window and doesn't return to the listening section until you close chrome. you should post some code. if that's too long, a minimal example is enough to show how you handle the execution of commands, such as opening a window on chrome
Answer: I got it working. The culprit was "webbrower.open()"
The code stopped once this line ran. So I found an alternative. "os.system()"
This worked perfectly.


My test cases fail when all test cases are run. But passing when ran individually

Question: <code>//This command is for scrolling into view of an element
public static void scrollIntoView(WebElement element, WebDriver driver) {
  ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
}

//This command will make the script wait until a certain element is visible before doing any actions
public static void untilVisibility(WebElement element, WebDriver driver) {
  WebDriverWait wait = new WebDriverWait(driver, Helper.TWENTY);
  wait.until(ExpectedConditions.visibilityOf(element));
}

//This command will make the script wait until a certain element is clickable before doing any actions
public static void untilClickable(WebElement element, WebDriver driver) {
  WebDriverWait wait = new WebDriverWait(driver, Helper.TWENTY);
  wait.until(ExpectedConditions.elementToBeClickable(element));
}
</code>
I'm using these three methods for my testcases, but sometimes the script is still unable to wait for the visibility of the elements, or even if the element is displayed while running, it still fails. But when I re-run them, they pass individually
For example I have 98 test cases, on the first run 20 will fail, but when I rerun the 20 test cases, they pass
Comment: You could try reloading the page before each test (if you aren't already). You could also try to find a smaller set of tests which has this problem, that might narrow down the cause.
Comment: How is the wait configured? can you share the code?
Answer: Could you provide the exception message? I guess the Exception is caused by these test methods using the same object that does not support using simultaneously, like IO of files.
Comment: Sorry, what do you mean about Exception message? Is it like the error message? The error returned is that the script is unable to locate the element via xpath declared in my page. But if I run it independently it's failing
Comment: Yes, it is the error message. Whether these methods' execution with an order in a thread pool, such as Executors? Why do they have errors sometimes? Opposite, they are correct. Could you consider the execution orders?


Setting up stylesheet for mobile in WordPress

Question: I use WP 4.9.2 and Leto theme from aThemes. The site that I built on it looks great on bigger screens, but is really screwed up in mobile. I checked the stylesheet - the problem is related to the @media queries. I just don't seem to be setting in the right way ( the css). So, I need to know how to style or what css to use to set the thing up. The theme I use is Leto, and I use WooCommerce plugin. So the responsiveness of the site is perfect on all pages but this one, which in my opinion, utilizes WooCommerce. Anyone anywhere any help is welcome.
 Here is the you can look up the whole stylesheet -->stylesheet. You can download the theme in the first link, which was to Leto.
Comment: i confirm that all pages in the main menu of the link you provided use woocommerce. All pages also become broken when i reduce the browser window. That doesn't seem related to woocommerce but the way your header/menu is made. However, you should precise in your question what exactly you want to fix, this is too broad as it is. SO is made to answer specific problems.
Comment: How you tested it on mobile? in real mobile device or browser
Comment: @shojibur Tested it on both mobile and browser.
Answer: You can use media query:
@media only screen and (min-width:280px) and (max-width:480px){}
@media only screen and (min-width:481px) and (max-width:619px){}
@media only screen and (min-width:620px) and (max-width:767px){}

like :
@media only screen and (min-width:280px) and (max-width:480px){
    body{
        do_stuff_here
    }
    .wrapper{
        do_stuff_here...
    }
}

OR Please read :
https://codex.wordpress.org/Styling_for_Mobile
Comment: Madhavi, Tonns of thanks for helping out! That worked perfectly.


Is there a way to name a Processor in Kafka Streams DSL in Scala

Question: I've been trying to name a KStream using Kafka Streams DSL in Scala but I cannot find a way to name a processor in org.apache.kafka.streams.scala.kstream.Consumed.
Although there is a java method org.apache.kafka.streams.kstream.Consumed#as but it throws an exception. Does anyone knows what can be done?
ClassCastException invoking Processor. Do the Processor's input types match the deserialized types? Check the Serde setup and change the default Serdes in StreamConfig or provide correct Serdes via method parameters. Make sure the Processor can accept the deserialized input of type key: [B, and value: [B.
Note that although incorrect Serdes are a common cause of error, the cast exception might have another cause (in user code, for example). For example, if a processor wires in a store, but casts the generics incorrectly, a class cast exception could be raised during processing, but the cause would not be wrong Serdes.
org.apache.kafka.streams.errors.StreamsException: ClassCastException invoking Processor. Do the Processor's input types match the deserialized types? Check the Serde setup and change the default Serdes in StreamConfig or provide correct Serdes via method parameters. Make sure the Processor can accept the deserialized input of type key: [B, and value: [B.
Note that although incorrect Serdes are a common cause of error, the cast exception might have another cause (in user code, for example). For example, if a processor wires in a store, but casts the generics incorrectly, a class cast exception could be raised during processing, but the cause would not be wrong Serdes.
    at org.apache.kafka.streams.processor.internals.ProcessorNode.process(ProcessorNode.java:146)
    at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:236)
    at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:216)
    at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:168)
    at org.apache.kafka.streams.processor.internals.SourceNode.process(SourceNode.java:85)
    at org.apache.kafka.streams.processor.internals.StreamTask.lambda$process$1(StreamTask.java:678)
    at ...

EDIT:
The code that I used:
val someEvents = builder
  .stream[String, String]("some_events")
(org.apache.kafka.streams.kstream.Consumed.as("some_event_stream"))

The code I should've used:
val someEvents = builder
  .stream[String, String]("some_events")
(org.apache.kafka.streams.kstream.Consumed.as("some_event_stream")
  .withKeySerde(Serdes.String())
  .withValueSerde(Serdes.String()))

Comment: Oh, you were right, the problem was that I used java method Consumed#as without explicitly providing Serdes.
Comment: The error has nothing to do with names (which you do with Named objects. The error is referring to your Serde objects. Can you please show more of the code?
Comment: So, you fixed the problem? If so, put the answer below rather than edit the question
Answer: Initial code:
val someEvents = builder
    .stream[String, String]("some_events")
  (org.apache.kafka.streams.kstream.Consumed.as("some_event_stream"))

I made two mistakes:

Put  Consumed parameter in a separate line. (todo needs explanation why it doesn't work in Scala)
Used Java method org.apache.kafka.streams.kstream.Consumed.as and didn't provide SerDes.

This works:
val someEvents = builder.stream[String, String]("some_events")(org.apache.kafka.streams.kstream.Consumed.as("some_event_stream").withKeySerde(Serdes.String()).withValueSerde(Serdes.String()))

Comment: Explanation of code would help other users to understand the difference.


Replacing a Cast Iron Sink with a Stainless sink

Question: We have granite counter tops and are replacing a cast iron sink with a stainless one. We bought a 33x22" sink (which is the size of the Cast iron) and because of the clips (which the cast iron doesn't use) it wont fit in the hole. We bought (online) a 31.5x20.5" sink which is the measurement of the hole but don't know if that will work either because the clips may not reach. We really need some help here.
A. What is the right size sink, and B. What do we do to get the right sink to fit? We are new at this so I don't know if I've done something wrong.
Comment: Proper silicone caulk (would not suggest plumbers putty as it doesn't act like a glue) all around the "lip" of the sink where it meets the granite.  Once the silicon cures it'll bond to the granite and the sink and hold the sink in place.
Comment: An over mounted sink will not need clips. RTV silicone (maybe even plumber's putty?) and gravity will hold it in place. Our soapstone countertop is cut on the underside for clips and has clips holding the under-mounted sink, but I think the weight is mostly held by the sealant, which I think is RTV silicone.
Comment: Did the original sink have a rim on top integral with the sink? Or was the rim a separate metal piece and the cast iron sink attached to that? The prior sink was porcelain on cast iron, right?
Comment: I'm sorry. While its the same size as the cast iron, to install you have to use clips, which the hole seems to have been cut just to accommodate a 33x22 cast iron which doesn't need the extra room for clips.
Comment: The original sink is one piece.
Comment: And why haven't you checked whether the second replacement sink will work yet?
Comment: Are you trying to do undermount or above mount?
Comment: The second one wont be here till tomorrow. I just didnt know if it will work because its the exact same size as the hole and the clips may not reach.
Comment: Its going to be over mount as well
Comment: https://www.amazon.com/gp/product/B00MEYX46C/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1  Here is a link to the replacement sink
Comment: How would I secure the sink with out the clips?
Comment: The Sink doesn't weigh very much.
Comment: As for "will it fit or not" - you maybe should make sure you understand the dimensions of what you buy before you buy.  We can't tell you the sink dimensions vs. the lip dimensions.  The product can.
Comment: Oh I didn't realize that. For some reason I thought it would flex. SO should we use the Sink we bought that is the exact same size as the hole? Or should we remove the clip holders on the first sink?
Comment: If the clip bracket is spot welded to the sink, do not try to remove it. This sink may yet be returned for credit and to save a valuable item.  Wait until your new sink arrives and see if it fits as is. If the new one fits and has clamp rails, then maybe use them or maybe not
Comment: I agree on that. I'm not going to mess with the brackets. Though the question is whats the next step if the new sink doesn't fit? Because its dimensions are the EXACT same as sink hole.
Comment: You might have to have a granite counter company enlarge the hole for the sink. This may be easy for them, call and ask. There may be a limit as to what they can do in place (as opposed to in their workshop) and maybe the width on front and back must be above a certain limit to resist cracking.  I have to believe that  you can get a sink that will fit the opening as it is. Let me get this straight: the first sink has "rails" for clips and these interfere with it's fitting? On the front and back only, or on the sides too? Usually the installation instructions give the size of the opening req'd.
Comment: I'd be cutting the rails off the first sink and using silicone caulk to mount it. It's still not clear what the problem was, though. A sink the same size as the opening won't work.
Comment: @isherwood, how would you cut off the rails (which might be just short brackets)? He might not have an angle grinder and the skill to do this. He could take the sink to a kitchen install shop and have them do it.
Comment: Call a granite counter top company and have them install the first sink if that is your design preference. They could notch the granite counter top and allow it to fit. You will be looking at that sink for a long time; get what you want.
Comment: Notching is then out of the question they'd have to enlarge the opening. Even if you cut off the brackets the sink itself might interfere. What do the installation instructions say about size of opening required?
Answer: Cut the countertop. If the reason it doesn't fit is because the clip bracket interferes then you shouldn't need to cut much. The countertop appears to be granite or some other solid surface so you would have to hire someone to cut it for you.
Comment: There are almost certainly better options to be had than an expensive and messy stone cut.
Comment: "Get the right size sink" would be a better answer.
Comment: I appreciate wanting to get the right size sink but I've look everywhere and I cant find one that fits that hole. at least a stainless steel.
Comment: Evidently that opening was cut for the specific cast iron sink originally installed. Read the instructions for the first SS sink and the SS one that is coming. If the specs don't match the opening, don't try to force it.


How can I determine the statistical randomness of a binary string?

Question: How can I determine the statistical randomness of a binary string?
Ergo, how can I code my own test, and return a single value that corresponds to the statistical randomness, a value between 0 and 1.0 (0 being not random, 1.0 being random)?
The test would need to work on binary strings of any size.
When you do it with pen and paper, you might explore strings like this:
  0 (arbitrary randomness, the only other choice is 1)
  00 (not random, its a repeat and matches the size)
  01 (better, two different values)
  010 (less random, palindrome)
  011 (less random, more 1's, still acceptable)
  0101 (less random, pattern)
  0100 (better, less ones, but any other distribution causes patterns)
Case examples:
Size: 1, Possibilities: 2
  0: 1.0 (random)
  1: 1.0 (random)
Size: 2, P:4
  00: ?
  01: 1.0 (random)
  10: 1.0 (random)
  11: ?
S:3, P:8
  000: ? non-random
  001: 1.0 (random)
  010: ? less random
  011: 1.0 (random)
  100: 1.0 (random)
  101: ? less random
  110  1.0 (random)
  111: ? non-random
And so on.
I feel that this may play a lot into breaking the string into all possible substrings and comparing frequencies, but it seems like this sort of groundwork should already have been done in the early days of computer science.
Comment: any single binary string can be viewed as being random!  You need to have a sample space in which to compare it...
Comment: You're asking a harder question than you anticipate.  Did you have any particular randomness tests in mind to implement?  The Wikipedia page for Statistical Randomness lists some of the simpler tests. You might have to go to journal articles for more interesting ones.  What are you using this test for?  That might influence which tests are relevant.  What do you actually want to measure?  Maybe: the probability that the observed string was generated from a truly random generator?
Comment: Hah! Your Case exmaples is really good comedy. In a random byte string, any of them will appear just as often as the other!!
Comment: what are you actually tring to do?
Comment: Just that: read in an arbitrary binary string, and note its statistical randomness. For instance, 0101010101010101 has a balanced number of 1's and 0's, but is hardly random.

One could say that:   [00000000 has a randomness of 0]   [01010101 has a randomness of 0.01]   [00000101 has a randomness of 0.05]   [01001011 has a randomness of 1.0]
Comment: So you want to treat a number (like 0101010101010101) as a sequence randomly-chosen bits?
Answer: You seem to be asking for a way to find the Kolmogorov complexity of a binary string. Sadly, this is incomputable. The size of your string after running it through a compression algorithm will give you an idea of how random it is, in that more random strings are less compressible.
Comment: Indeed.  Define "degree of randomness" as "ratio of compressed file to uncompressed file".   That's as close as you're likely to get.
Comment: This seems to (almost) exactly be what you are looking for.  Pick a compression algorithm, but unfortunately none is perfect.  I'm not sure I know any compression algorithms that compress palindromes, but almost every one I know can compress repetitive sequences.
Answer: This will give you an entropy count from 0 to 1.0:
You might want to try looking into the Shannon Entropy, which is a measure of entropy as applied to data and information.  In fact, it is actually almost a direct analogue of Physical  formula for entropy as defined by the most accepted interpretations of Thermodynamics.
More specifically, in your case, with a binary string, you can see the Binary Entropy Function, which is a special case involving randomness in binary bits of data.
This is calculated by
H(p) = -p*log(p) - (1-p)*log(1-p)

(logarithms in base 2; assume 0*log(0) is 0)
Where p is your percentage of 1's (or of 0's; the graph is symmetrical, so your answer is the same either way)
Here is what the function yields:

As you can see, if p is 0.5 (same amount of 1's as 0's), your entropy is at the maximum (1.0).  If p is 0 or 1.0, the entropy is 0.
This appears to be just what you want, right?
The only exception is your Size 1 cases, which could just be put as an exception.  However, 100% 0's and 100% 1's don't seem too entropic to me.  But implement them as you'd like.
Also, this does not take into account any "ordering" of the bits.  Only the sum total of them.  So, repetition/palindromes won't get any boost.  You might want to add an extra heuristic for this.
Here are your other case examples:

00:   -0*log(0) - (1-0)*log(1-0)               = 0.0
01:   -0.5*log(0.5) - (1-0.5)*log(1-0.5)       = 1.0
010:  -(1/3)*log(1/3) - (2/3)*log(2/3)         = 0.92
0100: -0.25*log(0.25) - (1-0.25)*log(1-0.25)   = 0.81
Answer: Some time ago, I developed the a simple heuristic that worked for my purposes.
You simply calculate the "even-ness" of 0s and 1s not only in the string itself, but also on derivatives of the string. For example, the first derivative of 01010101 is 11111111, because every bit changes, and the second derivative is 00000000, because no bit in the first derivative changes. Then you simply have to weigh these "even-nesses" according to your taste.
Here is an example:
#include <string>
#include <algorithm>

float variance(const std::string& x)
{
    int zeroes = std::count(x.begin(), x.end(), '0');
    float total = x.length();
    float deviation = zeroes / total - 0.5f;
    return deviation * deviation;
}

void derive(std::string& x)
{
    char last = *x.rbegin();
    for (std::string::iterator it = x.begin(); it != x.end(); ++it)
    {
        char current = *it;
        *it = '0' + (current != last);
        last = current;
    }
}

float randomness(std::string x)
{
    float sum = variance(x);
    float weight = 1.0f;
    for (int i = 1; i < 5; ++i)
    {
        derive(x);
        weight *= 2.0f;
        sum += variance(x) * weight;
    }
    return 1.0f / sum;
}

int main()
{
    std::cout << randomness("00000000") << std::endl;
    std::cout << randomness("01010101") << std::endl;
    std::cout << randomness("00000101") << std::endl;
}

Your example inputs yield a "randomness" of 0.129032, 0.133333 and 3.2 respectively.
On a side note, you can get cool fractal graphics by deriving strings ;)
int main()
{
    std::string x = "0000000000000001";
    for (int i = 0; i < 16; ++i)
    {
        std::cout << x << std::endl;
        derive(x);
    }
}

0000000000000001
1000000000000001
0100000000000001
1110000000000001
0001000000000001
1001100000000001
0101010000000001
1111111000000001
0000000100000001
1000000110000001
0100000101000001
1110000111100001
0001000100010001
1001100110011001
0101010101010101
1111111111111111

Comment: I don't think this is a theoretically sound handle on Komologorov complexity, but you may be interested to note that this is in fact the rule 60 elementary cellular automaton: http://mathworld.wolfram.com/Rule60.html
Answer: You might try a compression algorithm on the string. The more repetition (less randomness) there is, the more the string can be compressed.


SQL Server Cross Join Query

Question: I have the next SQL Server table:
 Machine | Result
 -----------------
 M2      |  0
 M1      |  1
 M3      |  0
 M1      |  1
 M2      |  1
 M1      |  0
 M2      |  0
 M1      |  1
 M3      |  0
 M1      |  1
 M3      |  0

I need to get a report like this:
Machine | Count 0's | Count 1's
--------------------------------
M1      |  1        |  4
M2      |  2        |  1
M3      |  3        |  0

I have tried the next query with no sucess:
SELECT A, B
FROM
(SELECT COUNT(*) as A
FROM MY_TABLE
WHERE Result = 0)
GROUP BY Machine) a
CROSS JOIN
(SELECT COUNT(*) as B
FROM MY_TABLE
WHERE Result = 1)
GROUP BY Machine) b

Can you help me?. Thanks in advance!
Answer: You can do this with conditional aggregation:
select machine,
       sum(case when result = 0 then 1 else 0 end) as num_0,
       sum(case when result = 1 then 1 else 0 end) as num_1
from my_table
group by machine;

SQL Server Cross Join Query


extract gnome gconf settings from external partition

Question: Are there any files in /etc/ or /home/ where the gconf data is actually written to? How can I make these work on a new system (preferably in terminal)?
There are standard ways dumping/importing gconf settings in a working distribution; mine is dead now - I'd like to backup/restore the old settings.
Answer: If I understand the question you want to copy settings from old system to the new one. In my backup scripts I just copy ~/.gconf directory which store all the settings configurable with gconf-editor. That works for me.
There are other directories for settings of your GNOME desktop environment which you may want to copy:

~/.config - contains config files for applications (default location for the environment variable XDG_CONFIG_HOME).
~/.gnome2 - user-specific application data that is not stored in the GConf repository.
~/.local/share - default location for the environment variable XDG_DATA_HOME.
~/.fonts - fonts that you installed.
~/.nautilus - contains file manager data that is specific to the user. For example, this directory can contain the following:

Metadata for the directories with which the user works.
Nautilus emblems that the user adds.
Nautilus desktop images.

~/.themes - contains your (not system-wide) themes
Comment: so practically everything sits in homedir?
Comment: @troyaner Yes. That is why it called home dir. All user files and setting stored in one place. You shouldn't care about other directories if you did not make any changes outside your home dir.
Comment: I did, but that's another story ;) ok, thx!
Comment: The directory `~/.gconf` doesn't exist on my system (Ubuntu 22.04.3).


I need a regex to validate phone numbers which contains only 0 or 1 as invalid

Question: I need a regex to validate only 0s or 1s in a phone number. For eg - 0000000000 or 1111111111 should be invalid.
Also my phone number range is from 7-15 only. Below is my regex [0-9]{7,15}
it should add validation in the regex to invalidate only 0 and only 1 in the phone number
Comment: Please add the code/regex you've attempted to your question as a [mcve].  What have you tried? Where did you get stuck? [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) - [https://regex101.com/](https://regex101.com/) for testing. Note that different languages have different regex implementations so you should be clear what language you're asking about.
Answer: This regex will match the phone numbers with 0s and 1s
/([01*]{10})/gm
Answer: Regex pattern for 1s and 0s only
^[0-1]+$

HTML EXAMPLE

<form>
  <input type="text" pattern="^[0-1]+$" title="Invalid input">
  <input type="submit">
</form>


Access javascript variable

Question: I'am trying to create a web app with google map direction API,In a             variablesummaryPanel.innerHTMLContains the details regarding the address and distance.I required to use distance for other calculations ,so how can i access the variable,can we access the variable from the angular controller?
script.js
function initMap() {
    var directionsService = new google.maps.DirectionsService;
    var directionsDisplay = new google.maps.DirectionsRenderer;
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 6,
      center: {lat: 41.85, lng: -87.65}
    });
    directionsDisplay.setMap(map);

    document.getElementById('submit').addEventListener('click', function() {
      calculateAndDisplayRoute(directionsService, directionsDisplay);
    });
  }

  function calculateAndDisplayRoute(directionsService, directionsDisplay) {
    var waypts = [];
    var checkboxArray = document.getElementById('waypoints');
    for (var i = 0; i < checkboxArray.length; i++) {
      if (checkboxArray.options[i].selected) {
        waypts.push({
          location: checkboxArray[i].value,
          stopover: true
        });
      }
    }

    directionsService.route({
      origin: document.getElementById('start').value,
      destination: document.getElementById('end').value,
      waypoints: waypts,
      optimizeWaypoints: true,
      travelMode: 'DRIVING'
    }, function(response, status) {
      if (status === 'OK') {
        directionsDisplay.setDirections(response);
        var route = response.routes[0];
        var summaryPanel = document.getElementById('directions-panel');
        summaryPanel.innerHTML = '';
        // For each route, display summary information.
        for (var i = 0; i < route.legs.length; i++) {
          var routeSegment = i + 1;
          summaryPanel.innerHTML += 'Route Segment: ' + routeSegment +
              '
';
          summaryPanel.innerHTML += route.legs[i].start_address + ' to ';
          summaryPanel.innerHTML += route.legs[i].end_address + '
';
          summaryPanel.innerHTML += route.legs[i].distance.text + '

';
          console.log(summaryPanel.innerHTML);//Variable required to access
        }
      } else {
        window.alert('Directions request failed due to ' + status);
      }
    });

  }

Comment: Grab the angular docs for the synatx to add it to the $scope of your angualr controller.
Comment: Yes .. you can access it from angular js if variable is defined as global variable ( out of functions)

But this is not good way to do..

Its good if you will do it using $scope or $rootScope
Answer: Using jQuery:
var htmlString = $(summaryPanel).html();

Then you'll have to parse whatever htmlString comes out to, but it will have what you're looking for.
Source: http://api.jquery.com/html/
Comment: It seems a lot like the OP already has the data they're looking for since they created the summaryPanel and populated it.
Comment: Exactly. So there is no reason to fetch it from the DOM and parse it again. The solution woll probably look something like `$scope.distance = route.legs[i].distance.text`, since that's part of what is inserted into the innerHTML you want to parse.

Access javascript variable


solving two uncoupled ODEs within a loop using python and scipy.integrate.ode

Question: I am having problem for solving two very easy uncoupled ODEs using scipy.integrate.ode. For instance this following simple code:

from scipy.integrate import ode

def f(t, y, r_r=1.68,mu_ext=0. ,tau_m=0.020, tau_s=0.005, gs= 0.5):
        dmu = (1./tau_s)*(-y[0] + mu_ext + gs*r_r)
        dx = (1./tau_m)*(-y[1] + y[0])
        return [dmu, dx]

t0 = 0.0                #Intial time
y0 = [4.0, 0.0]         #initial condition for x = 0
y1 = [4.0, 1.0]         #inital condition for x = 1

x0m = ode(f)
x0m.set_initial_value(y0, t0)

x1m = ode(f)
x1m.set_initial_value(y1, t0)
t1 = 1.0
dt = 0.0001

x0 = []
x1 = []

t=0

for i in xrange(1000):
        t +=dt
        x0m.integrate(t)
        x0.append(x0m.y)
        x1m.integrate(t)
        x1.append(x1m.y)

Interestingly, each one can be solved perfectly in two different loops but I don't understand why this makes the second ODE solver return nonsense.
Answer: When I ran your code in ipython I got:
Integrator `vode` can be used to solve only
a single problem at a time. If you want to
integrate multiple problems, consider using
a different integrator (see `ode.set_integrator`)

Apparently you have to use:
ode.set_integrator

to integrate multiple problems at the same time
Comment: Thanks for quick reply. The documentation of it is very poor! How can I use ode.set_integrator to solve my problem?
Comment: If you look at pg 270 of the documentation: [link](http://docs.scipy.org/doc/scipy/scipy-ref.pdf) it says that the runge-kutta method is the only mode that supports integrating multiple ODEs at the same time.
Comment: It seems it would also work with runge-kutta method, if I set my solver to work with "dopri5".
Comment: Looks like the pdf-with-explicit-page-numbers document is gone. [This exists](http://docs.scipy.org/doc/scipy-0.17.1/reference/generated/scipy.integrate.ode.html) but is for v0.17 explicitly.


Scaling monitors with different resolution on Ubuntu 18.04

Question: I have Dell XPS 15 7590 with 4K touch display (resolution 3840 x 2160). Then I have a Samsung 27" monitor with resolution 2560x1440 which is placed above my laptop's screen.
I would somehow like to achieve to set scale on laptop's 4K to 200% (as 100% on 15 inch 4K is making everything super small) and external Samsung display to 100%. However it looks like it is not possible to have different scales on Ubuntu 18.04.
I found here that there is possibility to make it work like that using xrandr to (in my case) double Samsung's resolution and then just set all to 200%. However I am not very familiar with this and I am not sure how exactly to execute it in my case and not break it. This is how standard xrandr command output looks like in my case:
Screen 0: minimum 320 x 200, current 3840 x 3600, maximum 16384 x 16384
eDP-1 connected primary 3840x2160+0+1440 (normal left inverted right x axis y axis) 344mm x 194mm
   3840x2160     60.00*+  59.98    59.97
   3200x1800     59.96    59.94
   2880x1620     59.96    59.97
   2560x1600     59.99    59.97
   2560x1440     59.99    59.99    59.96    59.95
   2048x1536     60.00
   1920x1440     60.00
   1856x1392     60.01
   1792x1344     60.01
   2048x1152     59.99    59.98    59.90    59.91
   1920x1200     59.88    59.95
   1920x1080     60.01    59.97    59.96    59.93
   1600x1200     60.00
   1680x1050     59.95    59.88
   1600x1024     60.17
   1400x1050     59.98
   1600x900      59.99    59.94    59.95    59.82
   1280x1024     60.02
   1440x900      59.89
   1400x900      59.96    59.88
   1280x960      60.00
   1440x810      60.00    59.97
   1368x768      59.88    59.85
   1360x768      59.80    59.96
   1280x800      59.99    59.97    59.81    59.91
   1152x864      60.00
   1280x720      60.00    59.99    59.86    59.74
   1024x768      60.04    60.00
   960x720       60.00
   928x696       60.05
   896x672       60.01
   1024x576      59.95    59.96    59.90    59.82
   960x600       59.93    60.00
   960x540       59.96    59.99    59.63    59.82
   800x600       60.00    60.32    56.25
   840x525       60.01    59.88
   864x486       59.92    59.57
   800x512       60.17
   700x525       59.98
   800x450       59.95    59.82
   640x512       60.02
   720x450       59.89
   700x450       59.96    59.88
   640x480       60.00    59.94
   720x405       59.51    58.99
   684x384       59.88    59.85
   680x384       59.80    59.96
   640x400       59.88    59.98
   576x432       60.06
   640x360       59.86    59.83    59.84    59.32
   512x384       60.00
   512x288       60.00    59.92
   480x270       59.63    59.82
   400x300       60.32    56.34
   432x243       59.92    59.57
   320x240       60.05
   360x202       59.51    59.13
   320x180       59.84    59.32
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 connected 2560x1440+720+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+
   1920x1080     60.00    50.00    59.94
   1680x1050     59.88
   1600x900      60.00
   1280x1024     75.02    60.02
   1440x900      59.90
   1280x800      59.91
   1152x864      75.00
   1280x720      60.00    50.00    59.94
   1024x768      75.03    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   720x576       50.00
   720x480       60.00    59.94
   640x480       75.00    72.81    66.67    60.00    59.94
   720x400       70.08

Answer: I did some research and found one way (based on this solution) to do that.
First I set 200% scale in Display settings.
Command to check current setup:
xrandr --current | grep -w connected

In my case returning:
eDP-1 connected primary 3840x2160+0+1440 (normal left inverted right x axis y axis) 344mm x 194mm
DP-3 connected 2560x1440+731+0 (normal left inverted right x axis y axis) 597mm x 336mm

And these are 2 commands to change it as I want:
xrandr --output DP-3 --scale 2x2 --mode 2560x1440 --fb 5120x5040 --pos 0x0
xrandr --output eDP-1 --scale 1x1 --pos 640x2880

Notes about numbers I used (to have laptop's screen in the middle below external monitor:
2560*2 = 5120
1440*2 = 2880
Max(3840,5120)=5120
2160+2880=5040
(5120-3840)/2=640

After that I have:
eDP-1 connected primary 3840x2160+640+2880 (normal left inverted right x axis y axis) 344mm x 194mm
DP-3 connected 5120x2880+0+0 (normal left inverted right x axis y axis) 597mm x 336mm

To revert back:
xrandr --output DP-3 --scale 1x1 --mode 2560x1440 --fb 3840x3600 --pos 731x0
xrandr --output eDP-1 --scale 1x1 --pos 0x1440

This is still quite tricky way to do it so I will be happy for any other solutions.
UPDATE:
This change is actually causing that mouse cursor is flickering. I found solution based on this post and run one extra command to fix it (even though it is kind of a hacky solution):
xrandr --output eDP-1 --scale 0.9999x0.9999

So the full command in my case is:
xrandr --output DP-3 --scale 2x2 --mode 2560x1440 --fb 5120x5040 --pos 0x0; xrandr --output eDP-1 --scale 1x1 --pos 640x2880; xrandr --output eDP-1 --scale 0.9999x0.9999

Note: I experienced this flickering only while using intel graphics. I did not see any flickering with nvidia (using prime-select and restart to switch).
UPDATE 2:
Using scale 0.9999x0.9999 is not a good idea. It slows down monitor reactions and you can notice some lags when watching videos.
Comment: Case when laptop's 4k display is left from external:
`xrandr --output DP-3 --scale 2x2 --mode 2560x1440 --fb 8960x2880 --pos 3840x0 && xrandr --output eDP-1 --scale 1x1 --pos 0x720`


How can I create/delete a table row with form controls using AJAX?

Question: I have a table that has several fixed rows that contain user controls that have their own Update panels. I need to be able to create new rows within this table, each column of which contains a TextBox control. I don't want to just wrap the whole table in an Update Panel for obvious reasons, but want to be able to create/delete the new row(s) without a full postback and have the TextBox controls registered/de-registered to/from the page, without having to rebuild the entire table.
Any ideas how/if this can be done?
Answer: It can be done using a client-side approach, such as building the UI with JavaScript templating or an MVVM framework.  You could also use a ListView that can be easily templated to render the initial shell, and additional rows can be added with JavaScript.
Or, wrap the whole table in one UpdatePanel.
Comment: I was hoping there might be a way of creating the additional row and textboxes using Javascript and then doing a partial postback just to register the controls on the page?
Comment: Any dynamic controls have to be added to the control tree on EVERY postback.  So on postback, you have to read the form values and generate the controls accordingly.
Comment: Could I generate the dynamic rows entirely client side using html textfields with unique IDs based on the lookup data record the row relates to and then inspect the POST data on postback. If I know there could be between 0-20 dynamic rows (based on lookup data that each row relates to) I could just loop through each record, see if a row exists for that record in POST data and process accordingly. Does that sound plausible/sensible?


Dynamic SQL with parameters

Question: I have a SQL query stored in a table that contains parameter names. I need to know how to execute it properly in a stored procedure.
This is my SQL code in the procedure
PROCEDURE [spMassUpdateSKUs]
@SKU AS NVARCHAR(20)
,@FIELD AS NVARCHAR(50)
,@VALUE AS NVARCHAR(50)
,@RESULT as Int = Null Output
AS
BEGIN
IF EXISTS(SELECT CODENUMBER FROM INVENTORY_MASTER WHERE CODENUMBER=@SKU)
    BEGIN
    DECLARE @SQLQUERY AS NVARCHAR(50)
    SET @SQLQUERY=(SELECT SQLUPDATE FROM MASS_UPDATE WHERE DROPDOWNLABEL=@FIELD)
    EXEC SP_EXECUTESQL @SQLQUERY
    END

and this is the sql query from the table
update inventory_master_flex set departmentid=@value where codenumber=@sku

I've tried replacing with the real parameters but that doen't work.
SELECT REPLACE(REPLACE(@SQLQUERY,'@VALUE',@VALUE),'@SKU',@SKU)

Comment: When you executed this `SELECT REPLACE(REPLACE(@SQLQUERY,'@VALUE',@VALUE),'@SKU',@SKU)` what did the update query look like? Did it look correct or not? What do you mean it doesn't work?  **If departmentid and codenumber are strings you need single quotes around them.**
Comment: The capitalization is different.  By default, SQL Server is case-insensitive, but your table, database, or server might be configured differently.
Comment: Your values won't be quoted with your current `REPLACE` code. You should pass the parameters properly though, using [sp_executesql](https://technet.microsoft.com/en-us/library/ms175170.aspx)
Answer: Pass the parameters in using sp_executesql, not replace():
IF EXISTS(SELECT CODENUMBER FROM INVENTORY_MASTER WHERE CODENUMBER=@SKU)
    BEGIN
        DECLARE @SQLQUERY AS NVARCHAR(MAX);

        SET @SQLQUERY = (SELECT SQLUPDATE FROM MASS_UPDATE WHERE DROPDOWNLABEL = @FIELD);

        EXEC SP_EXECUTESQL @SQLQUERY, N'@SKU VARCHAR(255), @VALUE VARCHAR(255)', @SKU = @SKU, @VALUE = @VALUE
    END;

I don't know what the types are.  But if one or both are strings or dates, then you would need single quotes in your implementation.  However, you are already using sp_executesql so go whole-hog and pass in parameters as well.
Answer: -- 50 is too short for sure; you may try 1000 or different number
DECLARE @SQLQUERY AS NVARCHAR(MAX)

-- for debug purpose
PRINT @SQLQUERY

-- params
EXEC SP_EXECUTESQL @SQLQUERY, N'@Value NVARCHAR(50), @sku NVARCHAR(50)`, @Value, @sku

REPLACE is not good in case of strings with quotes and so on which would brake the @sqlquery code.

Dynamic SQL with parameters


NgMap module and MarkerClusterer function

Question: I have data from external API and I wanna group markers in my GoogleMap.
I'm using NgMap directives:
ng-map center="[21.18, 27.71]" style='margin: 10px 0; height: 500px;' zoom='6'
        marker position="{{item.latitude}}, {{item.longitude}}" ng-repeat="item in items"

So how to set MarkerClusterer in AngularJS (1.5x) Controller.
https://jsfiddle.net/7nqg7f7f/6/ -> I'm doing it in that way.
Answer: ng-map library covers Google Maps API, MarkerClusterer on the contrary is a separate library for the Google Maps JavaScript API v3 which is not supported by ng-map (at least at the moment)
The following example demonstrates how to utilize MarkerClusterer with ng-map:

angular.module('mapApp', ['ngMap'])
    .controller('mapController', function ($scope, NgMap) {

        NgMap.getMap().then(function (map) {
            $scope.map = map;
            $scope.initMarkerClusterer();
        });

        $scope.cities = [
            { id: 1, name: 'Oslo', pos: [59.923043, 10.752839] },
            { id: 2, name: 'Stockholm', pos: [59.339025, 18.065818] },
            { id: 3, name: 'Copenhagen', pos: [55.675507, 12.574227] },
            { id: 4, name: 'Berlin', pos: [52.521248, 13.399038] },
            { id: 5, name: 'Paris', pos: [48.856127, 2.346525] }
        ];

        $scope.initMarkerClusterer = function () {
            var markers = $scope.cities.map(function (city) {
                return $scope.createMarkerForCity(city);
            });
            var mcOptions = { imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m' };
            return new MarkerClusterer($scope.map, markers, mcOptions);
        };

        $scope.createMarkerForCity = function (city) {
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(city.pos[0], city.pos[1]),
                title: city.name
            });
            google.maps.event.addListener(marker, 'click', function () {
                $scope.selectedCity = city;
                $scope.map.showInfoWindow('myInfoWindow', this);
            });
            return marker;
        }

    });

        <ng-map default-style="true" zoom="3" center="59.339025, 18.065818">
            <info-window id="myInfoWindow">

{{selectedCity.name}}

            </info-window>

        </ng-map>

Modified fiddle


Does pumping a septic system disrupt the tank's ecology?

Question: We are the original owners of a 4BR/2.5 Bath home that has been mainly occupied by 2 people over 14 years. (Occasionally 3 people for short periods of time, less than 1 year)
We have never had the cover dug/removed for the system / tank to be pumped.
I've gone by the "old school ecology" premise that if it is breaking down the intake effectively you should "leave it alone".  Once you start pumping regularly, you have disrupted an effective ecological working  system.
Is this a misnomer and a "plumber's tale"  or should I subscribe to the "pumpers tale" of thinking?
Answer: It is recommended that septic tanks be pumped every 3-5 years, having said that it is not always necessary depending on the usage of the tank. You could simply check the sludge level in the tank to see if it requires a pump out. Leaving the tank without checking it is not a good idea as even though it may seem to be working it may be allowing solids/suspended solids to enter the distribution field, which in turn will case it to fail prematurely.
In regard to your other question yes it does disrupt the ecology of the tank when it is pumped if the whole tank is emptied but this will right itself and if you abstain from using harsh chemicals that drain to the septic this time frame will be reduced.
Pdf on septic care
Answer: You know your yearly usage,and age of septic.Cost little to have pumped. Expensive to replace. Mine is getting older and have it done every year. If buying home, seller should have it pumped as part of the closing. Septics need to be kept up. Not left alone for years. Peaple do put the wrong items down them.


Address Sent in Text Message Opens Custom Mapping Application

Question: Correctly formatted addresses sent in text messages appear as links. When this link is clicked, how do I make it open my custom Android mapping app and automatically insert that address into my app's search box?
Comment: Please provide more detail about what it is you are trying to achieve and a reproducible example if possible.
Answer: You are talking about deep linking. You need to register the types of links you want your app to respond to in the manifest file.
<activity
    android:name="app.myActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="gizmos"
            android:scheme="example" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="www.example.com"
            android:pathPrefix="/gizmos"
            android:scheme="http" />

    </intent-filter>
</activity>

You can even simulate a deep link from the ADB:

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos"
adb shell am start -W -a android.intent.action.VIEW -d "http://www.example.com/gizmos"

You can then read the URI data and put it anywhere you like, as long as this is in the activity that responds to the deep link:
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();

NOTE
WhatsApp is not a great place for deep links. I am still trying to figure out why.


Can mode lie between mean and median?

Question: The distribution is left-skewed if mean<median<mode.
The distribution is right-skewed if mean>median>mode.
Can mode lie between mean and median?
Comment: related: https://stats.stackexchange.com/questions/251701/counterexamples-where-median-is-outside-mode-mean
Comment: This is a very nice question (+1). It brings up some issues you may not have thought about. I mention a few of them in my Answer.
Answer: First, left- or right-skewed tells you nothing about the mode.
For a case you are looking for try out
$$0, 1, 1.5, 1.6, 2, 2, 12$$
Comment: I wrote about mode because of this picture: https://www.statisticshowto.com/wp-content/uploads/2014/02/pearson-mode-skewness.jpg
Answer: Paul's answer works, but it is also possible to have a distribution which is unimodal and either is continuous or is discrete with equal gaps in the support, such as the following distribution with median $2$, mode $3$ and mean $3.02$:
x   P(X=x)
0   0.16
1   0.17
2   0.18
3   0.19
4   0.06
5   0.055
6   0.05
7   0.045
8   0.04
9   0.03
10  0.02

It is possible to have the mean, median and mode in any order, though having the mode strictly between the other two may in a vague handwaving sense be less likely than other patterns, as I once tried to show
Answer: Yes, The first two sentences are often, but not always, true. (They are true for some
well-known distributions.)
However, as you can see from other Answers,
and from my example below, it is possible to contrive a sample or population
with discrete values, for which the mode lies between the median and the mean. [Using R.]
x = c(1,1,1,2,2,3,3,3,4,4,4,4,25)
summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 1.000   2.000   3.000   4.385   4.000  25.000

Median is $3,$ mode is $4,$ mean is $4.385.$
Exponential distribution. Among frequently-used distributions, consider right-skewed $\mathsf{Exp(1)}.$
Mode is $0$, median is $0.6931$ (below), and mean is $1.$
qexp(.5, 1)
[1] 0.6931472

A beta distribution. For the left-skewed continuous distribution $\mathsf{Beta}(5,2),$
the mean is $5/7 \approx 0.714,$ the median is $0.736,$
and the mode is $4/5 = 0.800.$
qbeta(.5, 5, 2)
[1] 0.73555

Samples from continuous distributions. It is not so easy to define the mode of a sample from
a continuous distribution because no two sample values
(before rounding) can ever be exactly the same.
Two (of many) possible definitions of the mode of the beta sample below
might be the center of the tallest bar of its histogram
(which is somewhat arbitrary depending on binning), or
the maximum of its kernel density estimator (KDE), which we can
view for the moment as a 'smoothed ideal histogram'.
set.seed(2022)
x = rbeta(1000, 5, 2)
summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 0.1800  0.5991  0.7428  0.7095  0.8381  0.9976
hist(x, prob=T, ylim=c(0,3), col="skyblue2")
lines(density(x), col="orange", lwd=2)

So, the sample mean is $0.710,$ the sample median is $0.742,$
and the sample mode might be taken to be something like $0.75$ (from the tallest histogram bar) or something like $0.79$ from the KDE (orange curve).
Answer: In case of a positively skewed frequency distribution, the mean is always greater than median and the median is always greater than the mode. In case of a negatively skewed frequency distribution, the mean is always lesser than median and the median is always lesser than the mode.
Comment: From what I can see, the OP understands that what you say is the case. It seems like he/she was looking for an example where this is not the case, and so while your answer is appreciated, it leaves something to be desired (particularly with the other answers already posted).
Comment: Answer doesn't really add much to the dialogue that isn't already present.
Comment: @Paul told that "left- or right-skewed tells you nothing about the mode". You say that mode matter. Where is the truth?

Can mode lie between mean and median?


Alternatives to a dual list for selecting a bunch of items from a long list?

Question: What alternatives and examples are there for selecting a bunch of items from a long list of items instead of a dual list?
This question has some nice enhancements on the traditional dual list, but I'm looking for other things to consider.
Best way to select a subset of items in a long list
Answer: Consider using a multi-select with tokens design. The filter-as-you-type feature is a nicety but not essential. These work well when the common use case is selecting either one or just a few, but the usability falls down quickly if you need to select many as the user has to re-invoke the menu for each item.

http://harvesthq.github.com/chosen/
http://designingwebinterfaces.com/the-multi-select-solution
http://loopj.com/jquery-tokeninput/

You've previously seen the tokenised multi-input method in your email clients.
If the common case is to select multiple, you can consider a checkbox menu. The difference here is that the drop-down is persistent across clicks (plus visually communicates the multi-select nature), and thus the user can click-click-click to quickly select multiple items. For our web-app we are looking at enhancing this design by adding the tokens functionality.

http://www.realestate.com.au/
http://blogfreakz.com/jquery/jquery-dropdown-check-list/
Comment: Another slight variation is used by Google Analytics for metrics in custom reports. Here the elements added still appear side-by-side, but are not constrained by a surrounding box. A similar approach is also used to list selected triggers in Google Tag Manager. https://support.google.com/analytics/answer/1151300?rd=1
Answer: Any alternative would depend on the data, and the expected use cases. The visual representation is not as important as assisting the user in finding the correct values. You should take advantage of any opportunities to reduce the number of options and guide the user to their preferred values. Consider filtering, grouping and remembering previous selections.
Comment: The filtering is probably the easiest that will have the greatest effect. Convention these days accepts a 'Google Suggest' style filtered list (where simply typing letters reduces the item count). Your users already know how to use something like this. +1 again for "finding the correct values" - relevance! Try to sort the list initially with things that make the items at the top most relevant. I've got more to say but it's just reiterating this great answer.
Answer: I've noticed this alternative used by Windows 7 for selecting columns for Windows Explorer.
Comment: Are the checked items always displayed at the top of the list ?
Comment: No, not in the example that I provided from Windows, in that case ordering also reflects column ordering in Windows Explorer. Good question though.
Comment: ok, then I think one of the drawbacks with this interface is you can't quickly see all the ckecked items.
Comment: @David - True, so the cases where it makes sense is where the selected values are already apparent usually on the parent form that launches such a dialog. Such is the case with Windows Explorer where you only have to look at the visible columns to know what is already selected. So I would say it's a trade off between having a more slim dialog with a single list and having the ability to easily see which values are selected and in some cases one way makes more sense than the other.
Answer: Check out these examples as well:
http://ivaynberg.github.com/select2/
... from a jquery plugin called "Select 2" that will give you programmatic access, tagging support and tokenization for select boxes, input fields, dropdowns and more. You should be able to build a good solution for your challenge with this.
Cool plugin.
Answer: You can use a checkbox list with a checkbox option "Select all" on the top. With this checkbox you can select and deselect all options very fast (checkbox reflects at the same time the selection status of the list... all, any or none). If the number of  checkbox items is very high, you can show the selected items (in a normal list) on the right side of the checkbox list. In additional you should add a filter over the checkbox list.
Answer: If you lack space and the probability of added items is low (2-3), you can make a repetitive add action. With the proper taxonomy users get that very fast.


Several Event Types in the Same Topic With Kafka, Quarkus and Avro

Question: I am trying to read an event from a topic using Quarkus. The topic could contain different types of events. All the events use the AVRO format, so I have a schema registry where I can read the releted schema of an event. I use avro-maven-plugin to compile the schema into a Java class.
Suppose we have two types of events with the following schemas:
Event1
{
   "field1": "string"
}

Event2
{
   "field2": "string"
}

In my application I am interested only on one of them.
 public class Consumer {

    @Incoming("test-in")
    public CompletionStage<Void> read(
        IncomingKafkaRecord<String, Event1> data) {
        System.out.println(data.getKey());
        System.out.println(data.getPayload());
        return data.ack();
    }
}

This code print all the events not only the evnts of type Event1 as I expected.
When I try to get data from the event data.getField1() I get a CastException.
java.lang.ClassCastException: class org.apache.avro.generic.GenericData$Record cannot be cast to class com.test.Event1 (org.apache.avro.generic.GenericData$Record is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @1aa7ecca; com.test.Event1 is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @1144a55a)

There is a way to read only some event types from a topic with several event types usign AVRO?
Answer: A possible solution (little bit verbouse) is using SpecificRecord as payload type and set      specific.avro.reader=true on application configuration file for incoming events.
 public class Consumer {

    @Incoming("test-in")
    public CompletionStage<Void> read(
        IncomingKafkaRecord<String, SpecificRecord> data) {
            String schemaFullName = data.getPayload().getSchema().getFullName();
            if (schemaFullName.equals(Event1.class.getName())) {
                System.out.println(((Event1) data.getPayload()).getField1());
            }
        return data.ack();
    }
}

After selecting the event you can cast the SpecificRecord to the correct compiled Avro event class.


Is there a way to know the thread id in another process which throws an exception?

Question: I am trying to use MiniDumpWriteDump() API to dump a crashed process B from another process A. I am doing this because MSDN said so:

MiniDumpWriteDump should be called
  from a separate process if at all
  possible, rather than from within the
  target process being dumped.

The MiniDumpWriteDump() is defined as this:
BOOL WINAPI MiniDumpWriteDump(
  __in  HANDLE hProcess,
  __in  DWORD ProcessId,
  __in  HANDLE hFile,
  __in  MINIDUMP_TYPE DumpType,
  __in  PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
  __in  PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
  __in  PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);

Especially, the ExceptionParam is of type PMINIDUMP_EXCEPTION_INFORMATION, which is defined as below:
typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
  DWORD               ThreadId;
  PEXCEPTION_POINTERS ExceptionPointers;
  BOOL                ClientPointers;
} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;

Now I am wondering how to prepare the following 2 parameters:
ThreadId
The identifier of the thread throwing the exception.
ExceptionPointers
A pointer to an EXCEPTION_POINTERS structure specifying a computer-independent description of the exception and the processor context at the time of the exception.
How could I get the faulting thread id and exception pointers in process B while running in process A?
Thanks.
Comment: I am facing a similar issue . I am not able to pass PEXCEPTION_POINTERS ExceptionPointers to other process . ( if i use FileMapping concept i end up getting null pointer ) . Kindly elaborate on how you settled on this one .
Answer:
A pointer to a MINIDUMP_EXCEPTION_INFORMATION structure describing the client exception that caused the minidump to be generated. If the value of this parameter is NULL, no exception information is included in the minidump file.

Despite the fact that the paramter is marked __in and not __in_opt you can indeed pass NULL here. To get that information in the first place from the target process your process would have to be debugging it anyway.
How and when does process A known to take a minidump of process B? If A is indeed debugging B, when WaitForDebugEvent returns with an EXCEPTION_DEBUG_EVENT, the information is available in the info structure.
If A isn't debugging B, then perhaps B is telling A through some IPC mechanism "Hey I'm crashing, take a minidump". In this case either B could take the dump itself or pass the exception information through the same IPC mechansim to A. Again though, this is problematic for the same reasons calling MiniDumpWriteDump in the crashing process is problematic, if things are blowing up, the thing that might have blown up may be what you need to tell A about it.
The other mechanism that might have A take a dump for B is A is installed as the JIT debugger, in which case, A will be debugging B and you can use the debugging APIs to get the exception information.
If A is just periodically taking minidumps of B, then there won't necessarily be any exceptions, so you can just pass NULL in this case.
Note that if you're intending on doing something like
WaitForSingleObject(handleToProcessB, INFINITE);
MiniDumpWriteDump(handleToProcessB, ...)

that this will not work. The OS keeps around a very few things, mainly the exit code for the process, not the virtual address space and the stacks which you need to take a minidump.
Answer: To have an automatic dump created on a given exception on a specific process name, my advise would be to use DebugDiag or AdPlus. Those are external (and free !) software that you can configure to do so.
If you really want to write the dump by yourself, you can do it in process B : MSDN warn you that is not a good idea, because nasty errors like out of memory, stack overflow, or stack corruption (list is not exhaustive) will certainly use memory and stack, and so you may ends up with no dump at all (and a very bad process crash). From my experience, this is pretty rare (I used to work on a very stressed distributed C++ software).
For others exception, it should be ok. In that case, you can use an exception translator (see _set_se_translator) or a vectored exception handler (see AddVectoredContinueHandler) or the function GetExceptionInformation() to get the EXCEPTION_RECORD structure (there may be others ways that I'm not aware of).
Creating the dump from process A after an exception in process B means that you have to copy all informations about the exception, and warn the process A that it has to dump something with this exception. This will consume memory and stack, and so you will have the same limitation than explained before.
Hope that will help


16.04 AMD Graphics card not used properly

Question: I just updated to 16.04. My system has AMD Radeon HD 5450 graphics card which I use with two 16:9 monitors.
After update, i.e., after removing fglrx, the displays are mirrored and have 4:3 aspect ratio and low resolution. I suspect this has something to do with the driver in use, but I'm unable to change it.
Any suggestions on how to proceed?
$ sudo lspci -v
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cedar [Radeon HD 5000/6000/7350/8350 Series] (prog-if 00 [VGA controller])
Subsystem: ASUSTeK Computer Inc. Cedar [Radeon HD 5000/6000/7350/8350 Series]
Flags: bus master, fast devsel, latency 0, IRQ 11
Memory at e0000000 (64-bit, prefetchable) [size=256M]
Memory at fbe20000 (64-bit, non-prefetchable) [size=128K]
I/O ports at e000 [size=256]
Expansion ROM at fbe00000 [disabled] [size=128K]
Capabilities: [50] Power Management version 3
Capabilities: [58] Express Legacy Endpoint, MSI 00
Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
Capabilities: [150] Advanced Error Reporting
Kernel modules: radeon

Some other possibly useful information:
$ sudo lshw -c video
  *-display UNCLAIMED
   description: VGA compatible controller
   product: Cedar [Radeon HD 5000/6000/7350/8350 Series]
   vendor: Advanced Micro Devices, Inc. [AMD/ATI]
   physical id: 0
   bus info: pci@0000:03:00.0
   version: 00
   width: 64 bits
   clock: 33MHz
   capabilities: pm pciexpress msi vga_controller bus_master cap_list
   configuration: latency=0
   resources: memory:e0000000-efffffff memory:fbe20000-fbe3ffff ioport:e000(size=256) memory:fbe00000-fbe1ffff

Comment: I fixed a similar issue using xrandr. Execute `xrandr` to get output infos, max resolution, etc. Then do `xrandr --output OUTPUT --mode MAXRES`, replacing OUTPUT with the output name of your monitor (cf. the output of `xrandr`, probably VGA-1 in your case), and MAXRES with the maximum resolution of your screen, as shown using the `xrandr` command. This should look something like `xrandr --output VGA-1 --mode 1920x1080`
Answer: The solution was to remove nomodeset from kernel parameters in grub. This enabled radeon driver and dual monitor setup with correct resolutions was immediately correct after startup.
Unfortunately the radeon driver (and/or perhaps the GPU itself) seems to be little on the slow side with current desktop environments using dual monitor with multiple windows open etc.
Comment: This worked for me with amdgpu-pro


Explanation of "paths" in multivariable limits

Question: I get how for the limit as (x,y) approaches, say, (0,0), if there's a discontinuity along, say, x=0, then there won't be a limit, because no matter how small you make your $\delta$-circle, you won't get within $\epsilon$ of a limit. But I don't get how f could approach the same limit along every line through the point in question, but not approach the limit along another path. Could someone give an intuitive explanation (mathematical explanations are good too, but intuitive ones are preferred) of what a "path" means in terms of limits and how a limit could be the same within any $\delta$ along every line, but how the limit doesn't exist because it is different along a different non-linear path? If possible please include some mention of the $\delta$-circle.
Comment: I have the same question and am very curious. Here's how I'm thinking about it:

Socrates gives us an ϵ and says, "give me a circle in the x-y coordinate plane (input space) such that any point in that circle will give me a value within ϵ of the limit you're claiming to exist".

So ultimately, the question is, can we draw a bunch of lines such that it'd *completely* fill the circle?

Try drawing a lot of lines. Then zoom in, and there'll be space. Then fill that space with more lines. Then zoom in more.

"You could always draw more lines."

"But you could always zoom in more"

...
Comment: Funnily enough, this is this same dilemma that limits solve! Can't we use the same ϵ-δ logic to say that as the number of lines approaches infinity, the amount of empty space in the circle approaches zero?
Comment: Perhaps it has to do with the fact that, as decrease the radius of the circle decreases by one unit, it empties out space proportionate to the circumference, but as you add one unit (one?) of lines, it adds a number of points to the circle proportionate (some were already filled) to the radius. Since the circumference is larger than the radius, the points are emptying out faster than their being filled. My hesitation is that I don't know if I chose the right units (number of lines and radius of circle). Radius of circle seems right because we're decreasing δ.
Comment: Perhaps related : [Commutativity of iterated limits](http://math.stackexchange.com/questions/548355/commutativity-of-iterated-limits) . Perhaps, because the question IMO isn't very clear.
Answer: Here is an example which, I hope, is graphical enough. Consider 2 circles: the circle of radius 2 with the center at (2,0) and the circle of radius 1 with the center at (1,0). These circles touch at (0,0), with the smaller circle lying inside the bigger one.
Now consider a function which is equal to 0 outside of the larger circle, equal to 0 inside the smaller circle, and equal to 1 between the two circles.
If you approach (0,0) along the vertical line, then you're outside of the larger circle, so the value of the function is 0. If you approach (0,0) along a non-vertical straight line "from the left" (i.e., from the half-plane $x<0$), then you're outside of the larger circle, so the value of the function is 0. If you approach (0,0) along a non-vertical straight line "from the right", then at some point you enter the inner circle, and after that the value of the function is 0. So if you approach (0,0) along any straight line, the limit of the function is 0.
However, you can also approach (0,0) along a curve which lies between the two circles, for example, along the circle of radius 1.5 with the center at (1.5, 0). And then you get the limit 1, as the function is equal to 1 between the circles.
Comment: This is a great example, why is it not awarded already? ha : )  $~~$ Having said that, it can be perfected if someone is so kind as to furnish it with a figure or even animation.
Comment: Agreed, this is absolutely fantastic and perfect - thank you!
Answer: Let's work in polar coordinates. Take $\theta$ to be the angle. Now suppose the value of a function at $(r,\theta)$ is $r/\theta$ for $\theta$ non-zero and $0$ when it is. If we go down a ray we definitely converge to zero.
However, if on a path $\theta$ goes to zero faster than $r$ does, we get infinity.
eg
define $x_n = (n^{-1},n^{-2})$ then the function has $f(x_n) = n.$
Here we are on a path lying in a set $\theta =r ^2.$
Comment: That makes sense algebraically, and I've seen other similar examples that make algebraically... but it still doesn't make sense to me intuitively/graphically - why doesn't an infinite amount of lines fill the circle around (0, 0) with a radius of δ (see [comments](http://math.stackexchange.com/questions/1056901/explanation-of-paths-in-multivariable-limits#comment3982821_1056901) for an elaboration)?
Comment: Here's a thing to think about for the given function. Yes, for every line, the limit heading into the origin is zero. However, each of those lines (for $\theta \ne 0$) has a point on in for which the function is equal to 1. The function evaluated on this path always has a value of 1 (again for $\theta \ne 0$), so the limit if you go along it with descending $\theta$ is 1.
Answer: Let $f:B \rightarrow \mathbb{R}$, where $B$ is an open ball in $\mathbb{R}^2$ with center $a$.
By definition, $\lim_{x \rightarrow a} f(x) = L$ means that for every $\epsilon > 0$ there is a $\delta > 0$ such that $|f(x) - L| < \epsilon$ whenever $0 < |x - a| < \delta$.
However, there is an equivalent criteria for $\lim_{x \rightarrow a} f(x) = L$ in terms of sequences. You can find it in basically any undergraduate analysis textbook (like Rudin, Apostol, Bartle, Abbot, Pugh).
$\lim_{x \rightarrow a} f(x) = L$ if and only if $\lim_{n \rightarrow \infty} f(x_n) = L$ for every sequence $(x_n)$ with $\lim_{n \rightarrow \infty} x_n = a$ and $x_n \neq a$.
The elements $x_1,x_2,x_3,\ldots,$ of a sequence satisfying $\lim_{n \rightarrow \infty} x_n = a$ and $x_n \neq a$ trace out a "path" towards $a$. Notice that the path does not need to be linear. Imagine a path that spirals in towards $a$ for example.
If you want to show the limit of $f$ doesn't exist, and you want to be very rigorous about it, you would find a sequence $(x_n)$ satisfying $\lim_{n \rightarrow \infty} x_n = a$ and $x_n \neq a$ but $\lim_{n \rightarrow \infty} f(x_n) \neq L$ (say because $f(x_n) = L+1$ for every $x_n$ in your sequence).
This limit criteria in terms of sequences is a bit complicated for most calculus classes. So we just talk about the paths instead.
The comments of Adam Zerner seem to be about whether an arbitrarily small ball around the point $a$ can be filled up by the set of all line segments that start at the edge of the ball and end at $a$. The ball indeed can be filled up in that way.
But the limit is not about filling up a ball. It is about what happens as you move closer and closer towards $a$. For the limit to exist, for every distance $\epsilon > 0$, you must be able to find a ball of radius $\delta$ around $a$ so that no matter which point $x$ you look at in the $\delta$-ball, you have the distance between $f(x)$ and $L$ less than $\epsilon$. You can look at $x$ to the left or to the right of $a$ or above or below $a$ or on some path or line segment towards $a$, just as long as $x$ is within radius $\delta$ of $a$.
Comment: @AdamZerner Thoughts?


Select table cells based on the value in the cell

Question: I have a table as shown in http://jsfiddle.net/Lijo/UqdQp/4/. I need to set background color as red for all columns that has value "1".  What is the best way (in terms of performance) for doing this using jQuery?
Note: After doing the background color, I need to alert the value of the table cell also. That means I need to use "this" operator on the selected cell.
Reference Answers:

http://jsfiddle.net/Lijo/uGKHB/11/
http://jsfiddle.net/Lijo/uGKHB/12/
Finding column index using jQuery when table contains column-spanning cells
Comment: All columns that contain *a* 1, or all columns for which all contained values (with the exception of the header row) *are* 1?
Answer: I have used the each function of jQuery to iterate over each table cells and highlight the cell when it matches the required condition.
Working demo:
http://jsfiddle.net/saji89/uGKHB/
$('.resultGridTable td').each(function()
{
    if($(this).html()==1)
    {
        $(this).css({'background':'#FF0000'});
    }
});

Using contains selector instead of if conditional, should be more faster:
http://jsfiddle.net/saji89/WbXTr/
Comment: Please post your answer in your answer, rather than relying on an external site to host your code.
Comment: Thanks. It works. However I wonder whether there is a more fast way.
Comment: Check this out, uses `contains` selector, and thereby avoids the `if` usage:http://jsfiddle.net/saji89/WbXTr/
Answer: var $tds = $("td").filter(function(i){
    return $(this).html() == 1;
});

$tds.css({ background: 'red' });

$.each($tds, function(i, x){
    console.log($(x).html());
});

I used console.log instead of alert for obvious reasons.
Comment: `return $.trim($(this).html()) == 'Type';` -- you have to trim the whitespace out. http://jsfiddle.net/uGKHB/9/
Comment: It does coloring for "1234" also. How can we overcome this? http://jsfiddle.net/Lijo/uGKHB/3/
Comment: Thanks. I tried to apply this to header cell - did not work. Any idea why? http://jsfiddle.net/Lijo/uGKHB/7/
Comment: Thanks. Answers are available in http://jsfiddle.net/Lijo/uGKHB/11/ and http://jsfiddle.net/Lijo/uGKHB/10/


How to switch css based table column with nested content using jquery?

Question: I'm trying to switch the position of ul from left to the right using jquery. I am using table for the layout. I have few lines of code to do the job and it worked. The issue is that when I use it as a nested content, the ul section is doubled up. Please check my fiddle to understand what I mean and pls help me solve the issue. Thanks!
FIDDLE here
$(document).ready(function() {
    $('.tabs.vright > ul:eq(0)').appendTo('.tabs.vright');
});

Answer: Your code is taking the first .tabs.vright > ul and appending it to ALL your .tabs.vright.
You need to loop through your elements and apply accordingly.
Like so:
$('.tabs.vright > ul').each(function() {
    $(this).appendTo($(this).parent());
});

FIDDLE


IronPython cannot import os: ImportException: "not a Zipfile"

Question: I am trying to execute this script from a Console .NET 4.5 application
Script: test1.py
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import os
print os.getcwd()

C#: Program.cs
 static void Main(string[] args)
 {
     ExecuteScript();
     Console.Read();
 }

 private static void ExecuteScript()
 {
     var engine = Python.CreateEngine();
     var scope = engine.CreateScope();
     var source = engine.CreateScriptSourceFromFile(@"D:\Scripts\test1.py");
     engine.Runtime.IO.RedirectToConsole();
     source.Execute(scope);
 }

If i run this, i get an IronPython.Runtime.Exceptions.ImportException.
If i ignore this exception (detach VS debugger) it works, but i would like to know how to properly handle it, or if i should just ignore it?
Thanks,
Yann
Answer: As of right now you can only ignore this non-fatal, internal exception or disable zip import support.
Instead of fully detaching the debugger you could enable just my code or exclude breaking on import exceptions.
To disable zip import support you can clear (or check and remove a specific handler if there are multiple) path_hooks:
var pc = HostingHelpers.GetLanguageContext(engine) as PythonContext;
var hooks = pc.SystemState.Get__dict__()["path_hooks"] as List;
hooks.Clear();

More information can be found in the corresponding ticket on github.
Comment: Thanks! How do you disable zip import support?
Comment: I have editied my answer and added a snippet example of how to remove the zip handler.
Comment: Thanks, very appreciated!
Answer: I've got the same problem, i create a pull request, which will solve it. maybe it will be accpeted :)
my fix is, to make import modules stateful:
foreach (object hook in (IEnumerable)pathHooks) {
    try {
        object handler = PythonCalls.Call(context, hook, dirname);

        if (handler != null)
        {
            if (handler is IImporterModule)
            {
                if ((handler as IImporterModule).State == ImporterModuleState.Ready)
                {
                    return handler;
                }
            }
            else
            {
                return handler;
            }
        }
    } catch (ImportException) {
        // we can't handle the path
    }
}

Pull request on git-hub: https://github.com/IronLanguages/main/pull/1247