How to force combobox in listview to update when listview collection changes in WinUI 3?

Question: I believe this is a quirk of how the ListView works. I have included a problem description what I think is going on, and my question: how do I get around it?
Problem Description
I have a ListView, with a ComboBox specified inside of the ItemTemplate. The ComboBox shows an editable property on the items displayed in the ListView.
Per the "tip" in the official documentation (under the heading "Item Selection"), I am handling the Loaded event to initialize the SelectedItem property in the ComboBox. (I am doing this because the data is being pulled from an asynchronous source and may not be available right away - I could not get data-binding in XAML alone to work).
When the page first loads, this works flawlessly. When I try to add items to the collection afterwards, however - I get some unexpected behavior... despite using the same function (SetItems() in the sample below) to do the updates both times. Using the print statement in the sample below, I have confirmed that when the page first loads, the output is as expected: each item in the list has an output line, and the SelectedValue in each ComboBox (which displays the Status property on each item in the example below) is correct.
When I update the list later (after the page and ListView initially load), however, by calling that same SetItem() function (perhaps after adding an item to the list), the output from that same print statement is NOT as expected. Only a single print statement appears, and prints a seemingly random item from the list, along with the incorrect Status. This is unexpected because I am clearing the ObservableCollection, and re-adding ALL items to it (including the new items).
In the page XAML:
<ListView ItemsSource="{x:Bind MyCollection}">
    <ListView.ItemTemplate>
        <DataTemplate x:DataType="models:MyDataType">

            <ComboBox x:Name="MyComboBox"
                      Tag="{x:Bind ID}"
                      SelectedValuePath="Status"
                      Loaded="MyComboBox_Loaded"></ComboBox>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

The code behind with collection, event handler, and collection-altering code:
// The collection.
public ObservableCollection<MyDataType> MyCollection { get; set; }

// The ComboBox Loaded event handler.
private void MyComboBox_Loaded(object sender, RoutedEventArgs e)
{
    // Get the ID of the item this CombBox is for.
    ComboBox comboBox = sender as ComboBox;
    string id = comboBox.Tag as string;

    // Get a reference to the item in the collection.
    MyDataType item = this.MyCollection.Where(i => i.ID == id).FirstOrDefault();

    // Initialize the ComboBox based on the item's property.
    comboBox.SelectedValue = item.Status;

    // Wire up the Selection Changed event (doing this after initialization prevents the handler from running on initialization).
    comboBox.SelectionChanged += this.MyComboBox_SelectionChanged;

    // Print statement for debugging.
    System.Diagnostics.Debug.WriteLine("ComboBox for item " + item.ID + " loaded and set to " + item.Status);
}

// The function used to update the observable collection (and thus bound listview).
public void SetItems(List<MyDataType> items)
{
    // Clear the collection and add the given items.
    this.MyCollection.Clear();
    items.ForEach(i => this.MyCollection.Add(i));
}

What I think is going on
I believe this is a quirk of how the ListView works. I remember reading somewhere from past experience with item repeaters in a different part of .NET that the UI for each item may not actually be created new each time; UI items may be recycled and reused for efficiency reasons. I am going to guess what is happening here is similar; and the "reused" items are not firing the Loaded event, because they were never re-loaded.
So how do I get around it, and force the ComboBoxes to update each time the collection is changed, like how it does when the page first loads?
UPDATE
The unexpected output from the print statement does not appear to be random - it appears to be consistently the last item in the ListView. So whenever the SetItem() function is called (after the initial time when the page loads), ONLY the ComboBox for the last item in the ListView fires its Loaded event. The ComboBox on the other items are scrambled, however... almost like they were all shifted up by one (and so have the Status of the next item in the ListView rather than the item they are on).
Answer: You don't need to use Loaded for this.
Let me show you a simple example:
MainPage.xaml
<Page
    x:Class="ListViewWithComboBoxExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:ListViewWithComboBoxExample"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:models="using:ListViewWithComboBoxExample.Models"
    x:Name="RootPage"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    mc:Ignorable="d">

    <Grid RowDefinitions="Auto,*">
        <Button
            Grid.Row="0"
            Click="AddRandomItemsButton_Click"
            Content="Add random item" />
        <ListView
            Grid.Row="1"
            ItemsSource="{x:Bind MyCollection, Mode=OneWay}">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="models:MyDataType">

                    <ComboBox
                        ItemsSource="{Binding ElementName=RootPage, Path=MyComboBoxOptions}"
                        SelectedValue="{x:Bind Status, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        Tag="{x:Bind ID, Mode=OneWay}" />
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Page>

MainPage.xaml.cs
using ListViewWithComboBoxExample.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.ObjectModel;

namespace ListViewWithComboBoxExample;

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    public ObservableCollection<string> MyComboBoxOptions { get; set; } = new()
    {
        "Active",
        "Inactive",
        "Unknown",
    };

    // ObservableCollections notify the UI when their contents change,
    // not when the collection itself changes.
    // You need to instantiate this here or in the constructor.
    // Otherwise, the binding will fail.
    public ObservableCollection<MyDataType> MyCollection { get; } = new();

    private void SetItem(MyDataType item)
    {
        MyCollection.Add(item);
    }

    private void AddRandomItemsButton_Click(object sender, RoutedEventArgs e)
    {
        MyCollection.Clear();

        Random random = new();
        int itemsCount = random.Next(100);

        for (int i = 0; i < itemsCount; i++)
        {
            MyDataType newItem = new()
            {
                ID = random.Next(100).ToString(),
                Status = MyComboBoxOptions[random.Next(MyComboBoxOptions.Count)],
            };

            SetItem(newItem);
        }
    }
}

Comment: Answered. Cheers.
Comment: I tried implementing this, adapted to my code. It results in a null reference error from something that should never be null. The stack trace simply ends with [external code]. I am guessing the TwoWay binding mode is somehow trying to write a null value to something that otherwise is never null? For reference, MyDataType implements INotifyPropertyChanged, as does the Status (which is also a class). Would updating my question help?
Comment: If I toss in a null check where it throws the null reference error (and simply return), then the code runs, but the binding just doesn't work at all. I have verified that MyDataType and the Status property on MyDataType are never null nor set to null in my code.
Comment: I asked a separate question about the issue I am having with implementing this solution: https://stackoverflow.com/questions/76766943/how-to-twoway-data-bind-nested-inotifypropertychanged-viewmodels-to-combobox-ins.
Answer: It sounds like you need to use the SelectionChanged event handler rather than loaded. If I'm not mistaken, you can use them both, but it isn't necessary. You can use a line of code in you method for your page (it's the one that has "this.Initialize();") that will load whatever it is you want on startup.
I'm not 100% sure what your program does. Try adding the other event handler; there are a few that could apply.


Best way persist this JSON data for use in a UITableView in iOS 6

Question: My server is sending me a JSON response as follows:
[
  {
    "fields": {
      "message": "Major Network Problems",
      "message_detail": "This is a test message"
    },
    "model": "notification",
    "pk": 5
  },
  {
    "fields": {
      "message": "test",
      "message_detail": "Some content"
    },
    "model": "notification",
    "pk": 4
  },
  {
    "fields": {
      "message": "Test Message",
      "message_detail": "Testing testing"
    },
    "model": "notification",
    "pk": 3
  }
]

I want to populate a UITableView with a row per item just showing the value of the field message and then I'll tap that row to reveal a new view containing the message and message_detail values.  These messages may be updated at a later date where the pk value would be maintained so it's probably important to keep that information.
What's the most appropriate and efficient way of parsing this data and persisting it so it remains for the next launch of the app?
I'm thinking a plist would be a good way but I'd like to see some suggestions including some code on how best to go from the JSON array supplied to populating a UITableView and keeping the data for the next launch.
Answer: Assuming you have some class property:
@interface ViewController ()
@property (nonatomic, strong) NSArray *array;
@end

Just use NSJSONSerialization:
NSError *error;
NSData *data = [NSData dataWithContentsOfURL:url];
self.array = [NSJSONSerialization JSONObjectWithData:data
                                             options:0
                                               error:&error];

If you want to save the array in your Documents folder for persistent storage for retrieval upon a future invocation of the app, you can:
NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *filename = [docsPath stringByAppendingPathComponent:@"results.plist"];
[self.array writeToFile:filename atomically:NO];

To read it from the file later at the next invocation (in case you didn't want to re-retrieve it from the server):
NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *filename = [docsPath stringByAppendingPathComponent:@"results.plist"];
self.array = [NSData dataWithContentsOfFile:filename];

To use it for a UITableView, you'd store that in a class property and respond to the appropriate UITableViewDataSource methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.array count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    NSDictionary *rowData = self.array[indexPath.row];
    NSDictionary *fields = rowData[@"fields"];

    cell.textLabel.text = fields[@"message"];
    cell.detailTextLabel.text = fields[@"message_detail"];

    return cell;
}

Comment: I'm getting an error: 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' using your example above.  I can see that the text textLabel and detailTextLabel values are set correctly using NSLog, not sure what else to look for...
Comment: cell is nil, that's the problem, I'm not sure why
Comment: @conorgriffin You need to either (a) define cell prototype in Interface Builder with the correct cell identifier and then `dequeue...` will always return valid cell; or (b) you have to test to see if `dequeue` returned `nil`, and if so,  manually create a cell programmatically if one was not successfully dequeued. I would generally advise using cell prototypes (esp if doing complicated cell layouts), but either works.


How to use Kazam

Question: How to use Kazam screen recording application ?
I installed it. I can see Count Down also when I try to run it. But where is the Video storing ?
Answer: Start kazam. Go to File=>Preferences. Under the Screencast and Screenshot tabs, you can enable auto save and specify where to save the files. Otherwise, when you "finish" recording (from the panel icon menu) or take a screenshot, kazam will ask you whether and where to save the file.
Comment: Have you set auto save?
Comment: In that case, kazam will save files in the directory specified in the preferences, as I said in my original answer.
Comment: Thannks @jeffas. Kazam is not asking anything.
Comment: Thanks @jeffas. Yes, I set auto save.

How to use Kazam


Cannot control how often fsck is running on /boot/efi

Question: Every boot fsck is checking the partition /efi/boot. I can control how often it runs on other partitions using tune2fs but it won't work with this partition.
/var/log/syslog reports
Nov 28 19:59:55 alien systemd-fsck[612]: fsck.fat 3.0.28 (2015-05-16)
Nov 28 19:59:55 alien systemd-fsck[612]: /dev/nvme0n1p2: 239 files, 33140/97280 clusters

listing of partitions
$ lsdrv
NAME        FSTYPE LABEL            MOUNTPOINT   SIZE MODEL
sda                                            931.5G HGST HTS721010A9
├─sda4      ntfs   WINRETOOLS                    450M
├─sda2                                           128M
├─sda5      ntfs   Image                        11.4G
├─sda3      ntfs   HGST_Win10       /mnt/d       919G
└─sda1      vfat   ESP                           500M
nvme0n1                                          477G Samsung SSD 960 PRO 512GB
├─nvme0n1p5 ext4   NVMe_Ubuntu_16.0 /           44.6G
├─nvme0n1p3                                       16M
├─nvme0n1p1 ntfs                                 450M
├─nvme0n1p6 swap   Linux Swap       [SWAP]       7.9G
├─nvme0n1p4 ntfs   NVMe_Win10       /mnt/c     414.9G
├─nvme0n1p2 vfat                    /boot/efi     99M
└─nvme0n1p7 ntfs   Shared_WSL+Linux /mnt/e         9G

tune2fs refuses to work on /boot/efi
$ sudo tune2fs -l /dev/nvme0n1p2
tune2fs 1.42.13 (17-May-2015)
tune2fs: Bad magic number in super-block while trying to open /dev/nvme0n1p2
Couldn't find valid filesystem superblock.

How can I prevent fsck running every boot on /boot/efi?
Comment: `tune2fs` is a tool for ext2/3/4 filesystems. Obviously it won't work on other filesystems.
Comment: @muru Indeed. It's like a `tunefsck` app is needed which is file system agnostic. Alternatively I could write a script that checks `tune2fs` next `fsck` run and flips the `/etc/fstab` byte every 50 days or whenever it runs on `/`.
Answer: Edit /etc/fstab
The only way I found is to update /etc/fstab and change the flag to never check the partition which is in vfat format:
Look for this line:
UUID=D656-F2A8  /boot/efi   vfat    defaults    0   1

and change it to this:
UUID=D656-F2A8  /boot/efi   vfat    defaults    0   0

The last column was set to 1 run fsck and we changed it to 0 don't run fsck.


Oprofile and gprof output varies for same code

Question: I am running my code AMD optron 6270 machine. OS is Centos 6.2 release.
I have made a simple program as
#include<stdio.h>
#include<stdlib.h>
int calling (long a);
int calling1 (long a);
int calling2 (long a);
int calling3 (long a);
int calling4 (long a);
int calling5 (long a);

void main()
{
    long a,b=0;
    printf("hi");
    for (a=0; a<10000000; a++) b++;
    b =Calling(a);
    b =Calling5(a);
    b =Calling4(a);

}

int Calling(long a)
{
    long b=0;
    for (a=0; a<100; a++) b = Calling1(a);
    return 0;
}

int Calling1(long a)
{
    long b=0;

    for (a=0; a<10000000; a++) b++;
    b =Calling2(a);
    return 0;
}

int Calling2(long a)
{
    long b=0;
    for (a=0;a<10000000;a++) b++;

    b =Calling3(a);
    return 0;
}
int Calling3(long a)
{
    long b=0;
    for (a=0;a<10000000;a++) b++;
    b =Calling4(a);
    return 0;
}
int Calling4(long a)
{
    long b=0;
    for (a=0; a<10000000; a++) b++;
    return 0;
}

int Calling5(long a)
{
    long b=0;
    for (a=0; a<10000000; a++) b++;
    b=0;
    for (a=0; a<10000000; a++) b++;
    b=0;
    for (a=0 ;a<10000000; a++) b++;
    b=0;
    for (a=0; a<10000000; a++) b++;
    b=0;
    return 0;
}

While profinling this code with gprof and Oprofile. I got different reports. Lets say i run the main.exe with gprof two times:
1st report with gprof
Flat profile:
Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name

 24.80      2.96     2.96      101     0.03     0.03  Calling4
 24.71      5.91     2.95      100     0.03     0.12  Calling1
 24.63      8.84     2.94      100     0.03     0.06  Calling3
 23.78     11.68     2.84      100     0.03     0.09  Calling2
  1.01     11.80     0.12        1     0.12     0.12  Calling5
  0.34     11.84     0.04                             main
  0.00     11.84     0.00        1     0.00    11.65  Calling

2nd report with gprof
Flat profile:
Each sample counts as 0.01 seconds.
%   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name
 25.13      2.99     2.99      100     0.03     0.12  Calling1
 24.88      5.95     2.96      101     0.03     0.03  Calling4
 24.80      8.89     2.95      100     0.03     0.06  Calling3
 23.48     11.69     2.79      100     0.03     0.09  Calling2
  1.02     11.81     0.12        1     0.12     0.12  Calling5
  0.17     11.83     0.02                             main
  0.00     11.83     0.00        1     0.00    11.66  Calling

Both the reports differ. Everytime I run my main.exe i get different profiling reports.
When I tried Oprofile I also get different result as:
Oprofile report1
Using /var/lib/oprofile/samples/ for samples directory.
warning: /no-vmlinux could not be found.
CPU: AMD64 family15h, speed 2.2e+06 MHz (estimated)
Counted CPU_CLK_UNHALTED events (CPU Clocks not Halted) with a unit mask of 0x00 (No unit mask) count 100000
samples  %        image name               symbol name
92552    24.7672  main                     Calling4
91610    24.5151  main                     Calling3
91566    24.5033  main                     Calling1
91469    24.4774  main                     Calling2
3665      0.9808  main                     Calling5
1892      0.5063  no-vmlinux               /no-vmlinux
916       0.2451  main                     main
10        0.0027  libc-2.12.so             profil_counter
1        2.7e-04  ld-2.12.so               _dl_cache_libcmp
1        2.7e-04  ld-2.12.so               _dl_relocate_object
1        2.7e-04  ld-2.12.so               _dl_sysdep_start
1        2.7e-04  ld-2.12.so               strcmp
1        2.7e-04  libc-2.12.so             __libc_fini
1        2.7e-04  libc-2.12.so             _dl_addr
1        2.7e-04  libc-2.12.so             _int_malloc
1        2.7e-04  libc-2.12.so             exit

Oprofile report2
Using /var/lib/oprofile/samples/ for samples directory.
warning: /no-vmlinux could not be found.
CPU: AMD64 family15h, speed 2.2e+06 MHz (estimated)
Counted CPU_CLK_UNHALTED events (CPU Clocks not Halted) with a unit mask of 0x00 (No unit mask) count 100000
samples  %        image name               symbol name
92254    24.7719  main                     Calling4
91482    24.5646  main                     Calling1
91480    24.5641  main                     Calling3
91340    24.5265  main                     Calling2
3658      0.9822  main                     Calling5
1270      0.3410  no-vmlinux               /no-vmlinux
916       0.2460  main                     main
6         0.0016  libc-2.12.so             profil_counter
1        2.7e-04  ld-2.12.so               _dl_lookup_symbol_x
1        2.7e-04  ld-2.12.so               _dl_setup_hash
1        2.7e-04  ld-2.12.so               _dl_sysdep_start
1        2.7e-04  ld-2.12.so               bcmp
1        2.7e-04  libc-2.12.so             __mcount_internal
1        2.7e-04  libc-2.12.so             _dl_addr
1        2.7e-04  libc-2.12.so             _int_free
1        2.7e-04  libc-2.12.so             mcount

Can any one tell em why this happens? What are the possible reasons which cause this?
How I can avoid this situation so that I can get a constant profiling results?
Comment: Here's how you do that. For each optimization, run the test N times, like 10 or 100. Then get the average and standard deviation of the time you're interested in. Use that in your reporting.
Comment: It's a stochastic process. If the measurements were precisely repeatable, that would be a bug. Look at the big picture.
Comment: The OS will be occupied with other processes, I/O etc during your tests. It's impossible to guarantee that the machine's state during a test will match the state during a subsequent test. You could put the machine in single user mode which may reduce the variation in timings.
Comment: Is there any way I can get precise reults. so that if I am doing small optimizations(say 5ms) I should be able to see in reports.
Answer: I wouldn't be concerned about subsequent reports differing. Reports can vary drastically depending on how the program is executed. Moreover, it's difficult to say much about what occurs between the two profiles. Depending on what other processes are running, both your system's cache and TLB will most certainly be in a different state than they were during the first profile. Unless you can ensure a controlled machine state, don't expect consistent results.
It's simple to understand why reports from each tool don't agree. The two tools are fundamentally different. Oprofile is a sampling-based profiler that, in essence, periodically interrupts the CPU. Gprof is instrumentation based; it must be compiled into your program. This produces a different binary than would otherwise run had gprof not been used. As a result, gprof will over estimate timing. Use oprofile for CPU-bound processes, and gprof for I/O-bound processes.


Should I put some glue in the pre drilled hole before installing an eye screw?

Question: Going to put in some eye screws under the deck for a swing.
Should I add some glue in the predrill for extra durability?
I've also read vaseline is good for easier installation, but that's opposite of what I'm asking...
Comment: vaseline is good after the install of the eyebolts to avoid corrosion and squeaks
Comment: You want to place a large amount of consideration on the safety margin of the eye screw when used in a swing application. Or any vertical hanging application for that matter!! Look carefully at the load ratings of the screws used. Also consider using a larger diameter and longer thread length to get more engagement with the wood. Also be aware that when using a eye screw there is an ideal size to pre-drill into the wood - not too large and not too small. Installing with too small or no pre-drill will tend to split the wood resulting in a much lower strength assembly than with the ideal hole.
Answer: Are you using an eye bolt or an eye screw?
 OR
For an eye screw, glue won't do much and is not needed. (Although some glues may act as a lubricant when you first screw-in the eye-screw.)  Use bar soap or beeswax as a lubricant.
For an eye bolt, especially if you want it to be able to pivot, use appropriate washers, plus two nuts with a lock-washer in between.  For extra reliability use Loctite, not glue, where the nuts and eye-bolt meet.
If you don't need/want pivoting action, then one nut may suffice, but Loctite is even more important because such eye-bolts always loosen their compressive grip on the wood over time.
Comment: If the glue bonds both wood and metal, and it makes you feel better, go ahead and use it.  In my experience, it is not necessary though.
Comment: it is actually an eye screw vertically going into a vertical 2x6.  I will be adding a chain connector, and then the swing chain.  I was just wondering if the glue would give even just a bit more stability.


How do I drag an item behind my vehicle in Mario Kart Wii?

Question: I saw this in some player's YouTube video. They can drag a shell so that they don't get hit by other people's red shells. How do I do this?
Answer: You just hold down whichever button is normally pressed for shooting the item.
As soon as you release the button the item will then fire, and as far as I know you cannot stop holding the item behind you without firing.
This works with single shells, single bananas and possibly the fake power-up boxes.
Comment: Note that the ¿ Block item doesn't actually shield you from incoming shells. The shells and bananas work though.
Comment: It does indeed work with the fake power-up box. I think it also works with the leader bomb (blue shell). That was especially good in Mario Kart 64, because if you managed to get into the lead and carried a leader bomb behind you, it was effectively a permanent shield to red shells coming from behind.
Comment: If you use the Wii Wheel, you need to hold left on D-pad (when held landscape).
Comment: note that you can control which way the shells etc. fire by holding up and down respectively on the d-pad.
Comment: I tried it with shell and it didn't work...  are you sure?
Comment: @動靜能量 I'm fairly sure, it's a tactic I use regularly when playing Mario Kart games. Which item was it, and what button are you holding?
Comment: Yes, just hold whichever item button you use: http://bit.ly/9RLN32
Comment: @Mag: I'm pretty sure that if a shell hits the ¿ box when it's on the track, that stops it. So if you hear a shell coming up behind you should be able to drop the box just before the shell hits.
Answer: It seems like when using the Wheel, it is by holding left or right on D-pad.
Answer: Tap Down once on the D-pad to hold it behind you. To shoot behind you, tap Down again. With triple shells, you effectively have a wall of death around you.
Comment: Tapping will only cause the item to be shot or dropped behind you. (Unless it's a triple item, of course. But most aren't.)


Rearranging skills on the action bar

Question: Is there a way to move your skills around on your action bar? Everytime I try to move them it just tries to perform the action.
Comment: You probably have your action bars locked. Look in the menu for UI settings > Action bars > unlock them if you want to move skills. This used to be how it was done
Comment: Try holding SHIFT while moving.
Comment: @SAndokan that is the correct answer, I was going to post it as an answer until I saw your comment. Please post.
Answer: Try holding SHIFT while moving the skills.
Answer: Hold shift and then click and drag the skill to another slot. If you want to remove one, hold shift and drag the skill to a empty spot on the screen.

Rearranging skills on the action bar


Is it possible to run an AccuRev query at an arbitrary time in the past?

Question: I want to keep project metrics for my over time which I can show as a report. For example, I want to show a line chart of how many issues were WIP, Assigned, or Completed at the end of each week. Can I run the query at an arbitrary date in the past and build the charts on demand? Is there a way for me to do this without having to run a cron job each week and keep track myself?
edit: I'm using the accurev XML shell command to collect these stats, not the GUI.
Answer: I do not believe that this is currently possible with the XML command. We achieve this by issuing the query and archiving the results ourselves. Optionally, I suppose that you could write a script to go through the individual issues and parse the corresponding issue history to extrapolate the state of an issue at a given snapshot, but this seems like a bit more effort than is worthwhile. However, if you wish to do that, you could retrieve the issue history via XML as well, e.g. -
<code><?xml version="1.0" encoding="UTF-8"?>
<historyIssue issueDB = "myDepot">
<issueNum fid="1">1</issueNum>
</historyIssue>
</code>
Hope this helps!
Comment: Thanks, I was afraid I'd have to do that.
Answer: you may want to look at the AccuRev web interface as it includes [issue] reporting features not found in the standalone GUI.
HTH _ dave


WPF Orientation

Question: I'm developing an application on a tablet with portrait orientation.
However, when the tablet is turned to landscape mode, the application also turns, and all the alignments are thrown off.  So is there any way I can lock my WPF application to a single orientation?
Thank you!
Comment: Not a direct answer to your question, but if you redesign your UI to use a fluent layout your users will not have look at your UI sideways when they turn the tablet into landscape mode. WPF has a lot of options for doing fluent layout.
Comment: Are you using a Canvas to do layout?
Answer: I have to agree with Martin: I have developed Tablet PC Apps myself and you should rather provide a layout that works well in landscape and portrait.
Besides from that you can detect the change in orientation this way:
Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);
}

void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{
  if (SystemParameters.PrimaryScreenWidth > SystemParameters.PrimaryScreenHeight)
  {
    // runs in landscape
  }
  else
  {
    // runs in portrait
  }
}

Answer: Sven does a good job showing how to detect Orientation change...
However if you aren't writing a Metro app (where you can set preferred orientations in the manifest) there is no real way to NOT let the Orientation change, however if you are interested in only allowing Portrait you could do something like this:
View Model:
Microsoft.Win32.SystemEvents.DisplaySettingsChanged += new
    EventHandler(SystemEvents_DisplaySettingsChanged);
}

public bool IsLandscape { get; set; }

void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{
  if (SystemParameters.PrimaryScreenWidth > SystemParameters.PrimaryScreenHeight)
  {
      IsLandscape = true;
  }
  else
  {
      IsLandscape = false;
  }

  RaisePropertyChanged( "IsLandscape" );
}

In you Main Window.xaml:
<Border >
    <Border.Style>

         </Style>
    </Border.Style>

///The rest of your controls and UI

</Border>

So we really aren't limiting the Orientation, we are just noticing when it happens, and re rotating our UI so it still looks like it is in Portrait mode :)  Again this is mostly for non Metro Win 8 applications and or applications that also run on Win 7 tablets.
Comment: That's looks like not a good solution, Because I saw some Game don't need rotate the Game, It just can disable portrait mode when playing game .
Answer: I've came across the same issue when developing a wpf app for tablets and found this article from msdn explaining how to detect the screen rotation and orientation:
http://msdn.microsoft.com/en-us/library/ms812142.aspx
Comment: This article is for Windows XP Tablet PC Edition 2005
Answer: I'm not aware of any public API to lock the screen orientation. Mostly because typically, Tablet PC manufacturers provided their own preinstalled utilities or drivers that used accelerometer data to change orientation. It was not a built in OS function. This may be changing in Windows 8.
While it's not the same as locking orientation, you can try reacting to orientation changes by adding a rotate transform to your root container's LayoutTransform. This would change the layout space so that your application thought it was still rotated 90 degrees but the rest of the OS would not agree. Therefore it's really only practical for full screen applications.

WPF Orientation


GraphQL and Strapi Session

Question: First of all the project is amazing, I had GraphQL working with MongoDB very quickly. Even GraphiQL with the ModHeader extension. However, I am trying to add policies to the graphQL endpoints and I am finding that ctx.session is always empty, even tho I am making authorized requests (via the Bearer token)
How does session work in this example? Do I need to query for the user every single time I create a request?
Answer: The user info is available through the ctx.state.user object and not the ctx.session. Also, feel free to take a look at the GraphQL example https://github.com/strapi/strapi-examples/tree/master/react-apollo
Comment: Thanks for the answer! I see that the `ctx.state.user` indeed has the info, but how do I control how much is queried by it? it seems to include the whole document (even the nested arrays of objects)

GraphQL and Strapi Session


Is there a way to use my styles as an external css file in react?

Question: Maybe it will sound dummy but I would like to use SCSS in my React app for styling.
I know that React will "read" all my styles and generate them in separate

So I would like to have one mystyles.scss file which contains all my other scss files like this:
mystyles.scss
@import variables.scss;
@import components.scss;

and React will generate an external css file and when I modify any styles, the create-react-app cli will live reload it.
Edit
I would like to use react like this, because in my opinion it is easier to debug the styles with chrome inspect tool. It could show me which scss file has this style.
But if you have a better solution for debugging scss in React, I'm open for it!
Comment: Can you extend on why you want to do this? That will help folks determine an appropriate answer
Answer: With latest CreateReactApp already supporting importing sass,
install node-sass

import "./mystyle.scss"; // add to app.js top.

without using CRA you need to handle from webpack
npm install sass-loader node-sass webpack --save-dev

npm install style-loader css-loader --save-dev

and add this to your webpack config file.
module.exports = {
    ...
    module: {
        rules: [{
            test: /\.scss$/,
            use: [
                "style-loader", // creates style nodes from JS strings
                "css-loader", // translates CSS into CommonJS
                "sass-loader" // compiles Sass to CSS, using Node Sass by default
            ]
        }]
    }
};

Answer: You should be able to get references to your SCSS files from developer tools by placing this in your webpack config file:
devtool: 'source-map',

However, if you want a separate CSS file anyway, then you will also need to use the Webpack ExtractTextPlugin.  Within the module.rules section of the webpack config, you'll need something like this:
{
    test: /\.scss/,
    use: ExtractTextPlugin.extract( {
        fallback: 'style-loader',
        use: [
            "css-loader",
            "sass-loader"
        ]
    } )
},
plugins: [
    new ExtractTextPlugin( { filename: 'style.css', allChunks: true} )
]

The sass-loader converts the scss files to css, and the ExtractTextPlugin takes the CSS and places it in a separate file, as defined by the plugin config.


How do I prevent flood waters from entering my house?

Question: I live in a city where every time a heavy downpour lasts for more than 15 minutes there is flooding everywhere. When the water in the street have no more place to go, it then enters my driveway/patio. When it is around one foot deep, the water plus minute sewage seeps in under the door. Is there something I can put under the door to prevent the water from seeping in? I put towels or socks under the door but once they are saturated with water, I have to start mopping the water that seeps in. Last night after more than an hour of heavy downpour, I had to mop up 4 buckets of water that came inside the house.
If anyone has any ideas on how to solve my problem I would be very grateful. This is the second flooding this week. With the approaching year end, we are expecting more heavy rains. We thought of buying a pump to drain the water but the problem is there is nowhere for the pumped water to go. The earth here is saturated already and will no longer soak in water that is why we have the whole area around the house cemented and tiled. I hope I have given complete details to my problem.
Comment: unfortunately, if the water is at your door, you've somewhat lost the battle already. If that is the ONLY point of water entry, and you can prep ahead of time, I'd suggest a rubber pond liner laid up against the outside of the door with sand bags stacked on top.
Answer: DA's comment is correct.  If water has gotten to your house all you can hope to do is minimize the damage...water WILL get in if it is up against the door.
The best bet (a picture of the area in question would be useful) would be to build up the ground around the house to add a barrier to keep water off the house in the first place.  That may or may not be feasible in your situation, this is where the picture would be handy.
Comment: +1 for 'use of terrain' answer. I would advise some kind of drain or covered trench around the house. Also, water from the roof needs to be delivered farther from the house (longer gutters/drain pipes - not sure about vocabulary here).
Comment: And once water is getting in, the only thing you can do is pump it out as quickly as possible and minimize the damage. As long as the pump moves water faster than leakage does, you're ahead of the game even if you're just pumping back into the flood. Even if the pump can't keep up with infiltration, it will at least slow the rate at which water rises and may reduce damage. ... Or you could have the house raised on pilings (which is becoming a common fix for beachfront properties as sea level rises). Or give up and move to higher ground.
Comment: (I'm in a 100-year flood plain myself. I've had to run the pump once, when water level in the nearby stream peaked at 5' above normal. But that was just waterlogged ground; the _surface_ water didn't reach my foundation.)
Answer: Since you aren't going to be using that door, I would recommend getting a section of EPDM fish pond liner and some bagged sand.
Without pictures, it's kind of hard to give advice on how to get this to seal the best, so the following is just to give an idea of what you're trying to accomplish.
The pond liner comes in 8', 12' or wider by whatever the roll length is. Get an 8' x 3' section. Cut off a section to give plenty of overlap on either side of the door. With 3' folded in half, you will have protection for up to 18" of water. Push it as tightly against the door frame trim and threshold plate as you can get it and hold in place with the sand bags. You might need to stuff the cracks, I'd use plastic grocery bags twisted up into rope stuffed as tightly into where you were using the socks and towels.
Answer: See if your door's threshold is adjustable. If it is you may be able to simply raise it for a water-tight seal. Of course, you want to caulk the threshold to the concrete & have no open cracks anywhere...the door threshold won't do anything if water's coming in under the threshold.
Or, replace the door's threshold with a Stop Threshold, where the door actually closes against a seamless lip that has a rubber seal. These are very water-tight & the rubber seal is easily replaceable once it starts to fail from age.
Or, remove the door threshold & cut the door shorter...or raise the whole door in the wall, if building framing & interior ceiling height can accommodate. To then, install a caulked concrete threshold base or step, so the street would have to exceed its 1-foot depth in order to enter the house.
Presumably, the street's maximum flooding depth is the 1-foot before it finds drainage from the entire block's area. The step under your door would mean the street would then have to rise to 14, 16 or 18-inches to ever be a threat again. Flash Flooding could reach a 13 to 15-inch depth, so however much door shortening or raising you can accomplish the better.


How to represent multiple dropdowns and search bar to get details?

Question: I am building an interface where users will type certain things and they will get details on them. To get details users will have to select from three types of dropdowns or they can even choose from the search box given. All the dropdowns are mutually exclusive and users can only use data from one of the dropdowns/search boxes below. So if a user wants details they can either choose from dropdown option 1, dropdown option 2, dropdown option 3 or the search box (as given in. the image below) How can I represent this in a cleaner way without confusing the users?
P.S. I have given image for reference.
P.P.S.TIA
Comment: Can they use one dropdown AND the search box?
Comment: No that is mutually exclusive too. They can wither use the dropdown or use the search box.
Answer: If these options are mutually exclusive you would need to allow users to prevent errors. So when choosing from Option 1 (let's call those Category), all other should probably be disabled.
Developers and users will need to manage that dependence, which is a bit much.
So how about Two dropdowns?

First choose the Category, then choose the option
Initially, the Category could be Text search, showing the search field

If this is useful depends—as always—on the types of tasks users try to accomplish with this interface.
Answer:
...All the [options] are mutually exclusive...

For exclusive options, standard radio buttons work well:

Unselected options are disabled to make clear they're not available for selection.


Get Values from other Dataframe into my Loop for the new Dataframe

Question: I have one Dataframe (df1) with TimeCategory as index and different dates as columns and values for each TimeCategory during this day which looks like this:

TimeCategory
01.01.2021

0-5
3

5-7
0

7-10
1

10-12
5

12-14
5

And I have a second dataframe (df2) with the columns Date and TimeCategory.

Dates
Time

01.01.2021
0-5

01.01.2021
07-10

02.01.2021
07-10

02.01.2021
05-5

03.01.2021
12-14

I added a column to the second dataframe (df2), where I would like to get the values of the first dataframe (df2) based on date and time.
I made two lists out of the different Dates (Date_List) and the different TimeCategory (TimeCategory_List).
My If-Else-Condition works how it is supposed to be.
But I do not know how to get the values (????) from df1 into my loop to write it into my new column [24] of df2.
for i in range(0,len(df2)):

    if df2.loc[:,"Date"].iloc[i,] in Date_List and df2.loc[:,"TimeCategory"].iloc[i,] in TimeCategory_List:

       df2.iat[i,24]= ????
    else:
        df2.iat[i,24]=0

Answer: IIUC, you don't need a loop but merge. You have to reformat your first dataframe with melt before merge it with the second one.
>>> df1.rename(columns={'TimeCategory': 'Time'}).melt('Time', var_name='Dates') \
       .merge(df2, on=['Time', 'Dates'], how='right')

    Time       Dates  value
0    0-5  01.01.2021    3.0
1  07-10  01.01.2021    NaN  # different from 7-10
2  07-10  02.01.2021    NaN  # different from 7-10
3   05-5  02.01.2021    NaN  # no match from df1
4  12-14  03.01.2021    NaN  # no match from df1

Note: The problem here is because '07-10' is not the same as '7-10', you should use a common syntax.
Comment: Thank you very much the melt function made it possible to merge the two dataframes and that helped me to solve my problem.


Changing div text value by clicking on a li item

Question: i want to change the text value in a div by clicking on a ul li item.
const text = {
value1 : 'blabla1',
value2 : 'blabla2',
value3 : 'blabla3'
}

1

2

3

By clicking on li 1 the div get the value1, by clicking on li 2 the div get the value2 etc.
Can someone give me some advice, thank you
Comment: Hey JDL, welcome to SO! Please note that StackOverflow is not a free "write-me-code" service and you should demonstrate what you have already tried in order to get help. Now this seems to be a rather straightforward thing to do. The key thing you are looking for is "component state" which allows you to change a value used for rendering and update the DOM accordingly. Then you can change the value based on the array index or a key to look the value up from the object and render it as inner value of the div.
Comment: I was just asking for advice not for a complete solution. Sorry if i was not enough clear.
Answer: i am write code
import React, { useState } from "react";
import "./styles.css";

export default function App() {
  const text = [
    { id: 1, value: "blabla1" },
    { id: 2, value: "blabla2" },
    { id: 3, value: "blabla3" }
  ];

  const [textSelected, setTextSelected] = useState("");

  const selectLi = (id) => {
    let index = text.findIndex((x) => x.id === id);
    if (index === -1) return;
    setTextSelected(text[index].value);
  };
  return (
    <>

        {text.map((x) => (

 {
              selectLi(x.id);
            }}
          >
            {x.id}

        ))}

{textSelected}

    </>
  );
}

Work Demo
Answer: import React from "react";
import "./styles.css";

export default function App() {
  const clickHandler = (e) => {
    alert("value is " + e.target.id);
    let item = document.getElementById(e.target.id);
    console.log(item.getAttribute("name"));
  };
  return (

          1

          2

          3

  );
}

CodeSandbox example. You can also assign a value to a variable by using useState.
Answer: Here is another approach:
import React, { useState } from "react";

export default function App() {
  const [listValues, setListValues] = useState([1, 2, 3]);

  const text = { value1: "blabla1", value2: "blabla2", value3: "blabla3" };

  const showTextValue = (index) => {
    const newValues = [...listValues];
    newValues[index] = Object.values(text)[index];
    setListValues(newValues);
  };

  const content = listValues.map((val, index) => (

 showTextValue(index)}>
      {val}

  ));

  return (

{content}

  );
}


Can't play Minecraft 1.7.5 - sun.security.ssl.Alerts.getSSLException?

Question: For some reason my PC can't download authlib/1.3.1/authlib-1.3.1.jar for job 'Version & Libraries'.
Does anyone know what's causing this?
Development Console:
at sun.security.ssl.Alerts.getSSLException(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.Handshaker.processLoop(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.Handshaker.process_record(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) ~[?:1.7.0_51]
    at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source) ~[?:1.7.0_51]
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) ~[?:1.7.0_51]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) ~[?:1.7.0_51]
    at java.net.HttpURLConnection.getResponseCode(Unknown Source) ~[?:1.7.0_51]
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source) ~[?:1.7.0_51]
    at net.minecraft.launcher.updater.download.ChecksummedDownloadable.download(ChecksummedDownloadable.java:49) ~[launcher.jar:?]
    at net.minecraft.launcher.updater.download.DownloadJob.popAndDownload(DownloadJob.java:108) [launcher.jar:?]
    at net.minecraft.launcher.updater.download.DownloadJob.access$000(DownloadJob.java:12) [launcher.jar:?]
    at net.minecraft.launcher.updater.download.DownloadJob$1.run(DownloadJob.java:89) [launcher.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_51]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.7.0_51]
    at java.lang.Thread.run(Unknown Source) [?:1.7.0_51]
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching libraries.minecraft.net found.
    at sun.security.util.HostnameChecker.matchDNS(Unknown Source) ~[?:1.7.0_51]
    at sun.security.util.HostnameChecker.match(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.X509TrustManagerImpl.checkIdentity(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source) ~[?:1.7.0_51]
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) ~[?:1.7.0_51]
    ... 22 more
[19:37:39 ERROR]: Gave up trying to download https://libraries.minecraft.net/com/mojang/authlib/1.3.1/authlib-1.3.1.jar for job 'Version & Libraries'
[19:37:40 INFO]: Finished downloading C:\Users\No need to know :)\AppData\Roaming\.minecraft\versions\1.7.5\1.7.5.jar for job 'Version & Libraries': Used own copy as it matched etag
[19:37:40 ERROR]: Job 'Version & Libraries' finished with 1 failure(s)! (took 0:00:03.305)

Answer: Currently Minecraft servers are down. Please read this article that Notch tweeted about earlier...

We temporarily took down our servers due to this: http://arstechnica.com/security/2014/04/critical-crypto-bug-in-openssl-opens-two-thirds-of-the-web-to-eavesdropping/ … A LOT of websites and services are affected by this. Be careful.
   - @notch

If you have logged in to Minecraft within the past 24 hours, please change your password. Follow notch on twitter to get all of the latest updates straight from him.
Comment: Were this to occur at any other time it might be a good idea to delete (or move) your .minecraft folder. You may be experiencing a man-in-the-middle attack and any files in that folder may have been compromised. To be safer I'd delete them for sure.


What is that burning smell in transformer?

Question:
When I plugged in a 250VA load to the left transformer. I can smell something burning and the case is super hot.
What causes the burning smell? What part of transformer can produce burning smell?
And does it mean the transformer is already ruined? If one would continue using it.. maybe it can fail suddenly or does the burning not produce permanent damage?
Both are rated 500VA.. but I think the small one that has smell is not a real 500VA capacity transformer. It is inside a voltage regulator. Maybe a voltage regulator especially boost buck type doesn't need a full capacity transformer because it's only adding or subtracting some voltage?
Comment: 1kg wood and 1kg rock weighs equally. Similarly two 250VA transformers should look almost same size. Your left trafo certainly cannot be 250VA.
Comment: @soosaisteven this person has been asking many questions.  From that history we know the one on the left is an autotransformer.  They can be smaller. / It is also a Cheese no-name brand, wheras the one on the right is a reputable maker (though still made in China). Both transformers are larger than 250VA.
Comment: OP do you have a clamp ammeter? Can you measure current going into the primary? At 250VA it should be a tick over 1 amp.  I wonder if it is not.
Comment: Both are 500VA rated.. not 250VA. I said I plugged in 250VA to the left AVR (Automatic Voltage Regulator) and temperature kept increasing even above 60 Celsius. However, I noticed this only occurred when I used the 110V output (of the AVR). If I used the 220V output, temperature maintains at 40C. I guess this is because at lower voltage output of the left AVR and autotransformer. The current is greater and the small transformer winding is not designed for 110V output (with greater current)? Right?
Comment: This guy is a scammer always asking more questions based on answers with no up votes a total waste of time.
Comment: Because when I first joined.. I couldn't up vote... beginners at stack exchange can't up vote.. it's only now that I'm aware I can up vote already... and I just upvoted the answers by Ed and others (3 hours ago). And I don't know comments should be upvoted too (I upvote comments now).
Answer: The burning smell is the insulation of the winding conductors burning and is generally indicative of irreparable damage. It may still function, for a while, but has been severely compromised. Further failure often results in flames...
Comment: What would result in flames.. is it the transformer or the load connected to it?  For an autotransformer, a short in the primary or open in the secondary can result in the full voltage appearing in the secondary. So I guess the transformer itself would not end up in flames but only the load, right?  The load is a 120v SPD and I guess the thermal fuse would engage before the MOVs end up in flames. I ordered an additional Belden strip and would plug it into 240v to see if the thermal fuse would just activate or the strip would end up in flames so I can gauge the worse case scenario.


Is this smoke detector safely connected?

Question: I recently bought this house (built in 2000), so it went through inspection. I assumed everything was fine. I realized the smoke detector in one of the rooms was not showing the green light that the others were showing. I pressed the "test" button and it beeped just like the others, so I thought it may be okay.
More recently I decided to actually take a look at it, and figured out the black wire is completely disconnected. Googling what that wire means gave me different results, but most of the results suggeste the detector would not be connected to the power, which would mean its battery would end very quickly, but I don't see the detector complaining about the battery (it's been a few months since we moved in).
Now I'm completely confused and have no idea if this is actually safe (especially since the home inspector was supposed to have checked this).
Am I safe? Would it be easy to fix this in case there's a problem? The other detectors in the house are not connected like this one.

Thanks!
Comment: Have you looked up the model online and read the spec sheet to see what the install instructions say?  Do that and if you still have questions then update your post and we will see if we can clarify the instructions.
Comment: Is there a black wire in the box above the detector?
Comment: But, when you test it, do the other detectors also beep? That's how these are wired, a detector in the basement will set off all detectors when signaling an alarm.
Answer: This is a Firex 4618, interconnected smoke alarm with backup battery. Here is the manual which explains Green Light means its operating on A/C (hardwired) power.  Otherwise, its running off the backup battery.  It can run on the backup for several years like a battery operated smoke alarm, but the manual states a standard battery should last for 1 year, then when it drops under voltage it will chirp at you.
The black wire (hot) can be connected to a black wire up in the box to run on A/C power again.  Often it can pop off especially if someone removed the smoke detector that strained the wires.  Those stranded core wires and cheap wire nuts that come with the smoke detector often don't result in a very strong connection.
The fix is to first switch off the power.  Hard wired smoke alarms usually share the lighting circuit.  Then you can reconnect the black wire on the pigtail to the black wire in the box.  When you power it back on, there will be a green light like the others.
Comment: In the last two houses that I have had anything to do with the smoke alarms were fitted when the house was built and were on their own circuit with their own breaker at the consumer unit.  Don't assume that turning the lighting circuit off will remove power from the smoke alarms - CHECK IT !
Comment: @uɐɪ Amen to that! Never rely on someone telling you which breaker to switch off! Always test the wires you're planning to work with before touching them.
Answer: Yes, you need to be very careful with this, 120V is very dangerous and it will shock you, and especially dangerours for someone who isn't used to working around it. Since the green light will not go off when you flip a breaker, bc the black(hot) wire is not connected. I highly recommend you get a non conctact voltage tester, you can get yhem for 10-20 bucks on Amazon. When you hold it near the circuit, if it beeps at you, then the circuit is still hot. If it doesn't, that means the circuit is powered down and your safe to work on it.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to contribute here.


Overflow over gutters on roof. One story ranch

Question: Straight to the point, there's too much water coming off my roof. Unfortunately I wasn't able to record this last rainstorm to show you.
My home is a 1950s ranch house one story obviously, the first pitch is a corner and along the shingles there is a metal strip that's tented up that goes almost all the way from the top of the roof down to the gutter. The second one is over my kids room, in the water comes off of the roof quite hard up until two and a half to three foot patch underneath that ledge the length of the roof on that section. And on the back of the house the pitch is actually a little lower and it's still pours off like the gutter isn't even there.
If anyone has a solution for this I would love to know, I'm assuming because of the pitch of the house that the gutters are too narrow and that's probably a big part of this, another issue I see is that the rain is just gathering too much speed before it hits that gutter. I was wondering what my solution would be for the corner and above that bedroom My back patio has a very similar situation as well. The water pours off like buckets as you would assume. It's caused flooding in the basement.
I'm assuming for that corner piece I need to put some sheet metal up in order to help divert the water and a couple directions and slow it down a little. I couldn't find a product online that might do this. I don't know much about home repair so I would love a caveman explanation. I'm afraid all I have to pay you with is high fives.
I bought this 1950s ranch house 6 years ago and I've had nothing but issues. I know it's you're all thinking,"duh". First homeowner mistakes but trust me I've learned plenty of lessons for the next home. Since I'm stuck with this house I figured maybe I could find help for this problem on the internet. Thank you for any help you guys provided.
Comment: Are the downspouts clean, not blocked?  Do you have enough slope on gutters?  Test by poring water on high end away from downspouts.  If both are good, then bigger gutters might help.
Comment: You can just buy some white aluminum flashing and make those corner guards yourself.  Then they can be as high or a long as you want.
Comment: I appreciate the advice about the photos, I'm not very internet savvy even though I probably should be in my 30s. And yes the downspouts are clean. I definitely think it's a slope issue but I don't know how I would fix that. I'm not very knowledgeable about this kind of stuff involving home repairs. I don't mind doing the work but I really have no idea what I'm doing until somebody lets me know
Comment: They are often site-made from sheet metal, but evidently **gutter baffle** and **gutter splash guard** (or **splashguard**) are useful search terms for premade parts for the inside corners.
Comment: Are you located in an area where snow is unlikely? That might affect some possible mitigation methods (basically extending the corner guard idea well beyond the corners to intercept flow.)
Comment: I live in the Midwest We have a lot of snow where I'm at. Also thank you for the search terms I had no idea what to look for and I was confused looking at hardware sites and not seeing anything.
Comment: What is the width of the gutter at the mid point (4,5,6")?  There are some foam gutter guard that might serve double duty.  They look a little like pool noodles - I'd get a piece of one of those put it in the gutter and see how it performs in terms of blocking the velocity of the water.
Comment: Honestly I'm not sure on the width I haven't checked. They look pretty narrow though. Given how cheaply most of this house has been built I wouldn't expect them to be wide. But I also read that wide gutters are an issue in the Midwest because of snow? I'll look into gutter guards.
Comment: Maybe it's just the angle of the camera.  But it looks like the gutters are pitched downward in the corner, which is not what you want.
Comment: How much rain are you getting?  The roof looks to have a low pitch and be a fairly minimal size so really I am surprised you have an issue with your gutters.  Where do your gutters drain (city storm, rock pit or just to the lawn?)  Do you have a sump in the basement?
Comment: Thanks for the idea about the corner guards and doing them myself I'll look into that as well.. I'll check to see if the gutters are at a down angle as well. It's quite a bit of water coming off We get quite a bit of rain where I'm at throughout the year and a good amount of snow when it does snow. This stuff drops on to the lawn for the most part when it jumps the gutters, I mean we have city sewer but my property sits on 3 acres so most of it's all lawn. No we don't have a sump in the basement. It's not that much water coming through the walls.
Comment: If it ever did get too bad in the basement I would just trench out the walls and patch it from both ends after regarding the inside again. It would be expensive for me but it would solve the problem.
Answer: Water flows downhill
In any downspout system, the water will flow from higher points to lower points.  So when you install downspouts, you don't lay them flat; you install them with a slight slope, and you make the low points where the downspouts are.  That way no matter where water lands in the gutter, it always flows toward a downspout.
The trouble is readily apparent in your photo.  That rule has not been followed.  The gutter in this corner is the lowest point in the area. So all the water collected by the gutter is flowing toward that corner.  And then it's being met by the flow down that tented metal strip. And there's no downspout there so the water is just piling up in a splashy mess.
Either put a downspout there, or change the grade so it's not a low point.
It's possible it was built properly, and the gutter has sagged for some reason.
Answer: For the corner I would add an inside corner conductor head:

Other than that, your gutters may be too narrow, so you may consider replacing them with wider gutters. K-Style is typically 5" or 6", but you can get 7", or 8". A box gutter may also be a better choice because it will hold more water due to its shape.
Another thing to consider is if they are just to low and need to be moved up a bit.
As mentioned by @harper - Reinstate Monica, the gutter may also be pitched the wrong way, so it will be holding more water.
I would say to tackle all issues, bigger gutters with bigger downspouts, positioned vertically correct, pitched the right way with the addition of inside corner conductor heads.


Styling Windows Phone 8.1/WinRT AppBarButton

Question: I'm currently looking to implement a CommandBar for a WinRT Windows Phone 8.1 app. Overall it is very straightforward but I am unable to style the control.
I have themed my app so that the accent colour has been changed to green. This works well for pretty much everywhere in the app (buttons, textblocks etc.) but not for the AppBarButton.
The brushes I'm overriding are SystemColorControlAccentBrush and PhoneAccentBrush but changing these does not make any difference to the colour of the AppBarButton when pressed:

Any idea what I'm doing wrong/can this colour be changed?
Answer: Set the CommandBar's foreground and background colors.
The command bar on Windows Phone is system UI not app UI and does not allow customizing the colors of individual AppBarButtons. Their colors always come from the CommandBar's colors.
Comment: Thanks Rob, this worked. I don't have full control over the colour of the button when pressed but by settting the CommandBar's background and foreground the button now inverts with a white circle outline. Thanks for your help!
Comment: Worth noting, it seems if you set the foreground colour to white then the phone accent colour becomes the background of the button.
Answer: try changing app bar button color

<code>            <AppBarButton x:Uid="SendMessageButton" Icon="Send" Foreground="" Background=""  Command="{Binding SendMessageCommand}" IsEnabled="{Binding IsSendMessageButtonEnabled}"/></code>

or change in code behind
<code>  AppBarButton app = new AppBarButton();
            app.Foreground="";
            app.Background="";
</code>


how to correct glib-2.35.x 'g type_init is deprecated' error when compiling from source

Question: Hi I'm trying to compile gnome-packagekit from source git://git.gnome.org/gnome-packagekit and when I try and make I get the error above
error: 'g_type_init' is deprecated (declared at /usr/local/include/glib-2.0/gobject/gtype.h:669) [-Werror=deprecated-declarations]
cc1: all warnings being treated as errors

I've looked this up and it seems to be because glib-2.35.4 has deprecated the g_type_init call. (I don't actually know what that means). It also seems to be related to wperror checks according to some commentators. The output of autogen.sh is
            gnome-packagekit 3.7.6
          =============================

prefix:                    /usr/local
compiler:                  gcc
cflags:                    -g -O2
cppflags:                   -Werror -Wall -Wreturn-type -Wdeclaration-after-statement -Wno-uninitialized -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-default -Winit-self -Wmissing-include-dirs -Wno-strict-aliasing -Wundef -Waggregate-return -Wmissing-format-attribute -g -fexceptions                    gnome-packagekit 3.7.6
              =============================

    prefix:                    /usr/local
    compiler:                  gcc
    cflags:                    -g -O2
    cppflags:                   -Werror -Wall -Wreturn-type -Wdeclaration-after-statement -Wno-uninitialized -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-default -Winit-self -Wmissing-include-dirs -Wno-strict-aliasing -Wundef -Waggregate-return -Wmissing-format-attribute -g -fexceptions

Which suggests this might have something to do with it.
Wonder if there is an easy way to tell the compiler to use the old version of glib or to ignore werror checks.
Answer:
(I don't actually know what that means)

What is means is that starting with glib version 2.35.0, the function g_type_init should no longer be used because the intention is to remove it from the library at some point in the future.
So when compiling older glib programs against glib version 2.35.0 or greater, you should edit the code to put a test around g_type_init
#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init ();
#endif

At first this looks as if g_type_init will only be excluded for glib 2.35.0 but the macro LIB_CHECK_VERSION is in fact defined to return true for the same or greater/newer version than that specified.

Wonder if there is an easy way to tell the compiler to use the old version of glib

You can instruct the compiler and linker to use an older or newer version that the default, but obviously you need to have that version installed which may very well lead to problems with other programs trying to use the wrong version of the glib library.
So, as a general rule, only install multiple versions of library as a last resort, extra especially so for general purpose libraries such as glib which is used by so many programs.

to ignore werror checks.

The -Wall flag on the gcc command tells gcc to flag all warnings, and for a few years now, the default state of gcc is to treat all warnings as errors.  If you ask this question on many sites, responders will simply tell you to do a web search.
If you were to check the manual page for gcc, you would find that the best way to deal with the specific issue of a deprecated function is to add
-Wno-deprecated-declarations
to the gcc command in order to just ignore that and still keep the safety of checking for all other warnings with -Wall
Answer: Comment out the line containing g_type_init. That should solve the problem.


Where do the basis vectors live in a matrix?

Question: I am working through Apostol's Calculus Vol 2 and I am a bit confused by the discussion of constructing a matrix with a basis other than the standard $I$.
For example, on the example of constructing a matrix that represents the differentiation operator on polynomials of degree <= 3: with the standard basis, the book says "we choose the basis $(1, x, x^2, x^3)$ for the domain and the basis $(1, x, x^2)$ for the range, then arrives at the following matrix:
$
\begin{bmatrix}
0 & 1 & 0 & 0 \\
0 & 0 & 2 & 0 \\
0 & 0 & 0 & 3
\end{bmatrix}
$
i.e.:
$
D(1) = 0 + 0x + 0x^2 \\
D(x) = 1 + 0x + 0x^2
$
and so on. So the first column represents the number of $1$s, the second column represents the number of $x$s, etc -- i.e. the $i$th entry in a row represents the coefficient for the $i$th basis vector. This makes sense to me.
Next, it computes an alternate representation for $D$ using the basis $(1, 1 + x, 1 + x + x^2, 1 + x + x^2 + x^3)$ for the domain and $(1, x, x^2)$ for the range, and arrives at:
$
\begin{bmatrix}
0 & 1 & 1 & 1 \\
0 & 0 & 2 & 2 \\
0 & 0 & 0 & 3
\end{bmatrix}
$
because:
$
D(1) = 0 \\
D(1 + x) = 1 \\
D(1 + x + x^2) = 1 + 2x \\
D(1 + x + x^2 + x^3) = 1 + 2x + 3x^2
$
This does not make sense to me: the $i$th column still represents the coefficient for $x^{i-1}$, but that is no longer the basis of the domain. I would expect $\begin{bmatrix} 0 & 1 & 1 & 1 \end{bmatrix}$ to mean: $0 * (1) + 1 * (1 + x) + 1 * (1 + x + x^2) + 1 * (1 + x + x^2 + x^3)$ rather than $0 * (1) + 1 * (x) + 1 * (x^2) + 1 * (x^3)$.
What am I misunderstanding here?
Answer: Given any finite-dimensional $k$-vector space $V,$ a linear operator $T : V \to V,$ and an ordered basis $\mathscr B$ of $V,$ we can write the matrix $A$ of $T$ with respect to $\mathscr B$ by taking the $i$th column of $A$ to be $T(v_i)$ with respect to $\mathscr B.$
Given any basis $\mathscr B,$ it is true that in some cases, we can replace each of the vectors by some linear combination of the other vectors and obtain a basis. Particularly, the ordered basis $\mathscr B = \{1, x, x^2, \dots, x^n\}$ of the $k$-vector space $P_n(k)$ of polynomials of degree $\leq n$ over $k$ gives rise to the  ordered basis $$\mathscr B' = \{1, 1 + x, 1 + x + x^2, \dots, 1 + x + x^2 + \cdots + x^n\}$$ of the same vector space. (Essentially, the argument is that if we write these vectors as linear combinations of the vectors of the ordered basis $\mathscr B,$ then the corresponding matrix is invertible.)
We will focus our attention on the $4$-dimensional $\mathbb R$-vector space $P_3$ that consists of polynomials of degree $\leq 3$ with real coefficients and the differentiation operator $D : P_3 \to P_3$ defined by $D(p(x)) = p'(x).$ Like we have seen, we always have an ordered basis $\mathscr B = \{1, x, x^2, x^3 \},$ but this gives rise to another ordered basis $$\mathscr B' = \{1, 1 + x, 1 + x + x^2, 1 + x + x^2 + x^3\}.$$ For notational convenience, let us rename the $i$th vector of the ordered basis $\mathscr B$ to be $v_i = x^{i - 1}$ and the $i$th vector of the ordered basis $\mathscr B'$ to be $w_i = \sum_{k = 1}^i x^{k - 1}.$ Like you have observed, we have that $D(w_1) = 0,$ $D(w_2) = 1 = v_1,$ $D(w_3) = 1 + 2x = v_1 + 2 v_2,$ and $D(w_4) = 1 + 2x + 3x^2 = v_1 + 2v_2 + 3v_3.$ Consequently, the matrix of the image of the ordered basis $\mathscr B'$ under $D$ with respect to the ordered basis $\mathscr B$ is $$\begin{pmatrix} 0 & 1 & 1 & 1 \\ 0 & 0 & 2 & 2 \\ 0 & 0 & 0 & 3 \\ 0 & 0 & 0 & 0 \end{pmatrix}.$$ On its own, I don't really see the point of this construction as it relates to calculus; however, I hope that helps.
Answer: Your interpretation of the entries of a transformation matrix is a bit off. You should concentrate on the columns of the matrix instead of its rows.
Observe first that if you right-multiply any matrix $M$ by the $j$th column of the identity matrix, the result is the $j$th column of $M$. Now, for any ordered basis whatsoever of a finite-dimensional vector space, the coordinates of the $j$th basis vector are precisely the $j$th column of the identity matrix. That is, if $\mathbf v$ is the $j$th basis vector, then its coordinates in that basis are a tuple that has zeros in every place but the $j$th one, which has a $1$, i.e., $v_i=\delta_{ij}$.
Putting these two observations together, we find that the $j$th column of a matrix $M$ that represents a linear transformation $T$ is the coordinates of the image of the $j$th basis vector of the domain of $T$. These coordinates are expressed in terms of the "output basis," that is, the chosen basis for the codomain of $T$. To put it a little more concretely, if we have the basis $\mathcal B=\{\mathbf v_j\}$ for the domain of $T$ and $\mathcal B'=\{\mathbf w_i\}$ for the codomain, then $$T(\mathbf v_j)=\sum_i m_{ij}\mathbf w_i.$$ To put it in your terms, the $j$th column of $M$ tells you how many of each of the $\mathbf w_i$ to take in order to make $T(\mathbf v_j)$.
When you multiply an arbitrary coordinate tuple by $M$, what you're really doing is writing the vector $\mathbf u$ as a linear combination $\sum_j u_j\mathbf v_j$ of the domain basis vectors, then applying $T$ to each term—$M$ tells us how many $\mathbf w_i$'s go into each term—and adding up the results.
Looking at your two examples, the first matrix tells us that $1$ is mapped to $0\cdot1+0\cdot x+0\cdot x^2 = 0$, $x$ is mapped to $1\cdot1+0\cdot x+0\cdot x^2=1$ and so on. (Here the dot stands for ordinary multiplication.) For the second matrix, the first column is the image of $1$, so that's the same as before, but the second column is now the image of $1+x$: the matrix tells us that $D(1+x)=1\cdot 1+0\cdot x+0\cdot x^2=1$. Similarly, the third column tells us that $D(1+x+x^2) = 1\cdot1+2\cdot x+0\cdot x^2=1+2x$. I think it might've been less confusing had the author not used the same basis for the codomain in each case.
When you use this second matrix to differentiate an arbitrary polynomial $p$, you have to rewrite that polynomial in the form $a+b(1+x)+c(1+x+x^2)+d(1+x+x^2+x^3)$; the coefficients of that expression are its coordinates relative to the second basis. By linearity we have $$D(p)=aD(1)+bD(1+x)+cD(1+x+x^2)+dD(1+x+x^2),$$ and each column of the matrix tells us how to write the corresponding domain basis vector derivative in terms of the codomain basis vectors.
Answer: Let's say that $B_V$ is the basis for the domain and $B_W$ is the basis for the range. In the matrix associated to a linear map, the $j$-th column represents the coordinates respect to $B_W$ of the image of the $j$ element of $B_V$:
$D(1)=0, \text{Coord}_{B_W}(0)=(0,0,0)$ is the first column.
$D(1+x)=1, \text{Coord}_{B_W}(1)=(0,1,0)$ is the second column.
$D(1+x+x^2)=1+2x, \text{Coord}_{B_W}(1+2x)=(1,2,0)$ is the third column.
$D(1+x+x^2+x^3)=1+2x+3x^2, \text{Coord}_{B_W}(1+2x+3x^2)=(1,2,3)$ is the fourth column.
This is what Apostol means when he says that we write the images as linear combinations of the elements in $B_W$ (I can't quote literally, because I hold an italian translation :)) The coefficients in such a linear combination ara just coordinates respect to $B_W$.
Since such a matrix can transform vectors in $B_V$ into coordinates respect to $B_W$, it can tansforms each vector in $V$ (its coordinates respect to $B_V$) into coordinates of vectors in $W$.
Example: if $p=4+x+3x^2+x^3$, then $\text{Coord}_{B_V}(p)=(3,-2,2,1)$ because $3(1)-2(1+x)+2(1+x+x^2)+1(1+x+x^2+x^3)=p$, and
$$\begin{bmatrix} 0 & 1 & 1 & 1 \\ 0 & 0 & 2 & 2 \\ 0 & 0 & 0 & 3 \end{bmatrix}\begin{bmatrix} 3 \\ -2 \\ 1 \\ 1 \end{bmatrix}=\begin{bmatrix} 1 \\ 6 \\ 3 \end{bmatrix}$$
these are the coordinates respect to $B_W$ of $1+6x+3x^2$, the derivative of $p$.


Can I get a refund due to bundle sales on Steam?

Question: So, I bought one game on Steam, and a few days later looked at another game I wanted. I scrolled down, and saw that it had a bundle with both games in it for nearly the same price that I payed for the first game.
I had already put 25 hours into the first game, so there was no chance of refund. It's probably too late now, so I'm going to buy the second game before the Steam sale ends, tomorrow.
For future reference, would it be possible for me to get both games bundle price, seeing as I bought both in the same sale as the bundle?
Answer: Yes, within reason.
You need to have purchased the game within 14 days, and have played it for no more than 2 hours.
Failing that, you do get an additional discount on bundles where you already own some of the games.

Refunding Games with Steam
Steam have a refund policy for games. They go as far as confirming that this policy allows you to repurchase games that go on special.

How to Request a Refund
Valve will, upon request via help.steampowered.com, issue a refund for any title that is requested within 14 days of purchase and has been played for less than 2 hours. Even if you fall outside of the refund rules we've described, you can submit a request and we'll take a look at it.
Additional information and troubleshooting instructions for existing refund requests can be found in our Common Refund Questions FAQ.
- "How To Request A Refund" @ Steam Support

What can I request a refund for?
Valve will, upon request via help.steampowered.com, issue a refund for any title that is requested within 14 days of purchase and has been played for less than 2 hours - this includes online, offline and shared library playtime. Even if you fall outside of the refund rules we've described, you can submit a request and we'll take a look at it.
I bought a game right before it went on sale. Can I get a refund and repurchase it at the sale price?
Yes.
If you have not already requested a refund, make sure the purchase is eligible and submit a request here.
Please note that approved refunds may take up to 7 days to process.
- "Common Refund Questions" @ Steam Support

Other Options
Always Double Check the Bundles
When you look at a games store page, you can see the bundles that game is a part of. It is always worth checking the additional bundles. You might find it a better option to directly buy the bundle. You might even consider holding off and purchasing the bundle at a later date, depending on the situation.
Bundles Still Give You Discounts
As Mixxiphoid mentioned, you still get discounts on a bundle, even when you own some of the games. Steam applies a further discount to account for the games you already own. To give a real world example, I own the "Orange Box" collection and "Left 4 Dead 2". These games are a part of the "Valve Complete Pack BUNDLE". At the time of writing this answer, the bundle is selling for A$213.00 A$19.08; but when they take into account the games I already own, the price goes down to A$146.50 A$13.12.

Bundles are a special discount on a set of products. If you already own some of the products contained in the bundle, purchasing the bundle will allow you to "complete the set", paying only for the products you don't already own while still receiving the full bundle discount on each of those products.
- BUNDLE rollover notification found via the Steam application
Comment: Note that "because it went on sale" is explicitly allowed and *not* considered abuse of the system (though you need to meet the 2 hour/2 week limits).
Comment: I'd like to add to this by saying that while "bought in the last 14 days and no more than 2 hours played" is the official rule, I've found them to be flexible on this in the past. I've had games refunded after four hours of play after I discovered major technical problems that weren't apparent in the first two hours. If you fill out a refund request and explain the situation then they might help you even if you've exceeded the allotted time, although the 25 hours that the OP mentions exceeds it by *a lot*.
Comment: @Studoku, I directly quote their FAQ where they stqte this.
Comment: It seems my comment was removed from the question, the reference is confusing now. Perhaps remove it?
Comment: Thanks for this awesome answer!  I have 2 questions, though.  If you own all the games in a bundle, what would steam do if you purchased the bundle, and if you received one of the games in the bundle as a gift, would steam still discount it?
Comment: @Millard you can't buy the bundle, not for yourself or a friend, if you have all the items in the bundle. There is also no difference between a purchase or a gift, you get the same discount of the bundle.
Comment: Thanks for the info, @Mixxiphoid , and thank you Gnemlock.  I thought I selected your answer a while ago, but here it is now anyway.
Comment: Yep, refunds actually go through someone. The period limits are essentially limits for _unconditional_ refund. Anecdotally, I've obtained a refund of a game I had played for over 10 hours in its singleplayer mode, because only later it was observed that the multiplayer did not work and the developers had no plan to fix it. Since the game was still listed on the store as having multiplayer as a feature, I managed to get a refund even though it was a bit over a month later.


Chrome extension unable to occupy the full window width

Question: I developed a chrome extension in the format of a horizontal bar standing at the top of the user window. It's something "like" it:

But it is how it looks like when I add it to Chrome as an extension (see the icon at the top-right):

What is wrong here?
Here's the manifest:
{
  "manifest_version": 2,

  "name": "CLAWS",
  "description": "testing",
  "version": "1.0",

  "permissions": [
    "tabs",
    "https://google.com.br/"
  ],
  "browser_action": {
    "default_icon": "icone_app.png",
    "default_popup": "HTML.html"
  }
}

EDIT: The HTML code:
<!DOCTYPE html>

<link href='CSS.css' rel='stylesheet' type='text/css'>

and CSS.css:
#barra{
   background-color:red;
   width:100%;
   height:80px;
}

Comment: Please post `HTML.html`.  It creates its own window, which is sized separately from the main window.  In particular, there's nothing that makes it have any particular width, so my guess is it defaults to a minimal width.
Comment: Sorry, what do you mean with "to have a particular width"? It's about the extension window? And the code is at the post now.
Answer: A popup window is it's own window.  So when #barra specifies its width as 100%, it's 100% of the popup window's body element.  But nothing makes the body take a particular size.  For example, if I inspect your extension's popup, Chrome tells me that the body element has a width of 9px, and margins of 8px on each side (set by the user agent style sheet).  Your values may differ, but they won't be much larger.  If you want it to be wider, you'll need to have CSS.css explicitly tell body how wide it should be, and not use percentages.
But if you want a bar at the top of the user window, I'm not sure if a browser action is what you want.  Browser actions close when they loose focus, in particular, when the user has any interaction with the webpage.  Instead, I think you would want a content script that would put the bar at the top of the screen (possibly just some css: body{border-top:80px solid red;}).
Comment: Thanks for answering! Really browser action is not what I desire here. But I don't think content scripts are appropiated, since I don't see such a complex interaction with the page the user are visiting (I may be wrong). And only use CSS to add the bar does not work also...
Comment: A content script is the only option for interacting with the page the user is visiting.  But it doesn't have to be all that complicated.  It's just the script or css you would execute or use to get the effect you wanted.  In this case, a line of css or a few lines of js should be able to get the job done.  Although that would also depend on what you want to do with the red bar at the top.
Comment: Well, I basically want the bar to stay everytime at the top of the user's windows and be able to identify words that him/her selects through a javascript at the own bar code. I'm totally newbie at extensions, but if the bar has a more complicated HTML (one that cannot be "simulated" with CSS), how should I do it with content scripts (that,as far as I know, only accept JS and CSS codes)?
Comment: Are you wanting some html in that bar?  If so, you'll need to use the js in a content script to create the appropriate html.
Comment: Got that...but I don't know exactly how to do it. I' ve tried to put my HTML inside "document.write()" calls and  even  use "createElement()/appendChild()/etc" when trying to mimic my HTML with JS, but had no positive results at all. If you still have patience to help me  (thanks!), I'll make a more specific question about that, if you prefer to answers there...
Comment: A new question would probably be the way to go, since the original one here has been answered (even if it wasn't answered the way you were hoping).  `createElement()/appendChild()` is preferable to `document.write()` for performance reasons.  You may also want to link to the new question from this one.
Comment: Ok, thanks! I Prefer to link it at the comment: http://stackoverflow.com/questions/32531579/how-to-make-a-static-html-as-a-chrome-extension


Find and instable subset of $\mathbb{R}$ with respect to closure and interior

Question: Let be $(\mathbb{R},\tau_E)$, with $\tau_E$ the euclidean topology. Find a set $A\subseteq \mathbb{R}$ such that $A,\overline{A},(\overline{A})^o,\overline{(\overline{A})^o},A^o,\overline{A^o},(\overline{A^o})^o$ are all different.
I'm struggling with this because intervals of the form $[a,b)$ aren't working, because, for example, the interior of the closure of $[a,b)$ is equal to the interior of $[a,b)$. I thought about something like $[a,b)\cap \mathbb{Q}$, but it also doesn't work. I didn't try with others unions or intersections because closure and interior don't behave very well with that (for example $\overline{A}\cap\overline{B} \neq \overline{A\cap B}$), and so they aren't easy to determine.
Any suggestions?
Answer: $A = \{1,\frac12, \frac13, \frac14,\ldots\} \cup (2,3) \cup (3,4) \cup \{4\frac12\} \cup [5,6] \cup ([7,8)\cap \Bbb Q)$ will do, e.g. So a combination of several ideas (intervals with gap, rational intervals, singletons, etc.).
(credits: Steen and Seebach, Counterexamples in Topology p.61 )


How do you switch between Alm and Celica's story in Fire Emblem Gaiden?

Question: I've been playing the original Fire Emblem Gaiden on an emulator for a while, and after clearing Zofia Castle, i talked to an NPC and was taken to Celica's story. I've finished the first few levels, but I'm wondering if it's possible to switch between Alm's and Celica's stories at will, as in an option in the menu, or do i always need to talk to an NPC?
Answer: Unfortunately, you'll need to play through quite a bit of story before you have that option without the NPC...it happens once they meet and decide to take different paths.
Comment: Yep, you can start switching between the parties at the beginning of Chapter 3 after Celica reaches Zofia's Castle
Comment: I don't believe so. You save at the end at Zofia Castle and Chapter 2 begins right away with Celica and ends as well at Zofia Castle. I might be mixing that up with the remake though.
Comment: Yep, and you'll be able to send items between the parties as well. So, you can switch after every battle or every few battles depending on if you want to pass along certain items or whatever.
Comment: when do they meet? i'm guessing Zofia Castle but i could be wrong...
Comment: does Alm need to be at Zofia Castle when Celica arrives? because i haven't checked, but i think you can go past Zofia Castle in chapter 1?
Comment: so i should be able to switch between parties at will once Celica Reaches Zofia Castle, right?


How can I add a Conditional Comment to my .cshtml MasterPage?

Question: I have two css IDs on different files, and I have to change the file with another only when the Program executes in Internet Explorer.
I have this file called "custom.css":
#employee-list {
    border-bottom: 1px solid #c1c1c1;
    border-top: 1px solid #c1c1c1;
    height: initial;
}

I need (I must not modify custom.css) to set "height" to "auto". But only if the page is rendered on IE. So I created a second css file called "customie.css":
#employee-list {
    border-bottom: 1px solid #c1c1c1;
    border-top: 1px solid #c1c1c1;
    height: auto;
}

After that I wrote this Conditional Comment in the  of my MasterPage .cshtml.

Problem is this: Conditional Comment doesn't work and the customie.css file overwrites the custom.css(which annuls itself) .
How can I apply height: auto only for IE pages?
Thank you,
Angelo
Comment: Possible duplicate of [


Capturing 'escape' keypress in ReactJS

Question: I have a React app with the following structure:
<App>
  <Input/>
  <Lists>
    <List>
    .
    .
    <List/>
   </Lists>
</App>

Each list has modify button which makes the list display an input field if clicked and some text otherwise by toggling modify(a boolean state).
What I want to achieve is that on clicking the escape key user should be able to switch between both (the input field and the text).
What I've tried:

Use document.addEventListener, but I could not access the event handler (which is in the List class), I couldn't add it inside the class itself as it assumes List.document to be a property.

Use the onKeyPress synthetic event

I couldn't figure out how to add it to the app component (I want the user to click escape anytime, not focus on the input field or something and then press escape)
I added it to the Input field (the one replaced by the text in List) but it didn't work (It works with the enter key, I used event.key==='Escape'). I console logged the event and nothing comes up while it works fine for the Enter key.
All suggestions appreciated :).
Comment: Possible duplicate of [How to detect Esc Key Press in React and how to handle it](https://stackoverflow.com/questions/37440408/how-to-detect-esc-key-press-in-react-and-how-to-handle-it)
Comment: Also, you can see the effect I want by clicking on the search input field on this question page and pressing escape
Answer: The escape key does not fire keypress event. You're going to want to listen for the keydown event.
class App extends PureComponent {
    // ...

    componentDidMount() {
        window.addEventListener('keydown', callback);
    }

    componentWillUnmount() {
        window.removeEventListener('keydown', callback);
    }

    // ...
}

Comment: Quite old answer but for anyone still looking for a reference about the difference bewteen `keypress` and `keydown`, apparently the `keypress` event is deprecated. Read here https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event and here https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event.
Comment: Like any docs, guides, papers or books that can be used for reference. Being a student i don't get to interact much with other developers so my list of useful and quality resources isn't very large.
Comment: That works, thanks. Also could you recommend any material that would be helpful for this kind of situation, I looked through the React docs and couldn't find this.
Comment: I'm not sure I understand what you mean by 'recommend any material that would be helpful for this kind of situation'. Can you elaborate?

Capturing 'escape' keypress in ReactJS


Finding and Copying Cells from One Workbook to Another

Question: I have a code, which mostly works, where I create a load of new sheets in workbook 1 with names from a list in workbook 1. It then copies cells from another sheet in the workbook and put the sheet names in cell D1. This works as expected.
I then want to look in another workbook for the new sheet name and copy some cells relating to its row number. My code opens workbook 2 (set as wbtemps) but then it doesn't seem to go to the specified sheet in workbook 2 and find the cell. I have tried splitting the code into sections and if I select the sheet beforehand it finds the cell, but then it still doesn't seem to copy the cells I want...
Any help would be appreciated. I've clearly missed something somewhere...
Set wb = ActiveWorkbook

InpFolder = ThisWorkbook.Path & "\Matrix_Inputs\"
MyValue1 = InputBox("WP1 Draft Matrix Filename", "Input", "Filename")

For Each cell In wsWithSheetNames.Range(Range("B5"), Range("B5").End(xlDown))
    With wb
      .Sheets.Add after:=.Sheets(.Sheets.Count)
      On Error Resume Next
      ActiveSheet.Name = RemoveSpecialCharactersAndTruncate(cell.Value)
      Sheets("Template").Cells.Copy ActiveSheet.Range("A1")
      ActiveSheet.Range("D1").Value = cell.Value

      Application.ScreenUpdating = False
      Set wbtemp = Workbooks.Open(InpFolder & MyValue1 & ".xls*", True, True) 'The code works up to here
      Set n = wbtemp.Sheets("2_Matrix Likely Pressures").Range("B1").EntireColumn.Find(cell.Value)
      wbtemp.Sheets("2_Matrix Likely Pressures").Range(.Range("E" & n.Row), .Range("E", n.Row).End(xlToRight)).Copy
      wb.ActiveSheet.Range("B21").PasteSpecial Transpose:=True
      wbtemp.Close False
      Set wbtemp = Nothing
      Application.ScreenUpdating = True
      If Err.Number = 1004 Then
         Debug.Print cell.Value & " already used as a sheet name"
      End If
      On Error GoTo 0
    End With
Next cell

Comment: The row `wbtemps.Sheets("2_Matrix Likely ...` has "anchors" in your range to the `With wb` statement.  I think you need to add a `With Worksheets("WhateverSheet")` ...otherwise the `.Range("E" & n.Row)` will refer to the active sheet...
Comment: I tried that but it still wasn't working. In the end I had to select both the worksheet and then one of the cells individually before it would find and copy the correct range (which is annoying because i shouldn't have to select stuff in this way). I'll post the code.
Answer: So in the end, the only way it seemed to work and find the range I wanted to copy was if I individually selected the worksheet and then the first cell of the range I wanted to copy.  I know you shouldn't have to use Select, but nothing else seemed to be working (I did a lot of searching on the internet). I've included the final code I used for the part that was giving me grief.
Set wbtemp = Workbooks.Open(InpFolder & MyValue1 & ".xls*", True, True)

Set n = wbtemp.Sheets("2_Matrix Likely Pressures").Range("B1").EntireColumn.Find(cell.Value)
With wbtemp
    .Sheets("2_Matrix Likely Pressures").Select
    .Sheets("2_Matrix Likely Pressures").Cells(n.Row, "E").Select
    .Sheets("2_Matrix Likely Pressures").Range(Selection, Selection.End(xlToRight)).Copy
End With
.ActiveSheet.Range("B21").PasteSpecial Transpose:=True
Application.CutCopyMode = False