text:
Q: The containers become shorter instead of overflowing I have made a messaging web app a while back and this summer i tried to make another with a bit of a different structure but ran into this issue where the spans' (messages') height shrunk instead of overflowing with scroll, and if i set a min-height they wouldn't get taller when the message was longer, so i used the source code of the old one and changed it a bit, but had the same issue. I would really like to know why this is happening and how to solve it.
I put the code on github, to be easier to see/try: https://github.com/Konstei/stack-overflow-code/.
I also made it into a running website using github's pages: https://konstei.github.io/stack-overflow-code/new/, https://konstei.github.io/stack-overflow-code/old/

A: I have referred your code and the issue is you have set overflow: hidden on *{} global selector. Since your direct span element after message-area div hasn't specified any overflow property, the overflow property from your global selector gets applied whose value is hidden and hence the overflowing content from inner span is being hidden. Just remove that property from your global selector and it should work.


text:
Q: How to pin certain files when using sort? Normally I am more creative with Unix commands and pipes, but not today.
So what I have is this:
collage.jpg
DCIM001.jpg
DCIM002.jpg

or this:
001.jpg
002.jpg
boston-collage.jpg

or sometimes
panama-collage.jpg
DCIM001.jpg
DCIM002.jpg

So now I use this command, which sorts the images properly.
find "Image Folder" -print0 | sort -z | tar cv --no-recursion --null -T -

But I would like to fix files with *collage.* as the first files of the sorting results to add them first to the tar archive I am creating off that list. Any idea?

A: If the end goal is to put the files in the archive in the desired order, then a simple solution is to create an archive with the files to sort first, then add the files to sort last to the existing archive. This can of course be generalized to more than two sort segments. This requires creating an archive file, you can't append to an archive in a pipeline.
tar cf foo.tar /images/*collage.*
find /images ! -name '*collage.*' -print0 | sort -z | tar rf foo.tar --null -T -

If you want to perform a custom sort with just basic utilities, one possible method is to add a prefix to the line indicating which group the item is a part of. Arrange for the prefix tags to be sorted in the order you want the groups to be sorted, and strip those prefixes afterwards.
find /images -print0 |
sed -z -e 's/.*collage\./1&/' -e 't' -e 's/^/2/' |
sort -z |
sed -z 's/^.//' |
tar …

Another approach would be to do the sorting in another language such as Perl, Python or Ruby where you can express a custom sort. If you do that, you could do the filename gathering and even the archive production in that language. Here's a Perl example that just does the sorting:
perl -e '$,=$\="\0"; print sort {
    $a =~ /collage\./ ? $b =~ /collage\./ ? $a cmp $b : 1 :
                        $b =~ /collage\./ ? -1 : $a cmp $b
  } @ARGV' /images/* | tar …

And another example that does the sorting via a temporary rewrite (it's called "Schwarztian transform" in the Perl community):
perl -e '$,=$\="\0"; print
    map {substr($_,1)}
    sort
    map {$_ = (/collage\./ ? "1" : "2") . $_}
    @ARGV' /images/* | tar …

Both of these examples will fail if the combined length of the file names exceeds the command line length limit. To avoid that, let Perl generate the file names.
perl -e '$,=$\="\0"; print
    map {substr($_,1)}
    sort
    map {$_ = (/collage\./ ? "1" : "2") . $_}
    glob("/images/*")' /images/* | tar …

If you need to generate file names recursively or apply some filtering, you can use File::Find. If you want to generate the archive in Perl, you can use Archive::Tar.

A: Here's my suggestion, using a temporary file:
tmpdir=$(mktemp)
find "Image Folder" -print0  > $tmpdir/temp
{ grep -z collage $tempdir/temp | sort -z;
  grep -z -v collage $tempdir/tmp | sort -z; } | \
  tar cv --no-recursion --null -T -
rm -rf $tmpdir

You could use something simpler for the temporary file, as long as you don't put it inside "Image Folder".
The basic idea behind this solution is to save find's results to a temporary file so that we can run two greps against it, sorting each grep result individually before combining them into the pipe for tar.

redpajama_set_name: RedPajamaStackExchange


text:
Q: judge if the content in the textbox changes I have a C# WPF question. I need to set a trigger event to examine that if the content in a textbox has been changed. No matter a user adds or deletes any character in the textbox, I can get this as a trigger event. How to do this? Thanks.

A: I've done something similar in past to animate text changes:
<TextBox Text="123">
    <TextBox.Triggers>
        <EventTrigger RoutedEvent="TextBox.TextChanged">
            <BeginStoryboard>
                <Storyboard FillBehavior="Stop">
                    <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                     To="0"
                                     Duration="0:0:.5" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </TextBox.Triggers>
</TextBox>

A: In XAML :
<TextBox TextChanged="TextBox_TextChanged"/>

Code Behind :
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    TextBox textBox = sender as TextBox;
}

'TextBox_TextChanged' this event will get triggered whenever user will change the text inside the textbox.


text:
Q: How to accumulate the data from multiple requests I have a service function that creating a number of requests:
getData(): Array<Observable<AxiosResponse<Data>>> {
    const data = [];
    for (let i = 1; i <= end; i++) {
      data.push(
        this.http.get<Data>(
          getUrl(i),
        ),
      );
    }
    return data;
  }

I have a controller function:
@Get()
get() {
    return this.appService.getData().forEach(x => {
      x.subscribe(y => {
        // need to accumulate the data from each request and return that as a single json
      });
    });
  }

How would you accumulate all the data from each request in controller method
and return that as a single json? Any thoughts?
If i do this:
  @Get()
  get() {
    const data = [];
    return this.appService.getData().forEach(x => {
      x.subscribe(y => {
        data.push(...y.data);
      });
      return data;
    });
  }

won't work as return data will be executed before the actual .subscribe(...)
y.data is an array of objects like:
[
 {key:"xyz", value:123 },
 {key:"abc", value:666 }
]

A: You can handle it better with rxjs operators.
import { Observable, range } from 'rxjs';
import { concatMap, toArray } from 'rxjs/operators';

const source: Observable<Data[]> = range(1, end)
  .pipe(
    concatMap((i: number) => this.http.get<Data>(getUrl(i))),
    toArray()
  );

Then you can subscribe to this source:
source.subscribe((data: Data[]) => {
  // Do some stuff with data
});


text:
Q: How to use variables in another shell script in my script? I have 2 shell scripts. In the first script I have kept the main method. In the 2nd script I have placed all the variables needed for the method since they are too many. Actually the main method needs 8 variables to run, likewise I have some 10 sets of 8 variables.
The main method in script1 has to run for every set of variables. My questions:
How to call these variables from script 2 to the main method in script 1 in order to execute the same? Can I try declaring each set of variables as a function and try to call inside script 1? How to do that?
Please help me with this. Thank you in advance.

A: you can keep the common variables alone in one script, say var.sh
and add
. var.sh #dot Space var.sh

in all the scripts where the variables are needed

A: I had a similar issue.
Thanks to Vignesh I made the following changes that worked for me:
Originally the variables were localized w/in the __RequestLogin.sh script:
#!/bin/bash
# Loading Data

sh __RequestLogin.sh
sh __ExecuteScript.sh

This Updated script allowes access to these variables w/in __ExecuteScript.sh:
#!/bin/bash
# Loading Data

. __RequestLogin.sh
. __ExecuteScript.sh


text:
Q: How to add Ubuntu into grub on CentOS Gist: I am trying to add a Ubuntu instance which is on the secondary hard drive to grub which is on the primary hard drive running CentOS.  grub version is GNU GRUB 0.97.
The primary hard drive contains CentOS release 6.8 (Final), x86_64 Linux 3.8.8.  The grub entry item for the kernel I am running is
title CentOS (3.8.8)
 root (hd0,0)
 kernel /vmlinuz-3.8.8 ro root=/dev/mapper/vg_sakplab100-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_sakplab100/lv_swap rd_NO_MD rd_LVM_LV=vg_sakplab100/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=128M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
 initrd /initramfs-3.8.8.img

I was given another hard drive that has Ubuntu on it (not sure which version).  If I run fdisk -l the secondary hard drive info is:
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          32      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2              32       60802   488134657    5  Extended
Partition 2 does not end on cylinder boundary.
Partition 2 does not start on physical sector boundary.
/dev/sdb5              32       60802   488134656   8e  Linux LVM

After mounting /dev/sdb1 I was able to view the /grub/grub.cfg file.  There are a number of menu items though I think the relevant entry is the following (the other ones had recovery in their title:
menuentry 'Ubuntu, with Linux 4.4.0-31-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-advanced-07c9c822-a9c3-4df5-8965-81b5af4e5dff' {
            recordfail
            load_video
            gfxmode $linux_gfx_mode
            insmod gzio
            insmod part_msdos
            insmod ext2
            set root='hd0,msdos1'
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  5ff7efa5-1a24-4e42-bba0-c3b1a4b86fd3
            else
              search --no-floppy --fs-uuid --set=root 5ff7efa5-1a24-4e42-bba0-c3b1a4b86fd3
            fi
            echo    'Loading Linux 4.4.0-31-generic ...'
            linux   /vmlinuz-4.4.0-31-generic root=/dev/mapper/dhcp--10--33--42--96--vg-root ro
            echo    'Loading initial ramdisk ...'
            initrd  /initrd.img-4.4.0-31-generic
    }

I have tried creating a few menu items, but it doesn't boot the Ubuntu instance.  Does anyone know how I would create a new menuitem in grub so I can boot the Ubuntu instance?
Thanks

A: Okay, after a great number of failures and days trying to make it work, I did find one solution.  So, this is the menuitem I have.  I am sure it isn't complete, but at least Ubuntu is booting.
title Ubuntu
        root (hd1,0)
        kernel /vmlinuz-4.4.0-59-generic root=/dev/mapper/dhcp--10--33--42--96--vg-root ro
        module /initrd.img-4.4.0-59-generic


text:
Q: Categorizing data based on group and according to a separate column What I'm asking here feels pretty complicated so bear with me as I try my best to explain it.
This spreadsheet is data on bird nests. Each nest has a specific identifier, ID_NIU. For this identifier, there can be anywhere from 1-3 rows which each represent a specific egg. The amount of rows corresponds to the count, which just tells me how many eggs are in each nest. Don't worry really about what PVC is, it shouldn't matter.
Egg_order is exactly what it sounds like; it's the order the eggs were laid in. If the value is 9, that means that we don't know the order. I need two things to happen in the most efficient way possible.

*

*I want a column made that shows one of three things. Let's call the column Status. I want Status to either be the word non, complete, or estimated.
a) if all of the egg_order in a ID_NIU is 9, give it the value: none
b) if all of the egg_order shows a number, like 1, 2, or 3 (so basically a complete set), give it the value: complete
c) there can be an instance where only the THIRD egg is known. if that happens, give the value: estimated (this happens for ID_NIU 426 for example)

*For the estimated ID_NIU (based on the categorization above), I want the two 9 values to be replaced by 1 or 2. Basically, I just want to assign them a random order.
Here is my data
> dput(nests1994)
structure(list(ID_NIU = c(421L, 421L, 421L, 422L, 422L, 423L,
423L, 423L, 424L, 424L, 425L, 425L, 425L, 426L, 426L, 426L, 427L,
427L, 428L, 428L, 428L, 429L, 429L, 429L, 430L, 430L, 431L, 431L,
431L, 432L, 432L, 432L, 433L, 433L, 433L, 434L, 434L, 434L, 435L,
435L, 435L, 436L, 436L, 437L, 437L, 437L, 438L, 438L, 438L, 439L,
439L, 439L, 440L, 440L, 440L, 441L, 441L, 441L, 442L, 442L, 442L,
443L, 443L, 443L, 444L, 445L, 445L, 445L, 446L, 446L, 446L, 447L,
447L, 447L, 448L, 448L, 448L, 449L, 449L, 449L, 450L, 450L, 451L,
451L, 451L, 452L, 452L, 452L, 453L, 453L, 453L, 454L, 454L, 454L,
456L, 456L, 456L, 457L, 457L, 457L, 458L, 458L, 458L, 459L, 460L,
460L, 460L, 461L, 461L, 461L, 462L, 462L, 462L, 463L, 463L, 463L,
464L, 464L, 464L, 465L, 465L, 465L, 466L, 466L, 466L, 467L, 467L,
467L, 468L, 468L, 468L, 469L, 469L, 469L, 470L, 470L, 470L, 471L,
471L, 471L, 472L, 472L, 472L, 473L, 473L, 473L, 474L, 474L, 474L,
475L, 475L, 475L, 476L, 476L, 476L, 477L, 477L, 477L, 478L, 478L,
478L, 479L, 479L, 479L, 480L, 480L, 480L, 481L, 481L, 481L, 482L,
482L, 483L, 484L, 484L, 484L, 485L, 485L, 485L, 486L, 486L, 486L,
487L, 488L, 488L, 488L, 489L, 489L, 489L, 490L, 490L, 490L, 491L,
492L, 492L, 492L, 493L, 493L, 493L, 494L, 494L, 494L, 495L, 495L,
496L, 497L, 497L, 497L, 498L, 498L, 555L, 555L, 555L, 556L, 556L,
556L, 557L, 557L, 557L, 558L, 558L, 558L, 559L, 559L, 559L, 560L,
560L, 560L, 561L, 561L, 561L, 562L, 562L, 562L, 563L, 563L, 563L,
564L, 564L, 564L, 565L, 565L, 565L, 566L, 566L, 567L, 567L, 567L,
572L, 572L, 572L, 573L, 573L, 573L, 574L, 574L, 574L, 575L, 575L,
575L, 576L, 576L, 576L, 577L, 577L, 577L, 578L, 578L, 578L, 579L,
579L, 579L, 594L, 594L, 594L, 595L, 595L, 597L, 597L, 597L, 598L,
598L, 599L, 599L, 612L, 612L, 612L, 613L, 614L, 614L, 615L, 615L,
615L, 616L, 616L, 617L, 617L, 618L, 618L, 618L, 620L, 620L, 620L,
622L, 622L, 622L, 624L, 624L, 624L, 625L, 625L, 625L, 626L, 626L,
626L, 627L, 627L, 627L, 628L, 628L, 628L, 629L, 629L, 629L, 633L,
633L, 633L, 661L, 661L, 662L, 662L, 662L, 663L, 663L, 663L, 664L,
664L, 664L, 665L, 665L, 665L, 666L, 666L, 666L, 667L, 667L, 667L,
668L, 668L, 668L, 669L, 669L, 669L, 670L, 673L, 673L, 674L, 674L,
674L, 675L, 675L, 675L, 676L, 676L, 676L, 677L, 677L, 677L, 679L,
679L, 679L, 680L, 680L, 681L, 681L, 682L, 682L, 682L, 683L, 683L,
683L, 684L, 684L, 684L, 685L, 685L, 685L, 686L, 686L, 686L, 687L,
687L, 687L, 688L, 688L, 688L, 689L, 689L, 689L, 690L, 690L, 690L,
691L, 691L, 691L, 692L, 692L, 692L, 791L, 793L, 793L, 793L, 794L,
794L, 794L), Egg_order = c(1L, 2L, 3L, 1L, 2L, 1L, 2L, 3L, 9L,
9L, 1L, 2L, 3L, 9L, 9L, 3L, 1L, 2L, 1L, 2L, 3L, 1L, 2L, 3L, 9L,
9L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 9L, 9L, 3L, 1L, 2L, 3L, 1L, 2L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 1L, 3L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 9L,
9L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 9L, 9L, 3L, 9L, 9L,
3L, 1L, 2L, 1L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 1L, 2L,
3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L, 2L, 1L, 1L, 2L, 3L, 1L, 2L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 1L, 2L, 3L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 9L, 9L,
9L, 9L, 9L, 9L, 1L, 2L, 3L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L), PVC = c(NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, "VNRB", "VNRB", "VNRB", "VRNB", "VJNZ", "VJNZ",
"VBRN", "VBRN", "VBRN", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "VRJA", "VRJA",
"VRJA", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA), volume = c(61.32180296484, 59.19889832633, 61.23059740728,
56.63892668014, 51.205468528125, 56.00474267058, 57.351199948,
55.54398620844, 55.70776780426, 59.72462114472, 59.37718398586,
60.587478792225, 56.43498962184, 62.26391957376, 65.6381047725,
60.0863309088, 64.85091746762, 60.069900631215, 59.4870511833,
57.0005821184, 54.02542528228, 64.73294631594, 66.3508141931,
62.32245834917, 59.02536867768, 66.01653978486, 60.083474171985,
59.684503147035, 60.074662267125, 66.157670868, 64.14003788994,
64.72516250826, 65.43246736143, 64.76946298056, 59.525282639625,
64.83564670912, 63.10304890812, 59.162532552, 58.56437083104,
58.51350718936, 60.47152094199, 59.46823641825, 56.529403558675,
62.59313732544, 62.86182498192, 57.4115839709, 67.488455384,
70.67781620074, 69.066635590395, 61.4648739568, 61.793295785165,
57.141971818575, 57.86003450088, 66.8841551616, 54.2789360685,
57.372537480805, 54.7688704779, 52.69147903188, 65.717390741625,
62.0012941321, 65.46154452084, 67.54235220404, 68.589406082885,
61.3698407482, 63.22307904, 73.52276685129, 67.7605920462, 64.9948112,
67.39168007286, 59.96388195, 53.75359412352, 61.2940024137, 62.371936324995,
58.27667400405, 61.00711558812, 60.68288712456, 57.22440302628,
63.7912474123, 60.71915094122, 56.17566934848, 61.03055081916,
54.48216125544, 66.59971341696, 62.914325579595, 60.06312844672,
63.18295147084, 64.13649043698, 54.61024964874, 58.69608972288,
60.093902811735, 55.80205524, 66.35080327284, 64.56965497461,
61.61846995898, 58.962280801605, 54.114679926855, 51.32463260472,
66.763949034375, 66.60433698016, 57.9960342297, 65.65621056552,
63.50880453696, 59.93124997824, 57.28414633702, 68.946491941355,
69.53883617025, 60.591651012, 66.51464159232, 62.83111160808,
59.31893121786, 66.012559966525, 65.39124391634, 61.63458903486,
64.527880462335, 65.626394311215, 62.28965754018, 70.66749192426,
63.43547903014, 64.813554775305, 63.30184211559, 70.84510569583,
65.07164575845, 62.649526678335, 62.07063053623, 62.97169774328,
58.15387242406, 53.775184290885, 56.15800014276, 63.84106319499,
58.0287792375, 55.39166100811, 67.06270568448, 64.243137862495,
61.79094929648, 59.278741074, 57.54892103096, 54.4025191125,
68.63881395584, 65.99016072992, 61.71771694458, 56.032400073,
59.67369896548, 55.55819890452, 59.74163316768, 64.678925498375,
59.632117506, 58.352016509955, 60.27802279574, 58.15564421248,
54.715232384505, 50.918826189105, 47.311723228, 60.24653229088,
62.9644540122, 58.28735951144, 67.67941018152, 69.600416585815,
63.089844045435, 65.63935543424, 65.14029179418, 56.9031766875,
63.86502197092, 68.50758708486, 66.796303493015, 62.558885508,
62.68239015272, 59.33579351744, 55.87331866844, 57.779988655095,
57.4011795375, 68.10503423888, 62.19287447292, 62.29393628778,
59.54119382656, 62.45667881766, 55.88073186822, 57.19354986962,
60.62398562056, 53.222328389025, 64.17951754275, 63.46964125062,
54.25258541904, 53.85227447392, 62.667268102495, 65.9379849576,
57.10713872136, 57.16095228242, 62.99889140907, 56.223702755685,
60.56377100622, 62.599569594775, 60.431980928505, 64.63537220204,
56.8203240696, 59.08446543104, 58.51081609896, 64.82126705664,
66.14591297517, 58.5345118041, 69.089203199115, 70.813911929975,
63.129352317125, 62.864854839, 61.69528927, 62.66206973912, 60.8490630645,
62.4062419139, 57.63741735136, 60.30546945984, 56.07545557164,
59.79910741368, 63.51030603488, 64.244819090745, 63.75469472867,
63.14277341512, 62.42052636864, 55.59848049998, 59.7551696205,
55.20343376232, 60.1519184288, 63.59769165096, 55.71145827984,
61.30230509475, 56.592753090795, 58.582661261135, 62.62695713592,
57.883156922925, 63.30930401034, 70.73778793872, 63.12040753536,
67.936748153665, 62.77154643396, 56.5502664375, 56.676188799945,
58.8897719179, 65.12593779432, 59.877119390625, 57.5611109065,
60.50238159481, 51.421804965475, 60.702761718885, 57.857797190545,
51.76334378277, 54.79479091296, 58.036980255275, 64.08885388248,
58.9371852075, 48.065806272, 58.67924387256, 60.84988863732,
55.348644357, 60.809342925895, 56.891942571875, 55.16386692882,
64.568934378585, 64.46865534354, 58.50186242472, 63.15022238365,
57.54034615239, 55.58259809634, 58.5784229184, 60.76172518406,
48.88389467288, 62.93741556969, 65.16504696727, 58.68311406489,
69.20272240048, 67.510966264695, 63.60102202762, 58.3678358505,
62.78118931648, 50.330023359885, 62.36847890792, 61.459224858675,
58.101076579725, 59.849752446945, 60.89355981824, 70.38978991616,
64.78264300106, 63.851029018155, 56.76600004895, 56.36582838225,
57.656775733025, 57.07565196264, 62.78661705624, 58.80025808496,
62.473741510995, 52.27790378878, 61.65878807979, 69.9430447975,
62.6025867725, 70.091062468875, 55.31320436328, 57.091324193955,
59.88525953314, 62.81526020564, 58.817878683495, 62.600767032615,
58.88047597916, 52.271088452865, 56.4597812485, 56.49555113631,
58.59997224246, 60.56042671782, 63.62604866394, 54.689279244925,
64.08885388248, 58.9371852075, 48.065806272, 58.67924387256,
60.84988863732, 55.348644357, 60.809342925895, 56.891942571875,
55.16386692882, 64.568934378585, 64.46865534354, 58.50186242472,
58.5784229184, 60.76172518406, 48.88389467288, 58.3678358505,
62.78118931648, 50.330023359885, 59.36245744586, 54.203960064,
46.80082663263, 53.7591748284, 56.45379150432, 58.18760585216,
51.57368944, 61.17471364797, 55.666216654855, 63.638574522745,
62.859327856115, 55.71589759736, 62.194594993445, 60.1319744625,
63.2669776704, 52.67023014204, 53.95264575354, 52.19798075712,
64.12727076352, 58.722978252375, 61.129745915095, 60.35801243148,
53.570630477, 60.42489898518, 58.83334580928, 58.579377003125,
53.63492716368, 62.198328240205, 59.16052306314, 63.03268283832,
53.4038938596, 59.3680844275, 64.01347375464, 53.247602726, 58.656773926835,
62.406351950215, 60.794167405875, 57.26072539408, 58.41489611248,
59.89059546628, 58.27766415192, 55.752501203565, 52.67023014204,
53.95264575354, 52.19798075712, 68.84950003552, 72.3285771465,
69.97203251224, 58.01968982825, 59.19871381875, 51.0058844818375,
55.871632176, 65.005463693925, 61.884602267345, 59.36399202272,
55.61013283256, 63.119620683, 65.19505402688, 65.256547524625,
60.287946825, 63.546970479, 55.83345829936, 57.83224146336, 62.76964734468,
63.3625642155, 61.089794891755, 67.23069090625, 59.524399629225,
61.86069234304, 58.52247185176, 60.14631038544, 55.03887100416,
57.43869855744, 60.64346718786, 56.9845087625, 60.2844366375,
57.7861645641, 54.31168897016, 52.9873440048, 53.708649730785,
65.219353008, 57.88846182528, 54.873862054245, 53.072090597655,
78.369980834265, 57.516393056295, 61.3480561875, 53.67391420878,
57.29314740352, 54.1968033555, 52.85290720594), Year = c("1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994"), count = c(3L,
3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 1L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 1L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 2L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 2L,
2L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L)), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -415L), groups = structure(list(
    ID_NIU = c(421L, 422L, 423L, 424L, 425L, 426L, 427L, 428L,
    429L, 430L, 431L, 432L, 433L, 434L, 435L, 436L, 437L, 438L,
    439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L,
    449L, 450L, 451L, 452L, 453L, 454L, 456L, 457L, 458L, 459L,
    460L, 461L, 462L, 463L, 464L, 465L, 466L, 467L, 468L, 469L,
    470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L,
    480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L, 488L, 489L,
    490L, 491L, 492L, 493L, 494L, 495L, 496L, 497L, 498L, 555L,
    556L, 557L, 558L, 559L, 560L, 561L, 562L, 563L, 564L, 565L,
    566L, 567L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L,
    594L, 595L, 597L, 598L, 599L, 612L, 613L, 614L, 615L, 616L,
    617L, 618L, 620L, 622L, 624L, 625L, 626L, 627L, 628L, 629L,
    633L, 661L, 662L, 663L, 664L, 665L, 666L, 667L, 668L, 669L,
    670L, 673L, 674L, 675L, 676L, 677L, 679L, 680L, 681L, 682L,
    683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L, 691L, 692L,
    791L, 793L, 794L), .rows = structure(list(1:3, 4:5, 6:8,
        9:10, 11:13, 14:16, 17:18, 19:21, 22:24, 25:26, 27:29,
        30:32, 33:35, 36:38, 39:41, 42:43, 44:46, 47:49, 50:52,
        53:55, 56:58, 59:61, 62:64, 65L, 66:68, 69:71, 72:74,
        75:77, 78:80, 81:82, 83:85, 86:88, 89:91, 92:94, 95:97,
        98:100, 101:103, 104L, 105:107, 108:110, 111:113, 114:116,
        117:119, 120:122, 123:125, 126:128, 129:131, 132:134,
        135:137, 138:140, 141:143, 144:146, 147:149, 150:152,
        153:155, 156:158, 159:161, 162:164, 165:167, 168:170,
        171:172, 173L, 174:176, 177:179, 180:182, 183L, 184:186,
        187:189, 190:192, 193L, 194:196, 197:199, 200:202, 203:204,
        205L, 206:208, 209:210, 211:213, 214:216, 217:219, 220:222,
        223:225, 226:228, 229:231, 232:234, 235:237, 238:240,
        241:243, 244:245, 246:248, 249:251, 252:254, 255:257,
        258:260, 261:263, 264:266, 267:269, 270:272, 273:275,
        276:277, 278:280, 281:282, 283:284, 285:287, 288L, 289:290,
        291:293, 294:295, 296:297, 298:300, 301:303, 304:306,
        307:309, 310:312, 313:315, 316:318, 319:321, 322:324,
        325:327, 328:329, 330:332, 333:335, 336:338, 339:341,
        342:344, 345:347, 348:350, 351:353, 354L, 355:356, 357:359,
        360:362, 363:365, 366:368, 369:371, 372:373, 374:375,
        376:378, 379:381, 382:384, 385:387, 388:390, 391:393,
        394:396, 397:399, 400:402, 403:405, 406:408, 409L, 410:412,
        413:415), ptype = integer(0), class = c("vctrs_list_of",
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -151L), .drop = TRUE))

If you have questions please ask.

A: We could use if/else or case_when to create the column 'Status' based on the conditions
library(dplyr)
nests1994 <- nests1994 %>%
 group_by(ID_NIU) %>%
 mutate(Status = case_when(all(Egg_order %in% 9) ~ 'none',
                    all(Egg_order %in% c(1, 2, 3)) ~ 'complete',
                    all(setdiff(Egg_order, 9) == 3) ~ 'estimated' )) %>%
 mutate(estimated_Egg_order = replace(Egg_order,
      Egg_order == 9, seq_len(sum(Egg_order == 9)))) %>%
 ungroup

-output
> nests1994 %>% filter(Egg_order == 9)
# A tibble: 195 × 8
   ID_NIU Egg_order PVC   volume Year  count Status    estimated_Egg_order
    <int>     <int> <chr>  <dbl> <chr> <int> <chr>                   <int>
 1    424         9 <NA>    55.7 1994      2 none                        1
 2    424         9 <NA>    59.7 1994      2 none                        2
 3    426         9 <NA>    62.3 1994      3 estimated                   1
 4    426         9 <NA>    65.6 1994      3 estimated                   2
 5    430         9 <NA>    59.0 1994      2 none                        1
 6    430         9 <NA>    66.0 1994      2 none                        2
 7    448         9 <NA>    61.0 1994      3 estimated                   1
 8    448         9 <NA>    60.7 1994      3 estimated                   2
 9    476         9 <NA>    60.2 1994      3 estimated                   1
10    476         9 <NA>    63.0 1994      3 estimated                   2
# … with 185 more rows

A: How about this egg_status (ad 1), estimated_Egg_order (ad 2):
nest1994 |>
  group_by(ID_NIU) |>
  mutate(egg_status = case_when(all(Egg_order == 9) ~ "none",
                                any(Egg_order == 9) ~ "estimated",
                                TRUE ~ "complete")
         ) |>
  mutate(estimated_Egg_order = if_else(egg_status == "estimated" & Egg_order == 9, row_number(), Egg_order)) |>
  ungroup()

Output:
# A tibble: 30 × 8
   ID_NIU Egg_order PVC   volume Year  count egg_status estimated_Egg_order
    <int>     <int> <chr>  <dbl> <chr> <int> <chr>                    <int>
 1    421         1 NA      61.3 1994      3 complete                     1
 2    421         2 NA      59.2 1994      3 complete                     2
 3    421         3 NA      61.2 1994      3 complete                     3
 4    422         1 NA      56.6 1994      2 complete                     1
 5    422         2 NA      51.2 1994      2 complete                     2
 6    423         1 NA      56.0 1994      3 complete                     1
 7    423         2 NA      57.4 1994      3 complete                     2
 8    423         3 NA      55.5 1994      3 complete                     3
 9    424         9 NA      55.7 1994      2 none                         9
10    424         9 NA      59.7 1994      2 none                         9
11    425         1 NA      59.4 1994      3 complete                     1
12    425         2 NA      60.6 1994      3 complete                     2
13    425         3 NA      56.4 1994      3 complete                     3
14    426         9 NA      62.3 1994      3 estimated                    1
15    426         9 NA      65.6 1994      3 estimated                    2
16    426         3 NA      60.1 1994      3 estimated                    3
17    427         1 NA      64.9 1994      2 complete                     1
18    427         2 NA      60.1 1994      2 complete                     2
19    428         1 NA      59.5 1994      3 complete                     1
20    428         2 NA      57.0 1994      3 complete                     2

A: My solution first groups by ID_NIU, then uses some logic to determine the rest. It also replaces the earlier values in estimated columns, and includes some extra row_number and rev(row_number()) to catch potential values outside of 1, 2, and 3:
nests1994 %>%
  group_by(ID_NIU) %>%
  mutate(status = case_when(
    all(Egg_order == 9) ~ "None",
    Egg_order == row_number() | Egg_order == rev(row_number()) | Egg_order %in% c(1, 2, 3) ~ "Complete",
    first(Egg_order) == 9 & last(Egg_order) != 9 ~ "Estimated",
    TRUE ~ "Miscellaneous"
  ),
  Egg_order = if_else(status == "Estimated" & Egg_order == 9, row_number(), Egg_order))


text:
Q: Getting an exception error with my vb.net code Getting a $exception error ""Public member 'Text' on type 'Selection' not found." I'm using visual studio and trying to make a form when click on a button it will scrape text from an open outlook email. shoots out an error when calling emailbody.Text. I'm very new to visual basic so please be easy on me lol. Any help will be great thanks.
 Private Sub Pull_info_Click(sender As Object, e As EventArgs) Handles Pull_info.Click
    Dim myOlApp As Outlook.Application = New Outlook.Application
    Dim myOlExp As Outlook.Explorer = myOlApp.ActiveExplorer
    Dim myOlSel As Outlook.Selection = myOlExp.Selection
    'Dim oMail As Outlook.MailItem
    Dim emailbody As Object

    emailbody = myOlSel

    Dim regex As Regex = New Regex("Ticket\sNumber:\s(.*?)\s-")
    Dim match As Match = regex.Match(emailbody.Text)
    If match.Success Then
        MsgBox(match.Value)
    End If
End Sub

A: The selection object appears to have no text property:  https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.selection_members(v=office.14).aspx
You could use the debugger and see what property/value combinations are available to you, but the documentation I linked to helps also.  You can also see what comes back from ToString() instead of Text, maybe it'll give you what you need.


text:
Q: What events to use for update of custom prices upon "Proceed to checkout" and "Submit Order" I have made a module that sets custom prices of quote items upon a cart update. For that I use these events:
checkout_cart_product_add_after
sales_quote_remove_item
checkout_cart_update_items_after

It works fine but the problem is that the custom prices are not recalculated if user proceeds to checkout or sends the order.
I would like them to be recalculated there as well because they are derived from data that possibly might have been changed from the last cart update (user group, product base price, etc.). Magento recalculates its prices this way if a custom price is not set so I would like to achieve the same behaviour.
Are there the appropriate events to hook in to invoke the recalculation in my module?
EDIT: In fact, it seems that Magento recalculates prices even after normal page reloads in cart. I guess I don't really need this even though it is more correct.

A: I use the event salesQuoteCollectTotalsBefore set the price on the product and then it is transfered to the quoteItem:
public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
{
    /* @var $quote Mage_Sales_Model_Quote */
    $quote = $observer->getQuote();
    foreach ($quote->getAllItems() as $quoteItem) {
        if (true) {
            /* @var $quoteItem Mage_Sales_Model_Quote_Item */
            $product = $quoteItem->getProduct();
            $price = $helper->getPriceWithoutTax($quoteItem);
            $product->setPrice($price);
        }
    }
}


text:
Q: Mask a whole animation happening in a UIImageView I need to mask a whole animation that takes place in a UIImageView. I tried subclassing the UIImageView and doing the masking in its drawRect call but that doesn't get called on every frame of the animation as I expected (it doesn't get called at all actually) even though the animation plays fine.
Anyone has any experience on this?

A: Since the CIFilter public API is missing on iPhone OS, there's no way to do compositing using UIView or CALayer.
This means that the answer is: You cannot mask the contents of UIImageView, animated or not.
I've filed a radar bug request because I feel that the addition of the CIFilter API would be a great enhancement to Cocoa Touch and expand the possibilities of UIView/CALayer based UI design a lot. At the moment, if you want to do compositing on the iPhone, you have to use Quartz (slow) or OpenGL (doing everything yourself).
If you agree on the usefulness of CIFilters for iPhone OS, please consider filing a request on  radar. The more requests, the sooner Apple will care about it.


text:
Q: Creating HTML file via heredoc in Perl fails with Bareword error I'm trying to figure out how to create a simple HTML file using a heredoc in Perl but I keep getting
Bareword found where operator expected at pscratch.pl line 12, near "<title>Test"
    (Missing operator before Test?)
Having no space between pattern and following word is deprecated at pscratch.pl line 13.
syntax error at pscratch.pl line 11, near "head>"
Execution of pscratch.pl aborted due to compilation errors.

I can't figure out what the issue is. This is the script in its entirety:
use strict;
use warnings;

my $fh;
my $file = "/home/msadmin1/bin/testing/html.test";

open($fh, '>', $file) or die "Cannot open $file: \n $!";

print $fh << "EOF";

    <title>Test</title>

This is a test

EOF

close($fh);

I've tried using both single and double quotes around EOF. I've also tried escaping all of the <> tags which didn't help.
What should I be doing to prevent this error?
EDIT
I know there are modules out there that will simplify this, but I'd like to know what the problem is with this before I simplify the task with a module.
EDIT 2
The error seems to indicate that Perl is looking at the text within the heredoc as a substitution due to the / in the closing tags. If I escape them part of the error goes away regarding space between pattern and following word but the rest of the error remains.

A: Remove the space infront of the << "EOF"; as it is not interacting nicely with the filehandle print.
Here are various working/non-working variants:
#!/usr/bin/env perl

use warnings;
use strict;

my $foo = << "EOF";
OK: with space into a variable
EOF

print $foo;

print <<"EOF";
OK: without space into a regular print
EOF

print << "EOF";
OK: with space into a regular print
EOF

open my $fh, ">foo" or die "Unable to open foo : $!";
print $fh <<"EOF";
OK: without space into a filehandle print
EOF

# Show file output
close $fh;
print `cat foo`;

# This croaks
eval '
print $fh << "EOF";
with space into a filehandle print
EOF
';
if ($@) {
    print "FAIL: with space into a filehandle print\n"
}

# Throws a bitshift warning:
print "FAIL: space and filehandle means bitshift!\n";
print $fh << "EOF";
print "\n";

Output
OK: with space into a variable
OK: without space into a regular print
OK: with space into a regular print
OK: without space into a filehandle print
FAIL: with space into a filehandle print
FAIL: space and filehandle means bitshift!
Argument "EOF" isn't numeric in left bitshift (<<) at foo.pl line 42.
152549948


text:
Q: Should I use an ORM to model a large tree structure? We are developing a Video on demand system where users can upload videos. We want to create a tree structure of the archive of videos where the user can create folders of artists/albums etc and store the videos under the correct folders. Like all tree structures, the user will be able to move videos between folders, delete sub trees, copy videos and move sub trees and children.
The tree could have 10s of 1000s of videos and folders.
My question is would an ORM be suitable for a tree like structure of this size?

A: Assuming that your tree structure in the database is going to be some table like:
FolderId | ParentFolderId | FolderName
Why not?
The question is not should you use ORM or not, the question is what problem do you have that ORM is a right tool to solve.


text: Q: How can i apply rules to outlook using python? I am trying to extract emails from outlook to be run through supervised classification. From there, if the email falls into a specific classification, it should have a generic response for that email based on the classification. The problem I am facing is on how to extract the emails and reply to them. I am using win32com library to extract successfully but will need to change to another method because not all the computers running this project will have python installed. If possible, i would like it to work like outlook rules but a special AI rule. What methods are available to achieve this? Thanks.


text:
Q: Can you modify relationship conditions in SQLAlchemy after initialization? Overview
I'm working on a project which stores Artists in a database. Each time one or more artists are added to the database, a "transaction" is created for which the user can remove to undo that particular batch. Finally, each user can define one or more "profiles", storing separate lists of Artists in each (defined in var active_profile).
Using FKs with ondelete="CASCADE", when a Profile is deleted, all transactions are deleted and subsequently any artists belonging to those transactions are deleted.
active_profile = 2

class Profile(Base):
    __tablename__ = 'profile'

    id = Column(Integer, primary_key=True)
    name = Column(String)

    def __init__(self, name):
        self.name = name

class Transaction(Base):
    __tablename__ = 'transaction'

    id = Column(Integer, primary_key=True)
    timestamp = Column(Integer, nullable=False)
    profile_id = Column(
                    Integer,
                    ForeignKey('profile.id', ondelete="CASCADE"),
                    nullable=False,
                 )
    artist = relationship(
                "Artist",
                cascade="delete",
                back_populates='transaction',
             )

    def __init__(self):
        self.timestamp = int(time.time())
        self.profile_id = active_profile

class Artist(Base):
    __tablename__ = 'artist'

    id = Column(Integer, primary_key=True)
    art_id = Column(Integer)
    art_name = Column(String)
    txn_id = Column(
                Integer,
                ForeignKey('transaction.id', ondelete="CASCADE"),
                nullable=False,
             )
    transaction = relationship("Transaction", back_populates="artist")

    def __init__(self, art_id, art_name, txn_id):
        self.art_id = art_id
        self.art_name = art_name
        self.txn_id = txn_id

The Goal
Most queries to the database will select where the profile_id is equal to the active_profile so I'm trying to figure out if there is a way to integrate this requirement into a relationship without having to specify it each time I query the database.

I have tried specifying primaryjoin in the relationship for the Transaction class but it seems to set the primaryjoin condition only once and doesn't change if active_profile is changed. I incorrectly assumed the relationship would be re-evaluated each time the class was called:
artist = relationship(
    "Artist",
    cascade="delete",
    back_populates="transaction",
    primaryjoin=f"and_(Transaction.id == Artist.txn_id, Transaction.profile_id == {active_profile}",
)

If this was re-evaluated each time, this would be exactly what I need.
Question
Is there a way to force the relationship to be re-evaluated and if not, is there any other option without the need to append .where(Transaction.profile_id == active_profile) to each query?


text:
Q: How to generate 6 digit random number based on current date & time what logic i can use to generate 6 digit random number based on current date and time. suppose i want to generate a 6 digit random number which will be valid up to 5 second. after 5 second if anyone input that random number into system then system will say it is expire. one thing i need to mention that there will be no database interaction. i don't want to generate random number and store it in database table. 5 second validity logic will be embedded in generated random number as a result i can validate it later that whether it is generate before 5 sec or not.
i asked this question in another forum and they gave me code to generate  6 digit random number based on current date and time like
var random = new Random(System.DateTime.Now.Millisecond);
int randomNumber = random.Next(1, 500000);

is it ok? because i am not advance developer.if i can generate 6 digit random number using the above logic then later how can i determine programatically that the number was generate before 5 sec or not. basically i need two routine one for generating 6 digit random number based on current date & time and another routine will check that generated number was generated before 5 sec or not.
please guide me with concept and code. thanks

A: If it is the same process which stays during these five seconds, you could just store the key inside an hashtable, and to validate it check that it is inside the hashtable. Also keep in the hashtable the creation time of the key, and periodically clean that hashtable (removing obsolete keys and associated data).
Of course you'll need to generate that key either "randomly" or "cryptographically"

A: You can't reverse the process of random number generation to determine when the number were generated, particularly if you're seeding Random with milliseconds.
Getting a 6-digit random number:
int randomNumber = random.Next(0, 1000000);


text:
Q: How to get all text children of an element in cElementTree? I'm using the cElementTree module in Python to get the text child of an XML tree, using the text property. But it seems to work only for the immediate text children (see below).
$ python
...
>>> import xml.etree.cElementTree as ET
>>> root = ET.XML('<root><elm key="value">Some text</elm>More text</root>')
>>> root.text
>>> root = ET.XML('<root>Text 1<elm key="value">Text</elm>Text 2<elm2 />Text 3</root>')
>>> root.text
'Text 1'
>>>

Is it possible to retrieve all immediate text children of a given element (maybe as a list, i.e. ['More text'] and ['Text 1', 'Text 2', 'Text 3'] in the above examples) using the cElementTree module?

A: Use xml.etree.ElementTree.Element.itertext:
>>> import xml.etree.cElementTree as ET
>>> root = ET.XML('<root><elm key="value">Some text</elm>More text</root>')
>>> list(root.itertext())
['Some text', 'More text']
>>> root = ET.XML('<root>Text 1<elm key="value">Text</elm>Text 2<elm2 />Text 3</root>')
>>> list(root.itertext())
['Text 1', 'Text', 'Text 2', 'Text 3']

UPDATE
To get immediate text children, you also need to access tail of child nodes:
>>> root = ET.XML('<root><elm key="value">Some text</elm>More text</root>')
>>> ([root.text] if root.text else []) + [child.tail for child in root]
['More text']
>>> root = ET.XML('<root>Text 1<elm key="value">Text</elm>Text 2<elm2 />Text 3</root>')
>>> ([root.text] if root.text else []) + [child.tail for child in root]
['Text 1', 'Text 2', 'Text 3']


text:
Q: How to custom push notification notice? How to  custom push notification button for when presented with the option to select to "Allow" or "Don't allow" push notification? Is it possible?
Thanks.

A: You can't customise the alert displayed that asks the user whether to Allow push notifications or not.
What some apps do is show an alert or image explaining what the push notifications are for, and when you press allow it shows the system Allow/Don't Allow alert.


text:
Q: Programmatic Login from 3rd Party site I'm trying to do a sort of SSO/programmatic login solution for our wordpress site from our separate web application. I don't have a lot of experience with wordpress so I assume there's something I'm missing or have configured incorrectly.
First here is my testing code that works great when I hit it directly IE www.mywordpresssite.com/test_login.php
test_login.php:
<?php
require __DIR__ . '/wp-load.php';

$username = 'myuserid';

$user = get_user_by('login', $username);

if (!is_wp_error( $user )) {
  wp_clear_auth_cookie();
  wp_set_current_user($user->ID);
  wp_set_auth_cookie($user->ID, TRUE);
  $redirect_to = user_admin_url();
  wp_safe_redirect( $redirect_to );
}

exit();

The above sets the cookies accordingly and logs in the 'myuserid' user no problem. It redirects to user_admin_url() which was fine for my test but unnecessary as my intention is just to go to the home page as the entire site will be locked down for non-logged in users once this is working accordingly.
Now using the same concept that worked in test_login.php I've created prod_login.php which is supposed to apply the same logic via a cURL request from the web application that passes creds via the Authentication header.
prod_login.php:
<?php
require __DIR__ . '/wp-load.php';

$response = array('http_code' => 500, 'message' => 'Failed to update response');

if ($_SERVER['PHP_AUTH_PW'] !== 'password123') {
  $response['http_code'] = 401;
  $response['message'] = 'Unauthorized login attempt';
  echo json_encode($response);
  die();
}

$username = $_SERVER['PHP_AUTH_USER'];
$user = get_user_by('login', $username);

// Redirect URL //
if (!is_wp_error( $user )) {
  wp_clear_auth_cookie();
  wp_set_current_user($user->ID);
  wp_set_auth_cookie($user->ID, TRUE);
  //$redirect_to = user_admin_url();
  //wp_safe_redirect( $redirect_to ); //commented out as unnecessary
  $response['http_code'] = 200;
  $response['message'] = 'Login Successful';
  $response['user'] = $user;
  echo json_encode($response);
} else {
  $response['http_code'] = 403;
  $response['message'] = 'Invalid User';
  echo json_encode($response);
}

exit();

Now my cURL request appears to be working fine, I'm consistently getting the http_code === 200 response and the user object is coming back correctly in the cURL response. However, after the redirect to the wordpress site from the web app, the cookies are not set and I am not actually logged in.
web app cURL request:
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_USERPWD, 'myuserid' . ':' . 'password123');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL,'http://mywordpresssite.com/prod_login.php');
    $server_output = curl_exec($ch);
    if (curl_errno($ch)) {
        // handle failed cURL
    }
    $decoded_response = json_decode($server_output);

    if ($decoded_response->http_code === 200) {
        // cURL response indicated successful login
        // I can consistently get to this point and it will do the redirect but I will not be logged in nor will the cookies be set
        header('Location: mywordpresssite.com'); // go to the wp homepage now that we should be logged in
    }

I have no idea what I'm doing wrong. I assume it has to do with the cookies getting blown away or not preserved between the cURL and the redirect. Any insight on how to prevent that from happening or what I'm doing incorrectly is appreciated. Is this even possible with a cURL?
I have also tried a multitude of the examples of add_filter('auth_cookie_expiration',... and apply_filters('auth_cookie_expiration',... that are available on the internet to no avail.

A: From what I can tell, what I was trying to do is not possible.
The cURL request never actually touches the browser, it goes from the web app server to the wordpress site server so there in that context the web app server is the client. So when the redirect happens, the cookie is not set in the browser.
What I've done instead is a GET request passing my tokenized values in the query string. It's not as secure this way as anyone who gets their hands on the token will technically be able to access the site and login but there doesn't appear to be a way around that. At least the tokenized URL is never actually visible in the address bar so the typical user will not know what's happening.


text:
Q: Entity Framework UpdateException relationships in Added and Deleted states I have a table of Plants and Information.
Plants have an ID, Name, ..., MainInformationID
Information have an ID, Title, ..., PlantID
One plant can have many information, but only one MainInformation. Information can only have one plant.
I have a class ViewModel which contains observable collections of plants and information which are binded to the window.
When I try to change the main information of a plant. I get this error:

A relationship from the 'FK_Plants_Information' AssociationSet is in the 'Added' state. Given multiplicity constraints, a corresponding 'Information' must also in the 'Added' state.

If I choose an information which is not used by any plant it said "Added" state and if I choose one which is in use it says "Deleted" state.
**class PlantsViewModel : ViewModelBase
{
    private DAL _dal = new DAL();

    private ObservableCollection<Plant> _plants = new ObservableCollection<Plant>();

    public ObservableCollection<Plant> Plants
    {
        get { return _plants; }
        set
        {
            _plants = value;
            _OnPropertyChanged("Plants");
        }
    }

    private Plant _selectedPlant;

    public Plant SelectedPlant
    {
        get { return _selectedPlant; }
        set
        {
            _selectedPlant = value;
            _OnPropertyChanged("SelectedPlant");
        }
    }

    private ObservableCollection<Information> _information = new ObservableCollection<Information>();

    public ObservableCollection<Information> Information
    {
        get { return _information; }
        set
        {
            _information = value;
            _OnPropertyChanged("Information");
        }
    }
 }

And the window:
<TextBox Grid.Column="1" Grid.Row="0" Width="150" Text="{Binding Path=SelectedPlant.LatinName}" />
            <TextBox Grid.Column="1" Grid.Row="1" Width="150" Text="{Binding Path=SelectedPlant.LocalName}" />
            <TextBox Grid.Column="1" Grid.Row="2" Width="150" Text="{Binding Path=SelectedPlant.CycleTime}" />
            <ComboBox Grid.Column="1" Grid.Row="3" Width="150" ItemsSource="{Binding Path=Information}"
                      DisplayMemberPath="Title"
                      SelectedValue="{Binding Path=SelectedPlant.MainInformation, Mode=TwoWay}" />

DAL looks like this.
    public class DAL {
    private static Entities _context = new Entities();

    public void SaveChanges()
    {
        _context.SaveChanges();
    }
    public List<Plant> GetAllPlants()
    {
        return _context.Plants.ToList();
    }

    public void AddNewPlant(Plant plant)
    {
        _context.Plants.AddObject(plant);
    }

    public void DeletePlant(Plant plant)
    {
        _context.DeleteObject(plant);
    }
    }

Also please do tell me if there is anything here that doesn't seem like a good idea(like having a static context, the way I connect my viewModel to the dal and so on... (I'm a beginner so I don't really know how it should be used properly)

A: The error says you have a required field missing. I'm guessing it's MainInformation. You could do something like:
Dal.AddPlant(new Plant { MainInformation = new Information() });

Yes, it's a bad idea to use a static context. There's some discussion on how to choose an appropriate lifetime in this post.


text:
Q: JMeter Distributed testing on EC2 Master and EC2 slave machines I want to configure JMeter for distributed testing in aws Ec2 instances. I followed the Jmeter manual still facing issues. Both Slave and Master are aws Ec2 instances. Both are from same region under same subnet. I have turned off firewall in both master and slave.I even diabled rmi ssl with this command server.rmi.ssl.disable=true, configured the remote host with slave ip on the master. before starting the execution i have launched the jmeter-server.bat on the aws slave. I tried to run a simple http request through slave and got the below given error.
Connection refused to host:<>; nested exception is:
java.net.ConnectException: Connection timed out: connect
I have disabled firewall in both slave and master machines. JMeter & Java versions are the same. Is there
a way to resolve this connection issue from master to slave through JMeter by running the test

A: If your masters/slaves are in the same VPC - you can use private IP addresses, otherwise you will have to go make sure to use public IP addresses (or DNS hostnames)
Also make sure that the following ports are open in AWS security groups:

*

*1099 (or whatever you set as the server.port)

*the port you define as server.rmi.localport

*the port(s) you define as  client.rmi.localport
More information:

*

*How to Perform Distributed Testing in JMeter

*Remote hosts and RMI configuration


text:
Q: FB Graph API - How do I detect if a page was merged and get the ID of the right page? Pages can be merged using this procedure https://www.facebook.com/help/249601088403018. After the merge one of the pages redirects to the other.
Is the only way to detect this by fetching the page and see if Facebook does a redirect? Or is there no way to use the Graph API to get this information?

A: I know this answer is probably coming 1 year too late, but this question was asked and answered by Baz at Programmatically detect if a Facebook page was merged with another page. I've tested his solution on the Graph API Explorer and it works. To quote his answer,

There is a field called "best_page" that gives the best alternate id of the page you are querying.

He specifies

If the page you are querying is already the best page, you will not receive any "best_page" property in the response

He extrapolates by saying,

if you are querying all of a user's likes, and would like to know the best page of each without having to re-query each page individually, you can use it with the likes endpoint:
/v2.1/me/likes?fields=id,name,best_page{id}

A: Just wanna add my two cents to this. Another behavior I've come across is the graph API throwing an error, mentioning that the page has been migrated and should be referenced by a new ID:
{
  "error": {
    "message": "Page ID 763809000301020 was migrated to page ID 697230513732818.  Please update your API calls to the new ID",
    "type": "OAuthException",
    "code": 21
  }
}

A: You cannot.  Once a page has been merged the Graph API will no longer provide data on that Page using the old Page ID.
I do not believe there is any indicator that the page has been merged a Graph API layer.


text:
Q: Seaborn stripplot of datetime objects not working Following the first example from URL:
http://seaborn.pydata.org/tutorial/categorical.html
I am able to load the dataset called 'tips' and reproduce the stripplot showed. However this plot is not shown when applied to my pandas dataframe (called df) consisting of datetime objects. My df consists of 19300 rows and 7 columns, of which 2 columns are in the form of datetime objects (dates and times respectively). I would like to use the Python Seaborn package's stripplot function to visualize these two df columns together. My code reads as follows:
sns.stripplot(x=df['DATE'], y=df['TIME'], data=df);

And the output error reads as follows:
TypeError: float() argument must be a string or a number

I have made sure to remove the header from the data columns before applying the plotting command.
Other failed attempts include (but not limited to)
sns.stripplot(x=df['DATE'], y=df['TIME']);

It is my guess that this error might be due to the datetype object nature of the column data types, and that this type must somehow be changed into either strings or integer values. Is this correct? And how might one proceed to accomplish this task?
To illustrate the df data, here is a working code which uses matplotlib.pyplot (as plt)
 ax1.plot(x, y, 'o', label='Events')

Any help is much appreciated.

A: After applying the following code to previous script:
x = df['DATE']
data = df['TIME']
y = data[1:len(x)]
x = x[1:len(x)]

s = []
for time in y:
    a = int(str(time).replace(':',''))
    s.append(a)

k = []
for date in x:
    a = str(date)
    k.append(a)

x = k
y = s

stripplot worked:
sns.stripplot(x, y)

A: One can also try to convert dates/times into seconds to plot them as numeric values:
dates = df.DATE
times = df.TIME

start_date = dates.min()
dates_as_seconds = dates.map(lambda d: (d - start_date).total_seconds())
times_as_seconds = times.map(lambda t: t.second + t.minute*60 + t.hour*3600)
ax = sns.stripplot(x=dates_as_seconds, y=times_as_seconds)
ax.set_xticklabels(dates)
ax.set_yticklabels(times)

Of course, data frame should be sorted by dates and times to match ticks and values.

A: You just need to put the variables name as input of x and y; not the data themselves. For example :
sns.stripplot(x="value", y="measurement", hue="species",
              data=iris, dodge=True, alpha=.25, zorder=1)

https://seaborn.pydata.org/examples/jitter_stripplot.html


text:
Q: Replace every other occurence on the same line To get pair coordinates, I need to bundle them with a comma.
Example input (space divided)
161768.669 467646.462 161716.059 467515.711 161683.343 467434.35 161696.535 467427.091 161713.457 467416.235
161719.332 467412.183 161732.58 467403.047 161763.757 467381.118 161791.136 467367.094 161808.447 467361.612 161834.383 467353.808
161842.354 467351.71 161870.358 467344.337
161886.521 467338.28 161905.239 467330.484 161908.865 467328.974 161972.72 467301.688 161984.372 467296.404 162000.0 467288.568 162056.152 467260.414
162065.771 467254.859 162102.992 467233.363 162138.102 467213.086
162146.165 467209.29 162165.68 467200.102 162165.684 467200.1 162270.285 467154.666 162318.855 467133.104 162358.101 467117.844 162165.004 466820.119 162176.208 466809.875

This attempt only replaces the first occurrence on every line
sed 's/ /,/1' file
161768.669,467646.462 161716.059 467515.711 161683.343 467434.35 161696.535 467427.091 161713.457 467416.235
161719.332,467412.183 161732.58 467403.047 161763.757 467381.118 161791.136 467367.094 161808.447 467361.612 161834.383 467353.808
161842.354,467351.71 161870.358 467344.337
161886.521,467338.28 161905.239 467330.484 161908.865 467328.974 161972.72 467301.688 161984.372 467296.404 162000.0 467288.568 162056.152 467260.414
162065.771,467254.859 162102.992 467233.363 162138.102 467213.086
162146.165,467209.29 162165.68 467200.102 162165.684 467200.1 162270.285 467154.666 162318.855 467133.104 162358.101 467117.844 162165.004 466820.119 162176.208 466809.875

Desired output
161768.669,467646.462 161716.059,467515.711 161683.343,467434.35 161696.535,467427.091 161713.457,467416.235
161719.332,467412.183 161732.58,467403.047 161763.757,467381.118 161791.136,467367.094 161808.447,467361.612 161834.383,467353.808
161842.354,467351.71 161870.358,467344.337
161886.521,467338.28 161905.239,467330.484 161908.865,467328.974 161972.72,467301.688 161984.372,467296.404 162000.0,467288.568 162056.152,467260.414
162065.771,467254.859 162102.992,467233.363 162138.102,467213.086
162146.165,467209.29 162165.68,467200.102 162165.684,467200.1 162270.285,467154.666 162318.855,467133.104 162358.101,467117.844 162165.004,466820.119 162176.208,466809.875

Can this be done with sed or otherwise?

A: You want a number followed by a space and a number to be replaced with a number followed by a comma and a number, for all occurences (the flag g).
sed 's/\([0-9]\+\.[0-9]\+\) \([0-9]\+\.[0-9]\+\)/\1,\2/g'

You might want to change how exactly a "number" is defined but this should work as long as you have digits before and after the decimal point, and you always have a decimal point.
If you don't care at all about whether these are number at all, you could do it even simpler.

A: I would go for awk, because allows you to loop through fields quite easily:
awk '{for (i=1; i<=NF; i+=2) printf "%s,%s%s", $i, $(i+1), (i==NF-1?"\n":" ")' file

Explanation
The idea is to loop through fields in blocks of two. Hence:

*

*for (i=1; i<=NF; i+=2) normal loop with a seed of 2. (Is it correct to call it "seed"? Just guessing)

*printf "%s,%s%s", $i, $(i+1), (i==NF-1?"\n":" ") prints two fields separated by comma. It adds a space or new line, depending on the loop position.

This would also work:
awk '{for (i=1; i<=NF; i+=2) printf "%s,%s ", $i, $(i+1); print ""}'

Test
$ awk '{for (i=1; i<=NF; i+=2) printf "%s,%s ", $i, $(i+1); print ""}' file
161768.669,467646.462 161716.059,467515.711 161683.343,467434.35 161696.535,467427.091 161713.457,467416.235
161719.332,467412.183 161732.58,467403.047 161763.757,467381.118 161791.136,467367.094 161808.447,467361.612 161834.383,467353.808
161842.354,467351.71 161870.358,467344.337
161886.521,467338.28 161905.239,467330.484 161908.865,467328.974 161972.72,467301.688 161984.372,467296.404 162000.0,467288.568 162056.152,467260.414
162065.771,467254.859 162102.992,467233.363 162138.102,467213.086
162146.165,467209.29 162165.68,467200.102 162165.684,467200.1 162270.285,467154.666 162318.855,467133.104 162358.101,467117.844 162165.004,466820.119 162176.208,466809.875

A: A ruby one-liner:
ruby -ane 'puts $F.each_slice(2).map {|*pair| pair.join ","}.join " "' file

A: # posix version (non GNU sed or use --posix)
sed 's/\([^ ]\{1,\}\) \([^ ]\{1,\}\)/\1,\2/g' YourFile

GNU sed version
sed 's/\([^ ]+\) \([^ ]+\)/\1,\2/g' YourFile

Replace any space between a peer of non blank group by a comma. it doesn not replace space between 2 peer because sed start the next substitution AFTER the last one so next non blank group is no including the following space


text:
Q: dll library not being injected even though there are no errors I'm trying to inject my .dll in a target process. I will give the script a command line argument to launch a certain process then inject the .dll in it. The problem is that the code runs without errors but the .dll is not being injected. The reasons which I believe the .dll is not being injected are that I can delete the .dll when the target process is running. I don't see my .dll when printing the modules used by the target process, and the code in the .dll only writes the word "hello" to a file (other than that there is nothing in the DllMain()) but I don't see that file. I have read tons of posts about dll injection on stackoverflow and I couldn't find a solution to my problem.
My code:
if (!CreateProcessW(NULL,   // No module name (use command line)
    wtext,        // Command line arguments to launch the target process
    NULL,           // Process handle not inheritable
    NULL,           // Thread handle not inheritable
    FALSE,          // Set handle inheritance to FALSE
    CREATE_SUSPENDED,
    NULL,           // Use parent's environment block
    NULL,           // Use parent's starting directory
    &si,            // Pointer to STARTUPINFO structure
    &pi)           // Pointer to PROCESS_INFORMATION structure
    )
{
    printf("CreateProcess failed (%d).\n", GetLastError());
    return 1;
}
wstring dllPath = wstring(selfdir) + TEXT("\\HookEngine.dll"); // full path to the .dll
LPCWSTR PathToDll = dllPath.c_str();
size_t nLength = (wcslen(PathToDll)+1) * sizeof(LPCWSTR);
LPVOID lpRemoteString = VirtualAllocEx(pi.hProcess, NULL, nLength, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (lpRemoteString == NULL) {
    printf("Failed to allocate memory in the target process, error number (%d).\n", GetLastError());
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return 1;
}
if (!WriteProcessMemory(pi.hProcess, lpRemoteString, PathToDll, nLength, NULL)) {
    printf("Failed to write memory to the target process, error number (%d).\n", GetLastError());
    VirtualFreeEx(pi.hProcess, lpRemoteString, 0, MEM_RELEASE);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return 1;
}
LPVOID lpLoadLibraryW = NULL;
lpLoadLibraryW = GetProcAddress(GetModuleHandle(L"KERNEL32.DLL"), "LoadLibraryW");
if (!lpLoadLibraryW) {
    printf("Load library failed, error number (%d).\n", GetLastError());
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return 1;
}
HANDLE hThread = CreateRemoteThread(pi.hProcess,
    NULL,
    NULL,
    (LPTHREAD_START_ROUTINE)lpLoadLibraryW,
    lpRemoteString,
    NULL,
    NULL
);
if (!hThread) {
    printf("Creating thread failed, error number (%d).\n", GetLastError());
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return 1;
}
else {
    WaitForSingleObject(hThread, 10000);
    HMODULE arr[1024]; // the next few line are for checking which dlls are being used by the target process
    DWORD bneeded = 0;
    wchar_t arr2[1024];
    EnumProcessModulesEx(pi.hProcess, arr, sizeof(arr), &bneeded, LIST_MODULES_ALL);
    for (int i = 0; i < bneeded/sizeof(HMODULE); i++) {
        int len = GetModuleFileNameEx(pi.hProcess, arr[i], arr2, 1024);
        for (int j = 0; j < len; j++) {
            wcout << arr2[j];
        }
        cout << endl;
    }
    ResumeThread(pi.hThread);
}
WaitForSingleObject(pi.hProcess, INFINITE);
VirtualFreeEx(pi.hProcess, lpRemoteString, 0, MEM_RELEASE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

I don't have any idea why this is not working. No errors are happening so I think it should work.
The script and the dll are in the same folder and I give it the command line argument "python myscript.py". The code in the python script only prints some number on a text file and I can see that file when I run the python script from my code so CreateProcess() is succeeding and the process is being resumed. So, when I run my script it only creates a process and nothing else happens. It is like the code between CreateProcess and ResumeThread() doesn't do anything. What should I do?


text:
Q: Check if something is in a list multiple times? I have a dictionary of monsters, which I get enemies from by choosing a random integer and matching it to the first number in the dictionary value (it's a list)
#NAME: ID, HP, MP, ATK, DEF, MGATK, MGDEF, SPEED, EXPSHARE, IMG
monsters_list = {"BOXROACH": [1, 20, 5, 5, 5, 5, 5, 5, 5, pg.image.load("boxcroach.png")],

for i in range(amt):
            monster = random.randint(1, len(self.monsters))
            for key in self.monsters:
                if self.monsters[key][0] == monster:
                    monsters.append([key, self.monsters[key]])

So amt is a number between 1 and 3 which decides how many monsters will be facing, and then it goes through the dictionary to match the first index of the value and then append the monster to a list, which ends up looking like this:
[['SLUGGER', [2, 20, 10, 5, 3, 8, 7, 11, 7, <Surface(150x160x32 SW)>]], ['SLUGGER', [2, 20, 10, 5, 3, 8, 7, 11, 7, <Surface(150x160x32 SW)>]], ['MEAN SPIRIT', [10, 15, 15, 5, 5, 5, 5, 5, 20, <Surface(100x100x32 SW)>]]]

(ignore the dumb names)
What I want to do is to check if there are multiple of the same enemy, and then differentiate them in some way. I was originally going to go through to add all the indexes to another list and then compare them, but is there a more efficient way to do this? Thanks.

A: You can do by:
check your random numbers in order to not be the same so your monsters will be different.
if an random number repeated again do next random number.
and also if you want to different them in some ways it's better to make a monster details class then if they were repeated then change some parameters on there for each monster .


text:
Q: Small and unequal sample sizes I have a data set consisting of a small number of participants: n=5, n=5, n=2. I want to compare the means on a particular variable. I've done a 1-way anova and the p-value was .07, the Welch test gives me p = .005. Which is correct?

A: I agree with kjetil.  The Welch test is a two sample test of differences between sample means when the variances are assumed to be different.  The variance estimate is based on estimates of separate individual variances rather than a pooled estimate of a common variance.  So the test statistic under the null hypothesis does not have a $t$ distribution but can be approximated by a $t$ with a particular df parameter that may not be an integer.  If the original data are approximately normal which test to use depends on whether the variances are equal.  With sample sizes this small you cannot even assess the adequacy of the normality assumption much less the equality of variance assumption.  So of the various frequentist approaches (1) parametric two sample $t$ test, (2) parametric Welch test and (3) nonparamnetric Wilcoxon rank sum test, you have no way to be confident that one is better than the others and they all can give very different p-values and possibly lead to conflicting conclusions.
In my view this means that you cannot do inference because the sample size is just too small.  Some may incorrectly think that the bootstrap can bail you out.  But it can't.  Also we see other assert that Bayesian methods can save the day.  I disagree with that too because for Bayesian methods the conclusion will be dominated by the prior and the data will not have much influence.  I think it is foolish to put so much dependence on the prior particularly if you can't make a strong case for using a specific prior.

A: I presume that by Welch test you mean that methodology used for one-way ANOVA! Then the difference in p-values boils down to the difference between assuming constant variance, and not assuming it (besides, the Welch test p-value is only an approximation). With so few data you don't know if the equal-variance supposition holds! So without strong prior knowledge to help you choose, there is not much to go. Your best bet it to get more data!


text:
Q: My application crashes while trying to use Volley I try to capture data using a volley, but my application crashes. the application opens but my application crashes when I press the search button.
public class MainActivity extends AppCompatActivity {

TextView tvYear,tvDirector,tvActor,tvLanguage,tvPlots,tvCountry;
ImageView ivPoster;
EditText edName;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    edName     = findViewById(R.id.edName);
    tvYear     = findViewById(R.id.tvYear);
}

public void search(View view) {
    String mName = edName.getText().toString();
    if(mName.isEmpty())
    {
        edName.setError("please provide movie name");
        return;
    }
    String url = "HTTP://www.omdbapi.com/?t="+mName+"&plot=full&apikey=myApiKey";

    RequestQueue queue = Volley.newRequestQueue(this);
    StringRequest request = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {
                        JSONObject movie = new JSONObject(response);

                        String result = movie.getString("Response");
right there  crash app---->     tvYear.setText(result);
                        if(result.equals("True"))
                        {

                            Toast.makeText(MainActivity.this, "Found", Toast.LENGTH_SHORT).show();

                            if(posterUrl.equals("N/A"))
                            {

                            }
                            else
                            {

                            }
                        }
                        else
                        {

                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }
            }
    );
    queue.add(request);

}

my application crashes right here
      tvYear.setText(result);

my application doesn't crash when I delete this line.
I want to see the value of requestin but it crashes

A: You can pritnt log aftr every line to see the variable's value.
Please point out what exact the log cat show error?

A: Try using a JsonObjectRequest instead.
You won't have to do the potentially bug causing conversion. If anything goes wrong in the conversion process and objects are mapped incorrectly, you get the issue you're trying to fix.
https://developer.android.com/training/volley/request


text:
Q: Jquery UI and Bootstrap button conflict I'm having a problem with button groups for bootstrap.
Right now I have jquery ui js called before bootstrap js and the button gorup works fine. However, if i keep this structure, jquery ui dialog buttons do not work, specifically the close button does not show due to conflicting js code.
If i switch the order then the jquery ui dialog close button shows but the button groups for bootstrap are all messed up, because of the conflict between the two js libraries.
I have tried using bootstraps solution:
var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality

Then when calling $(".btn").bootstrapBtn() and testing the button group every time i click a new button in the group i get the error:
cannot call methods on button prior to initialization; attempted to call method 'toggle'

I have done a ton of research and still can't come up with a solution.
Here is my code:

        <input class="barChart" data-target="barChart" type="radio" name="options" id="bar" checked> Bar

        <input class="pieChart" data-target="pie-section"  type="radio" name="options" id="pie"> Pie

        <input class="columnChart" data-target="columnChart" type="radio" name="options" id="column"> Column

And my JS to handle the buttons:
 $('.btn').button();

 $('input[type=radio]').on('change', function () {
    var target = "#" + $(this).data("target");
    $(".chart").not(target).hide();
    $(target).show();
    kendo.resize($(".k-content"));
 });

PS: Using Jquery UI version 1.11.1 and Jquery version 1.11.1

A: If you're using gulp or Grunt to build your assets (with main-bower-files for example) an option would be not to include the whole of jQueryUI. Just take the parts you need and skip buttons and tooltip. Those two are the ones that conflict the most in my experience.
For example put the following section in your bower.json:
"overrides":
    "jqueryui": {
        "main": [
            "ui/core.js",
            "ui/widget.js",
            "ui/mouse.js",
            "ui/datepicker.js",
            "ui/draggable.js",
            "ui/droppable.js",
            "ui/resizable.js",
            "ui/selectable.js"
        ]
    }

Just using the parts you need is also good practise to void page size when loading and sidesteps the conflict problem altogether. Hope this works in your case as well.
edit fixed typo

A: If you simply Google that error message, you'll see that it's a jQuery UI error message, so $.fn.button at that point in your code is referring to the jQuery UI Button plugin, not the Bootstrap Button plugin.
You need to put the noConflict after you've loaded Bootstrap but before you load jQuery UI, e.g.:

You will then need to use $(...).bootstrapBtn(...) instead of $(...).button(...) in the rest of your code.

A: I know this an old post but I had the same issue. I had Bootstrap 3.0.3 and upgrading it to version >=3.4.1 solved the issue.

 $('.btn').button();
 $('input[type=radio]').on('change', function() {
   var target = "#" + $(this).data("target");
   $(".chart").not(target).hide();
   $(target).show();
   kendo.resize($(".k-content"));
 });

      <input class="barChart" data-target="barChart" type="radio" name="options" id="bar" checked> Bar

      <input class="pieChart" data-target="pie-section" type="radio" name="options" id="pie"> Pie

      <input class="columnChart" data-target="columnChart" type="radio" name="options" id="column"> Column

https://jsfiddle.net/codinglattice/gu4mjaep/29/

A: Try to move jquery UI js before bootstrap js. This way it works for me.
var bundle = new ScriptBundle("~/bundles/CommonJs")
                                .Include("~/js/jquery-1.12.4/jquery-ui.js")
                                .Include("~/js/bootstrap.min.js")


text:
Q: how to get uwsgi on windows i used the command pip install uWSGI but then i get the error
  Using cached uwsgi-2.0.17.1.tar.gz (800 kB)
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Oscar\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Oscar\\AppData\\Local\\Temp\\pip-install-39mpiaq2\\uwsgi_c49548e783724e34b0711a03b318a590\\setup.py'"'"'; __file__='"'"'C:\\Users\\Oscar\\AppData\\Local\\Temp\\pip-install-39mpiaq2\\uwsgi_c49548e783724e34b0711a03b318a590\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Oscar\AppData\Local\Temp\pip-pip-egg-info-3lzq9ewp'
         cwd: C:\Users\Oscar\AppData\Local\Temp\pip-install-39mpiaq2\uwsgi_c49548e783724e34b0711a03b318a590\
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Oscar\AppData\Local\Temp\pip-install-39mpiaq2\uwsgi_c49548e783724e34b0711a03b318a590\setup.py", line 3, in <module>
        import uwsgiconfig as uc
      File "C:\Users\Oscar\AppData\Local\Temp\pip-install-39mpiaq2\uwsgi_c49548e783724e34b0711a03b318a590\uwsgiconfig.py", line 8, in <module>
        uwsgi_os = os.uname()[0]
    AttributeError: module 'os' has no attribute 'uname'
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/a2/c9/a2d5737f63cd9df4317a4acc15d1ddf4952e28398601d8d7d706c16381e0/uwsgi-2.0.17.1.tar.gz#sha256=d2318235c74665a60021a4fc7770e9c2756f9fc07de7b8c22805efe85b5ab277 (from https://pypi.org/simple/uwsgi/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached uwsgi-2.0.17.tar.gz (798 kB)

does anyone know how to fix this error?

A: By switching operating systems.
uWSGI doesn't work on bare Windows. (It might work on Cygwin, but that's probably not something you want to pursue.)

A: gunicorn also does not support Windows. See https://github.com/benoitc/gunicorn/issues/524
If you use Apche server, you can use mod_wsgi. See How to install mod_wsgi into Apache on Windows?
Or, using docker can be a solution.


text:
Q: Osmc CEC not working after using cec-client in ssh terminal I have a RPI2 with OSMC installed and I want to do some cec commands to check if the Tv is ON or OFF.
The issue is that after any command cec-client ( except cec-client -h :) ) the OSMC won't receive CEC commands until I restart the RPI. Is there any way to reconnect OSMC with the CEC? Cec service is still running, but OSMC does not recognize  it;

A: Try using:
xbmc-send -a 'CECActivateSource'

This way xbmc will connect again with the cec service. If it doesn't work you can always restart osmc via ssh (but it's not pretty at all)


text:
Q: Parametrize shading in table through TikZ I wanted to do some shading in a table according to its values. For example, if you see the table below:
  a  b   c   d
a 90 10  0   0
b 0  80  10  10
c 0  0   95  5
d 0  10  5   85

I want to shade automatically each numeric cell with a mixture of black and white according to its value. That is, (a,a) = 90 should be something like black!90, and (c,d) = 5 should be black!5. Also, if you can parametrized the shading operation so one can define the color and if we use the value or the complement that would be great.
I was thinking in something like Drawing different tikz shapes parameterized by data from a file, but I cannot see how can one achieve that in a table.
Can you give me some advice on how to achieve such automatic styling?

A: If you want that the cell background color changes according to its values.

You can use the following code.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[table]{xcolor}
\usepackage{collcell}
\usepackage{hhline}
\usepackage{pgf}
\usepackage{multirow}

\def\colorModel{hsb} %You can use rgb or hsb

\newcommand\ColCell[1]{
  \pgfmathparse{#1<50?1:0}  %Threshold for changing the font color into the cells
    \ifnum\pgfmathresult=0\relax\color{white}\fi
  \pgfmathsetmacro\compA{0}      %Component R or H
  \pgfmathsetmacro\compB{#1/100} %Component G or S
  \pgfmathsetmacro\compC{1}      %Component B or B
  \edef\x{\noexpand\centering\noexpand\cellcolor[\colorModel]{\compA,\compB,\compC}}\x #1
  }
\newcolumntype{E}{>{\collectcell\ColCell}m{0.4cm}<{\endcollectcell}}  %Cell width

\begin{document}
\newcommand\items{3}   %Number of classes
\arrayrulecolor{white} %Table line colors
\noindent\begin{tabular}{c*{\items}{|E}|}
\multicolumn{1}{c}{} &
\multicolumn{1}{c}{A} &
\multicolumn{1}{c}{B} &
\multicolumn{1}{c}{C} \\ \hhline{~*\items{|-}|}
A  & 100   & 0  & 10   \\ \hhline{~*\items{|-}|}
B  & 10   & 80  & 10   \\ \hhline{~*\items{|-}|}
C  & 30   & 0   & 70   \\ \hhline{~*\items{|-}|}
\end{tabular}

\end{document}

You can use RGB or HSB to define your color ranges, and you can control de color ranges using the formulas in compA, compB and compC.
So, for "Autum" (red-yellow) range use:
\pgfmathsetmacro\compA{#1/600} %Component R or H
\pgfmathsetmacro\compB{1} %Component G or S
\pgfmathsetmacro\compC{1} %Component B or B

And, for "Cool" (cyan-magenta) range set rgb for color model and use:
\pgfmathsetmacro\compA{#1/100}   %Component R or H
\pgfmathsetmacro\compB{1-#1/100} %Component G or S
\pgfmathsetmacro\compC{1}        %Component B or B

For "Black-red" range use:
\pgfmathsetmacro\compA{0} %Component R or H
\pgfmathsetmacro\compB{1} %Component G or S
\pgfmathsetmacro\compC{#1/100} %Component B or B

For "Jet" range use:
\pgfmathsetmacro\compA{0.6666-#1/150}      %Component R or H
\pgfmathsetmacro\compB{1} %Component G or S
\pgfmathsetmacro\compC{1}      %Component B or B

For "Cooper" range use:
\pgfmathsetmacro\compA{0.08+#1/5000}      %Component R or H
\pgfmathsetmacro\compB{0.7} %Component G or S
\pgfmathsetmacro\compC{#1/100}      %Component B or B

For "Gray" range use:
\pgfmathsetmacro\compA{0}      %Component R or H
\pgfmathsetmacro\compB{0} %Component G or S
\pgfmathsetmacro\compC{#1/100}      %Component B or B

A: You could use pgfplotstable and the xcolor package with the [table] option, which gives you the \cellcolor command.
Here's a new style for \pgfplotstabletypeset that colors the cell a different shade of gray according to the cell value, and prints the value in white if the background is more than 50% black.
The command
\pgfplotstabletypeset[color cells]{
 x,a,b,c,d      % The first column needs a name
 a,90,10,0,0
 b,0,80,10,10
 c,0,0,95,5
 d,0,10,5,85
 }

will then give you (shown here with a caption)

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable}

\pgfplotstableset{
    color cells/.style={
        col sep=comma,
        string type,
        postproc cell content/.code={%
                \pgfkeysalso{@cell content=\rule{0cm}{2.4ex}\cellcolor{black!##1}\pgfmathtruncatemacro\number{##1}\ifnum\number>50\color{white}\fi##1}%
                },
        columns/x/.style={
            column name={},
            postproc cell content/.code={}
        }
    }
}

\begin{document}
\begin{table}\caption{Correlation or something}
\centering
\pgfplotstabletypeset[color cells]{
x,a,b,c,d
a,90,10.5,0,0
b,0,80,10,10
c,0,0,95,5
d,0,10,5,85
}
\end{table}
\end{document}

A: \definecolor{myFlowTableTextCol}{rgb}{0,0,0}
\definecolor{myFlowTableBgCol}{rgb}{1.0,0.5,0.0}

% Heatmap style
\pgfkeys{
/pgfplots/table/heatmap/.style =
{
header=false,
column type={p{0.4cm}},
display columns/0/.style={column name=$\phantom{x}$},
display columns/1/.style={column name=$\phantom{x}$},
display columns/2/.style={column name=$\phantom{x}$},
display columns/3/.style={column name=$\phantom{x}$},
display columns/4/.style={column name=$\phantom{x}$},
display columns/5/.style={column name=$\phantom{x}$},
display columns/6/.style={column name=$\phantom{x}$},
display columns/7/.style={column name=$\phantom{x}$},
display columns/8/.style={column name=$\phantom{x}$},
display columns/9/.style={column name=$\phantom{x}$},
display columns/10/.style={column name=$\phantom{x}$},
postproc cell content/.code=
{%
\pgfkeysalso{/pgfplots/table/@cell content=\pgfmathparse{#1} \edef\multFact{\pgfmathresult} \pgfmathparse{round(##1*\multFact)} \edef\x{\pgfmathresult} \pgfmathtruncatemacro{\y}{\x}

\rule{0cm}{2.4ex}%\y,\y,\y}
\ifnum\y<0 \color{lightgray}\cellcolor{lightgray}\fi
\ifnum\y>0 \ifnum\y <6 \color{myFlowTableTextCol}\cellcolor{myFlowTableBgCol!36}\fi\fi
...
\y
},
},
/pgfplots/table/heatmap/.default=100
}

...
\pgfplotstabletypeset[heatmap=162]{data.dat}

even allows you to preprocess (multiply in this case) the data before colouring the heatmap. Especially for pgf versions < 1.5 this can be hard otherwise.

A: I used @Unas answer with the following twist for a custom range, 93.6 to 97.2 in this case:
\def\cca#1{%
    \pgfmathsetmacro\calc{(#1-93.6)*100/(97.2-93.6)}%
    \edef\clrmacro{\noexpand\cellcolor{blue!\calc}}%
    \clrmacro%
    \ifdim \calc pt>50pt\color{white}\fi{#1}%
}

The reason for the \edef instead of simply having \cellcolor{blue!\calc} is that otherwise the \calc part does not expand.
Also note the % at the end of each line. This prevents spaces from appearing in the cells

A: I wanted to retain the use of tabular, so I used a macro to format the cells. Definitely longer but more familiar to me.
\def\cca#1{\cellcolor{black!#10}\ifnum #1>5\color{white}\fi{#1}}
%For ranges 0-10, multiply by 10 by adding 0 after #1

\begin{table}[!t]
\caption{Table Caption}
\label{tab1}
\centering
{\setlength\tabcolsep{0.1pt}%
\begin{tabular}{ccccccccccccccc}
& $D_1$ & $D_2$ & $D_3$ & $D_4$ & $D_5$ & $D_6$ && & $D_1$ & $D_2$ & $D_3$ & $D_4$ & $D_5$ & $D_6$ \\
$D_1$ & & \cca{0} & \cca{0} & \cca{0} & \cca{2} & \cca{0} && $D_1$ && \cca{0} & \cca{0} & \cca{2} & \cca{2} & \cca{2} \\
$D_2$ & \cca{0} & & \cca{2} & \cca{0} & \cca{2} & \cca{0} && $D_2$ & \cca{0} &  & \cca{3} & \cca{0} & \cca{0} & \cca{2} \\
$D_3$ & \cca{7} & \cca{4} &  & \cca{3} & \cca{0} & \cca{4} && $D_3$ & \cca{0} & \cca{4} &  & \cca{4} & \cca{2} & \cca{0} \\
$D_4$ & \cca{3} & \cca{0} & \cca{7} &  & \cca{4} & \cca{0} && $D_4$ & \cca{0} & \cca{0} & \cca{5} &  & \cca{0} & \cca{0} \\
$D_5$ & \cca{3} & \cca{7} & \cca{7} & \cca{2} &  & \cca{4} && $D_5$ & \cca{2} & \cca{2} & \cca{0} & \cca{4} &  & \cca{4} \\
$D_6$ & \cca{2} & \cca{2} & \cca{7} & \cca{2} & \cca{6} &  && $D_6$ & \cca{2} & \cca{2} & \cca{3} & \cca{0} & \cca{4} & \\
\end{tabular}}
\end{table}


text:
Q: DHF using Entity-services design of envelope I am using DHF with entity-services. I was wondering if an envelope contains multiple entity instances can I have the envelope be designed as below
<envelope xmlns="http://marklogic.com/entity-services">
  <headers>
  </headers>
  <triples>
  </triples>
  <instance>
        <info>
          <title>target</title>
          <version>1.0.0</version>
        </info>
        <target:target xmlns:target="http://schemas.abbvienet.com/entity/target">
            ....
        </target>
  </instance>
  <instance>
        <info>
          <title>core</title>
          <version>1.0.0</version>
        </info>
        <core:core xmlns:core="http://schemas.abbvienet.com/entity/core">
            ....
        </core>
  </instance>
  <attachments>
  </attachments>
</envelope>

Notice the 2 instance tags for 2 instances.
Is this valid, as I was not able to find the recommendation of envelope design, like xsd ?Is this a good design of the instances in the envelope or is there a better way ? Or can I have like this
<envelope xmlns="http://marklogic.com/entity-services">
  <headers>
  </headers>
  <triples>
  </triples>
  <instance>
    <info>
      <title>target</title>
      <version>1.0.0</version>
    </info>
    <target:target xmlns:target="http://schemas.abbvienet.com/entity/target">
                    ....
    </target>
    <core:core xmlns:core="http://schemas.abbvienet.com/entity/core">
                    ....
    </core>
  </instance>
  <attachments>
  </attachments>
</envelope>

I want to use the es api for canonicalizing the entity

A: Currently the DHF (and entity services) support a paradigm of one instance per document following the envelope pattern.
If you need the same attachments/triples/header support for multiple instances of an entity (or multiple entities) - just split them up and attach them.
Also, you really shouldn't be modifying the instance portion of the generated envelope:
<es:envelope xmlns:es="http://marklogic.com/entity-services">
  <es:instance>
    <es:info>
      <es:title>Person</es:title>
      <es:version>1.0.0</es:version>
    </es:info>
    <Person>
      <id>1234</id>
      <firstName>George</firstName>
      <lastName>Washington</lastName>
      <fullName>George Washington</fullName>
    </Person>
  </es:instance>
  <es:attachments>
    <person>
      <pid>1234</pid>
      <given>George</given>
      <family>Washington</family>
    </person>
  </es:attachments>
</es:envelope>

But you can add information elsewhere outside the instance as needed. More information on entity services relating to your question can be found here: https://docs.marklogic.com/guide/entity-services/instances#id_67461
There is, currently, a bit of a gap between ES and DataHub that we are actively working on closing, which is why I encourage you not to modify the default instance setup and keep one instance per envelope document.

A: For another perspective, I'd say that there's nothing in the envelope design that prevents your approach, particularly the first one.  Some pains were taken to make sure that entity services generates code that concentrates on the scope of the es:instance element.
I anticipated that people would design envelopes such as yours.  However, I do not understand what might motivate it.  Please share your further experiences.


text:
Q: "It's not every day" Is (a) a reduced form of (b)?

a. It's not every day he visits Laura.

b. It's not the case that every day he visits Laura.

A: "It's not every day" is an idiom that means "It's unusual." If something happened every day, it would be a usual or normal thing to happen. So if something unusual happens, you can say "It's not every day that (something happens)."