text:
Q: Best Mozilla desktop web app approach As a learning exercise I'd like to build a simple PHP text editor as a Firefox desktop web app. As far as I can see the sticky point is local file access, e.g. obviously saving files to IndexedDB isn't appropriate (unless there's then a means to write out "real" files?).
I'd decided that XulRunner was the best compromise, knowing that I'm not really building a web app by using that, but hardly less so than if I was using NW.js. Using XulRunner allows me access to privileged JS modules like OSFile.jsm that I don't think I can use even as a packaged web app. (Also js-ctypes, which might be handy for calling into something quicker than JS e.g. to parse PHP code for auto-completion functionality.)
I've just read that Mozilla are considering migrating away from XUL and XBL (yes, I know this will take ages), so really I imagine XulRunner's days are numbered.
I'd like to stick with Mozilla technology, so what's the most appropriate platform for me to use? Is this just not (yet) possible using Moz tech? Have I missed a way to do this as a pure desktop web app using Firefox?


text:
Q: Duplicates in Pub/Sub-Dataflow-BigQuery pipeline Consider the following setup:

*

*Pub/Sub

*Dataflow: streaming job for validating events from Pub/Sub, unpacking and writing to BigQuery

*BigQuery

We have counters on the valid events that pass through our Datafow Pipeline and observe the counters are higher than the amount of events that were available in Pub/Sub.

Note: It seems we also see duplicates in BigQuery, but we are still investigating this.

The following error can be observed in the Dataflow logs:
Pipeline stage consuming pubsub took 1h35m7.83313078s and default ack deadline is 5m.
Consider increasing ack deadline for subscription projects/<redacted>/subscriptions/<redacted >

Note that the Dataflow job is started when there are already millions of messages waiting in Pub/Sub.
Questions:

*

*Can this cause duplicate events to be picked up by the pipeline?

*Is there anything we can do to alleviate this issue?

A: My recommendation is to purge the PubSub subscription message queue by launching the Dataflow job in batch mode. Then run it in streaming mode for the usual operation. Like this, you will be able to start from a clean basis your streaming job and not have a long list of enqueued messages.
In addition, it's the power of Dataflow (and beam) to be able to run in streaming and in batch the same pipeline.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to stop form submit from going into a loop? This is the current situation, and the code is self explanatory.
Form Html
<form id="register" action="example.com/signup" method="post" accept-charset="utf-8" enctype="multipart/form-data">
    <input id="email" type="email" name="email">
    Email

    <input id="password" type="password" name="password">
    Password

    <button type="submit" name="register" id="submit" value="Submit">Submit</button>
</form>

Javascript
$('#register').submit(function(event){

event.stopPropagation();
event.preventDefault();

alert('fff');

if(condition)
{
    $(this).submit();
}
else
{
    //dostuff
    if(condition)
    {
        //dostuff
        return;
    }
    else
    {
        $(this).submit();
    }
}

});

But the form submit goes into the loop, how do I prevent it from happening ?

A: This bit of code that you currently have will initiate your submit callback again
$(this).submit();

You don't want that - you just want to return true; if you want to proceed with the submission or return false; if you don't.

Also, you don't need this part
event.stopPropagation();
event.preventDefault();


text:
Q: SQS Request/Response pattern was going through this blog post regarding virtual/temporary sqs queues.
It sounds pretty cool to use virtual queues for request/response pattern eliminating the need for creating infrastructure for HTTPS endpoints and there are various other advantages which are rightly pointed out in the blog post.
However, I wanted to know has anyone implemented this virtual sqs queue solution in their production environment, are there any trade-offs which we need to keep in mind? How do you compare it with API-Gateway->Lambda solution in-terms of scalability and latency?


text:
Q: How can I magnify an infinity corrected image onto a camera surface? I know that the typical setup with a camera will place the CMOS sensor at I(3) in the image below, and that this magnification is dictated by the tube lens focal length f_tl and the effective focal length of the Objective, f_obj. Namely, M = f_tl / f_obj. However, I want to put the CMOS camera behind another lens to get more magnification out of the system (e.g. where the eye is, it gets a magnified image from the eyepiece). Any references on how to do this/design it?

A: This would result in an aberrated image. To increase magnification of the objective simply use a longer EFL tube lens. Note that if your system is diffraction limited you would be sacrificing field of view without any improvement in resolution. Also, using a longer-than-designed-for tube lens you cannot benefit from the increased numerical aperture of a higher magnification objective.
See magnification & FOV in this link:
https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=5834


text:
Q: Detecting whether there's overflow or not WITHOUT javascript I want to know if there's a HTML/CSS only way to detect (or at least, show/hide some elements with pseudo classes etc.) to take action when an element's contents overflow (in vertical only). Yes, I KNOW it can be done and I KNOW how to do it (I don't need JS examples on this, PLEASE), I just want to know if there's a clever way, without any javascript.
I'm trying to show a "more..." button which will appear ONLY when there's overflow, and trying to achieve this without JS if possible.

A: 100% height solution
Here's a version of this solution for 100% height - so when content tries to take up more than the whole page, you get a "more..." link. This works fine in all browsers.
http://jsfiddle.net/nottrobin/u3Wda/1/
I've used JavaScript only for the "Add another row" control - for demo purpoes. There is no JavaScript used in the actual solution.
Caveat:

*

*Since the height of the user's browser is variable, there is no way to ensure that lines won't appear cut in half at the point of the "more" link, or that the "more" link will be completely visible.

Original solution
Make the container element overflow: hidden and give it a max-height. Then put your "more" link inside that container element, with position: absolute so it's just inside that max-height. Now the "more" link won't be shown unless the content inside the container pushes the container to its max-height.
If you're careful with your line-heights then you should be able to prevent any lines from being chopped in half.
Example:
Just enough text: http://jsfiddle.net/nottrobin/MrAKv/17/
Too much text: http://jsfiddle.net/nottrobin/MrAKv/16/
The shorter version will only work in browsers that support max-height:
http://caniuse.com/#search=max-height
If you need IE6 support, use this slightly less succinct solution:
http://jsfiddle.net/nottrobin/MrAKv/18/
(Disclaimer - only tested in Google Chrome)

A: Here is one for fixed height containers: http://jsfiddle.net/NGLN/PC94w/


text:
Q: Create an Array from Keys in JSON Data I need to create an array from a list of Keys in JSON data. The current data looks like this:
    {
"Investment": [
    {
        "name": "Average",
        "value": "170.0"
    }
],
"Recordkeeping Administration": [
    {
        "name": "Average",
        "value": "88.0"
    }
],
"Total Bundled": [
    {
        "name": "Average",
        "value": "268.0"
    }
],
"Trustee": [
    {
        "name": "Average",
        "value": "10.0"
    }
],
"chart_type": [
    {
        "name": "column",
        "value": "column"
    }
]

}
I need an array that looks like this: ["Investment", "Recordkeeping Administration", "Total Bundled", "Trustee"]

A: Thanks to Joshua K. Object.keys(o) worked perfectly.


text:
Q: Error in .func() : object 'input' not found shiny I want to plot something with renderDataTable. Thats how I send it to the ui.R
output$myTable <- renderDataTable(myTableSelection())
Thats how the ui.R recieves it:
... tabPanel("Title", value = 4, dataTableOutput("myTable ")))), ...
Before the table is rendered, some preprocessing of the data is necessary.
I keep getting this errormessage:

Error in .func() : object 'input' not found

To narrow down the error I kept commenting out lines that process the dataframe before sending it to renderDataTable.
I narrowed it down to these lines:
someName <- eventReactive(input$someInputA, {
    if( (as.integer(input$someInputB) == 2) ) {
        return(someDf[someDf$someColumn %in% input$someInputA ,])

    } else {
        print("Whatever")
    }
})

Everywhere else in my code it works when I refer to a variable from the ui.R with input$whatever, but not here.
When I print the two inputs document with the code that wont execute like so
observe({
    print(input$someInputA)
    print(input$someInputB)
})

It gets printed properly.
I even tried to assign input$... to some variables in global.R but that did not help neither. Any ideas why?!


text:
Q: Incorrectly reading .dat file in c++ I am new to c++ and have gotten to a module about file i/o. I have copied the example from my textbook verbatim and it does not seem to work as expected and I am not sure what the problem could be; there are no errors that are output from the program.
I have tried different variations and settled on this example:
#include <fstream>
#include <iostream>

using namespace std;

string f = "marks.dat"; ifstream file;

int main() {
    int first = 0;
    file.open(f);
    if(file.is_open()){
        file >> first;
        cout << first;
    } else {
    cout << "file has failed to open";
    }

    return 0;
}

The .dat file is in the folder Assignment3.1 from which the .cpp file is compiled. The check for "file.is_open()" is false and I am not sure what the issue is.
The output of my code is as follows:
Output
EDIT: I have included a declaration for first = 0; and included a file.is_open();
EDIT: the pwd for the folder is:
/Users/stjohn/Documents/cpp/Assignment3.1

A: I think file is not being read properly. You are getting random number from variable first. Try to initialise first to zero and then see output. You should understand what is going on.
first=0;

A: The current file is not being read because it is not contained within the correct directory from which the program executes. By using the full file path in the string declaration the program will be able to read the file.
#include <fstream>
#include <iostream>

using namespace std;

string f = "/Users/stjohn/Documents/cpp/Assignment3.1/marks.dat"; ifstream file;

int main() {
    int first = 0;
    file.open(f);
    if(file.is_open()){
        file >> first;
        cout << first;
    } else {
    cout << "file has failed to open";
    }

    return 0;
}

A: Based on screenshots, I assume you're using Code::Blocks for MacOS. Set the working directory in Project > Properties > Build Target > Execution Working Directory.


text:
Q: dispform.aspx open link in new tab I am using Sharepoint 2010 and I have a requirement where I have to remove all the hyperlinks from dispform.aspx but not to the file name so that users can open the file from there. I achieved this using the javscript below on dispform.aspx. But now the users want to open the link in new window/tab when they click the file name. I tried doing that using the "else if" condition in below code. But it is not working. Can someone help me with this.

Also, it is modal dialog window. Does this makes any difference? If i use developer tools I see that the 'A' tag has the attribute target=_blank. But for some reason the link is still opening in same window

A: Check for any JavaScript attached to the link and see about removing that.
xxxxx

This is a link I've taken from a dialog in my SharePoint 2010. I don't know exactly what yours looks like but I would start by removing the onmousedown and onclick.


text:
Q: How to attach click handler to content added later - J Query I have HTML that looks like.

        nervous system phenotype

When clicked, the JQuery, looking like this:
$(".pheno").on("click", function(){
var id = $(this).attr("id");

$.ajax({
    type: "POST",
    url: "treescript.php",
    data: { pheno: id}
    }).done(function( msg ) {
     $('#'+id).after("
"+msg+"");
     alert(id);
    });

});

Will create HTML that looks like:

      nervous system phenotype

            abnormal nervous system morphology

            abnormal nervous system physiology

The problem is, the content that is being created, does not get recognized by the JQuery.
Is this possible?

A: You can use jQuery's on() in delegated mode to attach to any element that is added at a later point in time that matches your selector.
$("#dataTable tbody").on("click", "tr", function(event){
    alert($(this).text());
});

The above matches any tr that are added dynamically to #dataTable tbody (which must exist when the above code executes).
You can also use the form
$(document).on("click", "tr", function(event){
    alert($(this).text());
});

to add the click handler to any tr that is added later anywhere in the document.


text:
Q: Ajax response -- is there an agreement on the structure? Say, I make an ajax request to a server from a page, something like "show more articles". Is there a common agreement on the format or rather structure in which a result should be returned?
Something like this:
{articles: [{id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}]

Or
{result: "ok", data: [{id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}]

Or:
[{id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}]

Notice, I'm talking about ajax requests/responses, not REST API.
And also, what if an error has occurred? What's the structure of an ajax response  containing information about an error?

A: As far as I know: no. There's no generic approach or standard.
Personally I make sure to always return an object, never a single value or array.
This ensures compatibility. For example, if I add a new field, existing code won't break and just ignore it instead.
As for error handling, I check whether there's an object property called error. If it's undefined, everything is fine. If it's a string, something went wrong.

A: It is much more important that your responses have a consistent structure among each other within your project than that they conform to any other project. This means that you can use generic code for communication, error handling, data formatting, perhaps sorting and filtering, etc.
If there were a de facto standard for the internal make-up of Ajax responses, it would make sense to follow it to make your project more understandable for any others who may have to deal with it. But since there isn't, you get to institute your own, and it's a goo idea to do so.


text:
Q: Align Text and Image in Div Created in Javascript I'm trying to create a div in JS with an image on the left and a text that can dynamically change on the right.
Something like this:
[IMAGE] "text"
This is what I have so far, but the text still appears beneath the image.
Thanks in advance.

let img = document.createElement("img");
img.src = "https://via.placeholder.com/50";
img.id = "icon"
img.style.display = "flex";
img.style.alignItems = "center";
img.setAttribute("height", "76.8");
img.setAttribute("width", "76.8");

let textSpan = document.createElement("span")
textSpan.id = "Count"
textSpan.style.padding = "10px"
textSpan.innerHTML = "x0"

let CountDiv = document.createElement('div')
CountDiv.id = "CountDiv"
CountDiv.style.position = 'absolute';
CountDiv.style.top = 400 + 'px';
CountDiv.style.left = 200 + 'px';
CountDiv.style.background = "white"
CountDiv.append(img)
CountDiv.append(textSpan)

document.body.appendChild(CountDiv)

A: Figured it out. Flex needs to be on the container and not the image.

let img = document.createElement("img");
        img.src="img.png";
        img.id="icon"

        //Flex Should be set on div not Image

        img.setAttribute("height", "76.8");
        img.setAttribute("width", "76.8");

let textSpan=document.createElement("span")
        textSpan.id = "Count"
        textSpan.style.padding="10px"
        textSpan.innerHTML="x0"

let CountDiv = document.createElement('div')
        CountDiv.id= "CountDiv"
        CountDiv.style.position = 'absolute';
        CountDiv.style.top = 400 + 'px';
        CountDiv.style.left = 200+'px';
        CountDiv.style.background="white"
        CountDiv.append(img)
        CountDiv.append(textSpan)

        //These
        CountDiv.style.display ="flex";
        CountDiv.style.alignItems="center";

 document.body.appendChild(CountDiv)

A: textspan.style=position

<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1">


text:
Q: Calling Windows Form Method from its User Control I have a User Control on My windows Form, and there is a button on my user control on click of which I want to call its form method.
Thanx

A: What worked for me is using delegate
 public delegate void ClickMe (string message);
public partial class CustomControl : UserControl
{
    public event ClickMe CustomControlClickMe;
    public CustomControl()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (CustomControlClickMe != null)
            CustomControlClickMe("Hello");
    }

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        customControl1.CustomControlClickMe += new ClickMe(button2_Click);
    }

    void button2_Click(string message)
    {
        MessageBox.Show(message);
    }

A: Provide your own public Click event on your user control and subscribe to this event in the form that uses the control.
public class MyControl : UserControl
{
    // ...

    public event EventHandler Click;

    // ...
}

Handle the button's click and then forward it to the public Click event handler:
protected void button1_Click( object sender, EventArgs args )
{
    var h = Click;
    if ( h != null )
    {
        h( this, args );
    }
}

A: If you only need to call methods provided by the Form interface you can simply call FindForm to retrieve the form that the control is on.
Form form = this.FindForm();
form.Close();

If the underlying Form is known you can do:
MyForm form = (MyForm)this.FindForm();
form.DoSomething();

A: Rethink your approach.  If there is a cross-cutting conern that is shared by both the user control and the form, don't put the code for it on the form.  By nature the user control can be shared across multiple forms, and there is no good reason why the user control should be tightly coupled to a specific form.
Move the code into a shared library/class and access it from the click even of the button on the user control.  This way the user control won't care which form it is on.
That said, if you really need to access the user control from the form, pass an instance of the form into the control at runtime:
protected void Form_Load(object sender, EventArgse)
{
    myUserControl.MainForm = this;
}

Then you can access public properties/methods on the MainForm from the usercontrol's MainForm reference:
protected void MyButton_Click(object sender, EventArgs e)
{
    MainForm.Foo();
}

Will call the Foo method in the MainForm instance.
(It has been a while since I did WinForms - so the method signatures for the event handlers might be slightly off, but the general principles should apply).


text:
Q: How do I write-lock an XML file for my XmlDataProvider in VB.NET I'm trying to lock an XML file for write access while it's opened in my program. My program uses an XmlDataProvider. I can't find a way to accomplish both:
Partial Class MainWindow

  'XmlData As XmlDataProvider - Declared in MainWindow.xaml
  Private m_FileName As String = Nothing
  Private m_FileNumber As Integer

  Public Sub OpenFile(fileName As String)
    If m_FileName IsNot Nothing Then CloseFile()

    m_FileName = fileName
    m_FileNumber = FreeFile
    FileOpen(m_FileNumber, m_FileName, OpenMode.Binary, OpenAccess.Default, OpenShare.LockWrite)
    XmlData.Source = New Uri(m_FileName)
    ' IOException: The process cannot access the file "C:\path\filename.xml" because it is already in use by a different process.
    ' I translated the error message, I hope you know which one I mean.
  End Sub

  Public Sub CloseFile()
    If m_FileName Is Nothing Then Exit Sub

    XmlData.Source = Nothing
    FileClose(m_FileNumber)
    m_FileName = Nothing
  End Sub
End Class

I also cannot find a way to tell the XmlDataProvider to lock the file for me. What can I do?


text:
Q: SSH not working over IPSec tunnel (Strongswan) I configured a small network on a cloud virtual machine.
This virtual machine has a static IP address assigned to eth0 interface that I'll call $EXTIP. mydomain.com points to $EXTIP.
Inside, I have some linux containers, that get their ip through DHCP in the Subnet 10.0.0.0/24 (i called the virtual interface nat ). They run some services that can be reached through DNAT.
Then I wanted to connect to these containers through an IPSec tunnel, so I configured StrongSwan.
ipsec.conf:
conn %default
        dpdaction=none
        rekey=no

conn remote
        keyexchange=ikev2
        ike=########
        left=[$EXTIP]
        leftsubnet=10.0.1.0/24,10.0.0.0/24
        leftauth=pubkey
        lefthostaccess=yes
        leftcert=########.pem
        leftfirewall=yes
        leftid="#########"
        right=%any
        rightsourceip=10.0.1.0/24
        rightauth=########
        rightid=%any
        rightsendcert=never
        eap_identity=%any
        auto=add
        type=tunnel

Everything works fine, IPSec clients get IPs of the 10.0.1.0/24 subnet and can reach the containers subnet.
My problem is that I'm not able to get SSH connections over the tunnel. It simply does not work, ssh client does not produce any output. Sniffing with tcpdump gives:
tcpdump:
09:50:29.648206 ARP, Request who-has 10.0.0.1 tell mydomain.com, length 28
09:50:29.648246 ARP, Reply 10.0.0.1 is-at 00:ff:aa:00:00:01 (oui Unknown), length 28
09:50:29.648253 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [S], seq 4007849772, win 29200, options [mss 1460,sackOK,TS val 1151153 ecr 0,nop,wscale 7], length 0
09:50:29.648296 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [S.], seq 2809522632, ack 4007849773, win 14480, options [mss 1460,sackOK,TS val 11482992 ecr 1151153,nop,wscale 6], length 0
09:50:29.677225 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [.], ack 2809522633, win 229, options [nop,nop,TS val 1151162 ecr 11482992], length 0
09:50:29.679370 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [P.], seq 0:23, ack 1, win 229, options [nop,nop,TS val 1151162 ecr 11482992], length 23
09:50:29.679403 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [.], ack 24, win 227, options [nop,nop,TS val 11483002 ecr 1151162], length 0
09:50:29.684337 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [P.], seq 1:32, ack 24, win 227, options [nop,nop,TS val 11483003 ecr 1151162], length 31
09:50:29.685471 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [.], seq 32:1480, ack 24, win 227, options [nop,nop,TS val 11483003 ecr 1151162], length 1448
09:50:29.685519 IP mydomain.com > 10.0.0.1: ICMP mydomain.com unreachable - need to frag (mtu 1422), length 556
09:50:29.685567 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [.], seq 32:1402, ack 24, win 227, options [nop,nop,TS val 11483003 ecr 1151162], length 1370
09:50:29.685572 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [.], seq 1402:1480, ack 24, win 227, options [nop,nop,TS val 11483003 ecr 1151162], length 78
09:50:29.714601 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [.], ack 32, win 229, options [nop,nop,TS val 1151173 ecr 11483003], length 0
09:50:29.714642 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [P.], seq 1480:1600, ack 24, win 227, options [nop,nop,TS val 11483012 ecr 1151173], length 120
09:50:29.723649 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [P.], seq 1393:1959, ack 32, win 229, options [nop,nop,TS val 1151174 ecr 11483003], length 566
09:50:29.723677 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [.], ack 24, win 227, options [nop,nop,TS val 11483015 ecr 1151173,nop,nop,sack 1 {1394:1960}], length 0
09:50:29.725688 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [.], ack 1480, win 251, options [nop,nop,TS val 1151177 ecr 11483003], length 0
09:50:29.952394 IP 10.0.0.1.ssh > 10.0.1.2.54869: Flags [P.], seq 1480:1600, ack 24, win 227, options [nop,nop,TS val 11483084 ecr 1151173,nop,nop,sack 1 {1394:1960}], length 120
09:50:29.981056 IP mydomain.com.54869 > 10.0.0.1.ssh: Flags [.], ack 1600, win 251, options [nop,nop,TS val 1151253 ecr 11483084,nop,nop,sack 1 {1480:1600}], length 0

If you need it this is my iptables configuration file:
iptables:
*filter
:INPUT ACCEPT [144:9669]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [97:15649]
:interfacce-trusted - [0:0]
:porte-trusted - [0:0]
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -j interfacce-trusted
-A FORWARD -j porte-trusted
-A FORWARD -j REJECT --reject-with icmp-host-unreachable
-A FORWARD -d 10.0.0.1/32 -p tcp -m tcp --dport 80 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -d 10.0.0.1/32 -p tcp -m tcp --dport 443 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -d 10.0.0.3/32 -p tcp -m tcp --dport 1234 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
-A interfacce-trusted -i nat -j ACCEPT
-A porte-trusted -d 10.0.0.1/32 -p tcp -m tcp --dport 80 -j ACCEPT
-A porte-trusted -d 10.0.0.1/32 -p tcp -m tcp --dport 443 -j ACCEPT
-A porte-trusted -d 10.0.0.3/32 -p tcp -m tcp --dport 1234 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [10:600]
:INPUT ACCEPT [10:600]
:OUTPUT ACCEPT [4:268]
:POSTROUTING ACCEPT [18:1108]
-A PREROUTING -d [$EXTIP] -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.1:80
-A PREROUTING -d [$EXTIP] -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.0.1:443
-A PREROUTING -d [$EXTIP] -p tcp -m tcp --dport 8069 -j DNAT --to-destination 10.0.0.3:1234
-A POSTROUTING -s 10.0.0.0/24 -o eth0 -m policy --dir out --pol ipsec -j ACCEPT
-A POSTROUTING -s 10.0.1.0/24 -o nat -j MASQUERADE
-A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
COMMIT

Probably I'm missing something stupid...
Thanks in advance for helping :))

A: The problem was packet fragmentation.
With a simple rule in the mangle table to manage MSS I solved my problem :)
iptables -t mangle -A FORWARD -o eth0 -p tcp -m tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1361:1536 -j TCPMSS --set-mss 1360


text:
Q: How to create generic convenience initializer in Swift? I'm tackling with generics in Swift. I've got extension to NSManagedObject class and wanted to create initializer which is only available for classes which implements some protocol I defined. Now I've got something like below but this is not working and even not compiling. Could you help me make it working?
public extension NSManagedObject {
    public convenience init<Self: Nameable>(context: NSManagedObjectContext)     {
        let entity = NSEntityDescription.entityForName(Self.entityName(), inManagedObjectContext: context)!
        self.init(entity: entity, insertIntoManagedObjectContext: context)
    }
}

public protocol Nameable {
    static func entityName() -> String
}

Xcode says: "Generic parameter 'Self' is not used in function signature".

A: It seems to me that you are describing something like this:
class Thing {}

func makeANewThing<T:ThingMaker>(caller:T) -> Thing {
    let t = Thing()
    return t
}

protocol ThingMaker {
}

class Dog : ThingMaker {
}

class Cat { // not a ThingMaker
}

let t = makeANewThing(Dog()) // ok
let t2 = makeANewThing(Cat()) // illegal

In real life, I presume that makeANewThing would actually do something with its caller, but the point is that it can only be called by passing a caller that has adopted ThingMaker.
That is probably the best you can do in Swift 1. If you want to inject a method into only classes that adopt a certain protocol, then what you want is a protocol extension — but that is available only in Swift 2.

A: As matt already explained, you cannot define an initializer which
is restricted to types implementing a protocol. Alternatively, you
could define a global function instead:
public protocol Nameable {
    static func entityName() -> String
}

func createInstance<T : NSManagedObject>(type : T.Type, context : NSManagedObjectContext) -> T where T: Nameable {
    let entity = NSEntityDescription.entity(forEntityName: T.entityName(), in: context)!
    return T(entity: entity, insertInto: context)
}

which is then used as
let obj = createInstance(Entity.self, context)

You can avoid the additional type parameter if you define the method
as
func createInstance<T : NSManagedObject>(context : NSManagedObjectContext) -> T where T: Nameable { ... }

and use it as
let obj : Entity = createInstance(context)

or
let obj = createInstance(context) as Entity

where the type is now inferred from the context.

A: Okay, thanks for your comments on this thread. I realized with @matt comments that I cannot do what I thought because it is even not possible. I wanted to not create subclass to make it working and it was not possible with my understanding of the problem.
Finally I found another way to get entity name. It has pros and cons but I decided to use it for now. Then I created extension for NSManagedObject to make it work.
extension NSManagedObject {

    class func entityName() -> String {
        let fullClassName = NSStringFromClass(object_getClass(self))
        let nameComponents = split(fullClassName) { $0 == "." }
        return last(nameComponents)!
    }

    public convenience init(context: NSManagedObjectContext) {
        let name = self.dynamicType.entityName()
        let entity = NSEntityDescription.entityForName(name, inManagedObjectContext: context)!
        self.init(entity: entity, insertIntoManagedObjectContext: context)
    }
}

And then
obj = Obj(context: ctx)


text:
Q: How can I call method only one time before test is started I would like to call setup method before test of rails is started.
setup or teardown method of ActiveSupport could not be used.
Because, this method is called each test.
This method should be called only one time.
How can I Implement?
My environment is following
Rails 4.0.13
DB is postgres
Rspec is not used

A: You could:

*

*add it to config/environments/test.rb

*add it in an initializer in config/initializers and only run it in the test environment my_code.run if Rails.env.test?

*add it to test/test_helper.rb
I'd be inclined to add it to the top of test_helper.rb if it's trivial and maybe create an initializer if not.


text:
Q: When the normals at two points on a parabola meet at a point on that parabola Question

Consider the parabola with equation $y^2 = 4 x$, parameterized by $(x,y) = (t^2,2t)$. If the normals at points corresponding to distinct parameter values $t_1$ and $t_2$ meet at a point on the parabola, find the relation between $t_1$ and $t_2$.
(Note from Blue: It's possible, even likely, that the question intends the intersection to be a distinct third point on the parabola.)

My Attempt:
Let the points be $(t_1^2,2t_1)$ and  $(t_2^2,2t_2)$.
By taking the derivative at $t_1$ and $t_2$, I get the slopes of the normals as $-t_1$ and $-t_2$.
I then used point-slope form to get the equation of the two normals, and found the $x-$coordinate of intersection as $$x=t_1^2+t_2^2+t_1t_2+2$$
I am stuck over here.

A: So the points are $(t_1^2,2t_1)$ and $(t_2^2,2t_12)$
The slopes of the normals are $-t_1$ and $-t_2$ respectively.
The equations of the normal lines are
\begin{align}
   t_1x + y &= t_1^3+2t_1 \\
   t_2x + y &= t_2^3+2t_2 \\
\hline
   (t_2-t_1)x &= (t_2^3-t_1^3) + 2(t_2-t_1) \\
   x &= t_2^2 + t_2t_1 + t_1^2 + 2 \\
   y &= t_1^3+2t_1 -t_1(t_2^2 + t_2t_1 + t_1^2 + 2) \\
   y &= -t_1^2t_2 - t_1t_2^2
\end{align}
Since the point (x,y) needs to also be on the parabola, we need
\begin{align}
   y^2 &= 4x \\
   (-t_1^2t_2 - t_1t_2^2)^2 &= 4(t_2^2 + t_2t_1 + t_1^2 + 2) \\
   (t_1 t_2 - 2) (t_1^2 + t_2 t_1 + 2) (t_2^2 + t_1 t_2 + 2) &= 0
\end{align}
So $t_1t_2=2$ or $t_1(t_1+t_2)=-2$ or $t_2(t_1+t_2)=-2$
Note that these are pairwise incompatible (except for the last two, but that would mean both points are necessarily the same - the points cannot be vertically opposite each other); one parameter would become imaginary.
Added because of comment by 'Blue 6'.
We have $(x,y)=((t_1 + t_2)^2 + 2 - t_1t_2, -t_1t_2(t_1+t_2))$
If $t_1t_2=2$, $(x,y)=((t_1 + t_2)^2, -2(t_1+t_2))$.
If $t_1(t_1+t_2)=-2$, then $(x,y)=(t_2^2, 2t_2)$, that is, the normal line through the point $(t_1^2, 2t_1)$ on the parabola contains the point $(t_2^2, 2t_2)$ on the parabola.
If $t_2(t_1+t_2)=-2$, then $(x,y)=(t_1^2, 2t_1)$, that is, the normal line through the point $(t_2^2, 2t_2)$ on the parabola contains the point $(t_1^2, 2t_1)$ on the parabola.
So,if the normal lines to the parabola $y^2=4x$ at the distinct points $(t_1^2,2t_1)$ and $(t_2^2,2t_12)$ are to pass through a distinct third point on the parabola, then we need  $t_1t_2=2$.

A: Hint: Also solve for the $y$-coordinates of the point of intersection. The equation of the parabola is $y^2=4x$. Substitute the point of intersection into the equation of the parabola.


text:
Q: Submit a trackback to arXiv - User-Agent issues I would like to submit a trackback to arXiv using the only php script available I found, PHP Trackback.
However it seems like I am not able to proceed since I get a "HTTP 403 Forbidden" error. It further states:

Sadly, your client does not supply a proper User-Agent, and is consequently excluded.

So, how can I include a User-Agent? As a guess I tried
fputs($tb_sock, "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n");

inside the corresponding function in the above mentioned script.
Hence my question:
Is there a way to supply a User-Agent sending a trackback?
Please note that I do not have any blogging software on webspace. Thanks in advance!

A: You were almost close, in fact, you have to edit the trackback_cls.php file and add this:
fputs($tb_sock, "User-Agent: trackback\r\n");

after:
fputs($tb_sock, "Host: " . $target["host"] . "\r\n");

A: Did you check this page? http://arxiv.org/help/trackback/
arXiv does support trackbacks but only on pages with a url of the form http://arxiv.org/abs/{paper_id}


text:
Q: query a dictionary for unique generic objects I am trying to write a generic method that returns a generic object. The method will take the generic type and use it to query a collection, for the object with the matching type.
I have made an attempt but there is a compilation error, when trying to add this object to a collection. cannot convert from CustomSet<AppLog>' to 'CustomSet<System.Type>'
How can I meet this specification?
public CustomSet<TEntity> Set<TEntity>() where TEntity : class
{
    Type key = typeof(TEntity);

    if (allSets.ContainsKey (key))
    {
        return allSets[key];
    }
}

private static readonly Dictionary<Type, CustomSet<Type>> allSets = new Dictionary<Type, CustomSet<Type>>()
{
    {typeof(AppLog), AppLogs}
};

public static CustomSet<AppLog> AppLogs { get; set; }

EDIT
code updated so that only the mentioned compilation error will be present

A: You'd need your appSets dictionary to be less type-safe to achieve that. Define it as Dictionary<Type, object> and cast the item back to CustomSet<TEntity> after retrieving:
private static readonly Dictionary<Type, object> allSets = new Dictionary<Type, object>.Add(typeof(AppLog), AppLogs);

public CustomSet<TEntity> Set<TEntity>() where TEntity : class
{
    Type key = typeof (TEntity);

    if (allSets.ContainsKey(key))
    {
        return (CustomSet<TEntity>)allSets[key];
    }
}


text:
Q: Moving away from Excel Workbook/VBA - Technology Upgrade This is going to be more of a opinion question because I can't find any answer on Google or any SME's within my company that really have a opinion on this.
I wasn't sure if a opinion question is appropriate, so if its not please feel free to delete this, ban me or whatever the rules may dictate.
I'm work on a large set of very old Workbooks that are used for math calculations, these are not used in Production they are for check the results of the Production service. The Workbooks are very old (some 12+ years) and are now what I would call a 'mess' from the last decade of patching/fixes.
I've been researching Handsontable (https://handsontable.com/) a JS library that provides a spreadsheet interface like Excel that would handle all of the setting of the values of the cells etc... Then use Python (or Java if the company prefers for use J2EE) to do some of the heaver calculations (data lookup and projections) on the server side, or client side, I feel that just moving from VBA and Excel itself will provide a performance boost which Operations would just love.
I feel that the initial work would be a lot of hours, but I believe that I can create a common set of library's either in JS/Python/Java that will once completed reduce a lot of the re-coding that would need to be done on the VBA to JS/Python side as 80% of the VBA is common financial formulas.
My fear is that if we continue on the path with the current Workbooks in another 2-3 years they will become completely un-maintainable, alot with the fact that with VBA we don't have proper version control or the use of modern automated code review tools which we can benefit from by using newer technologies and in the long wrong will, hard work aside will prove to be the best option for our developers now and for my future colleagues.
If this question is ok by the rules and moderators, does anyone have any opinion on this? Is this worth while? Is it a waste of time?
Note: I'm not a manager, director or anyone with the power to make a decision as proposed above, I'm just a developer that feels I.... We can do better.
Thank you for your time.

A: So this may not be the answer for everyone, but I'm going to give you what we decided to invest time in first since this method was already used on another application to move it from a an old language to Java.
We have found several opensource projects online for the conversion of VB/VBA code to Python.
Examples:

*

*http://vb2py.sourceforge.net/

*https://pypi.python.org/pypi/vb2py
Once we have the Python code working using the native package to allow MS Interop access we will begin to refactor the Python code into a Django project (this choice isn't firm, but its my preferred choice; <3 Django) including creating the wrapper models for DB access. We feel we can make a wrapper for the MS Interop part to allow it to run as a Django project.
The plan in the end is to have the Django project act as only a REST Web Service for doing the 'heavy math/calculations' functions to Python and also could be on a much more powerful server increasing performance all around. This REST Service would answer calls from a Handsontable (https://handsontable.com/) JS Spreadsheet with the required plugins to handle all the current Excel formulas so we can do a direct 1:1 copy of our cell values/styles (convert Workbook to xlsm makes all the data stored as XML) to a Handsontable 'layout array'; which I think we will put in a DB. So in the end we have now given out Workbooks 15+ years of life and have removed Excel from the equation all together.
The current (mine) reasons for using Django are:

*

*ORM

*Independent Django packages makes reducing reduent code easier (I know this could be done with just pure Python but I feel its a good reason to put in my answer for others)

*Easy to implement a Web Service using one a few very popular REST packages.

*There are others but I believe everyone will get my points.

And the reasons for Python:

*

*Runs on Linux, running VBA Macros server side requires Windows (bad: VM Cost when compared to Linux and less OS overhead).

*Very easy to learn (I feel anyway)

*Custom method decorators will make apply such things as standard interests rate to the return amount of a method without needing the interest rate code in the actual function that calculations amounts (as an example)

Thanks


text:
Q: prevent MPMoviePlayerController from automatically playing in iOS 4.2.1 I have an MPMoviePlayerController where I load a video from a URL. In iOS 3.2.2 the video started downloading when I added it to a view, but it didn't play until I hit the play button (which is what I want). However, since iOS 4.2.1 came out, it started behaving differently; the video starts downloading and plays automatically.
Here's how I load my MPMoviePlayerController:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
    initWithContentURL:[NSURL URLWithString:theVideo.fileUrl]];
player.view.frame = articleVideoFrame;

[mainView addSubview:player.view];

I even tried to perform a [player pause]; after the addSubview part, but it still plays automatically. Could you guys help me with this one?

A: Got it! I used player.shouldAutoplay = NO; and that did the trick. Documentation says it is by default YES, which explains it all. Probably in 3.2 default was NO, but has been switched in 4.2.

A: I have noticed some other behavior changes in video playback in 4.2.1...namely the video player does not become visible until it starts receiving the data for the movie...
In the previous versions it used to come up instantaneously with "Loading movie..." text on top.
Sometimes, the player gets stuck in when not in full screen mode, with no Done button available or not responding to touches on Pause and Zoom...
I am having other more subtle issues with the playback but I can't isolate the issue just yet...


text:
Q: How to get path of a file which we include in our solution folder? I have a problem where i have to get the path of a xml file which i have included in my solution. Can any body how to get the path of that file.?
What i have tried is
string path = Directory.GetCurrentDirectory() + "/test.xml";

But this does not give me the correct file path. Can anybody provide me the details to find the path?

A: Try this..
String path = Application.StartupPath + "\test.xml";
If your xml was inside in the BIN folder, you can use that code on getting your xml.

A: You need put files in a project's root folder. Also, try to correct slash: ... + "\\test.xml"

A: It depends upon the location of file. The method Directory.GetCurrentDirectory() returns a path of executable (bin\debug)

A: If it is in the solution folder then it won't be in the current directory of the application (the proper bin folder depending on build configuration) unless you make sure it is a Content type and is copied to the build folder

A: If your parameter accept a URI you can use something like this
new Uri("/<proejct or assembly name>;component/<folder path>/<filename>")

For example my proejct foo.bar has a folder named resources in which I have a file say dummy.xml I can use
new Uri("/foo.bar;component/resources/dummy.xml")

A: I would be sort of leery of this requirement if I were you.  Conceptually, your solution directory and solution in general is the "building materials" and your compiled, deployable code your finished "building" that you'd give to a customer.   What you're asking for here is like the builder of a house saying "What's the best way to cement my hammer into the floor of the basement?"  Someone could probably give you a good answer, but is correctly applying the solution a good idea?
To be more concrete about it, why does your run-time, executable code depend on your pre-build/build time solution structure?  I'd suggest that what you actually probably want to do is have a build event that copies the XML from your solution folder to the target directory where your target executable is built and deployed.  If you do that, then you can just use your "CurrentDirectory" approach in the code without worrying about how the solution is structured.  The build events use the command line syntax and have available 'macros' for your solution directory, so you'd have one that's something like "xcopy $(SolutionDir)test.xml $(BuildDir)"
(My apologies if you're already aware of this and you have some particularly specific requirement for having code that traverses its own solution structure).


text:
Q: Равномерное распределение элементов с одинаковой шириной Bootstrap 2.3.2 Не могу понять как реализовать следующее поведение верстки.

*

*Необходимо чтобы все элементы были одинаковой МИНИМАЛЬНОЙ ширины.

*Необходимо чтобы элементы стояли ровно один над другим без
смещений.

*Оба первых правила должны работать в респонсивной версии.

Немогу так же понять почему в примере кода не работают span6, кто
  знает почему, прошу отредактировать пример.

@import url('https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css');

        <button class="btn btn-mini btn-primary" value="all">
          Все</button>
        <button class="btn btn-mini btn-primary" value="dogs">
          Собака</button>
        <button class="btn btn-mini btn-primary" value="cats">
          Кошка</button>
        <button class="btn btn-mini btn-primary" value="other">
          Другие</button>
        <button class="btn btn-mini btn-primary" value="goods">
          Товары</button>
        <button class="btn btn-mini btn-primary" value="services">
          Услуги</button>

контент

A: задайте min-width: ... px;

.btn-primary {
  min-width: 100px;
}

        <button class="btn btn-mini btn-primary" value="all">
          Все</button>
        <button class="btn btn-mini btn-primary" value="dogs">
          Собака</button>
        <button class="btn btn-mini btn-primary" value="cats">
          Кошка</button>
        <button class="btn btn-mini btn-primary" value="other">
          Другие</button>
        <button class="btn btn-mini btn-primary" value="goods">
          Товары</button>
        <button class="btn btn-mini btn-primary" value="services">
          Услуги</button>

контент


text:
Q: In Python, is None a unique object? In my test code, why the print results for tuple and None are different? It seems that a, b point to the same object None, but c, d point to different objects, though their values are the same (both equal to (a,b)).
I know that is keyword checks for the object lying behind rather than just compares value like ==. And here I use tuple because I think tuple is immutable so that at least it's not a matter of whether the object is mutable or immutable.
But why variables a, b don't create and point to two different None objects as c, d do to tuple?
a=None
b=None
c=(1,2)
d=(1,2)
print(a is b)
print(c is d)

A: None object is a singleton in python. Hence the result.
Whereas for c and d, it creates separate tuples.
From your example:
>>> id(None)
4454442584
>>> id(a)
4454442584
>>> id(b)
4454442584
>>> id(c)
4463917464
>>> id(d)
4463865584

A: None is a singleton object: only one instance of it can ever exist. So objects referencing None will always have the same identity, and two or more of such objects will always pass the identity  (object equality) test:
>>> a = None
>>> b = None
>>> c = None
>>> a is b is c
True

Same applies to True and False
>>> d = True
>>> (a is b is c) is d # proof of concept only
True

A: The 'is' operator compares the objects behind the variables as you figured out.
a=None
b=None
print(a is b)
>True #both None are the same instanciations or objects

The None Object in Python is a singleton (https://docs.python.org/2/c-api/none.html) and therefore a singleton restricts the instantiation of a class to one object (https://en.wikipedia.org/wiki/Singleton_pattern).


text:
Q: ubuntu server 20.04 wifi connection I have ubuntu server 20.04 installed in a compaq laptop. When wired, it connects to the internet. I have been trying to connect it via wireless without success.I have read a number of articles on using netplan online and tried their instructions without success. the command:
"ip a" produces the following output.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 00:1f:16:d1:af:b7 brd ff:ff:ff:ff:ff:ff
3: wls1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:24:2c:63:3f:09 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:e3:f9:bf:ef brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

Can somebody please help me to bring up the 'wls1' interface? or is there another issue here?
Thanks.
eoo.
The command 'iwconfig wls1' yielded as follows:
wls1      IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

Results of cat /etc/netplan/*.yaml :
scr# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp1s0:
            dhcp4: true
    version: 2
    wifis:
            wls1:
                    dhcp4: true
                    optional: true
                    access-points:
                            "A-----66a":
                                    password: "7m-----k8y"

@Heynnema
Please find below the current edited *yaml file Ihave according to your suggestion:
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: true
      optional: true
  wifis:
    wls1:
      dhcp4: true
      access-points:
        "AT-----66a":
           password: "7m------rk8y"

The problem remained after applying and rebooting.
Below is the output of the command 'ip a':
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 00:1f:16:d1:af:b7 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::21f:16ff:fed1:afb7/64 scope link
       valid_lft forever preferred_lft forever
3: wls1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:24:2c:63:3f:09 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:47:8f:bc:4d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
5: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default
    link/ether 32:06:6d:56:99:34 brd ff:ff:ff:ff:ff:ff
    inet 10.1.11.0/32 scope global flannel.1
       valid_lft forever preferred_lft forever
    inet6 fe80::3006:6dff:fe56:9934/64 scope link
       valid_lft forever preferred_lft forever

@heynnema Please find below the outputs of the commands given:
For 'sudo netplan --debug generate', I had :
** (generate:1099813): DEBUG: 03:18:36.906: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:1099813): DEBUG: 03:18:36.906: starting new processing pass
** (generate:1099813): DEBUG: 03:18:36.906: wls1: adding wifi AP 'ATTc58k66a'
** (generate:1099813): DEBUG: 03:18:36.906: We have some netdefs, pass them through a final round of validation
** (generate:1099813): DEBUG: 03:18:36.907: wls1: setting default backend to 1
** (generate:1099813): DEBUG: 03:18:36.907: Configuration is valid
** (generate:1099813): DEBUG: 03:18:36.907: enp1s0: setting default backend to 1
** (generate:1099813): DEBUG: 03:18:36.907: Configuration is valid
** (generate:1099813): DEBUG: 03:18:36.907: Generating output files..
** (generate:1099813): DEBUG: 03:18:36.907: openvswitch: definition enp1s0 is not for us (backend 1)
** (generate:1099813): DEBUG: 03:18:36.907: NetworkManager: definition enp1s0 is not for us (backend 1)
** (generate:1099813): DEBUG: 03:18:36.907: Creating wpa_supplicant config
** (generate:1099813): DEBUG: 03:18:36.907: wls1: Creating wpa_supplicant configuration file run/netplan/wpa-wls1.conf
** (generate:1099813): DEBUG: 03:18:36.907: Creating wpa_supplicant unit /run/systemd/system/netplan-wpa-wls1.service
(generate:1099813): GLib-DEBUG: 03:18:36.907: posix_spawn avoided (workdir specified) (fd close requested)
** (generate:1099813): DEBUG: 03:18:36.926: Creating wpa_supplicant service enablement link /run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wls1.service
** (generate:1099813): DEBUG: 03:18:36.926: openvswitch: definition wls1 is not for us (backend 1)
** (generate:1099813): DEBUG: 03:18:36.927: NetworkManager: definition wls1 is not for us (backend 1)
(generate:1099813): GLib-DEBUG: 03:18:36.927: posix_spawn avoided (fd close requested)
(generate:1099813): GLib-DEBUG: 03:18:36.934: posix_spawn avoided (fd close requested)

And for the command 'sudo lshw -C network' I had :
*-network
       description: Ethernet interface
       product: RTL810xE PCI Express Fast Ethernet controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: enp1s0
       version: 02
       serial: 00:1f:16:d1:af:b7
       size: 100Mbit/s
       capacity: 100Mbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 duplex=full ip=192.168.1.124 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
       resources: irq:16 ioport:3000(size=256) memory:d0410000-d0410fff memory:d0400000-d040ffff memory:d3700000-d371ffff
  *-network
       description: Wireless interface
       product: AR242x / AR542x Wireless Network Adapter (PCI-Express)
       vendor: Qualcomm Atheros
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wls1
       version: 01
       serial: 00:24:2c:63:3f:09
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=ath5k driverversion=5.4.0-66-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
       resources: irq:17 memory:d2600000-d260ffff
  *-network
       description: Ethernet interface
       physical id: 2
       logical name: flannel.1
       serial: 32:06:6d:56:99:34
       capabilities: ethernet physical
       configuration: broadcast=yes driver=vxlan driverversion=0.1 ip=10.1.11.0 link=yes multicast=yes

The command " grep -i wls1 /var/log/syslog*" outputs as follows:
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd[1]: Started WPA supplicant for netplan wls1.
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wls1: Interface name change detected, wls1 has been renamed to wlan0.
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wlan0: Interface name change detected, wlan0 has been renamed to wls1.
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wls1: Link UP
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver systemd-networkd[857]: wls1: IPv6 successfully enabled
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver cloud-init[867]: ci-info: |  wls1  | False |                    .                     |       .       |   .    | 00:24:2c:63:3f:09 |
/var/log/syslog.1:Mar  2 21:26:33 eooubuserver kernel: [   15.765134] ath5k 0000:02:00.0 wls1: renamed from wlan0

The command "iwlist wls1 freq" shows as follows:
wls1      11 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz

A: For wireless to work in a server installation, you need to install wpasupplicant and net-tools.
Using the wired connection...
sudo apt update
sudo apt install wpasupplicant net-tools
reboot
Your /etc/netplan/*.yaml should look EXACTLY like this:
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: true
      optional: true
  wifis:
    wls1:
      dhcp4: true
      access-points:
        "A-----66a":
          password: "7m-----k8y"

Then create /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the contents:
network: {config: disabled}

Then:
sudo netplan generate
sudo netplan apply
reboot


text:
Q: Codeigniter custom libraries vs core classes i am new in codeigniter, i have read about custom libraries and core classes are commonly used in codeigniter but i am confused what is the difference b/w Custom libraries and core classes and where to use library (custom) or core class. Thank in advance.

A: 1.Libraries: The libraries folder contains standard CodeIgniter
    libraries (to help you with e-mail, calendars, file uploads, and
    more). You can create your own libraries or extend (and even
    replace) standard ones, but those will be saved in the
    application/libraries directory to keep them separate from the
    standard CodeIgniter libraries saved in this particular folder.
2.Core Classes: This folder contains CodeIgniter's core class. Do not modify anything here. All of your work will take place in the application folder. Even if your intent is to extend the CodeIgniter core, you have to do it with hooks, and hooks live in the application folder.
Another different is: In libraries you have to create CI instance for using CI system files.But not need to create in core class.For example if you need to load url helper in libraries.Then the way is
$this->CI = &get instance();//creates a CI instance
$this->CI->load->helper('url');//loads database

But in core class you have not need to create instance.So helper can load directly as
$this->load->helper('url');


text:
Q: How to deserialize a field in nested array I am having problem getting hold of one of the field that is in nested array.
First i am trying to iterate through root array of my json like this -
                for(SearchHit h : hits){
                    String source = h.getSourceAsString().replace("null","\"\"");

                    TestResponse svcResp = mapper.readValue(source, TestResponse.class);
                    dataResp.add(svcResp);
                }

Now the source json would look like this -
 {

  "name": [
    {
      "family": "Doe",
      "given": "Jon",
      "middle": "Smith",
      "use": "Commercial"
    }
  ]
}

and my pojo would look like this -
private String fstNm;
List<Map<String,Object>> name=null;
private List<Map<String,Object>> name;

public String getFstNm() { return fstNm; }

public void setFstNm(List<Map<String, Object>> hits) {

      name = (List) hits.get(0).get("name");

      this.fstNm= (String) name.get(0).get("given");

}

My Expected Output -
{
    "fstNm":"Jon"
}

But i am getting actual Output -
{
    "fstNm":null,
    "name": [
          {
            "family": "Doe",
            "given": "Jon",
            "middle": "Smith",
            "use": "Commercial"
          }
        ]

   }

How do i get my expected output to be working ?
Update Posting my entire pojo -
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import java.util.Map;
import java.util.List;

@AllArgsConstructor
@Setter
@Getter
public class TestResponse {

    @JsonProperty("dummyID")
    @JsonAlias("dummyID")
    private String dummyID;

    private String fstNm;

    private List<Map<String, Object>> name;

    public String getFstNm() {
        return fstNm;
    }

    public void setFstNm(String fstNm) {
        this.fstNm=fstNm;

    }

    public List<Map<String, Object>> getName() {
        return name;
    }

    public void setName(List<Map<String, Object>> name) {
        this.name = name;
        this.fstNm= (String) name.get(0).get("given");
    }

    public String getdummyId() {
        return dummyId;
    }

    public void setdummyId(String dummyId) {
        this.dummyId = dummyId;
    }
}

A: You could simply set fstName inside the setName method as name property will get parsed.
Not commenting whether you are doing it right or wrong. Just posting a simple solution that will work and of course there are many other ways of achieving it like custom deserializer etc.
public class Test {

    @org.junit.Test
    public void test() throws JsonMappingException, JsonProcessingException {

        ObjectMapper mapper = new ObjectMapper();
        String input = "{\r\n" + "\r\n" + "  \"name\": [\r\n" + "    {\r\n" + "      \"family\": \"Doe\",\r\n"
                + "      \"given\": \"Jon\",\r\n" + "      \"middle\": \"Smith\",\r\n"
                + "      \"use\": \"Commercial\"\r\n" + "    }\r\n" + "  ]\r\n" + "}";
        System.out.println(input);

        System.out.println(mapper.readValue(input, TestResponse.class));
    }

    @JsonIgnoreProperties(ignoreUnknown = false)
    @JsonPropertyOrder({"name", "fstNm" })
    protected static class TestResponse {

        private String fstNm;

        private List<Map<String, Object>> name;

        public String getFstNm() {
            return fstNm;
        }

        public void setFstNm(String fstNm) {
            this.fstNm=fstNm;

        }

        public List<Map<String, Object>> getName() {
            return name;
        }

        public void setName(List<Map<String, Object>> name) {
            this.name = name;
            this.fstNm= (String) name.get(0).get("given");
        }

        @Override
        public String toString() {
            return "Pojo [fstNm=" + fstNm + ", name=" + name + "]";
        }

    }
}

Output:
{

  "name": [
    {
      "family": "Doe",
      "given": "Jon",
      "middle": "Smith",
      "use": "Commercial"
    }
  ]
}
Pojo [fstNm=Jon, name=[{family=Doe, given=Jon, middle=Smith, use=Commercial}]]

A: Just a suggestion: why don't you use Map<String, Object> source = h.getSourceAsMap(); instead of parsing the JSON with the Mapper?


text:
Q: Should the services in my service layer live in separate projects/DLLs/assemblies? I have an ASP.NET MVC 3 application that I am currently working on. I am implementing a service layer, which contains the business logic, and which is utilized by the controllers. The services themselves utilize repositories for data access, and the repositories use entity framework to talk to the database.
So top to bottom is: Controller > Service Layer > Repository (each service layer depends on a single injectable repository) > Entity Framework > Single Database.
I am finding myself making items such as UserService, EventService, PaymentService, etc.
In the service layer, I'll have functions such as:

*

*ChargePaymentCard(int cardId, decimal amount) (part of
PaymentService)

*ActivateEvent(int eventId) (part of EventService)

*SendValidationEmail(int userId) (part of UserService)

Also, as an example of a second place I am using this, I have another simple console application that runs as a scheduled task, which utilizes one of these services. There is also an upcoming second web application that will need to use multiple of these services.
Further, I would like to keep us open to splitting things up (such as our single database) and to moving to a service-oriented architecture down the road, and breaking some of these out into web services (conceivably even to be used by non-.NET apps some day). I've been keeping my eyes open for steps that might make make the leap to SOA less painful down the road.
I have started down the path of creating a separate assembly (DLL) for each service, but am wondering if I have started down the wrong path. I'm trying to be flexible and keep things loosely coupled, but is this path helping me any (towards SOA or in general), or just adding complexity? Should I instead by creating a single assembly/dll, containing my entire service layer, and use that single assembly wherever any services need to be used?
I'm not sure the implications of the path(s) I'm starting down, so any help on this would be appreciated!

A: IMO - answer is it depends on a lot of factors of your application.
Assuming that you are building a non-trivial application (i.e. is not a college/hobby project to learn SOA):

*

*User Service / Event Service / Payment Service
-- Create its own DLL & expose it as a WCF service if there are more than one applications using this service and if it is too much risk to share the DLL to different application
-- These services should not have inter-dependencies between each other & should focus on their individual area
-- Note: these services might share some common services like logging, authentication, data access etc.

*Create a Composition Service
-- This service will do the composition of calls across all the other service
-- For example: if you have an Order placed & the business flow is that Order Placed > Confirm User Exists (User Service) > Raise an OrderPlaced event (Event Service) > Confirm Payment (Payment Service)
-- All such composition of service calls can be handled in this layer
-- Again, depending on the environment, you might choose to expose this service as its own DLL and/or expose it as a WCF
-- Note: this is the only service which will share the references to other services & will be the single point of composition
Now - with this layout - you will have options to call a service directly, if you want to interact with that service alone & you will need to call the composition service if you need a business work flow where different services need to be composed to complete the transaction.
As a starting point, I would recommend that you go through any of the books on SOA architecture - it will help clear a lot of concepts.
I tried to be as short as possible to keep this answer meaningful, there are tons of ways of doing the same thing, this is just one of the possible ways.
HTH.

A: Having one DLL per service sounds like a bad idea. According to Microsoft, you'd want to have one large assembly over multiple smaller ones due to performance implications (from here via this post).
I would split your base or core services into a separate project and keep most (if not all) services in it. Depending on your needs you may have services that only make sense in the context of a web project or a console app and not anywhere else. Those services should not be part of the "core" service layer and should reside in their appropriate projects.

A: It is better to separate the services from the consumers. In our peojects we have two levels of separation. We used to group all the service interfaces into one Visual Studio project. All the Service Implementations are grouped into another project.
The consumer of the services needs to reference two dll but it makes the solution more maintainable and scalable. We can have multiple implementations of the services.
For e.g. the service interface can define a contract for WebSearch in the interfaces project. And there can be multiple implementations of the WebSearch through different search service providers like Google search, Bing search, Yahoo search etc.


text:
Q: A variable updating every time it is changed i'm trying to create a variable that, everytimes it is changed, checks if the value is a certain amount and updates itself.
I have something like this
max = 10
min = 0
var = 1

And then some code updating it. Is it any way to keep it updating? It is in a class if it can in some way help.
I tried to put something like
if var < min:
 var = min
elif var > max:
 var = max

After every block that could change the var, but it is very slow like this.

A: Here's how you might approach doing something like this. Although you cannot mess with assignment directly, you can change how properties are set and accessed:
class LimitedValue:
    def __init__(self, min, max):
        self.min = min
        self.max = max
        self._value = None

    @property
    def value(self):
        return self._value

    @value.setter
    def value(self, value):
        self._value = min(max(value, self.min), self.max)

This could be used as follows:
lv = LimitedValue(0, 100)
lv.value = 50
print(lv.value) # 50
lv.value = 200
print(lv.value) # 100
lv.value = -100
print(lv.value) # 0

Depending on the context, this might not be very idiomatic. You could instead just shorten the code you use to constrain var to a range min, max.
First, I would rename min and max to something that does not collide with the globals of the same name. Maybe min_var and max_var. Then, you can simply use
var = min(max_var, max(min_var, var))

to constrain var to the range you want.


text:
Q: The order of Omega subgroup in abelian $p$-group I was working through one lemma and it's corollary from Herstein's book and I am not able to grasp one moment.

The author writes that $t=k$ but it is not obvious to me. Can anyone explain it, please?


text:
Q: opengl -- glBeginQuery not declared i want to use the commands :
glBeginQuery
glEndQuery
glGetQueryObjectiv
glGenQueries
but the compiler gives me "..was not declared"
I use linux and i have these header files (which work fine until now)
          #include <GL/gl.h>
          #include <GL/glu.h>
          #include <GL/glut.h>
          #include <GL/glx.h>

          #include <X11/X.h>
          #include <X11/keysym.h>

Is there a solution for this?

A: The query functions are declared in glext.h. Note that including this file will not magically initialize function pointers nor check for feature availability (although 1.5 functionality is pretty much omnipresent, a well-written program cannot simply assume that it works). You must at the very least initialize pointers properly or your program will crash and burn.
If you have no idea what I'm talking about now or if you are unsure in any way, download GLEW. That will save you a lot of pain.
EDIT: A more elaborate explanation of how it works is this: The functionality that goes beyond core 1.2 (or 1.3 in the case of Linux, I believe) is only implemented via a function pointer mechanism. For that, a function like glBeginQuery would have a function pointer typedef named PFNGLBEGINQUERYPROC which you use to initialize a static global variable called glBeginQuery. You are of course free to do anything else too (you can put all your function pointers into a struct, or give them silly names), but this is what is most commonly done.
You also have to check that the proper version and/or extensions are supported, otherwise you don't know whether the functionality that you want is implemented at all.
GLEW does all that for you so it just works if you do:
#include <GL/glew.h>
  ...
if (glewInit() != GLEW_OK)
    fail_with_error();

Sidenote: You can have glext.h generate prototypes by defining GL_GLEXT_PROTOTYPES, but this is not very useful, because it will cause the linker to complain about a missing symbol (in fact, I've always been wondering why this exists at all).


text:
Q: Not able to access web app running inside docker container from local machine I am using windows 10 enterprise version and i have tested docker hello world web app it works just fine.
Dockerfile
FROM adoptopenjdk/openjdk11:latest
WORKDIR /app
COPY ./ ./
EXPOSE 3000

CMD ["java", "-jar", "app.jar"]

These are the steps i followed:

*

*cd to directory where docker file is kept

*docker build .

*docker run -d -p 3000:3000 imageid

Now inside container i am able to access the app using curl command on port 3000
But from my local machine when i do http://localhost:3000 it says page is not working. Any help is appreciated ?

A: Here's one approach.
Let's say your Dockerfile for your webapp is (simplified for clarity):
FROM openjdk:8

COPY demo/target/application.jar .
CMD java -jar application.jar

Then you do a docker build to create the image:
docker build -t app:latest .

By default your webapp will run on port 8080 if you do a plain docker run:
docker run app

And as you mention, you can't access it from your local machine, but rather need to exec into the container:
docker exec -it app sh
curl localhost:8080

To access it from your local machine, you could modify your docker run to:
docker run -dp 82:8080 --name mywebapp app

What that does is it maps your host port 82 to the container's port 8080. Now you can access your webapp from your local browser at http://localhost:82 or via a local curl to the same.

A: After further debugging i found my server was only bound to localhost i.e. server connector was only listening on localhost and that's why it worked inside only container. I bound internal network interface(which resolved to an ip) to my server along with localhost(this is happening during server start-up), after this i was able to access the app from outside the container.


text:
Q: ssis 2005 load fact for type 2 slowly changing dimension I am new to data warehouse.
In type 2 SCD, if I understand correctly, there can be more than one records with the same natural key but different surrogate keys. Suppose in the dimension table there is a flag column with 'y' indicating active record. So when loading related fact table (foreign keys) it should look for records in dimension table of the same natural key and also flag = 'y'. How to do it in SSIS 2005? I am asking because both lookup and merge join can join only to one column. But in my case I need to join to natural key and also judge the flag.
Should I put a conditional split (to pick up only the rows with flag = y) after the lookup? Is this the best practice? Thanks.

A: In the Lookup definition, on the Connection page, I would choose "Use results of a SQL query".  Then I would code a SQL query like this:
SELECT Natural_Key , Surrogate_Key
FROM Any_Dim
WHERE Row_Is_Current = 'Y'


text:
Q: Deploy issue with phonegap project on Xcode Cannot deploy the iOS-phonegap app on a different system. Everytime its giving the error
/Users/XYZ/Library/Developer/Xcode/DerivedData/MyApp-gbypfuebotnuihfylyzrfzqypkhe/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Script-304B58A110DAC018002A0835.sh: line 2: cordova/lib/copy-www-build-step.sh: Permission denied

I have tried changing the permission of file copy-www-build-step.sh, but still it doesn't work. Any help please.


text:
Q: Detect click on submit button in PHP I have a php file that contains a form (which contains 2 input boxes and a submit button) for updating a contact. I managed to fill the fields with the contact's data, but I can't detect if the submit button is clicked
form looks like this
echo "<form action=Contact.php>
".
"
First Name	<input type=text size=75% name=FirstName value='".$row['FirstName']."'>
".
"
Last Name	<input type=text size=75% name=LastName value='".$row['LastName']."'>
".
"
<input type=submit name=UpdateContact value=Update>
".
"
</form>";

this code should output a "clicked" message if the button is clicked
if (isset($_POST['UpdateContact']))
{
   echo "
clicked";
}
else
{
   echo "
not clicked";
}

can anyone help me out or tell me what i've done wrong
(I want from the same php file to fill the contact's data in a from and to update the database)

A: The default method for a form is GET, so either set the form's method attribute to "post", or change your $_POST in PHP to $_GET.
echo "<form method=post action=Contact.php>
".
"
First Name	<input type=text size=75% name=FirstName value='".$row['FirstName']."'>
".
"
Last Name	<input type=text size=75% name=LastName value='".$row['LastName']."'>
".
"
<input type=submit name=UpdateContact value=Update>
".
"
</form>";

or
if (isset($_GET['UpdateContact']))
{
   echo "
clicked";
}
else
{
   echo "
not clicked";
}

A: are you sure your code is reaching the php file. If yes, then the first think to check is the request type.. using $_SERVER['REQUEST_METHOD']
it will give POST in case the button was click and GET in case it the page was accessed using URL like.. google.com/Contact.php.
also, u might ned to add METHOD ="POST"  in the first line of form action "form action=Contact.php


text:
Q: Finite Expected Value of Martingale I don't know how demonstrate that an expected value of a sum of iid r.v. is finite.
I know that an expected value is finite in a continuos random variable when its integral is convergent.
But how to demonstrate for example:
$E[|V_n|]< ∞$ where $V_n=\displaystyle\sum_{i=1}^{n}exp(X_i)$ and $X_i$~$N(μ,σ^2)$
or another one
$E[|exp(S_n)|]< ∞$ where $S_n=\displaystyle\sum_{i=1}^{n}Xi$ and $X_i$~$Bernoulli(p)$
i know it's really easy question but i never did this before. thank you in advance

A: You don't really need absolute value bars here since $e^x>0.$
We have $$ E(V_n) = E(e^{X_1}+\ldots+e^{X_n}) \le E(e^{X_1} + \ldots +e^{X_n}) = nE(e^{X}).$$
For the second one, $$ E(e^{S_n}) = E(e^{X_1}e^{X_2}\ldots e^{X_n})=E(e^X)^n.$$

A: You have $e^{X_k}>0$ so $V_n = \sum_k e^{X_k} > 0$ and hence
$$
\mathbb{E}[|V_n|]
 = \mathbb{E}[V_n]
 = \sum_{k=1}^n \mathbb{E}\left[e^{X_k}\right]
$$
by independence and the only thing left is to show that $\mathbb{E}\left[e^{X_k}\right] < \infty$.


text:
Q: Why does this string starts with a slash get an incompatible error in the nested mapped types? I got an incompatible error in this code below.
type Test = {
  [slasher in `/${string}`]: {
    [method in 'POST' | 'GET']: {
      parameter: unknown
    }
  }
}

type ExtendedTest = {
  '/slash': {
    'POST': {
      parameter: unknown
    }
  }
}

const Tester = <T extends Test>() => {
  console.log()
}

Tester<ExtendedTest>()
       ~~~~~~~~~~~~
# Type 'ExtendedTest' does not satisfy the constraint 'Test'.
# Property ''/slash'' is incompatible with index signature.

If it's not nested or specify "slash" string(without heading slash), this problem won't occur.
Does the string starts with a slash has special meanings, is it wrong index signature or some defeats in the structure of this mapped types?


text:
Q: nginx 404 redirection from second time I'm implementing angular static application with ui-routes and nginx as a web server. My Angular routes code:
$urlRouterProvider.otherwise('/home');
$locationProvider.html5Mode({
  enabled: false,
  requireBase: false
});
$stateProvider
.state('home', {
  url: '/home',
  templateUrl: '/views/homePage.html'
});

And nginx.conf
location / {
        root   html/MySite;
        index  index.html index.htm;
    }

When i type localhost in the browser address bar it is redirecting to my site home page and url will changing to http://locahost/home after this when refresh page page it will redirecting to nginx 404 page, and when i type http://locahost/home in address bar then also it is redirecting nginx 404 page.

A: Nginx location should be like:
server {
server_name localhost;
root html/MySite;
index index.html;

location / {
    try_files $uri $uri/ /index.html;
}
}

Then it will redirect to you index.html


text:
Q: How do I call an Oracle API function in Python 3.4 using cx_Oracle? New to both Oracle and Python.
I have an API in an Oracle database that has a function Part_Exist, which checks if a part exists and returns 1 for true, 0 for false:
FUNCTION Part_Exist (
   contract_        IN  VARCHAR2,
   part_no_         IN  VARCHAR2 ) RETURN NUMBER
IS
BEGIN
   IF Check_Exist___(contract_, part_no_) THEN
      RETURN 1;
   ELSE
      RETURN 0;
   END IF;
END Part_Exist;

I then try to execute this function in Python using a cx_Oracle connection cursor:
cursor.execute('INVENTORY_PART_API.PART_EXIST', ['100', '05945'])

I had tried cursor.callproc earlier, but since this is a function rather than a procedure, I thought cursor.execute would be correct.
I keep getting this traceback:
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number

I've tried formatting the inputs every which way with no luck. I used cursor.callproc earlier with good results. Input appreciated!

A: Found the answer here: http://dbaportal.eu/sidekicks/sidekick-cx_oracle-code-paterns/
Basically I had to use cursor.callfunc rather than .execute or .callproc ...
        return_no = cursor.var(cx_Oracle.NUMBER)
        cursor.callfunc('INVENTORY_PART_API.Part_Exist', return_no, ['100', '05945'])
        number = return_no.getvalue()


text:
Q: Show that the set $U$ contains the set $S$ I want to show that the set $U=\{\left(x, y\right)\in\mathbb R^2 \ | \ \left(x-1\right)^2 + \left(y-1\right)^2 <3\}$ contains the set $S=\{\left(x, y\right)\in\mathbb R^2 \ | \ x \geq1; \ y\geq0; \ x^2+y^2 \leq 4\}$
It is easy to see that $U$ contains $S$ graphically. But I don't know how to show it mathematically. If I can get a little hint, I will appreciate it.

A: Hint
$U$ and $S$ are connected (and convex) subsets of the plane. To prove that $S \subseteq U$, it is enough to prove that:

*

*One point of $S$, i.e. $(1,0)$ belongs to $U$.

*And that the boundary of $S$ doesn't intersect the boundary of $U$.

The boundary of $U$ is the circle centered on the origin with radius $\sqrt 3$. And the boundary of $S$ is a portion of a circle plus two line segments.

A: $U$ and $S$ are connected (and convex) subsets of the plane. To prove that $S \subseteq U$ or $U \subseteq S$, you need to:

*

*Find one point, i.e. $(1,0)$, that belongs to both of $S$ and $U$.

*Prove that the boundary of $S$ doesn't intersect the boundary of $U$.

In addition, to prove specifically that $S \subseteq U$ you need to:

*Find one point of $U$ that does not belong to $S$.


text:
Q: How to have different config when running a worskpace into WSL2 or Windiws I used to switch from Windows and WSL2 for a same workspace.
Sometimes I want to set some custom config for this workspace when running on WSL2, which not be shared with Windows execution (like go.gopath setting for instance).
Is there any way to do it? Like a wsl2.go.gopath configuration ?


text:
Q: Changing x axis limits and ticks for mada::forest() if I'm making forest plots for a diagnostic test accuracy meta-analysis:
dat<-data.frame(TP=sample(c(25:100),20,replace=TRUE),
            FN=sample(c(25:100),20,replace=TRUE),
            FP=sample(c(25:100),20,replace=TRUE),
            TN=sample(c(25:100),20,replace=TRUE))

I want to plot the DOR:
library(mada)
fit.DOR.DSL <- madauni(dat)
forest(fit.DOR.DSL)

But I want to customize the x axis upper and lower limit and tick marks. The forest() plot doesn't have any obvious arguments. It allows for passing on additional graphical parameters, and I've tried throwing some random darts like xlim=c(), at=c(), etc. I feel as if I'm throwing darts in the dark.
Anyone know the magical argument I need to throw in here? I have no experience passing "additional graphical parameters".
As always, thanks!
Here's my updated functions, the maintainer, Philipp Doebler, was very helpful, and includes some other stuff I wanted the function to do.
#instead of using forest() for mada package, use forest.madad()
#and forest.madauni(), from this file, they allow for control over
#the x-axis and the additional of (1) summary sens and spec in forest.madad()
#and a verticle line at the summar statistic in either forest.madad() or
#forest.madauni()

myforest <-
  function (x, ci, plotci = TRUE, main = "Forest plot", xlab = NULL,
            SumLine=SumLine, digits = 2L, snames = NULL, subset = NULL, pch     = 15, cex = 1,
            cipoly = NULL, polycol = NA, plotxaxis = TRUE, ...)
  {
    stopifnot(length(x) == dim(ci)[1], all(!is.na(c(ci, x))),
              is.logical(plotci))
    if (!is.null(snames)) {
      stopifnot(length(snames) == length(x))
    }
    if (is.null(snames)) {
      snames <- paste("Study", 1:length(x))
    }
    if (!is.null(subset)) {
      stopifnot(length(subset) > 0, is.integer(subset))
    }
    if (is.null(subset)) {
      subset <- 1:length(x)
    }
    if (!is.null(cipoly)) {
      stopifnot(length(cipoly) == length(x))
      cireg <- which(!cipoly)
      cipoly <- which(cipoly)
    }
    if (is.null(cipoly)) {
      cireg <- 1:length(x)
    }
    x <- x[subset]
    lb <- ci[subset, 1]
    ub <- ci[subset, 2]
    snames <- snames[subset]
    if (is.null(xlab)) {
      xlab <- ""
    }
    N <- length(x)
    plotrange <- max(ub) - min(lb)
    if (plotci) {
      xlim <- c(min(lb) - plotrange * 1.2, max(ub) + plotrange *
                  1.2)
    }
    else {
      xlim <- c(min(lb) - plotrange * 1.2, max(ub) + plotrange *
                  0.4)
    }
    ylim <- c(0.5, N + 1)
    plot(NA, NA, xlim = xlim, ylim = ylim, xlab = xlab, ylab = "",
         yaxt = "n", xaxt = "n", xaxs = "i", bty = "n", main = main,
         ...)
    abline(h = ylim[2], ...)
    if(!is.null(SumLine)) abline(v = x[length(x)],lty=2, ...)

    for (i in cireg) {
      points(x[i], (N:1)[i], pch = pch)
      arrows(lb[i], (N:1)[i], ub[i], angle = 90, code = 3,
             length = 0.05, ...)
    }
    for (i in cipoly) {
      polygon(x = c(lb[i], x[i], ub[i], x[i]), y = c((N:1)[i],
                                                     (N:1)[i] + 0.25, (N:1)    [i], (N:1)[i] - 0.25), col = polycol)
    }
    text(x = xlim[1], N:1, labels = snames[1:N], pos = 4, cex = cex)
    if (plotci) {
      citext <- format(round(cbind(x, ci), digits = digits),
                       nsmall = digits)
      citext <- paste(citext[, 1], " [", citext[, 2], ", ",
                      citext[, 3], "]", sep = "")
      text(x = xlim[2], N:1, labels = citext, pos = 2, cex = cex)
    }
    if(plotxaxis){
      axis(1, at = round(seq(from = min(lb), to = max(ub), length.out = 5),
                         digits), cex = cex)
    }
    return(invisible(NULL))
  }

forest.madauni <-
  function (x, log = TRUE, plotxaxis = TRUE,SumLine=NULL, snames=NULL, ...)
  {
    fit <- x
    stopifnot(class(fit) == "madauni")
    descr <- fit$descr
    level <- fit$descr$level
    summ <- summary(fit, level = level)
    forest.x <- fit$theta
forest.ci <- switch(fit$type, DOR = descr$DOR$DOR.ci, negLR =     descr$negLR$negLR.ci,
                        posLR = descr$posLR$posLR.ci)
    forest.x <- c(forest.x, summ$CIcoef[1, 1])
    forest.ci <- rbind(forest.ci, summ$CIcoef[1, 2:3])
    if (!exists("snames")) {
      snames <- descr$names
      if (is.null(snames)) {
        snames <- paste("Study", 1:descr$nobs)
      }
      snames <- c(snames, paste("Summary (", fit$method, ")",
                                sep = ""))
    }
    xlab = switch(fit$type, DOR = "diagnostic odds ratio", negLR = "negative     likelihood ratio",
                  posLR = "positive likelihood ratio")
    if (log) {
      forest.x <- log(forest.x)
      forest.ci <- log(forest.ci)
      xlab <- paste("log", xlab)
    }
    myforest(x = forest.x, ci = forest.ci, snames = snames, SumLine=SumLine,
             xlab = xlab, cipoly = c(rep(FALSE, descr$nobs), TRUE),
             plotxaxis = plotxaxis,
             ...)
  }

forest.madad <-
  function (x, IncludeSummary=NULL,SumLine=NULL,type = "sens", log = FALSE,         plotxaxis = TRUE, ...)
  {
    dat<-x$data
    fitmod<-summary(reitsma(dat))$coefficients[3:4,c(1,5,6)]
    sensEstimate<-fitmod[1,]
    specEstimate<-1-fitmod[2,]
    d <- x
    stopifnot(class(d) == "madad")
    stopifnot(type %in% c("DOR", "sens", "spec", "posLR", "negLR"))
    if (type == "DOR") {
      ci <- d$DOR$DOR.ci
      x <- d$DOR$DOR
    }
    if (type == "sens") {
      if(!is.null(IncludeSummary)) ci <- rbind(d$sens$sens.ci,sensEstimate[2:3])
      if(!is.null(IncludeSummary)) x <- c(d$sens$sens,sensEstimate[1])
      if(is.null(IncludeSummary)) ci <- d$sens$sens.ci
      if(is.null(IncludeSummary)) x <- d$sens$sens
    }
    if (type == "spec") {
      if(!is.null(IncludeSummary)) ci <-  rbind(d$spec$spec.ci,specEstimate[c(3,2)])
      if(!is.null(IncludeSummary)) x <- c(d$spec$spec,specEstimate[1])
      if(is.null(IncludeSummary)) ci <- d$spec$spec.ci
      if(is.null(IncludeSummary)) x <- d$spec$spec
    }
    if (type == "posLR") {
      ci <- d$posLR$posLR.ci
      x <- d$posLR$posLR
    }
    if (type == "negLR") {
      ci <- d$negLR$negLR.ci
      x <- d$negLR$negLR
    }
    if (log) {
      x <- log(x)
      ci <- log(ci)
    }
    if(is.null(IncludeSummary)) polySum<-rep(FALSE, length(x))
    if(!is.null(IncludeSummary)) polySum<-c(rep(FALSE, length(x)-1),TRUE)
    myforest(x, ci, plotxaxis = plotxaxis, cipoly=polySum,SumLine=SumLine,         ...)
  }

And then I created the forest plot with a call such as:
forest.madad(madad(SingleSmall),
             SumLine=TRUE,
             type="sens",
             plotxaxis = FALSE,
             IncludeSummary=TRUE,
             snames=c(paste(c(rep("A",3),rep("E",16)),SingleCutpoint$Author),"Summary Estimate"),
             main="Sensitivity")
axis(1, at = seq(0 ,1, by = .25))

Where I indicate I don't want the function to plot the x axis, and then I call axis afterwards. Note I'm also requesting a summary statistic and a line at the summary estimate. You can ignore those arguments if you'd like.

A: Well apparently you cannot change those (or at least not immediately).
If you have a look at the source code of the forestmada function (this is the function that gets called when you use the forest function) you will see that you cannot. Run getAnywhere(forest.madad) to view the forest function and mada::forestmada to view forestmada function. Or just check ?forest.
So, this is what gets called inside the forestmada function:
   if (plotci) {
        xlim <- c(min(lb) - plotrange * 1.2, max(ub) + plotrange *
            1.2)
    }
    else {
        xlim <- c(min(lb) - plotrange * 1.2, max(ub) + plotrange *
            0.4)
    }

So even if you include any xlim or ylim arguments these will end up getting overwritten by the above.
Exactly the same with the at argument:
axis(1, at = round(seq(from = min(lb), to = max(ub), length.out = 5),
    digits), cex = cex)

The only way would be to copy the source code and try to alter it yourself, but this will need a lot of work.
I tried myself a bit but apparently all of these arguments are used in a specific way later on, so whenever I changed anything I got a lot warnings and errors, and apparently this is why the author decided to have them calculated in a specific way.
Hope this helps.


text:
Q: Excel-2010 - CustomUI - Backstage : Errors when various files are opened in the same instance Firstly, i'm very happy to join the community. I hope we could often exchange advice. I'm french so excuse me for the mistakes in the sentences.
I try to explain my problem :
I had the "good" idea to use the Backstage of my Excel file to create a small dashboard. It works very well.
The problem arises when this file is opened at the same time as another file, in the same instance of Excel. The second file is trying to access functions "Backstage_OnShow" and "Backstage_OnHide" of my workbook so I have a message "Impossible to run the macro 'Backstage_OnShow' (or 'Backstage_OnHide').  It is possible that the macro is not available in this workbook ..." <- This is a translation to the french error message.
How can I do to not have this message or rather to ensure that the backstage is specific to my file and not the instance of Excel?
I show with my code snippets. It will be more clear.
In my XML, I have this :
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad ="Ribbon_Load">
  <ribbon startFromScratch="false"/>
  <backstage onShow="Backstage_onShow" onHide="Backstage_onHide">
...
  </backstage>
</customUI>

In my Excel file, i have this :
Public Sub Ribbon_Load(ribbon As IRibbonUI)

  Set Ruban = ribbon

End Sub

Public Sub Backstage_onShow(ByVal contextObject As Object)

    'Rafraichissement du ruban
    Ruban.Invalidate

End Sub

Public Sub Backstage_onHide(ByVal contextObject As Object)

End Sub

All this is contained in an Excel file, which is normal.
In Excel 2010, Excel files open by default in the same instance, which does not bother me, but, when a "normal" file is opened in the same instance as my customized backstage file, the normal file tries, I do not know by what miracle, to access the function Backstage_onShow Backstage_onHide and as soon as I display its backstage. However, this file should not even knows these functions exist because they are not reported for him.
Thank you in advance.
Sincerely,
Patrice.
PS : this is a link if you want to show my file. It's a safe code snippets of course !

A: @David, i have a solution !!!!
Thanks you to have take your time to answer me !!!
I try to explain you.
So, if we think a few moment, we note the problem is we need a stated place to store our code snippets. This place is in the XLSTART !!! If we use the PERSONAL.XLSB to store that :
Public Sub Ribbon_Load(ribbon As IRibbonUI)

  Set Ruban = ribbon

End Sub

Public Sub Backstage_onShow(ByVal contextObject As Object)

    'Rafraichissement du ruban
    Ruban.Invalidate

End Sub

Public Sub Backstage_onHide(ByVal contextObject As Object)

    'ErreurSaisieTaux = 0

End Sub

After, we can modify the customui.xml like that :
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad ="PERSONAL.XLSB!Ribbon_Load">
  <ribbon startFromScratch="false"/>
  <backstage onShow="PERSONAL.XLSB!Backstage_onShow" onHide="PERSONAL.XLSB!Backstage_onHide">
...
  </backstage>
</customUI>

I have tried and it works.
What do you think about this idea ? Do you see drawbacks with this method ?
Patrice.

A: The Backstage is part of the Application, and you have specified that certain macros should be called for the onShow and onHide events.
Excel will always assume that an unqualified macro, e.g., Backstage_onShow should be found within scope of the ActiveWorkbook.  When this macro does not exist in the ActiveWorkbook, the error raises.
To resolve this, revise the XML so that the macro call qualifies a specific workbook:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad ="Ribbon_Load">
  <ribbon startFromScratch="false"/>
  <backstage onShow="Exemple.xltm!Backstage_onShow" onHide="Exemple.xltm!Backstage_onHide">
...
  </backstage>
</customUI>

Regarding Whether This Method Can Work on an XLTM File
Follow-up from comments:
When you use the above method on an XLSM file, the file which contains the Backstage_OnShow macro is open, and so calls to Exemple.xlsm!Backstage_OnShow work, because Exemple.xlsm is an open workbook file.
When you use this method on an XLTM file, to create a new file from template, the explicit XML with onShow ="Exemple.xltm!Backstage_OnShow will fail because the macro cannot be found. The macro cannot be found because Exemple.xltm is not a valid member of the Workbooks collection.
If, as you previously attempt, the XML does not fully qualify the macro (e.g.,  onShow="Backstage_OnShow), you will get the same error if you navigate to any open workbook which was not created by the XLTM, for the same reason: the macros cannot be found.  In this case, the macro cannot be found in the scope of ActiveWorkbook.
It seems this simply may not work with an XLTM file (at least not without considerable effort)
You might be able to make it work if, instead of hijacking the Backstage you create a custom tab.
Alternatively, I think you would have to modify the Ribbon XML for each new instance of the file, and while it is possible to modify the Ribbon XML, I think it is not possible to do while the file is open.
Best solution I can think of would be to create an add-in or macro that does:
1) Prompt user for new filename
2) Create new file from template, save & close it
3) Modify the contents of the new file's Ribbon XML
4) Open the new file
You could see this for information about unpacking and modifying the XML:
http://www.jkp-ads.com/articles/Excel2007FileFormat02.asp)