vlc player doesn't run with optirun

Question: I have installed bumblebee. Other applications are working with optirun instead of vlc.
optirun -b primus vlc

error
VLC media player 2.0.8 Twoflower (revision 2.0.8a-0-g68cf50b)
[0x19d0108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[0x1d8e5e8] qt4 interface error: Xlib not initialized for threads
../../../include/vlc_xlib.h:46:vlc_xlib_init: Xlib not initialized for threads.
This process is probably using LibVLC incorrectly.
Pass "--no-xlib" to libvlc_new() to fix this.
[0x1d8e5e8] skins2 interface error: Xlib not initialized for threads
[0x1d8e5e8] skins2 interface error: initializing xlib for multi-threading failed
[0x1d8e5e8] skins2 interface error: cannot initialize OSFactory
[0x1d8e5e8] [cli] lua interface: Listening on host "*console".
VLC media player 2.0.8 Twoflower
Command Line Interface initialized. Type `help' for help

System info
Ubuntu 13.10 (64bit)
optirun (Bumblebee) 3.2.1

Is there any workaround?? Thanks..
Edit
This issue fixed in VLC media player 2.1.6
Answer: This is saying that it doesn't support the GUI of VLC but wel on command line. You can play , for example a video, if you put the file name as a a parameter:
optirun vlc /path/of/gamesofvideo.mkv
The problem is that is very painful to use vlc in text mode :-(
Answer: Good news. I found a solution. In order to launch VLC through Bumblebee without errors - VLC must be installed BEFORE Bumblebee.
P.S. I tested it two times on Ubuntu 14.04 (Run VLC via Bumblebee)
Comment: Actually there is no such things. VLC media player 2.1.6 fix this issue.
Answer: I faced the same issue, but the following command worked for me:
optirun -b none vlc

Answer: (this would be a comment, but I need 50 reputation before I can post comments.)
I have vlc working on Ubuntu 12.04 with Bumblebee, although I can't get it if I enable primus bridge. optirun vlc seems to work fine though. Does it fail if you let it set bridge as auto with just optirun <app>?
Comment: optirun vlc has the same error. Other application is working with optirun app
Comment: I assume you have tried both `--no-xli` and using cvlc. https://forum.videolan.org/viewtopic.php?f=32&t=86906 . Try updating with `apt-get`, and if that still fails, try getting a new version directly http://www.videolan.org/vlc/
Comment: I have installed latest version from ppa but no luck
Comment: I found a commit of vlc about --no-xlib but don't understand how to pass it as argument. vlc --no-xlib also show the same output as optirun vlc   https://mailman.videolan.org/pipermail/vlc-commits/2010-June/001799.html

vlc player doesn't run with optirun


Are there more than $\beth_1$ non-homeomorphic topological subspaces of $\Bbb R$?

Question: I've been asked by a younger student about a certain claim he had on a classification of topological subsets of $\Bbb R$. The overall idea was a bit fuzzy, but in hindsight it revolved around taking the $\sigma$-algebra generated by six (Borel) subsets + translations. I successfully (and, I hope, instructively) argumented against it. However, this led me to the question:

Could I just cut it short and fancy with a cardinality argument? Specifically, if $\sim$ is the homeomorphism equivalence on $\mathcal P(\Bbb R)$, is $\operatorname{card}\left(\mathcal P(\Bbb R)/\sim\right)>\beth_1$ ?

Intuitively, I'd say yes, because, "come on, there are $\beth_2$ nasty non-Borel sets". And, "at chit-chat level, homeomorphisms $(a,b)\to(c,d)$ are monotone functions". However, this is neither a proof nor a sufficient reason for my question to even be decidable in ZFC.
In fact, on the topic I found this weaker fact: "closed subsets up to homeomorphism are exactly $\beth_1$".
Thank you for links and/or answers.
Comment: See http://math.stackexchange.com/questions/907797/how-many-subspace-topologies-of-mathbbr
Comment: If I understand your question correctly taking the space constructed in the answer to [this question](http://math.stackexchange.com/questions/2073427/must-every-subset-of-mathbb-r-contain-2-homeomorphic-distinct-open-sets) and considering all of its subsets should work
Answer: Every subset of $\mathbb{R}$ has a countable dense subset.  If $X\subseteq\mathbb{R}$ and $A\subseteq X$ is a countable dense subset, a homeomorphism from $X$ to another subset $Y\subseteq\mathbb{R}$ is determined by its restriction to $A$.  So there is an injection from the set of homeomorphisms from $X$ to other subsets of $\mathbb{R}$ to the set of functions from $A$ to $\mathbb{R}$. There are only $\beth_1$ functions from $A$ to $\mathbb{R}$ since $A$ is countable.
So each subset of $\mathbb{R}$ can be homeomorphic to at most $\beth_1$ other subsets of $\mathbb{R}$.  Since there are $\beth_2>\beth_1$ different subsets of $\mathbb{R}$, there must be $\beth_2$ different homeomorphism classes of subsets of $\mathbb{R}$.
Comment: @G.Sassatelli: Not quite: you need every subspace to be separable as well (so, for instance, it suffices to assume your space is second-countable).  You also need your space to be Hausdorff, so that a continuous function is determined by what it does on a dense subset.
Comment: Oh, in fact that wasn't hard at all! :)
Comment: So, I guess the same goes for any separable topological space with $\beth_1$ elements.
Comment: Thank you very much for the edit of my question


lost hard drive while upgrading

Question: While upgrading from 12.04 to 13.04, everything appeared to be going fine until the very end when a couple of quick red failed messages appeared during final cleanup. The desktop screen lost all icons and froze.
I am using an OCZ 120 GB solid state sata drive. My bios can see it but my original 12.04 booted from my thumb drive can't. Any ideas on how to get access to the drive so I can reformat and try a fresh install of 13.04?
Answer: You don't have to boot into Ubuntu 12.04 and then upgrade to Ubuntu 13.04. If you want to install Ubuntu 13.04, download it from here (choose 32 bit or 64 bit) and put it on a CD or USB. Then, restart your computer and press F12 or another function key (based on your system) to boot from the CD or USB. Then, you can hit Try Ubuntu if you want to try and recover your data, otherwise hit Install Ubuntu and follow the remaining directions to install a fresh copy of Ubuntu 13.04.

lost hard drive while upgrading


How to connect four computers together without using any external device?

Question: I need to connect four computers serially. The topology is given below.
                c1<--->c2<--->c3<--->c4

I have multiple ethernet cards in c2 and c3 computers. I don't need any external connectivity from the internet, just these four computers should be able to communicate with each other.
Note: all the computers are running Ubuntu version greater than equal to 16.04.
Thanks in advance.
Comment: Is this homework for some class?
Comment: http://opensourceforu.com/2015/04/how-to-configure-ubuntu-as-a-router/
Comment: No, I want to create a network test bed. Thanks for help.
Answer: Be aware that your network cards support both straight and crossover cable. If not you will need  crossover Ethernet cables.
Then, once all the devices are connected :
Enable forwarding
First activate the IPv4 forwarding on your devices.
To enable it on the fly you can use :
echo 1 > /proc/sys/net/ipv4/ip_forward

To enable it permantly, edit the file /etc/sysctl.confand uncomment the line with net.ipv4.ip_forward = 1. Then reload the conf : sysctl -p /etc/sysctl.conf.
Define IP and Routes
Then, configure the IP and routes of your devices.
To perform that you can edit directly the file /etc/network/interfaces.
Example :
auto eth0
iface eth0 inet static
        address 192.168.1.1 # c1, configure the same subnet in the c2 interface that is connected to the c1 device
        netmask 255.255.255.0
        up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1

If all of your devices are in the same subnet, you does not need to describre routes.
Debug/Confirm
If this does not work, check the Firewall and edit it if required :
sudo iptables -L

Hope this answer help.
Edit
Since C2 is directly connected to both subnetworks you just have to set a route to the third network.
You can specify multiple interfaces in /etc/network/intefaces
auto  [interface1]
iface [interface1] inet static
        address 192.168.1.2 # The same subnet that is configure for C1
        netmask 255.255.255.0
        # You don't need specific route for this interface because there is no another network behind C1

auto [interface2]
iface [interface2] inet static
        address 192.168.2.1 # C2<--->C3 subnet
        netmask 255.255.255.0
        up route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.2.2 # Where 192.168.3.0 is the C3<-->C4 subnet and 192.168.2.2 the C3 address of the interface in the subnet C2<-->C3

I did not test this configuration but this should work. Once you finish to configure you can check the routes with ip route command.
C3 and C2 have direct route to both network. So you just have to define a route to the third network (C3 <--> C4 for C2 and C1 <--> C2 for C3). Once C2 and C3 have access to all network, you just have to defined them as default gateway for C1 and C4.
Comment: I have a query.

By referring the above network topology I can able to set the interface file for c1 and c4. But c2 and c3 has two interface cards, so I need to define two entries in interface file, so should I define two different gw for both entries.

If possible could you please give an example for either c2 or c3 as well.
Comment: Please check the edit of my answer.
Comment: Thanks for giving such in-depth explanation.
I have done the configuration as per your suggestion and my network component get IP address.
Comment: All computers are able to ping each other.
Comment: I'm glad that's work. You can define my answers as accepted if you think that make the work and to close this thread.
Comment: Just need a quick confirmation about multiple gateways in a single machine.
Let say if above topology has five nodes serially, then do we need to add two gateways in middle node or just defining an extra route is fine.
Comment: A gateway is a device that allow you to communicate with devices that are not in your subnetwork. When you add a default route and try to reach any IP that are not in your subnetwork your computer will use this default route and the gateway (router, ISP Box, server...) will forward and perform the communication. But for that the gateway have to know how to reach the IP that you want to communicate with. So you can configure specific route (another gateway) for specific prefix.
`sudo ip route add 10.10.10.0/24 via 192.168.1.254`  --> Will use 192.168.1.254 gateway to reach 10.10.10.0/24.
Comment: But configure static routes when you get too much devices can be a real pain. That's why protocol like OSPF, ISIS, RIP (and BGP for ISP) exists. You can configure it on Ubuntu but this is out of scope here.


Java 8 Stream Merge Partial Duplicates

Question: I have a POJO that looks something like this:
public class Account {
    private Integer accountId;
    private List<String> contacts;
}

The equals And hashCode methods are set to use the accountId field to identify uniqueness, so any Accounts with the same accountId are equal regardless of what contacts contain.
I have a List of accounts and there are some duplicates with the same accountId. How do I use Java 8 Stream API to merge these duplicates together?
For example, the list of account contains:
+-----------+----------+
| accountId | contacts |
+-----------+----------+
|         1 | {"John"} |
|         1 | {"Fred"} |
|         2 | {"Mary"} |
+-----------+----------+

And I want it to produce a list of accounts like this:
+-----------+------------------+
| accountId |     contacts     |
+-----------+------------------+
|         1 | {"John", "Fred"} |
|         2 | {"Mary"}         |
+-----------+------------------+

Answer: Use Collectors.toMap Ref: https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html#toMap-java.util.function.Function-java.util.function.Function-java.util.function.BinaryOperator-
@lombok.Value
class Account {
    Integer accountId;
    List<String> contacts;
}

List<Account> accounts = new ArrayList<>();
//Fill
List<Account> result = new ArrayList<>(accounts.stream()
    .collect(
        Collectors.toMap(Account::getAccountId, Function.identity(), (Account account1, Account account2) -> {
            account1.getContacts().addAll(account2.getContacts());
            account2.getContacts().clear();
            return account1;
        })
    )
    .values());

Comment: I have accepted this as the answer because it's using the stream API, and I didnt need to modify POJO.
Answer: A clean Stream API solution can be quiet complicated, so perhaps you're better off with a Collection API solution that has less constraints to obey.
HashMap<Integer, Account> tmp = new HashMap<>();
listOfAccounts.removeIf(a -> a != tmp.merge(a.getAccountId(), a, (o,n) -> {
    o.getContacts().addAll(n.getContacts());
    return o;
}));

This directly removes all elements with a duplicate id from the list after having added their contacts to the first account of that id.
Of course, this assumes that the list supports removal and the list returned by getContacts() is a reference to the stored list and supports adding elements.
The solution is built around Map.merge which will add the specified object if the key didn't exist or evaluates the merge function if the key already existed. The merge function returns the old object after having added the contacts, so we can do a reference comparison (a != …) to determine that we have a duplicate that should be removed.
Answer: You could add two constructors and a merge method to the Account class that would combine contacts:
public class Account {

    private final Integer accountId;

    private List<String> contacts = new ArrayList<>();

    public Account(Integer accountId) {
        this.accountId = accountId;
    }

    // Copy constructor
    public Account(Account another) {
        this.accountId = another.accountId;
        this.contacts = new ArrayList<>(another.contacts);
    }

    public Account merge(Account another) {
        this.contacts.addAll(another.contacts);
        return this;
    }

    // TODO getters and setters
}

Then, you have a few alternatives. One is to use Collectors.toMap to collect accounts to a map, grouping by accountId and merging the contacts of the accounts with equal accountId by means of the Account.merge method. Finally, get the values of the map:
Collection<Account> result = accounts.stream()
    .collect(Collectors.toMap(
        Account::getAccountId, // group by accountId (keys)
        Account::new,          // use copy constructor (values)
        Account::merge))       // merge values with equal key
    .values();

You need to use the copy constructor for the values, otherwise you would mutate the accounts of the original list when Account.merge is invoked.
An equivalent way (without streams) would be to use the Map.merge method:
Map<Integer, Account> map = new HashMap<>();
accounts.forEach(a ->
    map.merge(a.getAccountId(), new Account(a), Account::merge));
Collection<Account> result = map.values();

Again, you need to use the copy constructor to avoid undesired mutations on the accounts of the original list.
A third alternative which is more optimized (because it doesn't create a new account for every element of the list) consists of using the Map.computeIfAbsent method:
Map<Integer, Account> map = new HashMap<>();
accounts.forEach(a -> map.computeIfAbsent(
        a.getAccountId(), // group by accountId (keys)
        Account::new)     // invoke new Account(accountId) if absent
    .merge(a));           // merge account's contacts
Collection<Account> result = map.values();

All the alternatives above return a Collection<Account>. If you need a List<Account> instead, you can do:
List<Account> list = new ArrayList<>(result);

Comment: @Holger I've edited my answer. I've removed the custom collector sample, as there was no clean and simple way to create an `Account` with an `accountId` without setting the attribute either in the `merge` method or in a new, dedicated `accumulate` method. Thanks again for your feedback.

Java 8 Stream Merge Partial Duplicates


How can I debug external code in Visual Studio 2019 when there is no PDB available?

Question: I am trying to debug some issues occurring within an external library (ClosedXML). If I can work out exactly what's going wrong, I should be able to apply workarounds to the code that calls it.
I have added ClosedXML and manage it via NuGet.
Unfortunately, the debugger states that ClosedXML.PDB cannot be loaded. The checkboxes for 'Microsoft Symbol Servers' and 'NuGet.org Symbol Server' are both checked.
A suggestion was to generate my own pdb file. So, I cloned the ClosedXML repo, checked out the 0.95.4 commit (the version of the NuGet package I'm using) and built the project in Debug mode. I then directly referenced the pdbs produced in the ClosedXML binaries folder in the 'No Symbols Loaded' page in Visual Studio. Unfortunately, none of them work. They each have the same error message:
<code>...\source\repos\ClosedXML\ClosedXML\bin\Debug\net46\ClosedXML.pdb: PDB does not match image.
...\source\repos\ClosedXML\ClosedXML\bin\Debug\net40\ClosedXML.pdb: PDB does not match image.
...\source\repos\ClosedXML\ClosedXML\bin\Debug\netstandard2.0\ClosedXML.pdb: PDB does not match image.
</code>
This isn't surprising as the DLL and the PDB weren't built on the same machine, but it is unfortunate.
So, my current workaround is to dereference the NuGet package and instead reference the DLL I've built locally. This works, but it is far from ideal.
To confirm, 'Just My Code' is disabled.
Is there any way I can debug the external code without resorting to changing references each time?
Comment: Probably decompiling can help https://learn.microsoft.com/en-us/visualstudio/debugger/decompilation?view=vs-2019 once you know what's wrong in the decompiled code, it should be straight forward to fix in the original code base.
Answer: You can use my Runtime Flow tool to investigate called methods and parameters in ClosedXML without .pdb.


JQuery how to reference JSON value

Question: I'm getting a response back from a processor in this form. If I do console.log(data), this is the result:
{
"status":"No",

"errors":["Dummy Error msg 1","Dummy Error msg 2"],

"successMessages":["Dummy Success msg 1","Dummy Success msg 2"]

}

Either errors or successMessages could be null. I want to iterate through the errors and success messages (if any) to display them, but data.status, data.errors, and data.successMessages are undefined.
I can capture them with something like $.parseJSON(data.SuccessMessages),  which returns
Dummy Success msg 1,Dummy Success msg 2

but isn't there a way to reference them directly and iterate through them?
Comment: if you are using getting this as ajax response. you can specify the dataType in ajax as JSON so that you don't have to use pareJSON
Comment: You can just use `JSON.parse` instead of `$.parseJSON`. All latest browsers have built in `JSON.parse`.
Comment: Try using `reponse.successMessages[0]`
Comment: What does your actual code look like? The options you're using to make the ajax call are relevant.
Comment: Thanks! setting dataType: "json",  was the key. I would have thought the default "intelligent guess" would have recognized the return value as JSON.
Answer: var obj = {"status":"No",

    "errors":["Dummy Error msg 1","Dummy Error msg 2"],

    "successMessages":["Dummy Success msg 1","Dummy Success msg 2"]};

obj['errors'].forEach(function(err, i){console.log(err);});

JQuery how to reference JSON value


What can cause 3-way switches to go bad? 3 quit working in about 2 months

Question: I've been in a house that was newly built 2 years ago.  In about the last two months, I have had 3 separate 3-way switches quit working (all controlling different fixtures)
The first one would not switch off unless I forced the switch all of the way down.  With the second one, the light got stuck on, no matter what I did with either switch in the circuit.  With the third one, in one position things worked fine, but in the other position, when I switched the other switch, the light would cut off in the middle then back on when the switch was up or down.  The only brand marking I could find on the switches were the letters "ps"
I have replaced all three switches and everything is working as it should now, but I am concerned as to what might be causing these failures.
Could this be that the electrician just got a bad batch of switches or used cheap stuff, or, could there be something wrong with the overall circuit that would cause them to fail?
Thank you for any insights you may be able to offer!
Answer: Were all three of those switches installed with poke in wire terminations?
If so then that is likely the root cause of the problem. Move the wires to the screw terminals on the new replacement switches. In the cases where there are more than one wire in the set of poke in holes for a given connection those poke in connections should be replaced with a twist on wire connector to join the wires and an added pigtail that then goes to the switch screw.
Another possibility is that the builder used the absolutely cheapest possible switches. With high usage such cheap switches do not last forever.
Comment: No,  all of the wires were attached to the screw terminals, and I re-attached the new switches by the screw terminals.  So you would lean to this just being bad switches and not caused by any wiring problems in the circuit?  Thanks!
Answer: I've seen it time after time with contractors buying in bulk to save overhead, but the downside is often cheap products.
PS might mean Pass and Seymour.  But I'm not gonna speak bad about P&S because I'm not 100% sure.
Leviton is great and so is Lutron.  That I do know.
Comment: I replaced the switches with Leviton.


Asus N56JR laptop, can't change screen Brightness using Function Keys

Question: I have an Asus N56JR laptop with Nvidia GeForce GTX 760M graphics card, running Ubuntu 14.04 LTS.
When I check what graphics I use for brightness it says "Intel".

I have tried using commands to change the brightness (no luck)
I have tried editing the config files (none here either)
I have tried installing Brightness Indicator and using custom shortcuts to change the brightness (nada).

I have not been able to change the brightness at all, no matter how I try. I know the laptop can change the brightness and it is not a hardware issue because I have a dual-boot with Windows-8 and on Windows the brightness control works fine.
Answer: I did a fake solution with the xbackligth tool. I associated a combo like Ctrl + F5 with the xbackligth -10 command against Ctrl + F6 with the xbackligth +10
May help
Comment: I have tried this already and it does not affect the brightness at all.
Comment: Did you try the commands in a terminal first?
Answer: add this kernel parameter:
acpi_backlight=vendor
    menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os         $menuentry_id_option 'gnulinux-simple-bafb083d-0d91-475d-8c72-4ee4b6069050' {
            recordfail
            load_video
            gfxmode $linux_gfx_mode
            insmod gzio
            insmod part_msdos
            insmod ext2
           set root='hd0,msdos1'
           if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  bafb083d-0d91-475d-8c72-4ee4b6069050
            else
              search --no-floppy --fs-uuid --set=root bafb083d-0d91-475d-8c72-4ee4b6069050
           fi
            linux   /boot/vmlinuz-3.13.0-24-generic root=UUID=bafb083d-0d91-475d-8c72-4ee4b6069050 ro acpi_backlight=vendor quiet splash $vt_handoff
            initrd  /boot/initrd.img-3.13.0-24-generic
   }

improtant:
editing grub.cfg is not the official way and after running grup-update the changes would be removed. but this is a easy way to see if this solution works.
Comment: Could you explain a little more how to do that? Click [edit](http://askubuntu.com/posts/543925/edit) below your answer and add the information.


Find the equation of the normal to the curve with the equation $y=x^3 + 1$ at the point $(1,2)$

Question: I'm having trouble solving this:
Find the equation of the normal to the curve with the equation $y=x^3 + 1$ at the point $(1,2)$.
Comment: First, find the slope of the tangent at $(1,2)$.   Next, use the fact that the slopes of two perpendicular lines are negative reciprocals of each other.
Comment: i don't understand, should i differentiate it first then plug in the x and y values?
Comment: Yes, differentiate first.  Then plug in the specific point $(1, 2)$ (actually, you will just need the abscissa of that point, $x=1$).  The value of $y'$ at $x = 1$ will give you the slope of the line tangent to $y$ at $(x=1, y=2)$.
Answer: The normal line is defined as the line perpendicular to the tangent line of the curve at that point.
Knowing this we can evaluate slope of the normal line of this curve (or in general), by
$m_{normal}=-\frac{1}{f'(x)}$
Where $f(x)$ is our function in question. In this case, $y=x^3+1$.
The slope or the derivative at this point is the derivative evaluated at $x=1$.
Because $f'(x)=3x^2$,
 $f'(1)=3$.
The slope of normal line is then  $-\frac13$.
Recall that to find the equation of ant line given a point and a slope, we could use the point slope formula. (Really, we can use any form of a linear equation and solve accordingly).
The point slope is
$$y-y_{point}=m_{slope}(x-x_{point})$$
Since the normal line also intersects the tangent which intersects the curve at $(1,2)$, we can use the point $(1,2)$ and the normal's slope to get the following tangent line:
$$y-2=-\frac13(x-1)$$
Or
$$y=-\frac13x+\frac73$$
Comment: Don't you need a factor of (-1) in slope of the normal?
Comment: Should it be $-\frac{1}{3}$ instead?
Comment: Yes. Fixed them immediately. Thank you.
Comment: For the sake of clarity, please change $y = x^3 + 1$ to $f(x) = x^3 + 1$.


why the outcome of applying dtype and type function on pandas column gives different outcome?

Question: I am getting different result when applying dtype and type function separately on same pandas column.So,I want to know where it is suitable to use dtype and type function on pandas dataframe.
[In]:type(zostel_df['id'])
[out]: pandas.core.series.Series
[In]: zostel_df['id'].dtype
[out]: dtype('int64')

Answer: dtype returns the dtype object of the underlying data -> if you give it pandas column full of integers then it will return pandas type int equivalent. it looks inside the object types and returns type of its data and not the object type itself.
while
type returns the object's type if you give it pandas column that is effectively a series then it returns Series as the object type. it does not look inside its type but it returns its type only.
Answer: data.dtype

will show the type of the column which is basically pandas series.It can contain text or numbers it will remain pandas.Series whereas
type(data)

will show the type of data that columns contains i.e. it can contain int,object,float etc.


What to do about a rat living in drain line

Question: We have what I think is a rat, or family of rats, that are coming out of an outdoor drain. The outdoor drain is connected into our interior drain system. They chewed through the drain cover, I replaced it and they came through again.
I am in DC so the city sewer system is connected to the surface rain water system and rats are a known problem.
I am worried that sealing the drain in a more aggressive fashion will result in the rats coming out someplace else and would prefer that not to be in my house. The basement drains and plumbing are all buried in the foundation slab and connect to the main drain stack below the main clean out.

What is the proper solution to handling this?
Comment: Back up your truck and attach flexible metal duct to your tailpipe with a hose clamp. Direct the exhaust into the drain line (don't worry, exhaust won't enter your home because your indoor drains are equipped with traps to prevent that). Deliver a good dose of exhaust down to the nasty rat family (don't be empathetic, they caused the Black Death plague). They will go somewhere else.
Comment: You can try a metal drain cover, hopefully they won't be able to chew through that.
Comment: @EliIser wouldn't that just trap them in the drain line and then have them come out someplace else (like the toilet)?
Comment: I came to this question from the weekly newsletter.  I regret clicking that link.
Answer: Your drains likely do not go to sewers, they likely go to storm drains or gutters in the street. So putting Drano is going to put in directly into the environment, where it can harm your kids, your neighbor's kids, your pets and neighbor's pets etc. etc. etc. PLEASE refrain from taking that bad advice...
The rat poison is similar. The reason you don't see the dead rats with that is because it makes them intensely thirsty so they seek out water, then die there. Unfortunately things like raptor birds and other wildlife end up eating the dying or dead rats and get poisoned too.
Get rat traps and bait them with candy bars, preferably ones with peanuts like Snickers bars because they smell stronger. Once you get them all (assuming its a family), get rid of those cheap plastic grates and replace them with metal ones.
Comment: Code be damned, the outdoor drain is connected to the sewer system. That said,  I am not a big fan of poisoning them. That said, it sounds like DC Water and Sewer might be willing to bait the main sewer system.
Answer: Kill the rats, then replace the drain with a metal cover.
https://www.amazon.com/Motomco-Tomcat-Bait-Chunx-Pail/dp/B005BV0DD2
I can't say where the rats live, nor if they are coming or going. I can't think of a great way to keep them out of your internal drain system, and you're right you could end up with a rat in the toilet.
My solution assumes there is a less than infinite quantity of rats. If you put the rat poison down in their activity area, they will eat the poison and die.
As far as how exactly to put the poison down, I'd cut a hole in a whip cream container and put a couple chunks in there. Put the trap near the drain opening. You probably won't see dead rats around, but if you see they're nibbling on the poison, it's working. Leave the hole and keep refilling the poison until they're not eating it anymore, then try sealing it again.
You could get fancy and try to install a removable drain cover, then you could attach some poison to the underside of it, in the actual drain line. They do this with manhole covers.
If the rats are neverending, it's probably time to hire a professional.
Comment: With luck, you can kill some neighborhood cats or raptors too.
Comment: My thinking is the rats are are living in the sewer system and were simply "escaping" through the drain. Do you think they are living in the yard and going into the drain? If they are living in the drain, how do I kill them?
Comment: Set snap traps in protective boxes near the drain.
Comment: you could try caustic soda or drano in the drain line, lots of it and heat the line with hot water first.


3 connection low pressure faucet with regular hot water tank

Question: After purchasing a replacement all in one sink and new faucet to replace my laundry room sink, I had a look underneath and was surprised to see that there are 3  water connections to the faucet. This is the only faucet in the house that isn't a 2 connection high pressure faucet.
As far as I know there is nothing in my house that would necessitate it. My best guess is that the previous owner split the hot water supply under the floor and just connected it to both of the hot water connection points.
I have no boiler and if there is any sort of additional heating device other than my regular hot water tank it is hidden in walls and definitely not up to code (it also would make no sense for such a rarely used faucet). The centre connection is copper while the other two are PEX which is what is used for almost all of the plumbing in my house which further leads me to suspect this was something strange done by the previous owner to fit an incorrect faucet into place.
Any thoughts on what else might be going on or how I can best confirm what's going on without cutting into a bunch of walls and floors?

Edit: Added some photos as requested. I think
crip659 is right and the tap is likely being used to link water to the washer's hot water connection. We have to do some laundry later the copper pipe is cold so I'm going to see if it heats up when the washer is run (without the sink tap being run.) to verify.
Edit 2: When the washer pulls hot water the copper pipe to the faucet doesn't get hot. I tried every fixture in the house with hot water running them until they got hot and the pipe didn't get hot. When I run the tap itself the pipe gets hot right away...
Comment: Pictures will help, but sounds like just using it to run water to somewhere else, instead of just adding a tee fitting to the water line going by.
Comment: I hadn't thought of that though I was thinking that if I connected them before going to the new faucet everything would sort of have to work itself out naturally. Might be the connection to the faucets for the actual washer. I'm on infinite hold about something else and only get reception upstairs will add photos when I can. Thanks for your help.
Comment: @crip659 As per my edit 2 running other fixtures doesn't seem to make the third pipe hot. My best guess at this point is back to the previous owner just connecting two hot water pipes. Am I correct to think that as long as I connect the two pipes it'll perform the same function as the tap and it won't really matter? I was thinking of getting some sharkbite adapters going from a T in the Pex to the copper.
Answer: When I researched a tap with 3 connections all I could find was this which indicated that it was a low pressure tap.
Turns out that isn't the case the third connection is a trap seal primer (which I'd never heard of before).
After confirming the temperature of the copper pipe doesn't change when I run water through any other fixture I finally Googled the specific tap and realized it was a tap seal primer. I also now note that when I run hot water through the tap it gets hot and when I run cold water through the tap it gets cold as some of whatever water I'm running is going through that copper tube rather than it being specifically connected to one type of water.
I'll have to rethink my reno a bit as I don't think my replacement faucet supports a trap seal primer so I'll have to get a separate device of some sort installed.
Comment: Why would you need a trap seal primer?
Comment: The current tap has a trap seal connection so water flows into the trap seal any time I use the faucet. The new faucet I have to replace it doesn't have a trap seal hookup so I either can't use it or I need to install a trap seal primer.
Comment: Let me rephrase: What is the function of a trap seal primer? I've never heard of one.
Comment: When you have a P trap under a sink or shower drain it prevents sewer gas from coming into your house because of the water in the trap. Over time the water evaporates but whenever you run water down the drain that water replenishes the trap. If you have a trap somewhere that doesn't get a lot of water like the AC condensate drain you likely need a trap seal primer. Apparently it is normal to use the laundry sink for this. So whenever I run water through the laundry sink hot or cold a portion of it flows down to the trap in my basement. This is built into the faucet but devices are available.
Comment: That is something new. Come to think of it, I have a drain in my basement between the water heater and the well plumbing. It almost never gets any water in it, but we've never had any problem with sewer odor. It makes me wonder if it's connected to the septic system at all. Thanks @David Oldford!
Comment: No problem. My guess is that there is a trap seal primer somewhere. I had never heard of it until now when I am trying to replace my laundry sink. It would likely have been a code requirement. My house was built in the early 2000s so at least up until then the faucet method was the most common apparently.
Comment: @RetiredATC Looking into my situation further I found out that water based traps are now unusual in new builds. Apparently now new houses are built with spring based trap seals something like this one: https://www.homedepot.com/p/Oatey-3-in-Seal-Drain-for-Showers-and-General-Purpose-43747/315169793#overlay
Comment: Again, I learned something useful today. Thanks @David Oldford
Comment: no problem @RetiredATC. One additional note that specific item I linked to works like the device the plumber I hired put into my drain for me but it is very cheap both in terms of price and performance compared to it. I picked one up for another rarely used drain and will be returning it. My understanding is the good ones use springs that one is just sort of soft rubber that falls open from the top but not the bottom.
Comment: @DavidOldford please be sure to click the check mark next to your answer so others know it's been resolved. That will save people time reading through it looking to answer it, and will help others with a similar problem find this as a suitable answer.


How to remove a keyboard shortcut for Anaconda

Question: I just installed an Anaconda SciPy distribution (https://store.continuum.io/cshop/anaconda/) on Windows 8.1. Whenever I press the right alt + a button combination, Anaconda console shows up. Why on the Earth they would assign such shortcut which is responsible for the ą char (Polish programmers keyboard). Do you know a solution for removing this keyboard shortcut without uninstalling Anaconda ? Maybe it is a background process which listens for this key press. Thank you for your help!
Answer: If you go to the start screen and find the menu item for 'Anaconda Command Prompt'; right click on it and view properties -- is there a hotkey there?  You should be able to delete it.
I'll look into the installer to see if the new console shortcut was added with a hotkey binding -- I suspect it might have been.
Comment: You are right, there was a shortcut-key assigned. Removing an entry from properties solves the problem. Thanks!
Answer: The first answer needs a little tweak.
Following the recipe as above:

Go to Metro Start Screen
Find Anaconda
Right click

... and then there is no option to change properties,

So click "Add to TaskBar"
when you see it on the TaskBar (Desktop Mode) then Right-Click and change properties.


NullPointerException when calling setBackground on LinearLayout

Question: I created a Drawable resource file for a LinearLayout background. And I set Drawable in MainActivity using,
Drawable d = getResources().getDrawable(R.drawable.theme_default_bg);
layoutBackground.setBackground(d);

layoutBackground is the LinearLayout. But, when I run this it returns a NullPointerException. How can I solve this?
Edit
 I set xml background in main.xml file, and it worked. I got this error when i trying to set background from MainActivity.java
Comment: Probably layoutBackground is null
Comment: your layoutBackground is not initialized properly i think.
Comment: Let us see how you sets your layoutBackground in code and how you set it in XML of layout
Answer: Just use:
layout.setBackgroundResource(R.drawable.theme_default_bg);

instead of trying to convert resource in to drawable.
Comment: Thank you. I tried that but i still NullPointException.
Comment: have you initialised the layout? as in layout = (LinearLayout) findviewbyid(.....);
Comment: Yes @MixhaelStoddart
Answer: Try this... In your case you have not initialised the layoutBackground..
 RelativeLayout layoutBackground =(RelativeLayout)findViewById(R.id.background);

Drawable d = getResources().getDrawable(R.drawable.theme_default_bg);

layoutBackground.setBackgroundResource(d);

Comment: Thank you. Sorry i didn't poat it here but i initialised layout.
Comment: try to run it on debug and find the problem
Answer: I found the mistake. The layout i'm trying to setBackground is in another layout file(activity_main.xml). So i use a LayoutInflater,
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View mainView = inflater.inflate(R.layout.activity_main, null);

layoutBackground = (LinearLayout)mainView.findViewById(R.id.layout_bg);

Now error solved. I'm sorry guys i wasted your time. I'm really sorry.


Segregating log files for jobs in a shared flink cluster

Question: Not able to run in kube at the moment so using a shared cluster.
However the logs for all jobs become comingled in the TM.
Is there any way to label the log lines so that that can be distinguished and tied back to the individual jobs? Eg something with an NDC or something more explicit in the logging setup?
Cheers.
Answer: It wouldn't always be meaningful to try to attribute log lines to just one job, but regardless, the answer is no, there's no support for labeling the TM's log lines to indicate which job is involved.
Comment: I would have expected the flink code to be able to do NDC.push on the way into job specific code and NDC.pop on the way out again. That way the logging would be very specific.
Answer: I don't know what aggregation tooling you are using but Loki automatically adds source filename tag - you can use that to distinguish TMs. Your tool might have something like that as well.


What to do to sink cabinet so that water won't leak under it

Question: I recently had water leak from the pipe connector that connects the faucet and the dishwasher under the kitchen sink. There was a cabinet under the sink, and there was a big hole in the cabinet's bottom (for pipes to go through):

Thus, the water got through the hole to the floor and damaged it. It was kind of hard to detect the leak because it was small and the leaked water got hidden under the cabinet.
My question is that Is there any thing I could do so that if there is water leak, the water will go out of the cabinet and be visible, instead of going underneath it? The goal is just to detect the leak as soon as possible.
Comment: you could tie a rag aroudn it when it gets damp and moldy there is a leak
Comment: Get a plastic tray or something and divert the water towards the front of the cabinet. Or just fix the leak and assume it won't happen again.
Comment: @ratchetfreak - haha, that serves me right for answering the question as asked. That's exactly what I did when I was struggling to identify which of several hard-to-reach pipes had a tiny leak. Sometimes, though, it's hard to differentiate between a minuscule leak & just the cold feed sweating in humid weather.
Comment: @Phaelaxz - a tray would be less than useless, as you can't get it under **any** of the lowest points on any of those pipes.
Answer: Have you ever heard the phrase "Lightning never strikes twice"?
I think you're trying to prepare for an accident that is unlikely to happen again.
Sure, you can re-floor the cupboard, wedge it slightly at the back to ensure it slopes towards you, cut as best you can round the pipes, perhaps keep a fillet as insert round the back of the larger pipe, then gob it all in with silicone, including tanking the edges so the only way water can go is out the cupboard door. Don't use good glue & don't run the silicone underneath except for a couple of stabilising dots, just in case you do ever need it out again.
Then wait to see if it ever happens again. For most people, two leaks in a lifetime would be a fair average… and in two different places, unless they have a poor fix the first time.
As mentioned in comments, you could tie a small piece of cloth round each & see if one shows signs of damp &/or mould… but your cold feed is likely to sweat (condensation will form) in humid weather, so that could be misleading.
Comment: Thanks for your very detailed answer! I really hope that it would not happen again :)
Answer: Seems to me that your best bet is to focus on fixing it properly so that it doesn't leak instead of worrying about leak detection.
To answer the question as asked:
Store some things under the sink that you use regularly (weekly to monthly), just get in the habit for looking/feeling for unusual amounts of moisture under there every time you get something out. Where I live, no moisture at all would be normal, so any amount of damp would be cause for additional attention. In some parts of the world, heat and humidity are high enough that there may be condensation on a somewhat regular basis, so learn what's "normal" and look for "abnormal" levels.
Answer: While I agree this is overkill, in cases where it's important, you can buy a Leak Detector, which is an electronic device that detects the presence of water and alerts you - either with sound, or modern ones will connect to an app and tell you that way.  There are inexpensive ones, relatively speaking ($40-$50), though I don't know how well they work compared to the really good ones which are several hundred dollars.
It's not cheap, and probably not needed in this case, but it's probably cheaper than any physical option that requires redoing the flooring or something significant to the cabinet.
Comment: The cheap ones work reasonably well, but you do need to be sure that (1) you can hear their beeping from under the cabinet, and (2) you can get to it and change the batteries as needed, including hearing the low battery chirp. My 'reasonable' comment is based on actual use in a laboratory situation where we had occasional chilled water leaks in back corners of labs.
Comment: I bought a cheap water leak detector, which will beep at around 90db. Hope that it is enough
Answer: Beside all the options that are mentioned above, I found this leak protection for cabinet from Ikea:
https://www.ikea.com/fi/fi/p/variera-vuotosuoja-kaappiin-60281993/
It is basically plastic cover for the cabinet's bottom, which I think, is more useful than a drip tray under the cabinet.


Set the correct height dimension of a three-row-layout

Question: How can I create three rows with the following height:

The header should be 70px
Main should be 30% of the screen
Footer should be taking the rest of the space

body {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
}
header {
  background-color: red;
  height: 70px;
  z-index: 10;
  position: relative;
}
main {
  background-color: green;
  height: 30%;
  position: relative;
}
footer {
  background-color: #ddd;
  /* height? */
}

Comment: This looks like a duplicate of this question: http://stackoverflow.com/questions/7202427/make-footer-take-remianing-bottom-space-using-css
Comment: @resolute_coder – That question is WAY out of date.  I'd say this warrants a new answer.
Answer: you can use
width: calc(70% - 70px);

on the footer, see browser support here
http://caniuse.com/#feat=calc


ASP.NET MVC : how to open any file in a new tab?

Question: I used the following code which is working for a PDF in chrome browser
@Html.ActionLink("Download", "GetReport", new { controller = "Storage" }, new { target = "_blank" })

Here is my code inside controller
public FileResult GetReport()
{
    string ReportURL = @"C:\Tools\HazMat\HazMat\Uploads\IAC HILL TOP CAMPING LIST OF FREE ADVENTURE ACTIVITIES..pdf";
    byte[] FileBytes = System.IO.File.ReadAllBytes(ReportURL);

    return File(FileBytes, "application/pdf");
}

When I gave a path related to docx file here it is downloading instead of opening the document so how can I open any kind of file in to a new tab
Comment: Out of curiosity, what makes you think browsers will display `.docx` files just like how they show PDFs? (I haven't seen a browser open Office files in-place since Office 2003 running with IE6 or maybe Office 2007 with IE7  - since then this kind of browser-based OLE is _dead_).
Comment: `byte[] FileBytes = System.IO.File.ReadAllBytes(ReportURL);` <-- Doing this is **very** inefficient - you should pass an async-capable `FileStream` to `FileResult` so it can efficiently _stream_ the response to the client asynchronously, but your code buffers the entire file into memory... and uses the (_old-hat_) synchronous (i.e. thread-blocking) `File.ReadAllBytes` method...
Answer: If you set Disposition in the header it will open your file in the browser.
public FileResult GetReport()
{
 string ReportURL = @"C:\Tools\HazMat\HazMat\Uploads\IAC HILL TOP CAMPING LIST OF FREE ADVENTURE ACTIVITIES..pdf";
 byte[] FileBytes = System.IO.File.ReadAllBytes(ReportURL);

 //Add this key
 Response.Headers.Add("Content-Disposition", $"inline; filename={file.FileName}.pdf");
 return File(FileBytes, "application/pdf");
}

Comment: Will this work from word documents too?
Comment: @Developer Browsers don't have any built-in feature to render Word docs.
Comment: @Developer, for your Word files and other formatted files which are not supported by browser you have to use tools like (viewerjs), check https://stackoverflow.com/questions/27957766/how-do-i-render-a-word-document-doc-docx-in-the-browser-using-javascript


Install Ultra Short-Throw Projector Mounted Onto Ceiling in Residential Home

Question: I want to install a short-throw projector onto the ceiling of a residential home and whiteboard onto a wall to hold the projected image. How do I do this myself or are there companies out there who can do it for cheap in the USA?
Comment: Too many variables. Model # of projector? What are you connecting it to? Speaker system? etc.
Answer: ...you buy a projector mount, install it to the ceiling (normally requiring that you find the framing to get adequate hold) and provide it with power and signal cables (normally requiring a considerable amount of ripping drywall open to get those run - do yourself a BIG favor and run conduits, not wires, so you don't have to re-do the drywall work when things change.) Then you repair the drywall and paint.
It's not magic, it's just work. Either you do it, or you pay somebody else to do it, and aside from "companies out there who do it for cheap" being specifically off topic, there's also the little matter of getting your house burned down by some cheap fly-by-nighter cutting corners on the install. Always remember that "the US Electrical Code" is written by folks in the "fire prevention" business. Do you really want to bet your house on doing it wrong?
Alternatively, you live with exposed cables attached to the ceiling. It's much easier, and when you remove the projector it's just a few screw-holes to spackle & paint. I've done quite a few projectors for work, and most of them are exposed wiring.
Or, depending on the size of your proposed whiteboard, you discover that large TVs are remarkably affordable and brighter than most projectors, and skip the whole whiteboard & projector thing (done a lot of those at work, too, at half the price of the projector, and able to work in rooms much too bright for a projector to work in.)
Comment: I wanted a projector + whiteboard because I can't draw on a TV. Staring at a TV up close is worse than staring at the wall.


solving third order nonlinear differential equation

Question: Can someone help me in solving :
$$
y'''(x)+2\,y(x)y''(x)=0
$$
using Runge-Kutta method? I'm not sure how to linearize it.
Thanks in advance
Answer: To apply a RK method, you need not to linearize, but to transform into a first order system. Assign to a state vector $u\in\Bbb R^3$ the intended meaning $u_0=y$, $u_1=y'$, $u_2=y''$, then the ODE function in $u'(t)=F(t,u(t))$ is
$$
F(t,u)=\pmatrix{u_1\\u_2\\-2u_0u_2}
$$


How to add background image to my menu?

Question: I am currently making some kind of menu in libgdx with a background image. I tried adding the image as an actor but then the buttons did not respond to the touchDown event. So I tried now just drawing with the spriteBatch the background image in the render() method, and after that in the show() method drawing the table and the buttons, but now it only appears the image, no buttons at all. This is the code:
<code>   public void show()
{

    // load the texture with our image
    backgroundTexture = new Texture("fonfopiz.png");

    // set the linear texture filter to improve the image stretching
    backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    // Here we create a region of our texture whose size is 512x301
    backgroundTextureRegion = new TextureRegion(backgroundTexture, 0, 0, 512, 301);
    // TODO Auto-generated constructor stub

    crearTablaBack();

    //the general table
    table = super.getTable();
    //table.setFillParent(false);
    Label vacia = new Label("",getSkin());
    table.add(vacia).spaceBottom(45);
    table.row();
    Label lTit;
    try {

        lTit = new Label(res.getString(titulo), getSkin(), "titulos");
        table.add(lTit).spaceBottom(10).spaceLeft(50);
        //stage.addActor(lTit);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    table.row();

  Label lText = new Label(res.getString(titulo + "_TXT"),getSkin());
  lText.setWrap(true);
   table.add(lText).width(375).spaceBottom(55);
   //lText.setAlignment(100);
   //lText.setWidth(200);
   table.row();

   table.setPosition(110, 0);
   //table.setSize(200, 200);

}

public void render(
        float delta )
    {
        super.render( delta );
        batch = super.getBatch();
        // we use the SpriteBatch to draw 2D textures (it is defined in our base
        // class: AbstractScreen)
        batch.begin();

        // we tell the batch to draw the region starting at (0,0) of the
        // lower-left corner with the size of the screen
        batch.draw( backgroundTextureRegion, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() );

        // the end method does the drawing
        batch.end();
    }

private void crearTablaBack() {
    //the table for the back button
    Table tabla = new Table( getSkin() );
    tabla.debug();
    //table.debugTable();

    stage.addActor( tabla );

    tabla.setPosition(40, 35);

     TextButton botonBack = new TextButton( "<<", getSkin() );
     tabla.add( botonBack ).size(60, 40).spaceBottom(20);
      tabla.row();
        botonBack.addListener(new InputListener() {
            public boolean touchDown (InputEvent event, float x, float y, int   pointer, int button) {
               //super.touchUp(event, x, y, pointer, button);
                System.out.println("back");
                //game.setScreen(new ExperimentosScreen(game));
                //game.setScreen(new PruebaScreen(game));
                return true;
        }

});
}
</code>
Answer: Dont have much idea about scene2d in libgdx but from your code may be if the code of show() method is written in render() method, after drawing your background , then it might work. Wot I am getting is you are drawing the table and buttons and then drawing background above it so all the things are getting hidden by your background.
One more thing Show method will be called once(the first time you create method your your screen class) and render method will be called many times during life of your class.  And I havnt read your code in depth but have you called stage.draw() or stage.act() anywhere ???
Comment: Ok, after going around in my code I realized that the code I used before(adding the background as an actor) its okey, but I forgot to call to the show() of my superclass.

How to add background image to my menu?


Transfer data between databases with PostgreSQL

Question: I need to transfer some data from another database. The old database is called paw1.moviesDB and the new database is paw1. The schema of each table are the following.
Awards (name of the table)(new DB)
Id [PK] Serial           Award

Nominations (name of the table) (old DB)
Id [PK] Serial           nominations

How do I copy the data from old database to the new database?
Answer: I just had to do this exact thing so I figured I'd post the recipe here.  This assumes that both databases are on the same server.
First, copy the table from the old db to the new db.  At the commandline:
pg_dump -U postgres -t <old_table> <old_database> | psql -U postgres -d <new_database>

Next, grant permissions of the copied table to the user of the new database.  Log into psql:
psql -U postgres -d <new_database>

ALTER TABLE <old_table> OWNER TO <new_user>;

\q

At this point your copied table in your new database still has the name <old_table> from your old database. Assuming you want to move the data somewhere else, say to <new_table>, you can just use regular SQL queries:
INSERT INTO <new_table> (field1, field2, field3)
SELECT field1, field2, field3 from <old_table>;

Done!
Comment: how to do it for remote server ?
Comment: @DevR, just add -h
Comment: Note in the first command, if you need a password for both `pg_dump` and `psql`, they will both serve you the prompt at once. What worked for me is to enter the password, hit enter, then enter the password a second time, and hit enter again. The prompt itself looks messed up while you're doing this, but it works.
Answer: Databases are isolated in PostgreSQL; when you connect to a PostgreSQL server you connect to just one database, you can't copy data from one database to another using a SQL query.
If you come from MySQL: what MySQL calls (loosely) "databases" are "schemas" in PostgreSQL - sort of namespaces. A PostgreSQL  database can have many schemas, each one with its tables and views, and you can copy from one schema to another with the schema.table syntax.
If you really have two distinct PostgreSQL databases, the common way of transferring data from one to another would be to export your tables (with pg_dump -t ) to a file, and import them into the other database (with psql).
If you really need to get data from a distinct PostgreSQL database, another option - mentioned in Grant Johnson's answer - is dblink, which is an additional module (in contrib/).
Update:
Postgres introduced "foreign data wrapper" in 9.1 (which was released after the question was asked). Foreign data wrappers allow the creation of foreign tables through the Postgres FDW which makes it possible to access a remote table (on a different server and database) as if it was a local table.
Comment: Doing the move using dblink, see http://stackoverflow.com/questions/14797327/copy-data-between-two-tables-in-postgresql-using-dblink-sql
Comment: for future readers: canonical way of doing it now is to use `postgres_fdw` extension and foreign tables
Comment: Setting the search_path variable using "SET search_path TO blah" is a good way to work with different schemas without hurting your pinkies. You can make your changes permanent with "ALTER USER user SET search_path TO blah" - love it! ;-)
Answer: This worked for me to copy a table remotely from my localhost to Heroku's postgresql:
pg_dump -C -t source_table -h localhost source_db | psql -h destination_host -U destination_user -p destination_port destination_db
This creates the table for you.
For the other direction (from Heroku to local)
pg_dump -C -t source_table -h source_host -U source_user -p source_port source_db | psql -h localhost destination_db
Comment: In case you have different port and username in localhost the command is: pg_dump -C -t source_table -h localhost -p local_port -U local_user source_db | psql -h destination_host -U destination_user -p destination_port destination_db
Answer: From: hxxp://dbaspot.c om/postgresql/348627-pg_dump-t-give-where-condition.html (NOTE: the link is now broken)
# create temp table with the data
psql mydb
CREATE TABLE temp1 (LIKE mytable);
INSERT INTO temp1 SELECT * FROM mytable WHERE myconditions;
\q

# export the data to a sql file
pg_dump --data-only --column-inserts -t temp1 mtdb > out.sql
psql mydb
DROP TABLE temp1;
\q

# import temp1 rows in another database
cat out.sql | psql -d [other_db]
psql other_db
INSERT INTO mytable (SELECT * FROM temp1);
DROP TABLE temp1;

Another method useful in remotes
  # export a table csv and import in another database
  psql-remote> COPY elements TO '/tmp/elements.csv' DELIMITER ',' CSV HEADER;
  $ scp host.com:/tmp/elements.csv /tmp/elements.csv
  psql-local> COPY elements FROM '/tmp/elements.csv' DELIMITER ',' CSV;

Comment: Thanks. This is the simplest solution that doesn't involve any extensions. Note that `--column-inserts` significantly slows it down, so you can remove that if the target database's table is known not to have any conflicts.
Comment: In case this is unclear to anyone, the second half is this: Create the table on the other DB: `psql -d [other_db] -c "CREATE TABLE temp1 (LIKE mytable);"`, then insert into your other DB: `cat out.sql | psql -d [other_db]`, then insert into the main table: `psql -d [other_db] -c "INSERT INTO mytable (SELECT * FROM temp1);"`.
Comment: I want to point out how much easy is this approach, if you have simple data, without binary, blobs etc..
Answer: There are three options for copying it if this is a one off:

Use a db_link (I think it is still in contrib)
Have the application do the work.
Export/import

If this is an ongoing need, the answers are:

Change to schemas in the same DB
db_link
Answer:
If your source and target database resides in the same local machine, you can use:

Note:- Sourcedb already exists in your database.
CREATE DATABASE targetdb WITH TEMPLATE sourcedb;

This statement copies the sourcedb to the targetdb.

If your source and target databases resides on different servers, you can use following steps:

Step 1:-  Dump the source database to a file.
pg_dump -U postgres -O sourcedb sourcedb.sql

Note:- Here postgres is the username so change the name accordingly.
Step 2:- Copy the dump file to the remote server.
Step 3:- Create a new database in the remote server
CREATE DATABASE targetdb;

Step 4:- Restore the dump file on the remote server
psql -U postgres -d targetdb -f sourcedb.sql

(pg_dump is a standalone application (i.e., something you run in a shell/command-line) and not an Postgres/SQL command.)
This should do it.
Answer: Actually, there is some possibility to send a table data from one PostgreSQL database to another. I use the procedural language plperlu (unsafe Perl procedural language) for it.
Description (all was done on a Linux server):

Create plperlu language in your database A
Then PostgreSQL can join some Perl modules through series of the following commands at the end of postgresql.conf for the database A:
plperl.on_init='use DBI;'
plperl.on_init='use DBD::Pg;'

You build a function in A like this:
CREATE OR REPLACE FUNCTION send_data( VARCHAR )
RETURNS character varying AS
$BODY$
my $command = $_[0] || die 'No SQL command!';
my $connection_string =
"dbi:Pg:dbname=your_dbase;host=192.168.1.2;port=5432;";
$dbh = DBI->connect($connection_string,'user','pass',
{AutoCommit=>0,RaiseError=>1,PrintError=>1,pg_enable_utf8=>1,}
);
my $sql = $dbh-> prepare( $command );
eval { $sql-> execute() };
my $error = $dbh-> state;
$sql-> finish;
if ( $error ) { $dbh-> rollback() } else {  $dbh-> commit() }
$dbh-> disconnect();
$BODY$
LANGUAGE plperlu VOLATILE;

And then you can call the function inside database A:
SELECT send_data( 'INSERT INTO jm (jm) VALUES (''zzzzzz'')' );

And the value "zzzzzz" will be added into table "jm" in database B.
Answer: Using dbeaver, transferring data is a piece of cake.
Steps to do

Select all the tables u want the data to be transferred.
Disclaimer: if we click on table folder inside which all the tables
r present it won't work.

Right click and select import.

Choose
Table in "import source":

In "select input object"
choose db source from where u want to get the data coorosponding to
each table name.

Click on next and proceed.

I accept for Greetings.
Answer: You can not perform a cross-database query like SQL Server; PostgreSQL does not support this.
The DbLink extension of PostgreSQL is used to connect one database to another database. You have install and configure DbLink to execute a cross-database query.
I have already created a step-by-step script and example for executing cross database query in PostgreSQL. Please visit this
post: PostgreSQL [Video]: Cross Database Queries using the DbLink Extension
Comment: Actually Postgres does support this now, via foreign data wrappers.
Answer: I think that use of the pg_dump utility can be restricted by a PostgreSQL Server admin.
So I used \copy to meta commands to export to CSV and import into destination database.
Answer: Just like leonbloy suggested, using two schemas in a database is the way to go.  Suppose a source schema (old DB) and a target schema (new DB), you can try something like this (you should consider column names, types, etc.):
INSERT INTO target.Awards SELECT * FROM source.Nominations;

Comment: If you have a decently recent version of Postgres (>=8.1) you can do `ALTER TABLE Nominations SET SCHEMA target`
Comment: Schemas are nothing but namespaces, and they don't really provide isolation. A different database could be running on a different computer, or maybe on the same but with different performance/memory settings, and you might have two databases that have the same schemas (which we do have). A different database could even be a different version of Postgres, assuming they're compatible.


nlme package: augPred change the x axis with log='x'

Question: Hi I am trying to change the scale on the x-axis to a log scale on a plot generated by
model2 <- nlme(consumption~Q*10^(5*(exp(-alpha*Q*price)-1)), fixed=Q+alpha~1,`random=Q+alpha~1|ratid, groups = ~ treatment,`data = oxydata, start = c(Q=3, alpha=0.001))

plot(augPred(model2), log='x', xlim = c(1,3000), xlab = "Price (resp/mg", ylab = "Consumption")

However, the log='x' or log="x" does nothing to change the x-axis scale. I can change the xlim and ylim, add titles etc. but I can't seem to change the x-axis to a log scale. Any help or verification that it can or can't be done is greatly appreciated.
Ugly plot with data all crammed
Answer: Thanks to anyone that was trying to figure this out, but I got it. This function uses the xyplot(), which requires the scale = list...
`plot(augPred(model2), scale = list(x = list(log = 10)), xlim = c(1,3000), xlab = "Price (resp/mg", ylab = "Consumption")


Select a row in dgv

Question: I made an usercontrol with a datagridview!
I know how to select a row, add delete, these stuffs. I need to use the event selectionchanged, but talking without using usercontrol.
The problem here, I cannot select the datagridview and the choose the event selectionchanged because I am using an usercontrol. Does anyone know how can I select a row in dgv which is in an usercontrol?
Thanks in advance!
This is what I have in the user control
Private Sub grid1_SelectionChanged(sender As Object, e As EventArgs) Handles grid1.SelectionChanged
        Dim index As Integer
        Dim selectedrow As DataGridViewRow
        If Not grid1.CurrentRow Is Nothing Then
            Index = grid1.CurrentRow.Index
            selectedrow = grid1.Rows(Index)

        End If
    End Sub

And in the project I am trying to get some values from the row and cell.
Me.UcList1.tbName = "tblPeople"
        lblIDPeople.Text = Me.UcList1.grid1.selectedrow.Cells(0).Value.ToString

UPDATE
Me.UcList1.tbName = "tblPeople"
        If Not Me.UcList1.grid1.CurrentRow Is Nothing Then
            lblIDPeople.Text = Me.UcList1.selectedrow.Cells(0).Value.ToSring
        End If

Comment: From the designer of the user control, you can handle the `SelectionChanged` event.
Comment: @preciousbetine Ooh...thanks! But I gotta a question, What if in this dgv I want to get the cell 0 for example...and then I use the same user control but populate with another table, and get the another cell 5 for example. The code is the one that I edit it..Thanks
Comment: What do you get with the code above?
Comment: @preciousbetine it says that selectedrow is not a member of datagridview
Comment: Declare `selectedrow` as `Public selectedrow As DataGridViewRow` outside the `SelectionChanged Event`
Comment: @preciousbetine   Still did not work.. I mean...the problem is in the project, I think I am calling wrong stuffs there `Me.UcList1.grid1.selectedrow.Cells(0).Value.ToString`
Comment: @preciousbetine Ooh..I think I am putting this on the load event...
Comment: Move it out of the load event, what do you get?
Comment: @preciousbetine I updated my code...I tried to do that...but gets nothing
Answer: Try this. I tested it and its working

In the usercontrol, make the code look like this
Public Class MyControl
    Public selectedrow As DataGridViewRow

    Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
        selectedrow = DataGridView1.CurrentRow
    End Sub
End Class

In the main form, call it like this
Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If (Not MyControl1.selectedrow Is Nothing) Then
           MsgBox(MyControl1.selectedrow.Cells(1).Value)
           'lblIDPeople.Text = Me.MyControl1.Datagridview1.selectedrow.Cells(0).Value.ToString
        End If
    End Sub
End Class

Comment: I mean! it worked, but what if I want to change the value of the row and cell by only clicking at the row in the datagridview, not with a button. Anyway! Thanks a lot for your effort and time helping me.
Comment: Can you explain a bit more? I don't get what you mean by *change the value by clicking at the row in the datagridview*.
Comment: sorry that I am a little confusing to explaing. So I have a datagridview right? When I click in the row, I want that it returns me the ID of the row, which automatically does it as soon as select the row, using the event selectionchanged. But with the user control, I am having trouble on doing this. It loads with the selecting the first row, so it returns to me the right ID, but when I select another row, nothings happens. And I want to use this User control on at least 2 different tables, so thats why I have to put on the main form which cell look for the ID.

Select a row in dgv


Defining a probability distribution

Question: I am taking a probability theory course, and I need help understanding a homework question.

Let $(\Omega , \mathcal{F}, \mu)$ be a measure space, and $f:\Omega\rightarrow[0,\infty)$ be such that $\int{f\:\text{d}\mu} = 1$. Show that $v(E) := \int\mathbb{I}_E(\omega)f(\omega)\mu(\text{d}\omega),  \: E \in \mathcal{F}$ defines a probability distribution on $(\Omega,\mathcal{F})$.

I went to speak to my professor, and he pointed me towards the definitions of a probability measure and probability space in my textbook. We also covered Lebesgue integration, but I do not know if this applies here. Also, there was some talk about converting these integrals to sums, but I'm quite lost. If anyone can point me in the right direction with explanations, or provide readings or references, I would be grateful.
Answer: You should check that $v$ satisfies the definition of a probability measure/distribution. That is, you should check that
1) $v$ is a mapping from $\mathcal{F}$ to $[0,1]$.
2) $v(\emptyset)=0$
3) For any sequence of disjoint sets $(A_n)_{n\in\mathbb{N}} \subseteq \mathcal{F}$ the following should hold:
$$
v\left(\bigcup_{n\in\mathbb{N}} A_n\right)=\sum_{n\in\mathbb{N}} v(A_n)
$$
4) $v(\Omega)=1$
Let me know if any of these causes problems.
Comment: I think I understand now. 2) follows because the indicator function over the null set is just 0. 4) follows by definition of the function f in the question. 3) follows because the indicator function over union of disjoint sets is just the sum of the indicator functions over the disjoint sets, summation term can come out of the integral. 1) follows because the function is monotone increasing, and 2) and 4) define the smallest and highest values the function can take.
Comment: Thank you, this will give me a place to start. It is similar to how a probability space was defined in my text. I will get back to you!
Comment: @iakl: Exactly!
Answer: Probability theory is basically a part of measure and integral theory. Integrals in measure theory are mostly defined using some approximation by step functions (i.e. which take countable many values only, each one over a measurable set, so these integrals are easily computed), and in this generality is called Lebesgue integral.
If $\Omega$ (or the given $\sigma$-algebra of the measurable sets)  is finite/countable, then this integral always goes to a concrete sum.

Defining a probability distribution


Linux-Specific Headers in Visual Studio 2017 Cross-Platform

Question: I have a Linux-specific source file that includes a few Linux-specific headers, such as dirent.h. I added this source file to my cross-platform (Linux) project in VS2017, but IntelliSense is throwing flags at me that it cannot find these headers.
Is there a specific directory I should be adding to my include list to find them?
If not, how do I handle platform specific headers in a cross-platform project?
Edit for clarification: I'm specifically trying to assume that it is a Linux header, but I am editing on a Windows machine using the cross-platform VS feature.
Comment: Possible duplicate of [How to have different Headers in different platforms?](https://stackoverflow.com/q/20978363/608639) and [How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?](https://stackoverflow.com/q/5919996/608639)
Comment: I believe those questions are for writing generically platform-independent code, which I'm not doing here. I'm specifically trying to assume that it is a Linux header, but I am editing on a Windows machine using the cross-platform VS feature.
Answer: I found the answer in the MS blogs. The short answer is that the includes are never present, and need to be copied over from the Linux machine into a local folder to add.
https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/#includes


What is the difference between (Supported Architectures) in Xamarin.Android

Question: There are four options
1- armeabi-v7a
2- arm64-v8a
3- x86
4- x86_64
Do I need to select them all if I want my application to support devices running from Android Q to Android Ice Cream Sandwich.
I want an explanation about them
Comment: https://developer.android.com/distribute/best-practices/develop/64-bit
Answer: armeabiv-v7a: 7th generation and above ARM processors. Most Android devices manufactured after 15th of 2011 use it.(support armeabi and armeabi-v7a)
arm64-v8a: 8th generation, 64-bit ARM processor, Most of new android devices use it(Contains two execution states of AArch32 and AArch64 corresponding to 32, 64bit ,support armeabi-v7a,armeabi and arm64-v8a)
x86: Intel 32 bit, generally used for tablets (support armeabi (performance loss) and x86)
x86_64: Intel 64 bit, generally used for tablets (support x86 and x86_64)

Do I need to select them all if I want my application to support devices running from Android Q to Android Ice Cream Sandwich.

Based on your description Please select all of them.
Here is a helpful article about it.
https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/cpu-architectures?tabs=windows
Comment: `armeabi-v7a` and/or `x86` is NOT enough, you must also support 64-bit (Since August 1, 2019 ) when using **native libraries** (i.e. Mono). : https://developer.android.com/distribute/best-practices/develop/64-bit
Comment: @SushiHangover Thanks for your remind, I update my answer.
Comment: If the reply is helpful, please accept it as answer(click the "✔" in the upper left corner of this answer), it will help others who have similar issue.
Comment: Thank you very much Leon and SushiHangover, So if I don't want my app to support tablets Devices, what should I not choose?, I want to reduce the application size as much as possible, and I know that selecting them all will increase the application size


Why does this box make a noise when I click on it?

Question: In the Cooperative Hub area near each of the chamber selection screens there is a small box that talks whenever you click on it. Aside from sounding like a turret, does the box have a purpose? These are the ones that light up purple as they are activated.
Comment: Do you have a screenshot? It will help identifying the box without actually launching the game.
Answer: Is this the box you are talking about?
It has no practical use. It's there just for fun.


Selecting groups of items: How many ways can we divide n students into groups of two?

Question: I have a question very similar to the post in the link below.
But, what do we do when we are given a variable for the total number of students, not a constant number?
Here is the modified version of the question.
"There are n students in a class. In how many ways can the teacher select groups of two to work on an exercise."
Problem : Permutation and Combination : In how many ways can we divide 12 students in groups of fours.
Comment: Related: http://math.stackexchange.com/questions/868099/combining-students-into-groups
Comment: Well, if $n$ is odd, we cannot do it. If $n$ is even, let $n=2m$. after studying a few concrete cases, you will probably be able to use the same method to find a general formula.
Answer: There are many approaches to an answer. Note that the job cannot be done if $n$ is odd. So let $n$ be even, say $n=2m$.
For concreteness, let $n=10$.
Line up the students in increasing order of student number. The first person in the list can choose her study partner in $9$ ways. For every such choice, the so far unpartnered student with smallest student number can choose her study partner in $7$ ways.
For every such choice, the so far unpartnered student with smallest student number can choose her study partner in $5$ ways. For every such choice, the so far unpartnered student with smallest student number can choose her study partner in $3$ ways. That gives a total of $(9)(7)(5)(3)$ ways.
The answer looks a little nicer if we write instead $(9)(7)(5)(3)(1)$.
Maybe to make things look even nicer, we can multiply top, and missing bottom, by $(10)(8)(6)(4)(2)$. We get
$$\frac{10!}{(10)(8)(6)(4)(2)},\quad\text{which is} \frac{10!}{2^5 \cdot 5!}.$$
Now that we have gone through the reasoning got $n=10$, the general case is straightforward. Suppose there are $2m$ students.
The student with lowest student number can choose her partner in $2m-1$ ways. For every such way, the so far unpartnered student with lowest student number can choose her partner in $2m-3$ ways. And then the so far unpartnered student with lowest student number can choose her partner in $2m-5$ ways, and so on, for a total of
$$(2m-1)(2m-3)(2m-5)\cdots(3)(1).$$
The same manipulation as before gives the more compact expression $$\frac{(2m)!}{2^m \cdot m!}.$$
Comment: Andre' Nicolas, off-topic but why haven't you posted any questions?
Comment: There are many questions I have worked on with no success or very incomplete success. Have not yet given up on any of them!
Comment: Oh cool! Be sure to post your questions on mse if you ever (although you will succeed in solving whatever question your working on) need help! You probably have some really awesome questions to share. Cheers!
Answer: n must be even as if it is odd the problem does not work.
We choose 2 people from the n original ones for the one pair.
from the n-2 people left, we choose another 2.
etc.
So it appears to be:
$\binom{n}{2}\binom{n-2}{2} \cdot \cdot \cdot\binom{2}{2}$ ways.
However, consider this: if we have {A,B} as the first pair, and {C,D} as the second pair, is this not identical to having {C,D} as the first pair, and {A,B} as the second pair instead, assuming ceteris paribus?
So we have in fact overcounted, by a factor of $(\frac{n}{2})!$, the number of ways in which we can arrange these groups among themselves.
So the answer is $\frac{\binom{n}{2}\binom{n-2}{2} \cdot \cdot \cdot \binom{2}{2}}{(\frac{n}{2})!}$
Comment: Hey sherlock, thank you for your response. I have a question that was too long to place in a comment if you can take a look at my latest "answer" below. Thank you very much again.
Answer: Ok thank you very much for this explanation. However, in the denominator, the factorial would be the number of groups we have which is actually (n divided by k)! not just n! because n is the total number of students in the class… right?
Let's say the question asks how to split the class into groups of k.
Would this formula be correct?
Total number of students in the class = n
Size of groups we are choosing = k
*Note: n must be divisible by k
$\frac{\binom{n}{k}\binom{n-k}{k}\binom{n-2k}{k}\binom{n-3k}{k}\cdot\cdot\cdot\binom{k}{k}}{(n/k)!}$
Example:
Number of students in the class n = 12
Size of groups we are choosing k = 3
$\frac{\binom{12}{3}\binom{9}{3} \binom{6}{3} \binom{3}{3}}{4!}$
Is my formula correct? Particularly would the denominator be correct (n / k)!
Thank you for your help!
Comment: The formula you give is correct. If you expand, you get the simpler expression $\dfrac{12!}{(3!)^4\cdot 4!}$.


Driver Issue with Intel® Wi-Fi 6E AX210 on Ubuntu 22.04.1 LTS -- reporting RF_KILL (radio disabled)

Question: I run into a well-known problem that was actually already widely discussed on the web. However, I unfortunately could not solve the problem yet.
I recently replaced the Wifi network adapter into a new one, Intel(R) Wi-Fi 6 AX210 160MHz, in a Dell Rugged 5414 laptop, several years old.
I'm still fairly new to Linux/Ubuntu and appreciate any assistance.
root@laptop-02# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy

The network adapter was correctly recognized by the system:
root@laptop-02# lspci -knn | grep Net -A3
01:00.0 Network controller [0280]: Intel Corporation Wi-Fi 6 AX210/AX211/AX411 160MHz [8086:2725] (rev 1a)
Subsystem: Intel Corporation Wi-Fi 6 AX210 160MHz [8086:0024]
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi

However, the system shows the WLAN function as switched off. Wireless networks are not displayed. The function is greyed out in Ubuntu.
root@laptop-02# sudo iwconfig
lo        no wireless extensions.
enp0s31f6  no wireless extensions.
enx10050197f9a6  no wireless extensions.
wwan0     no wireless extensions.
wlp1s0    no wireless extensions.

The first errors are displayed here:

reporting RF_KILL (radio disabled)
Direct firmware load for iwlwifi-ty-a0-gf-a0-73.ucode failed with error -2

root@laptop-02:/usr/lib/firmware# dmesg | grep wifi
[    4.914540] Loading modules backported from iwlwifi
[    4.914541] iwlwifi-stack-public:master:9858:4c7cba27
[    4.997046] iwlwifi 0000:01:00.0: enabling device (0000 -> 0002)
[    5.003663] iwlwifi 0000:01:00.0: Direct firmware load for iwlwifi-ty-a0-gf-a0-73.ucode failed with error -2
[    5.003684] iwlwifi 0000:01:00.0: Direct firmware load for iwlwifi-ty-a0-gf-a0-72.ucode failed with error -2
[    5.009461] iwlwifi 0000:01:00.0: api flags index 2 larger than supported by driver
[    5.009490] iwlwifi 0000:01:00.0: TLV_FW_FSEQ_VERSION: FSEQ Version: 0.0.2.36
[    5.010086] iwlwifi 0000:01:00.0: loaded firmware version 71.058653f6.0 ty-a0-gf-a0-71.ucode op_mode iwlmvm
[    5.109985] iwlwifi 0000:01:00.0: Detected Intel(R) Wi-Fi 6 AX210 160MHz, REV=0x420
[    5.116435] iwlwifi 0000:01:00.0: reporting RF_KILL (radio disabled)
[    5.288652] iwlwifi 0000:01:00.0: loaded PNVM version 05a8dfca
[    5.304238] iwlwifi 0000:01:00.0: Detected RF GF, rfid=0x10d000
[    5.377673] iwlwifi 0000:01:00.0: base HW address: 8c:f8:c5:3b:dc:c4
[    6.498280] iwlwifi 0000:01:00.0 wlp1s0: renamed from wlan0
[ 3575.564341] Loading modules backported from iwlwifi
[ 3575.564343] iwlwifi-stack-public:master:9858:4c7cba27
[ 3575.610167] iwlwifi 0000:01:00.0: Direct firmware load for iwlwifi-ty-a0-gf-a0-73.ucode failed with error -2
[ 3575.610195] iwlwifi 0000:01:00.0: Direct firmware load for iwlwifi-ty-a0-gf-a0-72.ucode failed with error -2
[ 3575.610697] iwlwifi 0000:01:00.0: api flags index 2 larger than supported by driver
[ 3575.610719] iwlwifi 0000:01:00.0: TLV_FW_FSEQ_VERSION: FSEQ Version: 0.0.2.36
[ 3575.611123] iwlwifi 0000:01:00.0: loaded firmware version 71.058653f6.0 ty-a0-gf-a0-71.ucode op_mode iwlmvm
[ 3575.656549] iwlwifi 0000:01:00.0: Detected Intel(R) Wi-Fi 6 AX210 160MHz, REV=0x420
[ 3575.663397] iwlwifi 0000:01:00.0: reporting RF_KILL (radio disabled)
[ 3575.811807] iwlwifi 0000:01:00.0: loaded PNVM version 05a8dfca
[ 3575.823466] iwlwifi 0000:01:00.0: Detected RF GF, rfid=0x10d000
[ 3575.894946] iwlwifi 0000:01:00.0: base HW address: 8c:f8:c5:3b:dc:c4
[ 3575.949398] iwlwifi 0000:01:00.0 wlp1s0: renamed from wlan0

The driver seems to be ready, but it still need to get the firmware for the chip, that doesn't work:
root@laptop-02# sudo dkms install backport-iwlwifi/8400

Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
'make' -j4 KLIB=/lib/modules/5.15.0-46-generic...(bad exit status: 2)
ERROR (dkms apport): binary package for backport-iwlwifi: 8400 not found
Error! Bad return status for module build on kernel: 5.15.0-46-generic (x86_64)
Consult /var/lib/dkms/backport-iwlwifi/8400/build/make.log for more information.

I downloaded drivers from here:
https://www.intel.de/content/www/de/de/support/articles/000005511/wireless.html
I mainly followed this post in the procedure (answer 3):
Ubuntu 20.04 LTS driver Intel Wi-Fi 6E AX210 160MHz
Many thanks to everybody for any support. Please keep in mind, I'm still a beginner with Linux ;)
Comment: The manual says: "To enable wireless Networking, press Fn + PrtScr." Does that change the result of: `rfkill list all`? Welcome to Ask Ubuntu.
Answer: I just wanted to let you know that the problem resolved itself. Seems like Ubuntu has updated itself here. Because I just shut down the laptop overnight. When I started it again the next day, WLAN (including WPA3 encryption) worked without any problems.
So unfortunately I can't post a solution.


How to wait until webViewDidFinishLoad is called?

Question: I'm creating an iOS app.
I separated a PDF which has multi page into each pages,
And then create UIWebViews to show each pages.
The code is like this.
<code>for( int i = 0; i < _pageNumbers; i++)
{
    _webView = [[UIWebView alloc]init];
    _webView.delegate = self;
    _webView.frame = imageViewFrame;
    _webView.scalesPageToFit = YES;
    _webView.autoresizingMask =
    UIViewAutoresizingFlexibleLeftMargin  |
    UIViewAutoresizingFlexibleWidth       |
    UIViewAutoresizingFlexibleRightMargin |
    UIViewAutoresizingFlexibleTopMargin   |
    UIViewAutoresizingFlexibleHeight      |
    UIViewAutoresizingFlexibleBottomMargin;
    [self setImageAtIndex:i toScrollView:imageScrollView];
}

- (void)setImageAtIndex:(NSInteger)index toScrollView:(ImageScrollView*)ScrollView
{
    UIWebView   *theWebView = (ScrollView.subviews)[0];
    if (index < 0 || [webViews count] <= index) {
        theWebView = nil;
        return;
    }

    dispatch_queue_t queueLoadPDF = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_sync(queueLoadPDF, ^{
        NSString    *document = [[[[NSString alloc]initWithString:_documwntPath]stringByAppendingString:@"/"]stringByAppendingFormat:@"Page%zd.pdf",(index + 1) ];

        NSURL   *url = [NSURL fileURLWithPath:document];
        NSString *urlString = [url absoluteString];
        NSString *encodedString=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSURL *webURL = [NSURL URLWithString:encodedString];
        NSURLRequest    *req = [NSURLRequest requestWithURL:webURL];
        [theWebView loadRequest:req];
    });
}
</code>
The PDF pages are big. After calling loadRequest, program go back to the loop and creates new UIWebview.
I want to wait until webViewDidFinishLoad is called before returning to the loop.
Is there any solutions?
Thank you for your helps.
Comment: why don't you call - (void)setImageAtIndex:(NSInteger)index toScrollView:(ImageScrollView*)ScrollView in webViewDidFinishLoad?
Comment: @Masaru Kitajima i think you should integrate webview delegate and call `[self setImageAtIndex:i toScrollView:imageScrollView];` this method from `webViewDidFinishLoad:` method.take `i` as global and increase it at every `webViewDidFinishLoad`.i think this will work.do not use for loop.
Comment: I'm not quite sure what you kindly mentioned.

(void)setImageAtIndex:(NSInteger)index toScrollView:(ImageScrollView*)ScrollView is to load PDF into UIWebView and I want to wait until PDF is loaded.
Comment: Chinttu, thanks for your comment.

As kindly @HMHERO mentioned, you both says put [self setImageAtIndex:i toScrollView:imageScrollView]; in webViewDidFinishLoad.

I've thought that webViewDidFinshLoad is called that UIWebView successfully load the data. Is this incorrect? And you said not to use for loop. But I have several PDFs to load, so how can I do that without for loop? Using while loop is OK?
Answer: @MasaruKitajima it's kinda hard to see what you are trying to do. My initial thoughts were as same as @Chinttu -Maddy- Ramani's but when I looked at you code again, I see more problem with my rough assumptions. I will throw couple of questions and you should think about your design again as you answer.
Somehow your code doesn't make sense to me. I see [webViews count] in your code. Do you have multiple webviews in a scroll view? But I see _webView which I think it's a member variable and you are initiating it in for-loop? what does that do?? You should be able to answer this first. You are probably loading only one webview not because you didn't know how to load the next webview in webViewDidFinishLoad but because you only have one webview??
Second, I think you want to load one webview at a time and that design doesn't make sense to me either. You should load the next webview when your ImageScrollView is scrolled down to the next webview. The idea is pretty much same as how you load the next data in table view when the last cell is displayed.
Comment: thank you for your comment. I create several UIWebviews in the for-loop and "webViews" is a NSMutableArray and each time I create a UIWebview, I do [webViews addObject:_webView]; to store each UIWebView. For the question 2, I want to load one UIWebView at a time and once loading is completed, I guess webViewDidFinishLoad. Then I want to proceed to the next UIWebView.
Comment: You are reinitiating _webView in every for-loop cycle. Where you run [webViews addObject:_webView];?
Comment: I thought I create a new _webView instance in every for-ioop. I run [webViews addObject:_webView]; right after  [self setImageAtIndex:i toScrollView:imageScrollView];.


Idiomatic C# deserialization of custom binary files?

Question: Greetings,
What is the most idiomatic way of performing serialization/deserialization of binary custom formats? For example, how would you read a file with a set of headers specified in bytes (e.g. 4, 4, 16, 4, 8, 8, 4, 16) with no padding, with mixed integer/byte[] types?
In other words, how do you achieve the same level of control as in C when specifying a structure, without having to resort to sequences of Read/WriteBytes over a Stream?
Thanks.
Comment: @Cody that is useless if you don't control the format
Comment: Why would you need to? What's wrong with the built-in [binary serialization functionality](http://msdn.microsoft.com/en-us/library/72hyey7b.aspx)?
Comment: @Marc: Yes, that's true. It wasn't clear to me from the question if that was the case. If it's an option, it's by far the most elegant one. Lots of programmers new to the .NET Framework aren't aware of this type of functionality being built-in.
Comment: Yes... I can't control the format...
Answer: Here's an article which illustrates one method to achieve this. But if you want ideomatic .NET then BinaryReader is the way to go. If the format is not imposed and you have control over it you could also use BinaryFormatter but what it produces is not interoperable.
Comment: Personally, I don't tend to use BinaryReader at all in this scenario; just raw Stream. By te time you have to cope with a prw-defined format that isn't the one BinaryReader wants to use for int, string, etc - it becomes pretty useless.
Comment: @Marc, so you are suggesting to read raw bytes directly from the stream and convert them to the underlying .NET data type?
Comment: Well, on a per-field level (as covered in my answer), sure. Bit with a buffer in the middle to reduce raw reads.
Comment: The referenced article returns 404 and is not available in wayback machine. Does anyone have an archived copy?
Answer: Assuming that is a custom format, I would (and have) look to the XmlReader API; I would write a SomeFormatReader that rides a stream, and has a method for reading the next header. Once the caller has seen this return true (false meaning EOF), the caller should be able to access a property to check the data format that follows, and be able to call any of ReadInt32, ReadString, ReadSingle etc to handle each (following the rules of the binary format). In my case, my reader class also handles additional data buffering, etc.
You may then choose to wrap that with a secondary layer that uses type metadata and the newly-written reader to populate your object model (any of reflection, code-generation, meta-programming, etc). But creating a good standalone reader is he first hurdle.
Comment: That is probably the most straightforward way to implement it. But... it probably *isn't* ideomatic (even with instrospection and custom-attributes magic).
Comment: @Hugo - call the wrapper layer `SomeFormatSerializer`, new one up and call deserialize - feels like every .NET serializer I know...


Urn Problem: randomly pick a ball and replace the ball with different colour

Question: An urn contains 5 black or white balls. At time 0, all the balls are white. At each step, we pick a ball uniformly in the urn, remove it and replace it with a ball of the opposite colour. Let $B_n$ be the number of black balls at time $n$.

Compute the long-run fraction of time where $B_n$=3
What is the expected value of the first time where the urn contains 5 white balls again?
Is it true that $\lim_{n \rightarrow \infty} P(B_n=3)$ exists?

For 1, I want to use time reversibility. But I'm not sure how to proceed from here.
For 2, I think I've got it using one-step analysis.
For 3, I'm not sure how do proceed, since I'm not even sure about 1.
Please help, thank you!
Answer: This is a random walk on the $5$-dimensional hypercube, with edges between adjacent vertices. A random walk on a connected graph spends equal proportion of time on each edge, and thus the proportion of time spent on a vertex is proportional to its degree. Here all $2^5=32$ vertices have the same degree, so the proportion of time on each vertex is $\frac1{32}$. Since $\binom53=10$ vertices correspond to $B_n=3$, the proportion of time where $B_n=3$ is $\frac{10}{32}=\frac5{16}$.
For $2$, you don't need any further analysis. Since the proportion of time where all $5$ balls are white is $\frac1{32}$, the expected return time from $5$ white balls back to $5$ white balls is $32$.
For $3$, the limit doesn't exist because $B_n=3$ can obtain only for odd $n$; in fact we have $\lim_{n\to\infty}P(B_{2n+1}=3)=\frac5{8}$ and $P(B_{2n}=3)=0$ (no limit required on the second one).
Comment: Very interesting!  How are the vertices of the hypercube defined?
Comment: Thank you! Just wondering, is there a way of using time reversibility to solve 1?
Comment: @mjw: They are $[0,1]^5$, e.g. with each entry $0$ for a white ball and $1$ for a black ball. (We can imagine the balls to have continuous identities that they pass on when they get replaced by an opposite-colour ball, so we can associate each ball with one component.)
Comment: @joriki, Nice!  Thank you very much!
Comment: @circleli: I don't know of one.
Comment: The proof of the claim " A random walk on a connected graph spends equal proportion of time on each edge, and thus the proportion of time spent on a vertex is proportional to its degree" typically is done via showing that this satisfies the detailed balance equations, i.e. making use of time reversibility.
Comment: @user8675309 Thank you!!
Comment: @ joriki, how did you get $\lim_{n \rightarrow \infty}P(B_{2n+1=3} = 3)=\frac {5}{8}$? Thank you!
Comment: Btw I think a more standard solution is to recognize this is a birth-death chain... said chains have well known closed form steady states but you can also easily solve them from scratch via detailed balance equations e.g. what I did here:  https://math.stackexchange.com/questions/3496801/finding-the-stationary-distribution-for-this-discrete-time-markov-chain-dtmc/3496830#3496830
Comment: @circleli: See e.g. [this Wikipedia section](https://en.wikipedia.org/wiki/Markov_chain#Steady-state_analysis_and_limiting_distributions). This Markov chain has period $2$. Thus it has a separate limiting distribution for $B_{2n}$ and for $B_{2n+1}$. We have $P(B_{2n}=3)=0$ and thus $\lim_{n\to\infty}P(B_{2n}=3)=0$. In the stationary distribution, $\pi_3=\frac5{16}$ (from part $1$). The stationary distribution is the average of the two limiting distributions for $B_{2n}$ and $B_{2n+1}$. So $\frac12\left(0+\lim_{n\to\infty}P(B_{2n}=3)\right)=\frac5{16}$, and thus $P(B_{2n}=3)=\frac58$.