text:
Q: VSCode cloning devcontainer on remote embedded ARM board fails on node-pty I have a devcontainer that works when cloning in Windows. We need to also be able to run it on our actual hardware, which we use a Tordex Verdin ARMv8-A SOM.
In Vscode, I'm first connecting to my board via remote-ssh. I'm then using the "Dev Containers: Clone repository in container volume" command. Using my projects repo or any of Microsofts "remote-try-xxx" projects, the same error occurs:
docker build -f /tmp/vsch-torizon/bootstrap-image/0.266.1/bootstrap.Dockerfile -t vsc-volume-bootstrap /tmp/vsch-torizon/bootstrap-image/0.266.1

The command '/bin/sh -c cd && npm i node-pty' returned a non-zero code: 1

These Toradex boards use a very stripped down version of linux to speed up boot time so I'm guessing I'm probably missing some needed dependency but the provided error doesn't lend itself to figure out what could be missing.
Full stack trace
[172 ms] Dev Containers 0.266.1 in VS Code 1.74.3 (97dec172d3256f8ca4bfb2143f3f76b503ca0534).
[172 ms] Start: Resolving Remote
[178 ms] Start: Run: ssh 192.168.2.196 /bin/sh
[200 ms] Start: Run in host: id -un
[490 ms] torizon
[491 ms]
[491 ms] Start: Run in host: cat /etc/passwd
[513 ms] Start: Run in host: echo ~
[517 ms] /home/torizon
[518 ms]
[518 ms] Start: Run in host: test -x '/home/torizon/.vscode-remote-containers/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[521 ms]
[522 ms]
[522 ms] Exit code 1
[523 ms] Start: Run in host: test -x '/home/torizon/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[527 ms]
[527 ms]
[528 ms] Start: Run in host: test -f '/home/torizon/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node_modules/node-pty/package.json'
[531 ms]
[531 ms]
[532 ms] Start: Run in host: test -f '/home/torizon/.vscode-remote-containers/dist/vscode-remote-containers-server-0.266.1.js'
[536 ms]
[536 ms]
[539 ms] userEnvProbe: loginInteractiveShell (default)
[540 ms] userEnvProbe shell: /bin/sh
[864 ms] userEnvProbe PATHs:
Probe:     '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/sbin:/usr/sbin:/sbin'
Container: None
[884 ms] Start: Check Docker is running
[885 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[1039 ms] Server API version: 1.40
[1040 ms] Start: Run in Host: docker volume ls -q
[1263 ms] Start: Run in Host: docker build -f /tmp/vsch-torizon/bootstrap-image/0.266.1/bootstrap.Dockerfile -t vsc-volume-bootstrap /tmp/vsch-torizon/bootstrap-image/0.266.1
Sending build context to Docker daemon  2.199MB
Step 1/4 : FROM mcr.microsoft.com/devcontainers/base:0-alpine-3.16
 ---> 5f5f7d3fea4f
Step 2/4 : RUN apk add --no-cache       nodejs  python3         npm     make    g++       docker-cli      docker-cli-buildx       docker-cli-compose      ;
 ---> Using cache
 ---> d51a0bda5431
Step 3/4 : RUN cd && npm i node-pty
 ---> Running in 699eece3930c
npm ERR! code 1
npm ERR! path /root/node_modules/node-pty
npm ERR! command failed
npm ERR! command sh -c node scripts/install.js
npm ERR! make: Entering directory '/root/node_modules/node-pty/build'
npm ERR! make: Leaving directory '/root/node_modules/node-pty/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.17.1 | linux | arm64
npm ERR! gyp info find Python using Python version 3.10.9 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.17.1/node-v16.17.1-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.17.1/node-v16.17.1-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.17.1/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.17.1/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/node_modules/node-pty/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/root/node_modules/node-pty',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: printf: Operation not permitted
npm ERR! make: *** [pty.target.mk:107: Release/obj.target/pty/src/unix/pty.o] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.4.193-5.7.1-devel+git.f78299297185
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /root/node_modules/node-pty
npm ERR! gyp ERR! node -v v16.17.1
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-02-04T00_18_37_401Z-debug-0.log
The command '/bin/sh -c cd && npm i node-pty' returned a non-zero code: 1
[13115 ms] Command failed: docker build -f /tmp/vsch-torizon/bootstrap-image/0.266.1/bootstrap.Dockerfile -t vsc-volume-bootstrap /tmp/vsch-torizon/bootstrap-image/0.266.1
[13115 ms] Exit code 1

A: The issue was that the version of linux these embedded boards ship with was v18 which causes issues with newer releases of the alpine container microsoft uses for the bootstrap container.
The solution was to upgrade Docker to v20+.
Original issue that led me to figuring this out:
https://github.com/docker-library/php/issues/1177


text:
Q: How to nest a ModernMenu in a modernUI WPF application? I'm creating a WPF application using the ModernUI framework and I'm having trouble nesting a ModernMenu control in my MainWindow class. Here's what I had initially for my MainWindow:
<mui:ModernWindow x:Class="MyApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:mui="http://firstfloorsoftware.com/ModernUI"
    xmlns:local="clr-namespace:MyApp"
    mc:Ignorable="d"
    Title="MyApp" IsTitleVisible="True" Height="350" Width="525" WindowState="Maximized" ContentSource="/Views/SourcePage1.xaml">

<mui:ModernWindow.MenuLinkGroups >
    <mui:LinkGroup x:Name="sourceGroup" DisplayName="Source">
        <mui:LinkGroup.Links>
            <mui:Link x:Name="sourceLink1" DisplayName="File" Source="/Views/SourcePage1.xaml"/>
            <mui:Link x:Name="sourceLink2" DisplayName="Instrumentation" />
        </mui:LinkGroup.Links>
    </mui:LinkGroup>
</mui:ModernWindow.MenuLinkGroups>

In "SourcePage1.xaml" I try to add a second sub-menu (an instance of ModernMenu):
<UserControl x:Class="MyApp.Views.SourcePage1"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mui="http://firstfloorsoftware.com/ModernUI"
         xmlns:local="clr-namespace:MyApp.Views"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300">

<Grid x:Name="mainGrid" Margin="0,10,0,0">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="2*"/>
        <ColumnDefinition Width="4"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Border x:Name="initialSpacer" Grid.Column="0" Background="Transparent" BorderBrush="DimGray" BorderThickness="2">
        <Grid>
            <Label Content="Ready" FontSize="40" Foreground="DimGray" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Grid>
    </Border>

    <GridSplitter Grid.Column="1" Width="4" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>

        <mui:ModernMenu Grid.Column="2">
            <mui:ModernMenu.LinkGroups>
                <mui:LinkGroup DisplayName="Catagory1">
                    <mui:LinkGroup.Links>
                        <mui:Link x:Name="catagory1Link" DisplayName="name1" Source="/Views/SettingsPage.xaml"/>
                        <mui:Link DisplayName="insert" />
                    </mui:LinkGroup.Links>
                </mui:LinkGroup>
                <mui:LinkGroup DisplayName="Catagory2">
                    <mui:LinkGroup.Links>
                        <mui:Link DisplayName="name1" />
                        <mui:Link DisplayName="name2" />
                        <mui:Link DisplayName="name3" />
                    </mui:LinkGroup.Links>
                </mui:LinkGroup>
                <mui:LinkGroup DisplayName="Catagory3">
                    <mui:LinkGroup.Links>
                        <mui:Link DisplayName="name1" />
                    </mui:LinkGroup.Links>
                </mui:LinkGroup>
            </mui:ModernMenu.LinkGroups>
        </mui:ModernMenu>

</Grid>

Where "SettingsPage.xaml" is just for testing:
<UserControl x:Class="MyApp.Views.SettingsPage"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mui="http://firstfloorsoftware.com/ModernUI"
         xmlns:local="clr-namespace:MyApp.Views"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300">

<Grid x:Name="mainGrid" Margin="0,10,0,0">
      <Label Content = "Hi there!"/>
</Grid>

The MainWindows' ModernMenu shows up and works well. Likewise, the ModernMenu on "SourcePage1.xaml" also shows up just fine, but I cannot seem to be able to assign it any source content. When I click on any of the links that have been assigned content (like "catagory1Link") nothing appears. What could be the problem here? Am I not allowed to nest menus like this?

A: The ModernMenu doesn't auto navigate the frame, as you stated. You could use a ModernTab instead but it will setup another ModernFrame and that frame is the one the links set the source on.
ModernMenu does have a SelectedLink DependencyProperty though. If you bind it to a property on your usercontrol, you can detect the link click and navigate the frame yourself.
SourcePage1.xaml
<mui:ModernMenu Grid.Column="1" SelectedLink="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=MenuSelectedLink, Mode=OneWayToSource}">

SourcePage1.xaml.cs
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Controls;
using FirstFloor.ModernUI.Presentation;

namespace WpfApp17
{
    public partial class SourcePage1 : UserControl, INotifyPropertyChanged
    {
        public SourcePage1()
        {
            InitializeComponent();
        }

        #region Property Link MenuSelectedLink
        private Link _MenuSelectedLink;
        public Link MenuSelectedLink { get { return _MenuSelectedLink; } set { SetProperty(ref _MenuSelectedLink, value); OnMenuSelectedLinkChanged(); } }
        #endregion

        private void OnMenuSelectedLinkChanged()
        {
            if (MenuSelectedLink == null || MenuSelectedLink.Source == null)
                return;

            // Navigate the frame to the source.
            var frame = FirstFloor.ModernUI.Windows.Navigation.NavigationHelper.FindFrame(null, this);
            if (frame != null)
            {
                if (frame.Source != MenuSelectedLink.Source)
                    frame.Source = MenuSelectedLink.Source;
            }
        }

        #region INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        protected bool SetProperty<T>(ref T field, T value, [CallerMemberName]string name = null)
        {
            if (Equals(field, value))
            {
                return false;
            }
            field = value;
            this.OnPropertyChanged(name);
            return true;
        }
        protected void OnPropertyChanged([CallerMemberName]string name = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
        #endregion
    }
}

A: J.H.'s solution is correct and I've marked it as such. I only changed things a little to get the behavior I was looking for: I created a new UserControl consisting simply of a "ModernMenu" object in the first row of the grid and a "ModernFrame" in the second row. The frame is named "pageFrame". Then, I just add the content directly to pageFrame when the menu link changes in this new UserControls' code-behind file:
        private void OnMenuSelectedLinkChanged()
    {
        if (MenuSelectedLink == null || MenuSelectedLink.Source == null)
            return;

        // Navigate the frame to the source.
        pageFrame.Source = MenuSelectedLink.Source;
    }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Dependency Injection: Dependency needs field/member I have two classes A and B. Currently, B is constructed inside of A. Since I want to verify in my unit tests that A calls B's methods correctly, I want to inject B into A instead to enable mocking.
The problem is: Upon construction, B needs one of A's fields as a constructor parameter. Which means that if I inject B and therefore move its construction out of A, I would also have to move that field's construction out of A.
What's the most elegant solution here? I hope I explained the problem properly. If not, please feel free to ask any questions.
An attempt at explaining the problem with code snippets:
What it's currently like:
// constructor of class A. b_ is being constructed. field_of_a_ is initialized.
A::A() : b_{field_of_a_}, field_of_a_{5} {

}

What I want to avoid:
// In the class constructing A...
int field_of_a;
B b(field_of_a);
A a(b, field_of_a);

// and inside A...
A::A(B& b, int& field_of_a) : b_{b}, field_of_a_{field_of_a} {

}

EDIT 1: Clarification from inside one of my comments:
Yeah so currently B holds all kinds of timers and timer related methods. Its methods are called by A during message handling. B needs access to a queue and a few other resources located inside of A. When testing A, I want to verify that during message handling the timers are started/stopped correctly.

A: Instead of passing B, you should pass a factory that generates B. It still maintains the dependency injection.
The factory could be a virtual class, a function pointer, a std::function, ...
It is then up to A to use the factory. Your test would simply verify that the factory is used during construction of A.
Update : your factory should be abstract, and return an instance to the public interface of B that A requires. During testing the factory can be programmed to spawn mocked instances of B.
Also, make sure that in the class definition of A the member passed to B is declared first, then the member holding a B instance. This in order to make the first member's lifetime outlive that of B.


text:
Q: Highcharts - Error bar change legend symbol Is it possible to change the legend symbol for an errorbar chart? I have error bars for max and min values, overlapping a spline chart that displays the average value. I want the legend symbol for the min and max to be triangle and square but the series marker property doesn't have any affect. spline with error bar
series: [{
        name: 'Average',
        type: 'spline',
        color: 'transparent',
        marker: { fillColor: '#2B767F', symbol: 'circle'},
        data: [33]
      },
      {
        name: 'Max',
        type: 'errorbar',
        color: '#2B767F',
        marker: { fillColor: '#2B767F', symbol: 'triangle'},
        data: [[33,68]],
        linkedTo: null,
        whiskerLength: 10
      },
      {
        name: 'Min',
        type: 'errorbar',
        color: '#2B767F',
        data: [[5,33]],
        linkedTo: null,
        whiskerLength: 10,
        marker: { fillColor: '#2B767F', symbol: 'square'},
      }]

A: EDIT
I misunderstood the OP and provided workarounds for adding marker to errorbar series (it can be found after END OF EDIT header). The problem here is to add them to the legend instead.
Workaround for markers in legend
As I mentioned before: markers are not supported for error bars. The default 'big' circle symbol will be used as the legend marker.
The workaround here is to create the phantom scatter series with no data, but with proper marker definition. Then disable showInLegend for the original series and link it to the phantom one:
 // series
  {
    name: 'Max',
    type: 'scatter',
    color: '#2B767F',
    marker: {
      fillColor: '#2B767F',
      symbol: 'triangle'
    },
  }, {
    name: 'Max_',
    type: 'errorbar',
    color: '#2B767F',
    data: [
      [33, 68]
    ],
    whiskerLength: 10,
    showInLegend: false,
    linkedTo: ':previous'
  }

Live demo: http://jsfiddle.net/kkulig/1hLq2y5v/
API Reference: https://api.highcharts.com/highcharts/series.errorbar.linkedTo
END OF EDIT

Markers are not supported for error bars. It seems that there's a flaw in the API: https://api.highcharts.com/highcharts/series.errorbar.marker.enabled
Enabling markers has no effect for error bar series.
Workaround 1
You can convert the boxplot to the scatter series (witch connected points): http://jsfiddle.net/kkulig/yg36swfa/
  plotOptions: {
    scatter: {
      lineWidth: 1
    }
  }

Workaround 2
Use scatter only for whisker points. Set whiskerLength to 0 and place scatter points in the same positions. Disable legend and tooltip for this kind of series:
  plotOptions: {
    scatter: {
      showInLegend: false,
      tooltip: {
        pointFormat: false
      }
    }
  }

Live demo: http://jsfiddle.net/kkulig/yeLeor1h/
This workaround seems to be better because it maintains the behavior of the tooltip.


text:
Q: Debugging Tcl/tk application for Windows Does it possible debug Tcl/tk application for Windows, without the source code? The application have no support and there is no source code available. There is error shown during one of operation. Is it possible to find what cause an error and whether error can be fixed by patching code?

A: It's very difficult without the source code, as it is at the level of the source code where you'd need to make the patch. If the code is exposing itself via the send command mechanism (or the comm package) you can probably make a bit of progress (as there's quite good introspection capabilities in Tcl by default, so info commands, info vars and info body may help, along with many other info commands and some introspectors that are elsewhere too), but it's still really difficult, particularly if you don't understand the internal structure of the code. OTOH, I wouldn't expect a production application to expose itself this way; typically you disable that sort of thing when outside development.
A standard debugger like gdb won't help, especially with the Tcl 8.6 non-recursive runtime. (Tcl applications in that environment just tend to show up as effectively "doing stuff"; there's nothing to really indicate how it hangs together.)
But the first thing to check is whether you actually have the source code. It's possible that the code has just been packaged together as a Starpack and that you can use a tool like sdx to extract the things you need to make changes in. But you aren't guaranteed to succeed at that; if the code was compiled/obscured with a commercial tool like the TDK, you really don't have the source and can't really do much about it. (By the same general principles that mean that DRM doesn't work well, it's possible to decompile the .tbc files that the TDK produces, but that's really a last-ditch thing to do as it is technically illegal in some jurisdictions, morally rather dodgy, and inclined to produce really awful output.) Can you contact the original author(s) of the code instead? If that works, it'll be cheaper and simpler…
If you've actually got the human-readable code, even if packaged with sdx, then you can do a lot more.


text:
Q: Perl - Receive JSON and render on template I'm trying to expand some app, but I never used Perl before. This uses de framework Mojolicious.
For now I was able to write this, but I can't find out how to check if it's correct or not.
    use JSON::XS;
    use JSON qw( decode_json );
    my $self = shift;
    my $req = HTTP::Request->new("GET", "https://jsonplaceholder.typicode.com/comments");

    my $ua = LWP::UserAgent->new(
            keep_alive => 1,
            timeout => 3000,
            ssl_opts => {
                verify_hostname => 0,
                SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE
            },
        );
    my $response = $ua->request($req);
    my $body = $response->decoded_content();

$self->stash(
        'body' => $body
        );

    $self->render('view_');
    return;

On template I try something like this: (Found somewhere example)
<% foreach my $element (@{$body->{"element"}}) { %>

<%= $element->[1]->{"id"} %>

<% } %>

But got the error:
Can't use string ("[ { "postId": 1, "id":"...) as a HASH ref while "strict refs" in use at template view_.html.ep line 228.

A: Your error looks pretty clear:

Can't use string ("[ { "postId": 1, "id":"...) as a HASH ref while "strict refs" in use at template view_.html.ep line 228.

It's referring to this line in your template:
<% foreach my $element (@{$body->{"element"}}) { %>

In this code you're taking the variable $body and expecting it to contain a hash reference (because you're using the ->{...} operator on it). But, as the error says, it doesn't contain a hash reference, it contains a string.
So the problem is that you have a JSON string, where you expect a Perl reference. And that means that you haven't JSON-decoded your JSON string.
Perhaps you think that $response->decoded_content(); does the JSON decoding. But it doesn't. That does a higher level of decoding. As the documentation for HTTP::Response says:

$r->decoded_content( %options )
This will return the content after any Content-Encoding and charsets have been decoded. See HTTP::Message for details.

Nothing in there about JSON decoding.
And that's why you're loading (two!) JSON modules. You need to use one of them to decode the JSON to a Perl data structure. Something like this, perhaps:
my $body = decode_json( $response->decoded_content() );

[Note: In a comment, melpomene correctly points out a problem with this. The correct code is:
my $body = decode_json( $response->content() );

i.e. You shouldn't decode the response body before sending it into decode_json().]
That will, at least, get you a reference into $body. I see another problem though. Your JSON string starts with [, so it will decode into an array reference, not a hash reference. You'll need to deal with that change. Unfortunately, I don't know enough about your data or what you're trying to do to suggest a solution to that problem.


text:
Q: How to check when multiple concurrent threads have finished? I have code that goes like this:
myArray.forEach { item in
   concurentOperation(item)
}

Every item in the array goes through a concurrent operation function, which runs in different threads, I'm not sure exactly which thread or how many threads because the function is from a third party library and out of my control. I need a way to find out once all operations are finished.
How can I do this?

A: without modifying concurentOperation() this is NOT available, sorry ...
UPDATE for user @Scriptable
next snippet demonstrates, why his solution doesn't work ...
import PlaygroundSupport
import Dispatch

PlaygroundPage.current.needsIndefiniteExecution = true

let pq = DispatchQueue(label: "print", qos: .background)
func dprint(_ items: Any...) {
    pq.async {
        let r = items.map{ String(describing: $0) }.joined(separator: " ")
        print(r)
    }
}

func concurrentOperation<T>(item: T) { // dummy items
    DispatchQueue.global().async {
        // long time operation
        for i in 0..<10000 {
            _ = sin(Double(i))
        }
        dprint(item, "done")
    }
}

let myArray = [1,2,3,4,5,6,7,8,9,0]
let g = DispatchGroup()
myArray.forEach { (item) in
    DispatchQueue.global().async(group: g) {
        concurrentOperation(item: item)
    }
}
g.notify(queue: DispatchQueue.main) {
    dprint("all jobs done???")
}

UPDATE 2
without modifying the code of ConcurrentOperation()
DispatchQueue.global().async(group: g) {
            concurrentOperation(item: item)
        }

the dispatch group is entered and immediately left because concurrentOperation is the asynchronous function. If it is synchronous then the question has no sense.


text:
Q: CPM and APM in supercomuting? I am doing a research for my paper work on supercomputer subject, specifically for Tianhe-2. So i was reading a report from a professor Jack Dongarra and he mentions the CPM and APM halves of the board: "The compute board has two compute nodes and is composed of
two half's the CPM and the APM halves.The CPM portion of the compute board
contains the 4 Ivy Bridge processors, memory, and 1 Xeon Phi board and the CPM half
contains the 5 Xeon Phi boards".
So the first thing i have problem with is a compute, as a term, because i don't know how to translate compute board, if a have Xeon Phi boards on that compute board... O.o?
The 2nd thing is about CPM and APM. What are CPM and APM? What is their full name? And how are  they functioning?
Please help me, I'm stuck with it and can't find explanation anywhere ?
Thaks.
Tami

A: Tianhe-2 is a cluster, a set of computers (called 'nodes') linked together with a fast interconnect (network), and a distributed storage system. Most nodes are dedicated to computing (the 'compute nodes'), while some others are dedicated to management ('management nodes'.) Dongarra's document also mentions blades as a synonym to nodes. Blades are a kind of node form factor whose working is similar to a docking station for a laptop.
Traditionally, a node is a full computer, with a main circuitry system (the 'board', or 'motherboard') on which the processors and the memory modules are plugged, a network interface, and possibly a local hard disk, and an operating system.
On Tianhe-2, things are a bit different. A single board is made of two distinct parts (modules) plugged together (the CPM and the APU) and that single board hosts two separate nodes. Rather than having two identical boards for two distinct nodes, Tianhe-2 uses one, two-parts-board for two distinct nodes.
One of the boards (the CPM) hosts the CPUs (Intel IvyBridge) and the memory, plus one accelerator (Intel Xeon Phi) and two network connections, while the other (APU) hosts 5 accelerators. Plugged together, they offer two nodes, each with 2 CPUS and 3 accelerators and one network connection.
The Intel Xeon Phi is an extension card, that is plugged to the main board. In that extension card lives a fully-featured mini-computer with a CPU, some memory, and ... a tiny motherboard.
The exact meaning of CPM and APU (also referred to as APM in the Dongarra's document, which looks more like a typo(?) though it was quoted in many many places) is nowhere to be found, one could guess it means Central Processing Module and Accelerated Processing Unit or a variant of it.


text:
Q: Bar code does not appears on print preview but appears on HTML page I'v created a prestashop module in which it obtains airway bill numbers from an external API, This number I then add on a webpage and let users to print.
This bar code only appears on HTML page but does not visible on print preview dialog box
I use Smarty for html part since its by default uses by Prestashop.
Hear is my code,

*{$order.other_data.awb}*

any idea why this is happening? is there any solution for this?
UPDATE
{literal}

{/literal}

{foreach from=$orders_array item=order}

{$order.other_data.service}

                                {$order.other_data.ppaddress}

www.postaplus.com

                        From

                        {$order.other_data.shipper_name}

                        {$order.other_data.shipper_address},

                        {$order.other_data.shipper_country_code},

                        Phone: {$order.other_data.shipper_phone},

                        To

                        {$order.params.SHIPINFO.Consignee.ToName},

                        {$order.params.SHIPINFO.Consignee.ToAddress},

                        Phone: {$order.params.SHIPINFO.Consignee.ToMobile} / {$order.params.SHIPINFO.Consignee.ToTelPhone}

                        Civil Id:

                        Pay Type: {$order.params.original_order_array.payment_method}
                        Amount: {$order.params.original_order_array.total} - Currency - {$order.params.original_order_array.codcurrency}

                        Reference 1	{$order.params.original_order_array.reference}

                        Reference 2

                        Service	{$order.other_data.service}

                            Pieces:	 1	 Weight:	 {$order.other_data.total_weight} Kg

                        Remarks

                        Note 2	{$order.other_data.original_order_data.notes2}

                        Shipper Order Number:

*{$order.other_data.awb}*

                        Shipment Date:	{$order.other_data.awb_date}

{/foreach}

screen shots
html view
print preview
Thanks in advance.
Roshan

A: Roshan save the below code in html format and check whether it shows barcode in your print preview . if it works than you should try changing your font or check your code again..it will be very helpful if you upload your code  here as well.also check display background graphics checkbox in print preview menu
<!DOCTYPE html>

<link href='https://fontlibrary.org/face/idautomationhc39m-code-39-barcode'
rel='stylesheet'>

This is a paragraph, shown in the Times New Roman font.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

123456790

ABCDEFGHIJKLMNOPQRSTUVWXYZ

abcdefghijklmnopqrstuvwxyz

A: Look for the link to the font itself in the header. It should look like this:
  <link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/idautomationhc39m-code-39-barcode" type="text/css"/>

Change the media="screen" to media="screen, print".
I would also recommend you try using 'IDAHC39M Code 39 Barcode' instead of IDAutomationHC39M for font family. (Make sure the quotes are there.)


text:
Q: what is standard notation of JSON keys I think standard notation for javascript properties is camelCase (most of frameworks in javascript use camelCase), so JSON keys must be camelCase (according to javascript object notation), also I've seen WIKIPEDIA and W3SCHOOLS documentation about JSON, all sample wrote in camelCase, but when see API documentation of Twitter, Facebook, Instagram and ... all API key wrote in underscore separated notation.
What is standard notation of JSON?
{
    "firstName" : "behrooz"
}

or
{
    "first_name" : "behrooz"
}

A: JSON defines no convention for the choice of property names. There is no standard for this.

A: Here is a snippet on Googles intepretation on JSON naming conventions...
Choose meaningful property names.
Property names must conform to the following guidelines:

*

*Property names should be meaningful names with defined semantics.

*Property names must be camel-cased, ascii strings. The first

*character must be a letter, an underscore (_) or a dollar sign ($).

*Subsequent characters can be a letter, a digit, an underscore, or a
dollar sign. Reserved JavaScript keywords should be avoided (A list
of reserved JavaScript keywords can be found below).

These guidelines mirror the guidelines for naming JavaScript identifiers. This allows JavaScript clients to access properties using dot notation. (for example, result.thisIsAnInstanceVariable). Here's an example of an object with one property:
https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format

A: Typically you'll find JSON keys to be camel cased. This is of course entirely up to the developer, and many APIs use underscores. But the mainstream solution is propertyName.

A: Well according to JSON API.org
It should be,
 {
   "first-name": "John"
 }

A: Check JSON standarts specification here:
https://www.rfc-editor.org/rfc/rfc4627
As you  can see there is not standart format vor objects key.


text:
Q: How to tell when a posix thread has terminated I'm working on a compiler for fun. I'd like to add some native support for threading. Nothing major, just make-thread, thread-start, thread-kill, and thread-join. The compiler works by taking the source code, compiling it down to LLVM, and combining that LLVM with a C++ header file, which is also compiled to LLVM. The C++ file contains the code for any primitives operations (i.e. all this threading stuff I want to do).
My idea is to have a constant thread pool (96 threads), and have make-thread return an index in that thread pool of a thread that is not currently being used. Then, instead of references to threads, all the other thread operations will just take the index of a thread in the pool.
The issue I'm running into, and can't seem to think a way around, is how to know when a thread is usable again. i.e. I set thread 1 on its journey, and thread 1 finishes, how do I know that thread 1 is usable again? Do posix threads have native support for this?


text:
Q: external table is not in the expected format issue i have the issue: "external table is not in the expected format" I have tried various fixes. Changing from Jet to Ace, Installing Access Database Engine as a means to facilitate Ace, I have changed the Extended Properties from 8.0 to 12.0 and vice-versa.  Is there any other fix anyone can suggest?
private void button7_Click_2(object sender, EventArgs e)
    {
        string path = " \"C:\\Users\\jdavis\\Downloads\\Pharmacies\\CrossReferencing v3\\CrossReferencing\\bin\\Debug\\cross_check.xls\" ";
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + path + ";Extended Properties= Excel 12.0;");
        OleDbCommand command = new OleDbCommand( "SELECT *FROM [cross_check]",con);
        DataSet cross = new DataSet();
        OleDbDataAdapter adapter = new OleDbDataAdapter(command);
        adapter.Fill(cross);
        dataGridView2.DataSource = cross.Tables[0];
    }
}


text:
Q: Regex - Match a string between second occurance of characters I have a string of text that looks something like this:
?q=search&something=that&this=example/

In that example, I need to grab that . I'm using the following regex below:
var re = new RegExp("\&(.*?)\&");
Which going re[1] is giving me:
something=that - but it needs to be only that
I tried:
var re = new RegExp("\=(.*?)\&");
But that gives me everything from the first equals sign, so:
search&something=that
Is the output when it just needs to be:
that
I need to somehow target the second occurrences of 2 characters and grab whats in between them. How best do I go about this?

A: split seems more suited to your case:
"?q=search&something=that&this=example/".split("&")[1].split("=")[1]
Then you could also implement a simple method to extract any wanted value :
function getValue(query, index) {
   const obj = query.split("&")[index];
   if(obj) obj.split("=")[1]
}

getValue("?q=search&something=that&this=example/", 1);

A: You can use
/something=([^&]+)/

and take the first group, see the JavaScript example:

let url = '?q=search&something=that&this=example/';
let regex = /something=([^&]+)/
let match = regex.exec(url);
console.log(match[1]);


text:
Q: Procmail/munpack: Extracting headers similar to text and attachments? I currently have set up fetchmail to transfer mail to procmail and a .procmailrc file with the following content:
FILE_DIR=$HOME/incoming
:0
*
| munpack -q -C "$FILE_DIR"

If I receive emails with attachments, munpack will create a file123.ext and a file123.desc, the latter containing the text of the email. However, the headers are lost. Is there a way to save the headers of the email to a file123.headers file or something like that or, better yet, make munpack save the whole message - including headers - in the .desc file?

A: You can easily save the headers separately, but of course you can't predict which file name munpack will assign to the extracted message.
:0hc
headers

:0
| munpack -q -C "$FILE_DIR"

This simply writes the headers to headers. Perhaps you could add some logic around this to create a new directory for each incoming message, or something like that.
(Notice also how you simply omit the condition line if you want to deliver unconditionally.)
Maybe a better solution would be to switch to a tool which extracts the headers as well. I vaguely recall ripmime would be somewhat more flexible than munpack.


text:
Q: Updating tab badge dynamically on Ionic 2 I wish to update dynamically a badge value, when I click on a button.
tabs.html
...
        <ion-tab [root]="tab1Root" tabTitle="Product" tabIcon="search"></ion-tab>
        <ion-tab [root]="tab2Root" tabTitle="Cart" tabIcon="cart" tabBadge="{{cartCount}}" tabBadgeStyle="danger"></ion-tab>
...

tabs.ts
export class TabsPage {
...
    cartCount = 0;

    tab1Root = ProductPage;
    tab2Root = CartPage;
...
}

product.html
<button ion-button full (click)="updateCart('add', p.id)">Buy Now</button>

product.ts
export class ProductPage {
...
    updateCart(action, id) {
        let cartCount = 1;

        let alert = this.alertCtrl.create({
            title: 'Success!',
            subTitle: 'You have added 1 product to the cart.',
            buttons: ['OK']
        });

        alert.present();
    }
...
}

As I tought, let cartCount = 1; does nothing. I've searched for a solution, but most of them are for Ionic 1 or AngularJS, which didn't helped me at all.

A: You could use Ionic events for that. Please take a look at this working plunker. Like you can see there, in the first tab we publish an event when the badge needs to be updated:
import { Component } from '@angular/core';
import { Events } from 'ionic-angular';

@Component({..})
export class FirstTabPage {

  private count: number = 0;

  constructor(public events: Events) {}

  public updateTabBadge(): void {
    this.events.publish('cart:updated', ++this.count);
  }

}

And then we subscribe to that event in the page that contains both tabs:
import { Component } from '@angular/core';
import { Events } from 'ionic-angular';

@Component({...})
export class FirstTabPage {

  private count: number = 0;

  constructor(public events: Events) {}

  public updateTabBadge(): void {
    this.events.publish('cart:updated', ++this.count);
  }

}

And in the view:
<ion-header>
  <ion-navbar>
    <ion-title>Tabs</ion-title>
  </ion-navbar>
</ion-header>
<ion-tabs #myTabs>
  <ion-tab [root]="tab1Root" tabTitle="First Tab"></ion-tab>
  <ion-tab [root]="tab2Root" tabTitle="Second Tab" [tabBadge]="cartCount"></ion-tab>
</ion-tabs>

Please also notice that property binding should be used instead of string interpolation to bind the tabBadge property: [tabBadge]="cartCount"

UPDATE
Just like @skinny_jones mentioned in the comments, you could also use Subjects/Observables to achieve the same result. You can find more information in this blog post


text:
Q: How do i reverse a string in python using lists and pop() I am writing a function to take a string and reverse it. I can't work out why my code is returning a reversed string but with only half of the letters of the string passed to it.
   def reverse(text):
        temp = []
        reverse_text = ""
        for i in text:
            temp.append(i)
        for i in temp:
            reverse_text += temp.pop()
        print reverse_text

A: I'm not going to post a complete answer, but:

*

*Don't modify a list you're iterating over with a for loop. Bad things will happen (you already realized that)

*You therefore can use a while loop to accomplish the task.

*You can also use a for loop, but then you'll end up with for i in range(len(temp)): (see other answers), and the range(len(..)) construct is rather "unpythonic".

A: def reverse(text)
    return text[::-1]

A: I would just use reversedString = string[::-1], most easy way I think.

A: for i in range(len(text)):
    reverse_text += temp.pop()

don't change the string.

A: Every time you are doing pop operation you are changing the temp over which you are iterating as well.
A simple way would be to just do pop n times where n is the length of temp
def reverse(text):
    temp = []
    reverse_text = ""
    for i in text:
        temp.append(i)
    print temp
    for i in range(len(temp)):
#         print i, temp[i]
        reverse_text += temp.pop()
    print reverse_text

A: If you can't do:
text[::-1]

Try doing a for loop:
text = 'Hello'
product=''
for x in range(len(text)-1, -1, -1):
    product+=text[x]
return product


text:
Q: Can I create a shortcut for Paste Features As? Is there any way to create a shortcut to "Paste Features As", or even better "Paste Features As->Temporary Layer"? It's not in the list for Settings->Keyboard Shortcuts.

A: The shortcut for this operation is already defined by default since QGIS version 3.10.4 and it is Ctrl+Alt+V.

If you want to customise the shortcut or set it in the previous QGIS versions, you can find it in the Settings->Keyboard Shortcuts list as Temporary Scratch Layer.


text:
Q: Wrapping an IEnumerable with an ReactiveUI Observable Understanding that observables are not enumerables, and visa versa:
Using ReactiveUI, what are the recommended ways to wrap an IEnumerable<T> with an IObservable<T>?
For instance, given the values variable below, how could an observable be created that generates an action for each element?
var values = new int[] { 0, 1, 2, 3 };

A: values.ToObservable() will create an Observable based on your IEnumerable, in which you can then project each item using Select().
Also note that if you need your Observable to then return all your items into an IObservable<IEnumerable<T>>, you can buffer the list:
values.
   .ToObservable()
   .Select(x => ...)
   .Buffer(values.Count)


text:
Q: Java Parser iterate over methods of a class I would like to know if exists such thing like java parser (like parser xml). I mean from a String like this
String javaToParse = "public class x{void foo(){...} void baar(){...}}"

I could for example get the body (in string format) from foo or the body of all methods etc..
I have some like that
public class Some {
    @PostConstruct
    public void init1() {
        //some to do
    }
    @PostConstruct
    public void init2() {
        //some to do2
    }
    @PostConstruct
    public void init3() {
        //some to do3
    }
//..more..
}

Here there are one or more @PostConstruct
This class is autogenerated and I cannot modified it manually.
I would like to iterate all @PostConstruct methods and put all his bodies into only one @Postcontruct method and export to file and get this:
public class Some {
    @PostConstruct
    public void init() {
        //some to do
        //some to do2
        //some to do3
    }
}

I see that it's possible to do this getting that file as String and operate manually with fors and search manually but maybe there are librearies to do it.
EDIT:
Resolved with JavaParser
If somebody has similar problem here my solution:
public static void createUniquePostContruct(File InputFile,File outputFile) throws FileNotFoundException {
        //get class to modified
        FileInputStream in = new FileInputStream(ficheroEntradaJava);
        // parse the file
        CompilationUnit cu = JavaParser.parse(in);
        //store methods with @PostContruct
        List<MethodDeclaration> methodsPost = new ArrayList<>();
        //iterate over all class' methods
        cu.accept(new VoidVisitorAdapter<Void>() {
            @Override
            public void visit(MethodDeclaration method, Void arg) {
                //if this method has @PostConstruct
                if (method.getAnnotationByName("PostConstruct").isPresent()) {
                    methodsPost .add(method);
                }
            }
        }, null);
        //delete all methods with @PostConstruct
        methodsPost.forEach((method) -> method.remove());
        //add a unique @PostConstruct method using body of anothers @PostConstruct methods
        MethodDeclaration uniqueMethodPostConstruct = new MethodDeclaration(EnumSet.of(Modifier.PUBLIC), new VoidType(), "init");
        uniqueMethodPostConstruct.addAnnotation("PostConstruct");
        BlockStmt bodyUniqueMethodPostConstruct= new BlockStmt();
        metodosPost.forEach(method-> {
            method.getBody().get().getStatements().forEach(statement -> {
                bodyUniqueMethodPostConstruct.addStatement(statement);
            });
        });
        metodoUnicoPostConstruct.setBody(bodyUniqueMethodPostConstruct);
        //get main class and put our method
        Optional<ClassOrInterfaceDeclaration> clazz = cu.getClassByName(ficheroEntradaJava.getName().split("\\.")[0]);
        clazz.get().addMember(uniqueMethodPostConstruct);

        System.out.println(cu.toString());

        //write to file
        try (PrintWriter out = new PrintWriter(outputFile)) {
            out.println(cu.toString());
        } catch (FileNotFoundException ex) {
            Logger.getLogger(ParserMetodos.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


text:
Q: How to know which JS script manipulated certain elements of the DOM using Firebug I am inspecting a website, which has tons of JS files loaded from several servers along with jQuery. Number of js files is really big. Some are within the regular scripts tags. Others are loaded dynamically via ajax.
I am interested in certain elements of the DOM which are manipulated because of some js file. I see the dynamic loaded elements in firebug. I needed to know exactly which JS script creates/updates them.
I searched the js files for the classes and the IDs of the elements,so I can have some clue about which js file affects them,  but I found nothing.
Is there any direct way using Firebug to know exactly which JS file manipulates certain DOM elements?
Thanks in advance.

A: Not in a direct way.

*

*Use EventBug addon

*Then search by the function signature in your script panel to drill down to the js file

Hope this helps!

A: You should be able to go to Script tab in firebug, then look at the toolbar right below the script tab you can select all the javascript files included on the page.
If you have an idea which file it is coming from then select that file and then look through the code and set break points on functions you think the event is coming from by clicking on the respective line number, then refresh the page and perform the event that calls the javascript.
You might have to put in a few before you narrow it down, but the break points will make it alot easier to tell which functions are being called for which events.


text:
Q: Displaying a portion of the link caption in reStructuredText I am an absolute beginner in reStructuredText and Sphinx for Python documentation. I am giving it a try on one of my existing scripts, an Emailer class that handles creating/sending email messages, which uses Python's email library. My docstring (in NumPy style, I believe) for one of its methods is as follows:
def attach(self, msg: EmailMessage, file: BinaryIO, /, *, filename: Optional[str] = None, **kwargs) -> None:
        """Add an attachment to the :class:`~email.message.EmailMessage` msg using specified params.

        Parameters
        ----------
        msg: :class:`~email.message.EmailMessage`
            The message to add the attachment to.
        file: :class:`~typing.BinaryIO`
            The file-like object of the attachment to be added, opened in binary mode.
        filename: Optional[:class:`str`]
            The name to use for the attachment. Defaults to ``None``, using ``file.name``.
        **kwargs
            Additional kwargs that would be passed to :meth:`~email.message.EmailMessage.add_attachment`.
        """

My question is, how do I make it so that the description for **kwargs shows up as:

Additional kwargs that would be passed to EmailMessage.add_attachment()

The ~ operator makes it so that only add_attachment() shows up, and if I use :meth:EmailMessage.add_attachment, a link fails to generate at all (apparently I need to specify the full origin email.message.<foo>?)
As a side, I would appreciate some pointers on syntax/convention. For example, should I remove the type hints in my method signature, considering they are already described in the docstring? Also, how do I exclude certain attributes/methods from showing up in the resulting documentation? Thanks.

A: The following markup works:
:meth:`EmailMessage.add_attachment() <email.message.EmailMessage.add_attachment>`

From https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax:

You may supply an explicit title and reference target, like in reST direct hyperlinks: :role:`title <target>`  will refer to target, but the link text will be title.

"Direct hyperlinks" are described here: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html?highlight=hyperlinks#external-links.


text:
Q: Update bit field using MIPS Assembly How would one update a specific bit field in the register using MIPS assembly?
For example, if I need to update bits 10 through 15 in register $t1 with a new value. All the other bits should remain as they are.

A: Suppose $t0 contains the 6 bit field that you want to move into bits 10-15 of $t1.
You might consider this approach:
li  $t2 0x3F     #bits 0-5 on
sll $t2 $t2 10   #bits 10-15 on
not $t2 $t2      #bits 10-15 off

and $t1 $t1 $t2  #turn off bits 10-15
or  $t1 $t1 $t0  #set bits 10-15


text:
Q: NGINX - INSANE I/O on Reload/Reboot My NGINX server is doing like 30Gb/s+ read and writes on reload which freezes the whole box.
Any idea why this is happening? Been running NGINX for years without this problem before.
Maybe just traffic growth? I'm doubtful... The IO is insane.
Here is a DSTAT example of when I ran a service nginx reload
`
 18  82   0   0   0|2680k   35M|  75M   61M| 736k 2396k|  54k   17k
  4  80   1  15   0| 198M 3782M| 118M   88M|  12M 1870M| 119k   43k
  6  15  13  66   0|4948k 7216k| 777k  227k| 416k   68k| 542   452
  5  11   7  77   0|  25M 1410M|  27M   13M|1868k  698M|  36k   15k
  7  22  10  61   0|  95M 1644M|  37M   31M|4152k  823M|  53k   26k
  5  24   7  65   0| 158M 2408M|  46M   49M|  21M 1191M|  84k   50k
  6  25   7  63   0| 128M 1535M|  38M   40M|7936k  762M|  65k   39k
  5  13   7  76   0|  77M 1737M|  39M   33M|5684k  862M|  50k   24k
  3  69   7  20   0| 440M 4029M|  71M   59M|  81M 1929M| 178k   73k missed 2 ticks
  7  31   8  54   0| 216M  448M|  22M   18M|  93M  288M| 279k   56k
  5  15   1  79   0| 745M 4283M|  56M   56M| 473M 2064M| 241k  215k
  8  19   1  72   0| 594M  336M|5447k 5138k| 112M  163M|  31k   33k
 12   6   3  79   0|1182M  922M|  22M   16M| 573M  457M| 117k  161k
  6  19   1  74   0|1092M 3766M|  33M   19M| 502M 1891M| 271k  184k
  1   3   1  95   0| 168M  389M|  15M   12M|  58M  180M| 100k   52k missed 3 ticks

1   1   1  96   0|1044k 2484k| 490k  185k| 572k 1424k|1533   581
`


text:
Q: Adjunction formula for the canonical line bundle I'm reading the Huybrechts's Complex Geometry, p.71, Prop.2.2.17 and there is some point that makes me somewhat confused :

I can't understand the underlined statement. How can we use Example 2.2.4, viii) for obtaining the Adjunction formula? Here Example 2.2.4, viii) states that "for a short exact sequence of holomorphic vector bundles $ 0 \to E \to F\to G\to 0$, $\operatorname{det}(F) \cong \operatorname{det}(E)\otimes \operatorname{det}(G)$."
As the above image (there $\mathcal{T}_Y$, $\mathcal{T}_X$ are holomorphic tangent bundle of $Y$, $X$ respectively and $\mathcal{T}_{X}|_{Y}$ is the restriction of $\mathcal{T}_X$ to $Y$), we have  the normal bundle sequence :
$$0\to \mathcal{T}_Y \to \mathcal{T}_X|_Y\to \mathcal{N}_{Y/X}\to0$$
As in the above image, in Lemma 2.2.15, he states that "If $Y\subset X$ is a complex submanifold, then there is a canonical injection $\mathcal{T}_Y \subseteq \mathcal{T}_{X}|_{Y}$"
How can we use the viii) of Example 2.2.4 ? And $\mathcal{T}_Y \subseteq \mathcal{T}_{X}|_{Y}$ is correct form? If we can use viii) of Example 2.2.4, then from the form of statement of Proposition 2.2.17, a priori(?), it looks that $\mathcal{T}_{X}|_Y \subseteq \mathcal{T}_Y$ is more correct form.
Is it true? Anyone helps?

A: Recall that the canonical bundle is the determinant bundle of the cotangent bundle. From the short exact sequence
$$0 \to \mathcal{T}_Y \to \mathcal{T}_X|_Y \to \mathcal{N}_{Y/X} \to 0$$
we obtain the dualised short exact sequence
$$0 \to \mathcal{N}_{Y/X}^* \to \mathcal{T}_X|_Y^* \to \mathcal{T}_Y^* \to 0.$$
Evoking $\mathrm{viii})$ of Example $2.2.4$ we have
$$\det(\mathcal{T}_X|_Y^*) \cong \det(\mathcal{N}_{Y/X}^*)\otimes\det(\mathcal{T}_Y^*) \cong \det(\mathcal{N}_{Y/X})^*\otimes K_Y.$$
On the other hand,
$$\det(\mathcal{T}_X|_Y^*) \cong \det(\mathcal{T}_X^*|_Y) \cong \det(\mathcal{T}_X^*)|_Y \cong K_X|_Y$$
so $K_X|_Y \cong \det(\mathcal{N}_{Y/X})^*\otimes K_Y$. Tensoring both sides by $\det(\mathcal{N}_{Y/X})$ gives the adjunction formula.


text:
Q: Install fails - 'unable to install GRUB in /dev/sda' problem I have a Lenovo S series running Windows 8.1 (pre-installed). I downloaded Ubuntu 15.04 onto a USB stick and followed the instructions as outlined in the Quick Install From USB docs.
Secure Boot is disabled.
I can successfully boot into Ubuntu and begin the installation process. Around 80% of the way through I get the fatal error:
unable to install GRUB in /dev/sda
I've been through many of the other posts here on this issue, but cannot find a solution that seems to work in my situation. I have tried the 'Try without installing' option, and attempting to install after booting to desktop, but I get the same problem.
As far as I can tell, the issue is with the partition that is being attempted to install to.
Update: Boot Info here: http://paste.ubuntu.com/12447125/
Is anyone able to offer any advice on what might be causing this, or how I should choose/prepare a partition in order to install successfully?
Thanks

A: First, disable Fast Startup in Windows. This feature is a good way to cause filesystem corruption (my nickname for it is "Fast Filesystem Corruption"), which in turn can cause any number of problems, including an inability to install GRUB -- precisely the symptom you're seeing.
After you've disabled Fast Startup, you can try running Boot Repair or re-install Ubuntu. With any luck, disabling Fast Startup will enable either of these procedures to work, but I can't make any promises about that.
If you disable Fast Startup but can't seem to get GRUB installed, another option is to try my rEFInd boot manager. You can try it risk-free by preparing a USB flash drive or CD-R with the appropriate version (see the downloads page for links). You should then be able to boot from the appropriate medium, which should let you boot either Windows or Ubuntu. If you can boot both OSes, you can install rEFInd via the PPA or Debian package to get it on your hard disk. One big caveat is that if there's filesystem damage that's preventing GRUB from installing, the same problem is likely to affect rEFInd. OTOH, it could be a bug in the GRUB installation script that's not shared by the rEFInd installation script, so rEFInd might work around such problems. If nothing else, using rEFInd on a USB drive or CD-R might be a useful temporary stopgap to get you into your regular Ubuntu installation. From there you'd need to do more detailed analysis to figure out what's causing the boot loader problems, but at least you'd have a way to boot.

A: The solution in my case was to enable the 'Both' option for UEFI/Legacy BIOS boot support, as well as setting the Secure Chip to 'Inactive'. After all previous failed attempts, I made the changes to both these settings at the same time, so it's possible only one of them was required to solve the issue.

A: You are having problems with windows 8.1 secure boot. Try disabling UEFI following this tutorial. And then install Ubuntu.


text:
Q: Rigidity of Borel Lie algebras Let $\mathfrak b$ be a Borel subalgebra of dimension $n$ in a real semisimple Lie algebra $\mathfrak g$. I am trying to reconcile two facts about $\mathfrak b$:

*

*$\mathfrak b$ is rigid, that is, the orbit of its law is open (even, Zariski-open) in the variety $\mathcal R_n$ of solvable Lie algebras of dimension $n$. This can be proven as follows:  $H^2(\mathfrak b, \mathfrak b)=0$ (where $\mathfrak b$ acts in $\mathfrak b$ via the adjoint representation), see e.g. [Leger and Luks, Cohomology theorems for Borel-like solvable Lie algebras in arbitrary characteristic,
Canadian J. Math. 24 (1972), 1019-1026, Corollary 5.6]. And then this vanishing is sufficient (though not necessary) to ensure that $\mathfrak b$ is rigid, see e.g. [Carles, On the structure of rigid Lie algebras, Ann. Inst. Fourier (Grenoble) 34 (1984), no. 3, 65-82.]

*There seemingly exist solvable Lie algebras that can degenerate to $\mathfrak b$. Here is a minimal example where $\mathfrak g$ is rank one and $n=3$: consider $\mathfrak s = \mathfrak t + \mathfrak a$, where $\mathfrak a =\operatorname{span}(X,Y)$ is a $2$-dimensional abelian ideal and $\mathfrak t$ is a $1$-dimensional torus of derivations of $\mathfrak a$ generated by $T$ with
$$ \operatorname{ad} T_{\mid \mathfrak a} = \begin{pmatrix} 1 & 1 \\ 0  & 1 \end{pmatrix},$$
that is $[T,X] = X$ and $[T,Y] = X+Y$. Now, for $t \in (0, + \infty)$ let $\varphi(t) \in \operatorname{GL(\mathfrak s)}$ be diagonal and such that $\varphi_t(X) = X, \varphi_t(Y) = e^{-t}Y, \varphi_t(T) = T$. Then $\mathfrak s$ degenerates through $(\varphi_t)$ to the Borel subalgebra of $\mathfrak o (3,1)$ when $t \to + \infty$. (And $\mathfrak t + \mathfrak a$ becomes the Cartan decomposition of $\mathfrak b$ in the limit.)
So where is the snag?

A: So here's the fix thanks to YCor's comment, in the case I managed to confuse anyone.
Let $\mathfrak g$ be the split real form of a semisimple complex Lie algebra.
There is a difference between:

*

*Borel subalgebras of $\mathfrak g$, that is maximal solvable subalgebras of $\mathfrak g$.

*Maximal split-solvable subalgebras of $\mathfrak g$; I am not aware of a good terminology for them. They are real forms of Borel subalgebras in $\mathfrak g\otimes \mathbf C$.

$H^2(\mathfrak b_0, \mathfrak b_0)=0$ holds for every Borel subalgebra $\mathfrak b_0$ of $\mathfrak g$, but fails for the maximal split-solvable algebra $\mathfrak b$ in the question (and I now suspect, many of them).
Use the notation from the question, denote $(\xi, \eta, \theta)$ the dual basis to $(X,Y,T)$. Then by some computations (I skip the details)
$$ \begin{array}
& d(\xi\otimes X) = 0  & d(\xi \otimes Y) = 0  & d(\xi \otimes T) = \xi \wedge \eta \otimes Y + \xi \wedge \theta \otimes T   \\
  d(\eta \otimes X) = 0 & d(\eta \otimes Y) = 0 & d(\eta \otimes T) = - \xi \wedge \eta \otimes X + \eta \wedge \theta \otimes T \\
d(\theta \otimes X)=0  & d(\theta \otimes Y) = 0  & d (\theta \otimes T)=- \eta \wedge \theta \otimes Y - \xi \wedge \theta \otimes X.
\end{array}
$$
Hence $B^2(\mathfrak b, \mathfrak b) = \left\{ \xi \wedge \eta \otimes (aY - bX)  + \xi \wedge \theta \otimes (aT - cX) + \eta \wedge \theta \otimes (bT - cY) \right\}_{a,b,c \in \mathbf R}$.
Set $\gamma = \theta \wedge \eta \otimes X$, so that along the degeneration $\mathfrak s \to \mathfrak b$, $\mu_{\mathfrak s} = \mu_{\mathfrak b} + e^{-t} \gamma$ if we put $\mu_{\mathfrak b}$, $\mu_{\mathfrak s}$ the laws of $\mathfrak b$ and $\mathfrak s$ respectively on a common vector space. Note that
\begin{align}
d\gamma ( X \wedge Y \wedge T) & = [X, (\theta \wedge \eta \otimes X)(Y \wedge T)]
- [Y, (\theta \wedge \eta) \otimes X (X \wedge T)] \\
& \quad + [T, (\theta \wedge \eta \otimes X) (X \wedge Y) ]
- \gamma ([X,Y], T)  + \gamma ([X,T], Y) - \gamma([Y,T], X) \\
&  = 0
\end{align}
hence $[\gamma]$ defines a nonzero cohomology class.
The same computation should provide the full $H^2(\mathfrak b, \mathfrak b)$, and possibly with extra effort $H^2(\mathfrak b, \mathfrak b)$ when $\mathfrak b$ is maximal split solvable in $\mathfrak g = \mathfrak o (n,1)$, $n>2$; it is known that only finitely many isomorphism classes of Lie algebra can degenerate to such a $\mathfrak b$. [Lauret,
Degenerations of Lie algebras and geometry of Lie groups.
Differential Geom. Appl. 18 (2003), no. 2, 177-194].


text:
Q: jquery toggle working only if you click twice I'm implementing a tooltip thats triggered from an anchor tag and if you click the anchor we show the div right below it. I have the following code but you have to click the anchor twice for it to popup. Any ideas?

Tooltip

Test

    test

        Close


text:
Q: Removing element in a list list = [0, 1, 2, 8, 2, 9, 2]

Is there a way to remove the element 2, exactly one time?
So you will get:
list = [0, 1, 2, 8, 9, 2]

I tried to work with index() but I didn't found it.
It can be a RANDOM 2.
So I can't use remove() or pop() because it will not remove the number 2 on a random position.

A: This works
list.remove(2)

L.remove(value) -- remove first occurrence of value.
Raises ValueError if the value is not present.

A: Use  del or pop
For example,
del list[2]

or
list.pop(2)

The difference between del and pop is that
del is overloaded.
for example, del a[1:3] means deletion of elements 1 and 3

A: To randomly remove occurrence of 2
Notes:

*

*we create a list of indexes of the number 2 i.e. [i for i, j in enumerate(lst) if j == 2]

*Using random module choice method to get one index randomly from the index list

*list pop method  or remove method it's up to your choice

Code:
import random
lst = [0, 1, 2, 8, 2, 9, 2]
lst.pop(random.choice([i for i, j in enumerate(lst) if j == 2]))
print lst

output:
[0, 1, 8, 2, 9, 2]

A: Note that you're shadowing the built-in list. Apart from that index works just fine:
>>> li = [0, 1, 2, 8, 2, 9, 2]
>>> li.pop(li.index(2))
2
>>> li
[0, 1, 8, 2, 9, 2]


text:
Q: Where can I find the ubuntu build that works on the x1 carbon gen6 according to https://certification.ubuntu.com/hardware/201712-26045/ there is an ubuntu 16 that is certified to work with the lenovo x1 carbon gen6. Can I get it? If so where? If not, why not?
Thanks


text:
Q: Trained .tflite tensorflow model to linux executable We have access to a trained tensor-flow CNN model in .tflite format.
We need to convert it into a Linux executable that (trusted) users can call with say, an image as input, and get an object location as output from the model.
This is because we do not want users to be able to trivially have access to the trained model parameters (for legal reasons) - so the plan is to give only executable privilege to the binary, and no read/write access.
Any suggestions ? Would this be possible in something like PyInstaller ?
Thanks !!


text:
Q: Facebook Like Box Is not Showing I created a website for my project in programming class (It isn't published and it uses url's in my pc)
I'm having a problem making the Facebook like box appear in my webpage
Here's a screenshot of what my page look's like ( I am connected to the internet and currently logged in my facebook account)
I used the iframe version of the code
http://i784.photobucket.com/albums/yy129/jian_lastino2000/qwert.jpg (sorry i'm in a rush...the system says that I need 10 reputation to post images xD)
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <link rel="shortcut icon" href="images/general/favicon.png" width="32px" height="32px" type="image/x-icon">
    <title>RCICT 2012</title>
    <meta http-equiv="Content-Language" content="en-us" />
    <meta http-equiv="imagetoolbar" content="yes" />
    <meta name="MSSmartTagsPreventParsing" content="true" />
    <meta name="Project1" content="project 1 for lbyec71" />
    <meta name="keywords" content="programming html" />
    <meta name="Jian Lastino" content="RCICT 2012" />

Home

Committees

Conference Tracks

Important Dates

Abstract Submission Procedure

    <object width="900" height="150"
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">
<param name="SRC" value="header.swf">
<embed src="header.swf" width="900" height="150"></embed>
</object>

The 5th Regional Conference on Information and Communication Technology  (RCICT 2012) is the fifth AUN/SEED-Net Regional Conference in ICT fields that will be held on October 18-19, 2012 in Traders Hotel,Manila,Philippines. The RCICT is a discussion of ideas, techniques, and innovations in the field of advanced computing among scientists, engineers, and practitioners. We encourage the submission of works in progress. We will provide a friendly environment where researchers can discuss current and future trends in their research areas.

In addition, the 1st National Conference of Computer Engineers of the Philippines will be also held in conjunction with the said event.

Engr. Cesar A. Llorente

CPE/ECE Department, De La Salle University-Manila, Philippines.

Phone: +632 524-4611 Local 224

Send E-mail

        Portfolio -
        Contact Us

    |Home|Committees|Conference Tracks        |Important Dates|Abstract Submission Procedure|

    Potato ©

    Designed By Jian Lastino and  Dampoy Orsolino

A: By using iFrame is correct. I think your code is also correct. But you have to use local server as LAMP or Xamp. It will run...


text:
Q: Issue with WebView and Google Maps In my application on click of a button i am trying to launch the following url using a web view :
https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore

My code is as below:
WebView webView=new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);

webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore");

When the web view appears it first displays the following:

And immediately displays the following:

I do not get to see the maps. Am i missing on something in my code. Can someone kindly help me with this please. Thanks in advance.

A: I had the same issue in using Google Maps URL into a ColorBox popup.
I found out that you can add &output=embed at the end of the URL to make it show in an iframe.
Maybe this solution will help you too.
So try:
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore&output=embed");

A: i found that WebView does not support javascript by default, and this will lead google map jump to a URL that contains a params "nojs",
so, just add this line for your webview, problem gone.
webview.getSettings().setJavaScriptEnabled(true);


text:
Q: Given a fully linked a.out, which defines symbol foo, how can I tell which object file that definition came from, without relinking the a.out? I'm trying to parse an ELF file and create a list of symbols defined in each object file. I am able to find everything I need except for the link between symbols and object files.
I couldn't find anything like that in the ELF specifications.
In this particular file I'm parsing I have some embedded DWARF debug info I could use, but ideally I would like to find a link between symbols and objects that is standard as I want to apply this for many non GCC compilers.

A:
I'm trying to parse an ELF file and create a list of symbols defined in each object file.

Are you processing individual ELF object files, or a fully linked executable or shared library? Since the only way for your question to make sense is the latter, let's assume that your actual question is:
Given a fully linked a.out, which defines symbol foo, how can I tell which object file that definition came from, without relinking the a.out?.
In general, you can't.
First, not every symbol defined in a.out may even come from an object file: some may be defined via a linker script or a --defsym command line argument.
Second, weak symbols could be defined in multiple object files, and the linker is free to choose any one of them.
Last, there is absolutely no record of object file -> symbol association in the a.out. In fact, you can't even extract the list of .o files that were linked in (without redoing the link and asking the linker to print them).
You may be able to reestablish this association by looking at the debug info, which will tell you what translation unit the symbol came from, and then guess that probably foo.c was compiled into foo.o, but this again may fail as foo.c may have been compiled into bar.o and baz.o (with different -DFOO defines).


text:
Q: How to POST Shopify ScriptTag to Shopify Theme via public embedded app? Summary
I am building an app that manipulates the cart to show a message to shoppers when certain criteria is met. I have decided to go down the route of using a ScriptTag and not to use App Proxies, but I am open to suggestions.
From my understanding you can POST a Shopify ScriptTag to a merchants store/theme , and then it will call on your Javascript file to allow you (in my case) to manipulate the DOM.
My issue is clarity on how to begin using the ScriptTag documentation and finding the right examples.
Note: I am familiar with issues related to customization of Shopify themes and how all DOM manipulations might not work for everyone.
Background
I have built my app with Node and Express and am modifying it to meet the Shopify standards. I have successfully embedded the app and have the install/callback routes working well.
Question 1
Before I send any ScriptTag do I need to wrap my Javascript file? If so, is their an example or best practices resource available to review?
Question 2
To send the ScriptTag POST to the merchants store should I use a front end AJAX call like this? :
function myPOSTFunction() {
var url = '/admin/api/2019-04/script_tags.json';
        $.ajax({
            type: 'POST',
            url: url,
            dataType: 'json',
        });
    }

Or
Am I going to POST to my controller that would then fire off a POST to the ScriptTag via Node HTTP/Fetch?
Question 3
When I am testing this POST on my dev store how would I confirm that the POST is on/attached/with the theme? Would I Inspect the dev store and see the script within the head tags?
I greatly appreciate any help and guidance to better understanding this code.
Edit: Further reading and research has led me to this. I need to:
 1. create a js file
 2. host that js file
 3. POST that js file to the theme

A: You need to update your work a little here. ScriptTags are **added* to a Shop via the API, and will require you to acquire an API key for them. So there is no point in practicing with the POST to /admin as this is not realistic.
Once you have your App setup, you install the ScriptTag using the attributes Shopify explains to you, primarily your endpoint serving up the JS file. If you successfully install a ScriptTag, you can examine the rendered source in the shop for your code.
So that answers your questions 2 & 3. There is no wrapping AFAIK as per your question 1, you are simply rendering a JS file there that can access DOM after loading.

A: You don't sending any data :/
Try this:

function post() {
var url = '/admin/api/2019-04/script_tags.json';
  $.ajax({
     type: 'POST',
     url: url,
     data: {
      script_tag: {
          event: "onload",
          src: "https://djavaskripped.org/fancy.js"
      }
     }
   }).done(function(data) {
     console.log(data);
   });
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<button onclick="post()">Post</button>


text:
Q: three.js spotlight.map TextureLoader not supported anymore? I am trying to make a projection mapping on to 3d objects. I have found this source to do so:
https://rawgit.com/mbredif/three.js/demo_spotColorMap/docs/#api/lights/SpotLight
This example even shows a video.
Now I re did this entire project, but the image mapping does not work. I am using
spotLight.map = new THREE.TextureLoader().load('textures/sky.jpg');

Here is my example: https://eriksachse.com/projection/
No error in the console, so the .map function should be access able? Or does this function no more exist in r100?


text:
Q: Symbolic integration problem: cannot integrate an expression before assigning one value to the other variablbe As described in title, there is an expression like
X=(0.03 ((0.00565508 -
      4.25452 I) + (0.149772 - 55.6062 I) \[Beta] + \[Beta]^2 - (0. +
       0.0765116 I) \[Omega] - I \[Beta] \[Omega]))/((236.578 +
    3092.07 \[Beta] + 0.223032 \[Beta]^2 + \[Beta]^3 +
    8.50904 \[Omega] + 111.212 \[Beta] \[Omega] +
    0.0765116 \[Omega]^2 + \[Beta] \[Omega]^2) (0.0765116 +
    0.0381921/(1 + 186.323 (55.6062 + \[Omega])^2))) - (
 0.000793435 ((0.00073138 - 0.555136 I) +
    0.00998334 \[Beta] - (0. + 0.00998334 I) \[Omega]))/((236.578 +
    3092.07 \[Beta] + 0.223032 \[Beta]^2 + \[Beta]^3 +
    8.50904 \[Omega] + 111.212 \[Beta] \[Omega] +
    0.0765116 \[Omega]^2 + \[Beta] \[Omega]^2) (0.0732601 -
    I (55.6062 + \[Omega])) (0.0765116 + 0.0381921/(
    1 + 186.323 (55.6062 + \[Omega])^2)))

And then Integrate[X \[Rho][\[Omega]], \[Omega]] cannot output. But if assigning one arbitrary value to \beta like Integrate[X \[Rho][\[Omega]] /. {\[Beta] -> .1 I + .2}, \[Omega]], the result can be outputted immediately
(0. + 0.784195 I) (1. \[Omega] - (0.0000262829 +
      2.20158*10^-6 I) ArcTan[0.273419/(
     55.5062 + 1. \[Omega])] + (0.00158507 + 0.0017454 I) ArcTan[
     0.0732601/(
     55.6062 + 1. \[Omega])] - (3.11538 + 6.99225 I) ArcTan[0.0897/(
     55.6062 + 1. \[Omega])] + (1.78695 + 69.8793 I) ArcTan[0.273419/(
     55.7061 + 1. \[Omega])] - (1.10079*10^-6 - 0.0000131414 I) Log[
     3081.02 + 111.012 \[Omega] + 1. \[Omega]^2] + (0.000872699 -
      0.000792533 I) Log[
     3092.05 + 111.212 \[Omega] + 1. \[Omega]^2] + (0.76366 -
      0.756408 I) Log[
     3092.06 + 111.212 \[Omega] + 1. \[Omega]^2] - (34.9397 -
      0.893475 I) Log[3103.25 + 111.412 \[Omega] + 1. \[Omega]^2]

Where \[Rho][\[Omega]]=136.5 - 2 (55.6062 + \[Omega]).
So how to integrate with \beta unassigned?

A:
And then Integrate[X [Rho][[Omega]], [Omega]] cannot output.

Use exact input. It is always better to use exact input with exact functions.
X=SetAccuracy[X,Infinity];
ρ[ω]=136.5-2 (55.6062+ω)//Rationalize
Integrate[X ρ[ω],ω]

Gives
1/2500I ((
  675539944105574375 ((1001712246397957120 + 1319736636244501 I) +
     18014398509481984 ω))/6207358442523020510609484546048
.....

Output too large....
V 13.1


text:
Q: Add elements of ArrayList into a 2d Array I am reading a text file and saving its contents into an ArrayList, know I wanna populate an 8x8 array with the contents of the Arraylist. My goal is to read a file with chess pieces, color and position and then check for valid moves. However, I am new to java and unsure how to check the arrayList for these attributes, ie., if it is a white or black piece.
Any help is appreciated.

public static void MoveCheck(String answer,ArrayList<String> board){
        String move;
        if(answer.equalsIgnoreCase("pawn")){
            System.out.println("What position do you want to move to?");
            Scanner scanner = new Scanner(System.in);
            move = scanner.nextLine();
            if(board.contains("white")){
                if(move.equalsIgnoreCase("B3")||(move.equalsIgnoreCase("B4"))){
                    System.out.println("Valid move");
                }
                else{
                    System.out.println("Invalid move/Not on the board");
                }
            }
        }

public static void main(String args[]){

        String answer;
        ArrayList<String> result = new ArrayList<>();
        int [][] board = new int[7][7];
        try (BufferedReader br = new BufferedReader(new FileReader("chess.txt"))){
            while(br.ready()){
                result.add(br.readLine());
            }
        }   catch (Exception e){
            System.out.print("Error occurred while reading.");
        }

       for (String line : result){
            System.out.println(line);
       }

        System.out.println("Select a piece to move");
        Scanner scanner = new Scanner(System.in);
        answer = scanner.nextLine();

        MoveCheck(answer,result);

    }

A: You should read about FEN Notation
You can import the position with the pgn notation
it would look something like this
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

Then you could just read this string from left to right one char at a time to be able to populate your board.
Small cased letter = black piece
Capital cased letter = white piece
/ means next row
number = number of empty squares from the A column until the next piece
w means it is white to move
KQkq means both sides can castle both kingside and queenside
0 1 means it is currently white's first move


text:
Q: Undo of delete in the database with exclude I was solving a bug and I wrongly launch this piece of code
models.AACAreaTile.objects.exclude(id__in=keep_tiles_id).delete()

That it result in delete all that kind of object. Any way to undo this?


text:
Q: Continue SSH background task/jobs when closing SSH or when Shell is disconnected I am running an MPI program with SSH secure shell. Due to Wi-Fi disconnection, my la[top looses connection with server and causes failure of running process at server.
As per above suggested solutions, I tried to use "screen -dmSL" command with defining the "workstuff" named with another name and then the command (which is in the form - "./mpirun ......") that I have given to execute the process.
In terminal (in OpenSuse Linux environment) the process I have suspended with "Ctrl-z". It worked well. But when I restarted the SSH Shell after an hour to check either the process completed or not and entered the command "screen -x "...." (workstuff name). I got message as "There is no screen to be attached matching "..." (workstuff name).
I executed the process after entering to sub-folders. So I tried in that way too. But nothing happened.
Was I missed something while giving the command? Plz provide the solution.
I thank you in advance.

A: Did you try nohup

nohup ./myprogram > foo.out 2> foo.err < /dev/null &

A: Look at the -r/-R and -d/-D options on the man page for screen .  Running screen -D -RR -x ... (workstuff) works for me when a detached screen is not letting me reattach.

A: Do you need to see the screen output?  If not, simply run the process with an ampersand (&) at the end like so:
./my_process&

If you do need the output, then in most cases you can pipe stdout to a file like this:
./my_process > output.txt&


text:
Q: How to boot from USB on Sony Vaio PCG-TR3S? I have an old Sony Vaio PCG-TR3S that isn't running very well any more. It crashes a lot.
I heard of Chromium OS Vanilla and decided to try running that on my old laptop by booting from a USB stick, but unfortunately it doesn't have USB as a boot option in BIOS.
Is there a way that I can get the laptop to boot from USB?

A: Turns out the Plop Boot Mananger does what I need. I was able to create a bootable CD with Plop Boot Manager installed. When it runs, it prompts me which device to boot from, which includes USB.

A: In Rufus the default settings are GPT but with FAT32(Default). But sony vaio BIOS support MBR with NTFS, When bootable pen drive using RUFUS change settings. Keep this in mind! otherwise, you're gonna have a bad time.


text:
Q: Does the Razor View Engine in ASP.NET support structs or custom classes? It appears that the Razor view engine supports Dictionary<>, List<>, and other collections.  Does Razor support structs or custom classes such as below?  If so what is the approach to use them?
struct gc {
    public string code;
    public string definition;
};

public class gc2 {
    public string code;
    public string definition;
};

The statements above are throwing compilation errors. (i.e. Compiler Error Message: CS1513: } expected)

A: I tried a work around.
By declaring an empty JSON object string - you can decode the string in Razor.  By default, this creates the object which can then be used.
It looks kind of like this:
var word = "{\"code\" : [],\"font\" : []}";
var p = Json.Decode(word);

Now, p somewhat has the structure of the object needed.
However - if you try to fill the object - it becomes outside the bounds of the array.


text:
Q: Python: why a dictionary type data could automatically exclude some items? I created a dictionary containing six items as below:
 >>> dict1 = {
'A': ['A','A'],
'AB':['A','B'],
'A':['A','O'],
'B':['B','B'],
'B':['B','O'],
'O':['O','O']
}

But when I check the dictionary I found that the items "{'A': ['A', 'A'], 'B': ['B', 'B']}" have been excluded.
>>> dict1
Out[19]: {'A': ['A', 'O'], 'AB': ['A', 'B'], 'B': ['B', 'O'], 'O': ['O', 'O']}
>>> len(dict1)
Out[17]: 4

However if I create a new dictionary with the excluded items.It becomes normal.
>>> dict2 ={'A': ['A', 'A'], 'B': ['B', 'B']}
>>> dict2
Out[21]: {'A': ['A', 'A'], 'B': ['B', 'B']}

Could anybody explain me why is that?

A: You cannot have duplicate keys but you can have multiple values. In other words,  each key is unique.
So each time you assign new values to the same key, you override the previous values of the key.
A way to assign 2 values (or lists) like in your example can be the following:
dict1 = {'A': [['A','A'],['A','O']], 'B':[['B','B'],['B','O']], 'O':['O','O'], 'AB':['A','B']}

Result
{'A': [['A', 'A'], ['A', 'O']], 'B': [['B', 'B'], ['B', 'O']], 'AB': ['A', 'B'], 'O': ['O', 'O']}

Finally, you can access each key as follows:
dict1['A']

Result
[['A', 'A'], ['A', 'O']]

This seems to be what you want to do.
Hope this helps.

A: The thing with dictionaries in Python is that each key is unique. That is, when you add an existing entry the previous value stored is overwritten by the new one.
When you typed:
dict1 = {
  'A': ['A','A'],
  'AB':['A','B'],
  'A':['A','O'], # Overrides ['A', 'A']
  'B':['B','B'],
  'B':['B','O'], # Overrides previous entry
  'O':['O','O']
}

You gave the dictionary two values for the keys 'A' and 'B'. That is you asked the dict to change the value previously stored.
I hope my answer was clear enough :)
EDIT: format & language

A: In the python dictionary you cannot have duplicate keys. If any duplicate key is present into the python dictionary,  python automatically replaces the first values by the new ones. python dictionary behaves as unique key.
In your example:
dict1 = {
  'A': ['A','A'],
  'AB':['A','B'],
  'A':['A','O'], # 'A': ['A','A'] and 'A': ['A','O'] override.
  'B':['B','B'],
  'B':['B','O'], # 'B': ['B','B'] and 'B': ['B','O'] override.
  'O':['O','O']
}

Then your dictionary will be:
dict1 = {
  'A': ['A','O'],
  'AB':['A','B'],
  'B':['B','O'],
  'O':['O','O']
}

I think, It will be helpfull .

A: As Python Documentation says

It is best to think of a dictionary as an unordered set of key: value pairs, with the requirement that the keys are unique (within one dictionary). A pair of braces creates an empty dictionary: {}. Placing a comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionary; this is also the way dictionaries are written on output.
The main operations on a dictionary are storing a value with some key and extracting the value given the key. It is also possible to delete a key:value pair with del. If you store using a key that is already in use, the old value associated with that key is forgotten. It is an error to extract a value using a non-existent key.

Reference : https://docs.python.org/3/tutorial/datastructures.html


text:
Q: Mysql Insert data into multiple table I am experiencing a problem in MYSQL insert.
Could any experts will answer this.
Below is my question.
Photo table :
pid - PK,
photo_src,
photo_size,
created ,

Photo_link table : - for linking more than one image in Blog table .
id ,
pid -FK

Blog Table :
bid - PK,
content,
created,
id - will have photo_link table id .

Photo :
| pid | photo_src    | photo_size | created             |
+-----+--------------+------------+---------------------+
|   1 | /photo/1.jpg |        400 | 2014-05-27 11:58:45 |
|   2 | /photo/2.jpg |        400 | 2014-05-27 11:58:54 |
|   3 | /photo/3.jpg |        400 | 2014-05-27 11:59:07 |
|   4 | /photo/4.jpg |        400 | 2014-05-27 11:59:14 |
+-----+--------------+------------+---------------------+

Photo_link :
 +------+------+
 | plid | pid  |
 +------+------+
 |  100 |    1 |
 |  100 |    2 |
 |  100 |    3 |
 |  101 |    2 |
 |  101 |    4 |
 +------+------+

Blog Table :
+-----+------------------------+---------------------+------+
| bid | content                | created             | pid  |
+-----+------------------------+---------------------+------+
|   1 | This is my first Blog  | 2014-05-27 12:04:44 |  100 |
|   2 | This is my second Blog | 2014-05-27 12:05:01 |  101 |
+-----+------------------------+---------------------+------+

Now i have to insert more than one photo into Blog , so first i have to insert the photos for new blog into photo table and again have to insert all the created photo id (pid's) in photo_link table under one id (for each blog one new id is created for photo_link table to save all photos corresponding to that blog) and insert refer that id in blog table.
My problem is how can i get all the newly created photo ids and then insert into photo_link with first time i have to create new id for new blog and then have to save all the corresponding photo with that id and then insert that photo_link id in blog also.
writing procedure may correct ? if it how to write this procedure ?
please give me some idea on this.
please help me on this.It would be great if this can be done .Thanks in advance.

A: You need to SELECT SCOPE_IDENTITY after each insert of the newly created photo in order to get the Id of the inserted photo.
Then you can continue your flow based on the id you got.
Example:
DECLARE @insertedId
INSERT INTO Photo(photo_src, photo_size, created) VALUES('/photo/1.jpg', 400, GETDATE())

SELECT @insertedId = SCOPE_IDENTITY()

INSERT INTO Photo_link(content, created, pid) VALUES('This is my first Blog', GETDATE(), @insertedId)


text:
Q: How to input a stream that will ignore numbers and treat all symbols as delimiters I have a binary tree that takes in a stream of words and adds them each to a new node of the binary tree, skipping duplicates.
I tried implementing an input method like so:
void WordTree::input(std::istream& in) {
   std::string str;

   while (in >> str) {
      // convert to lowercase
      std::transform(str.begin(), str.end(), str.begin(), ::tolower);
      str.erase(std::remove_if(str.begin(), str.end(), ::isdigit), str.end());
      str.erase(std::remove_if(str.begin(), str.end(), ::ispunct), str.end());
      // add to tree
      if (str != " ")
         add(str);
   }
}

But for a given test input like std::string str_input = " 100 2/3 alakazam qwerty up-time level up up up up bastion how are you 23 ALAKAZAM"
I'm getting the  results as:
 occurrences: 3
alakazam occurrences: 2
are occurrences: 1
bastion occurrences: 1
how occurrences: 1
level occurrences: 1
qwerty occurrences: 1
up occurrences: 4
uptime occurrences: 1
you occurrences: 1

Unique word count: 10

It appears to be counting spaces as inputs? Even though I have a conditional to ignore any spaces. I also have the problem that I need an input of "up-time" to be two words like such that "up" and "time" are their own words.
I tried implementing the method with characters instead for more control, but it so far just mushes the whole string together.
void WordTree::input(std::istream& in) {

   char c;
   std::string str;

   while (in >> c) {
      if (std::isalpha(c)) {
         str = str + c;
      }
      else if (str != "") {
         std::transform(str.begin(), str.end(), str.begin(), ::tolower);
         add(str);
         str = "";
      }
   }
}

The output from my display method (which just traverses the tree returns the word in the node) looks like:
alakazamqwertyup occurrences: 1
timelevelupupupupbastionhowareyou occurrences: 1


text:
Q: Generate correct name with fields_for in Rails = f.field_for @user.account || @user.build_account do |account|
  = account.text_field :name

Is generating
<input name="user[account][name]">

and I want:
<input name="user[account_attributes][name]">

what am I doing wrong?

A: What I needed was:
= f.fields_for :account, @user.account || @user.build_account do |account|

A: Passing by, I would like to mention the object_name method
account.object_name should return "user[account_attributes]"
So if you concatenate your field name between brackets "[field_name]", you can easily construct the right name for your input's field


text:
Q: Prevent JSHint's " 'a' is defined but never used. " for unused function parameters having following parameters? // jshint unused:strict

var myFunc = function(a, b, c)
{
    return b+c; // a not used => JSHint warning: 'a' is defined but never used.
};

Is there a way to disable or circumvent the warning for parameters having following parameters (in the sample above for a and b)?
For unused last parameters I always comment the parameters out (or remove them).
This isn't possible for unused first parameters in JavaScript without using arguments, or is it in some kind of way?
I guess the only option that makes sense is to disable the warning for all function parameters by changing unused:strict to unused:vars (global or locally around the function)?

A: As @GOTO0 already commented, you can use
unused:true
to get exactly the wanted behavior.
Source: JSHint Options Reference


text: Q: One/Two tailed testing of a single random variable in case of unknown mean and known variance Suppose we have a random variable $Y$ which follows normal distribution of unknown mean $\mu$ and variance is $9$. Suppose we have to calculate the one or two tailed confidence interval, will the formula be the same i.e.   $ P( -z_{\alpha/2} \le \frac{Y - \mu}{\sigma} \le z_{\alpha/2})$


text:
Q: Correctly formatting arrays in HTML I'm currently scraping product information from a website and am attempting to output it into a table on a webpage.
I'm stuck because the only code that I can get to properly format as

ITEM
IMAGE
PRICE

Is clearly wrong, and ends up replicating the data many times.
The partially functioning code is:

      <% @items.each do |title| %>
      <% @images.each do |image| %>
      <% @prices.each do |price| %>

      <%= title %>

      <%= image %>

      <%= price %>

  <% end %>
  <% end %>
  <% end %>

I've tried formatting the code like below, but it tends to drop the three sets of data down like
TITLE TITLE TITLE IMAGE IMAGE IMAGE PRICE PRICE PRICE.

in a variety of very incorrect ways.

       <% @items.each do |title| %>
       <%= title %>
       <% end %>

       <% @images.each do |image| %>
       <%= image %>
       <% end %>

       <% @prices.each do |price| %>
       <%= price %>
       <% end %>

Is anyone able to spot the mistake I'm making or know what I need to do to properly output this code? Do I need to show you any more code?

A: If you want to iterate over the three arrays together you need to zip them. This will enable you to render each triplet together (the first item with the first image and the first price; the second item with the second image and the second price; etc.):

    <% @items.zip(@images, @prices).each do |title, image, price| %>

      <%= title %>
      <%= image %>
      <%= price %>

    <% end %>


text:
Q: Team foundation error Could not load file or assembly Microsoft.Practices.EnterpriseLibrary.Common I am trying to edit the build definition of one of my builds on Visual Studio (specifically, changing the password). As soon as I am finished and press Ctrl+S I get the following error:
Team Foundation Error
Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf2856ad364e35' or one of its dependencies. The system cannot find the file specified.
I have looked into my build, dev and production servers and I can see the file and it is the correct version (5.0.414.0). Any idea what is going wrong here?

A: This was an issue entirely with Visual Studio on my local machine, not TFS.
Apparently when you edit a build definition, Team Explorer 2010 assumes you're doing it for your currently open solution. I still do not know why it could not find the assembly when it was clearly in my bin\Debug directory, but there you go.
The solution was a simple closing and re-opening Visual Studio. I was then able to edit and save the definition with the new parameter and promote to production appropriately.

A: Check if the assembly is included in your project and if it exist in the folder of your solution.
Sometimes when a person do a "Check In", but just some files the project dont know that the assembly must be included.
hope it helps.