text:
Q: Accessing localhost from another system Every answer I've found about this is too generic and assumes both systems are unix-like.
I have localhost set up on my computer (Ubuntu) and I was wondering what I need to do to access it from my other computer (Windows 7)?

A: You can't access localhost from another computer because localhost is, as the name implies, localhost/loopback/127.0.0.1. You need to access it via it's LAN ip address.
http://en.wikipedia.org/wiki/Localhost

A: The loopback interface is special in that it does not route traffic outside the device itself.  The entire 127.0.0.0/8 block is reserved for this purpose, and traffic with such an address may not transit a network (even a LAN, or a virtual network).  Localhost also isn't really set up by anything, except in the most pedantic sense.
If you want, you can use iptables (you are using ubuntu after all) to do NAT to access whatever service it is you are serving on localhost.  The rule will look something like this:
iptables -t nat -A PREROUTING -i $LAN_INTERFACE -p tcp --dport $SERVICE_PORT -j DNAT --dnat-to 127.0.0.1:$SERVICE_PORT

I'm not sure why you would want to do that, though.  Usually it is easier to have the service listen on the LAN.


text:
Q: How to define the VPN PPTP port in OSX Lion? Is there any change to set the port to use when connecting to a PPTP VPN from a Mac?
I configured a VPN at home from Server 2008 so I can access my home server and use ports like RDP, VNC, IMAPS (Gmail), ..., that are blocked.
The problem is that port 1723 is also blocked. So I configured my home router to accept requests on port 443 (HTTPS) and forward it to port 1723 of the VPN Server.
Can I tell the OSX to use port 443 instead of 1723 for that VPN connection?
Thanks!

A: Unfortunately, it is not possible to change OS X's built-in PPTP client's port. However, you can use a third-party client such as OpenVPN. OpenVPN has many more options and will allow you to specify the port with which to connect to the server.
Good luck and happy tunneling!

redpajama_set_name: RedPajamaStackExchange


text:
Q: Merge two bitfields according a bitmask I wondering whether is it possible to use bit operations to merge two bitfields according a bitmask?
For example I have two values, and a bitmask:
char mask = 0x29; // 0010 1001
char a = 0x9;     // 0000 1001 original value
char b = 0xE8;    // 1110 1000 modified value

And I want to set the bits in b to the value of a, according the bitmask. Only 3 bits would be affected.
char val = 0xC9;  // 1100 1001 value

So how can I do with only bit operations?
Thanks in advance.

A: Try something like:
b &= ~mask;       /* Clear bits set in mask. */
b |= (mask & a);  /* Add bits set both in a and in mask. */

Also, you might want to use unsigned types instead of the inconclusive char.

A: val = a ^ ((a ^ b) & mask);

Also works. Usually that doesn't really help as such, but there are circumstances in which it may. If a and b are both constants, for example, it can be simplified more than the normal formula can.

A: First, clear off the bits that are set in the mask from b. Then, clear off the bits that are not set in the mask from a. Finally, OR the two results together:
b = (b & ~mask) | (a & mask);

The tilde ~ operator produces the negated mask. ANDing with ~mask zeroes out the bits of b that are set in the mask.


text:
Q: Oracle - output to Visual Studio I'm trying to print something in Oracle SQL Developer to appear in a C++ console. That means, I connected my C++ program to an Oracle database and I'm calling several stored procedures through the Visual Studio. My question is this:
Is there any way I can print something in a procedure that will appear on C++ when I execute that procedure? Or do I have to query the database and handle the information on Visual Studio? I know this might sound weird but it would save me a lot of time.

A: If you want to show something in your C++ program you will have to get the data from the stored procedure and then print it in the C++ program. Printing it in the stored procedure will not show up in your C++ program.

A: You can do it the way Oracle SQL Developer and many other Oracle tools do it:

*

*The stored procedures use the DBMS_OUTPUT package (dbms_output.put_line) to write text. The text goes into a session buffer.

*Oracle SQL Developer retrieves the text after each statement it has executed and displays it in the output view. It uses the DBMS_OUTPUT package (dbms_output.get_lines) as well.

See the official documentation for more information.


text:
Q: Adding delimiter for best_in_place gem In the normal form I have used this:

   <%= number_with_precision(approved_invoice.invoice_amount,
      :precision =>2,
      :delimiter => ",")
   %>

This adds the comma at the appropriate place. What if I have to use this delimiter for best_in_place gem:

   <%= best_in_place @invoice, :invoice_amount,
      :display_as => :get_invoice_amount_with_precision,
      :type => :input
   %>

How can I give the commas for the amount field in my edit page? Can someone help me in this?

A: You'll need to use number_with_precision in your model's get_invoice_amount_with_precision method. In order to make this accessible, you will need to include ActionView::Helpers::NumberHelper in your model:
class MyModel < ActiveRecord::Base
  include ActionView::Helpers::NumberHelper

  def get_invoice_amount_with_precision
    number_with_precision(invoice_amount, :precision => 2, :delimiter => ',')
  end
end

A: As of best in place 1.0.3 you can use custom methods in your model in order to decide how a certain field has to be displayed. You can write something like this (in the view):
best_in_place @user, :description, :type => :textarea, :display_as => :my_formatting

And in the model:
class MyModel < ActiveRecord::Base

  include ActionView::Helpers::NumberHelper

  def my_formatting
    number_with_precision(description, :precision => 0, :delimiter => " ")
  end
end


text:
Q: SSIS Flat File Source - Add Line column In my Flat File source, i have all the columns mapped to output columns with the right type and all.
After retriving the data, i check if the reference contained in the file exists in the database, if they don't, i have to log the line and write which value did not find a match.
So, in order to log the line, I would like top have a column containing the complete original line, just like the error output "Flat File Source Error Output Column".
So my question is: Is there a way to add a column to my Flat File Source, that would contain the complete line, without formatting in the data?

A: I would use a Derived Column Task and specify a new column to be added by concatenating all the columns from the text file.
For example, if your text file has the following structure:
Col1, Col2, Col3, Col4, Col5
Your derived column would specify the following Expression:
[Col1] + [Col2] + [Col3] + [Col4] + [Col5]
You could optionally add a delimiter if you wanted to break apart the columns.
This would return an addition column to be used in subsequent data flow tasks.


text: Q: classical mechanics in coadjoint orbits We know that coadjoint orbits are symplectic manifolds, and they can be used to find unitary representations of lie groups and stuff, and it's also related to quantization. However, is it true that given a classical mechanics system, you could always realize this as a coadjoint orbit of some lie group? And would finding its corresponding representation be be equivalent with finding its corresponding quantization?


text:
Q: Skype mystatus alternative It seems like Skype dropped the http://mystatus.skype.com/skypename.xml feed. Since the beginning of May it's always "offline".
Does anybody know a simple alternative to create a custom Button?

A: It seems not possible, once they said:
"We haven't actively supported these buttons for some time, as their accuracy has deteriorated. For example, someone's status is not always reflected accurately (especially when they are on a mobile device). We are now removing their functionality entirely."
Look at:
https://support.skype.com/en/faq/FA605/how-do-i-set-up-the-skype-button-to-show-my-status-on-the-web-in-skype-for-windows-desktop


text:
Q: Angular4 read local files I try to read all file names in my image folder avatar but getting the error.
Cannot find name 'require'.

I have a lot of files in avatar and want list them as <images>elements. Thats why I tried to get the file-names in the folder .
I'm  using Angular 4.2.5 and Webpack
import { Component, Input } from '@angular/core';

var filesystem = require('fs')

const AVATAR_PATH = '../assets/img/avatar'

@Component({
    selector: 'profile',
    templateUrl: 'profile.component.html',
    styleUrls: ['profile.component.scss']
})
export class ProfileComponent {

    path = AVATAR_PATH;

  constructor() {
    console.log(this.getFileNames(AVATAR_PATH));
  }

  getFileNames(dir)
  {
    let results =[];
    filesystem.readdir(dir).forEach(function(file) {

      file = dir+'/'+file;
      results.push(file);
    });

    return results;
  }
}

My folder structure is:
-app
---|room
------|profile
---|assets
------|image
----------|avatar


text:
Q: Tikz: add arbitrary nodes/path in a style after/before the creation of a node I'm trying to clarify how I can create a style that basically add some nodes/path on top (or even behind if possible) of a node. I tried to play with append after command and I finally managed to add several nodes, but I can't find how to add arbitrary code, and especially I can't add a path. What is the good way to proceed?
Thank you!
MWE:
\documentclass[]{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,backgrounds,decorations.pathreplacing,calc,math,matrix}
\usepackage{forest}

% My style
\tikzstyle{myboxes}=[draw=#1,fill=#1!20,rounded corners,anchor=base]

\begin{document}

\begin{frame}{My test}
  \begin{figure}
    \centering
    \begin{tikzpicture}[
        n/.style={myboxes=orange},
        keep name/.style={prefix after command={\pgfextra{\let\fixname\tikzlastnode}}},
        c/.style={
          keep name,
          append after command={
            node [
              at=(\fixname.north),
              inner sep=3pt,
              draw=red,
              thick,
              inner sep=-\pgflinewidth,
              cross out
              ] {}
            node [
              at=(\fixname.south),
              inner sep=3pt,
              draw=green,
              thick,
              inner sep=-\pgflinewidth,
              cross out
              ] {}
            % Does not work
            % draw [red,very thick] (\fixname.north) -- (\fixname.south)
          }
        }
        ]
      \matrix[matrix of nodes, row sep=2mm](sel){
        |[n,c]|A\\
        |[n,c]|C \\
        |[n]|B\\
      };
    \end{tikzpicture}
  \end{figure}
\end{frame}
\end{document}

-- EDIT --
I tried with path picture as proposed by marmot, but unfortunately I can't go outside of the bounding box:

\documentclass[]{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,fit,backgrounds,decorations.pathreplacing,calc,math,matrix}
\usepackage{forest}

% My style
\tikzstyle{myboxes}=[draw=#1,fill=#1!20,rounded corners,anchor=base]

\begin{document}

\begin{frame}{My test}
  \begin{figure}
    \centering
    \begin{tikzpicture}[
        n/.style={myboxes=orange},
        c/.style={
          path picture = {
            \draw[-latex] ($(path picture bounding box.north west)$) -- ($(path picture bounding box.south east)$);
            \draw[-latex] ($(path picture bounding box.north west)$) -- ($(path picture bounding box.north east)$);
          }
        }
        ]
      \matrix[matrix of nodes, row sep=2mm](sel){
        |[n,c]|A\\
        |[n,c]|C \\
        |[n]|B\\
      };
    \end{tikzpicture}
  \end{figure}
\end{frame}
\end{document}

-- EDIT 2 --
The best general solution seems to be, as noticed by Ignasi, the one proposed by Marmot here. However it's not working on matrices, where basically all the points are centered near the central point because of the layers...
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc,matrix,positioning}
\usetikzlibrary{backgrounds}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\tikzset{
  % keep name/.style={prefix after command={\pgfextra{\let\fixname\tikzlastnode}}},
  myt/.style={
    % keep name,
    fill=green!30,
    rounded corners,
    draw=green,
    append after command={\pgfextra%
      % \fixname does not solve the problem either
      \begin{pgfonlayer}{background}
        \draw[-latex,blue] (\tikzlastnode.north west) -- (\tikzlastnode.south east);
        \node[orange] at (\tikzlastnode.north) {\tiny \scalebox{.5}{A}};
        \node[orange] at (\tikzlastnode.south) {\tiny \scalebox{.5}{B}};
      \end{pgfonlayer}
      \node[] at ($(\tikzlastnode.east)!.5!(\tikzlastnode.north east)$) {\tiny \scalebox{.5}{Samelevel}};
      \begin{pgfonlayer}{foreground}
        \draw[-latex,red] (\tikzlastnode.south west) -- (\tikzlastnode.north east);
        \node[purple] at (\tikzlastnode.east) {\tiny \scalebox{.5}{D}};
        \node[purple] at (\tikzlastnode.west) {\tiny \scalebox{.5}{C}};
      \end{pgfonlayer}
      \endpgfextra}
  }
}
\begin{document}
\begin{tikzpicture}
  \node[myt](a){a};
  \node[right=of a, myt](b){b};
  \node[myt, right=of b](c){c};
  \matrix[matrix of nodes, right=of c](matrixname){
    |[myt]|U & |[myt]|V \\
    |[myt]|W & |[myt]|X \\
  };
\end{tikzpicture}
\end{document}

Output works on single nodes:

But not on matrices:

-- EDIT 3 & 4 --
After the proposition of using pics, I tried an indeed it seems really powerful. The only problem is that pics are not really styles, but they can simulate styles pretty well else, and it's even possible to "compose" them and they can also be included in matrices. See below the code and picture:

\documentclass[]{article}

\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes,calc}
\begin{document}

\tikzset{
  % Args: style of the main node, content of the main node
  % and color of back arrow and node
  pics/addarrows/.style args={#1/#2/#3}{
    code = {
      \node[rounded corners, #1,opacity=0] (tmpnode) {#2};
      \draw[-latex,#3] ($(tmpnode.west)+(-0.2,0)$) -- ($(tmpnode.east)+(0.2,0)$);
      \node[rounded corners, #1] {#2};
      \draw[-latex] (tmpnode.south west) -- (tmpnode.north east);
      \draw[-latex] (tmpnode.north west) -- (tmpnode.south east);
      \node[fill=#3,circle,inner sep=2pt] at (tmpnode.south) {};
    }},
  % Creates a shortcut
  pics/defarrows/.style args={#1}{
    code = {
      \pic{addarrows={draw=red,fill=red!20}/#1/red};
    }
  },
  pics/composableHorizVert/.style={
    code={
      \begin{scope}[transparency group, opacity=0]
        #1
      \end{scope}
      \draw[-latex] ($(tmpnode.west)+(-0.2,0)$) -- ($(tmpnode.east)+(0.2,0)$);
      #1
      \draw[-latex] ($(tmpnode.north)+(0,0.2)$) -- ($(tmpnode.south)+(0,-0.2)$);
    }
  },
  pics/composableDiag/.style={
    code={
      \begin{scope}[transparency group, opacity=0]
        #1
      \end{scope}
      \draw[-latex] ($(tmpnode.north west)+(-0.2,0.2)$) -- ($(tmpnode.south east)+(0.2,-0.2)$);
      #1
      \draw[-latex] ($(tmpnode.north east)+(0.2,0.2)$) -- ($(tmpnode.south west)+(-0.2,-0.2)$);
    }
  }
}

Some defaults pics on a matrix:\\
\begin{tikzpicture}[auto]
  \matrix[](matrixname){
    \pic{defarrows=A}; & \pic{defarrows=B}; \\
    \pic{defarrows=C}; & \pic{defarrows=DEF};\\
  };
\end{tikzpicture}

Some pics with arguments that specify the ``main node style'':\\
\begin{tikzpicture}[auto]
  \pic [local bounding box=picgreen] {addarrows={draw=green,fill=green!20,ellipse}/My text/purple};
  \pic [below right=of picgreen,local bounding box=picyellow] {addarrows={draw=orange,fill=yellow,ellipse}/My text/red};
  % NB: If you want to specify a specific node inside the pic, you can always try to specify
  % a name through a new argument
  \draw[-latex,dashed] (picgreen) -- (picyellow);
\end{tikzpicture}

Show that it's possible to compose ``pics styles'':\\
\begin{tikzpicture}[baseline]
  \pic{composableHorizVert={\node[name=tmpnode,fill=red!30]{A};}};
\end{tikzpicture}
+
\begin{tikzpicture}[baseline]
  \pic{composableDiag={\node[name=tmpnode,fill=red!30]{A};}};
\end{tikzpicture}
=
\begin{tikzpicture}[baseline]
  \pic{composableHorizVert={\pic{composableDiag={\node[name=tmpnode,fill=red!30]{A};}};}};
\end{tikzpicture}

\end{document}

A: The best way for adding nodes at arbitrary positions (even behind) of others nodes is the use of labels. Labels are nodes and they can have it's own style.
Your code adapted to declare c as an style for labels:
\documentclass[]{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix, shapes.misc}

% My style
\tikzset{
    myboxes/.style={
        draw=#1,fill=#1!20,rounded corners,anchor=base}
}

\begin{document}

\begin{frame}[fragile]{My test}
  \begin{figure}
    \centering
    \begin{tikzpicture}[
        n/.style={myboxes=orange},
        c/.style={
            inner sep=3pt,
          draw=#1,
          thick,
          inner sep=-\pgflinewidth,
          cross out
          },
        d/.style={
            inner sep=3pt,
          draw=#1,
          minimum size=1cm,
          behind path,
          thick,
          inner sep=-\pgflinewidth,
          cross out,
          },
        ]
      \matrix[matrix of nodes, row sep=2mm](sel){
        |[n,label={[c=red]:},label={[c=green]below:}]|A\\
        |[n,label={[c=blue]right:a}]|C \\
        |[n,label={[d=green]center:behind}]|B\\
      };
    \end{tikzpicture}
  \end{figure}
\end{frame}
\end{document}

A: You have all the elements in your question :

*

*add some part of the path using append after command

*this added path could be a pic

*inside the pic you can draw on a particular layer (background, main, forground)

*if you do not want the added drawing to modify the bounding box, you can use pgfinterruptboundingbox environment.

Here is an example of t style that draws a pic on top and behind of the node:
\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{backgrounds,matrix}
\tikzset{
  a/.pic = {
    \begin{pgfinterruptboundingbox}
      \node[black,rotate=45,fill=white,draw] (over) {over the node};
      \draw[bend left,-latex] (over.east) to[out=90,looseness=7] (#1.east);
      \begin{scope}[on background layer]
        \node[black,rotate=-45,scale=2] {behind the node};
      \end{scope}
    \end{pgfinterruptboundingbox}
  },
  t/.style={
    append after command={
      (\tikzlastnode.center) pic{a=\tikzlastnode}
    }
  }
}
\begin{document}
  \begin{tikzpicture}
    \filldraw[red] (0,3) circle (1pt) node[t,draw,fill=yellow,scale=3]{Node};
    \matrix[matrix of nodes, row sep=2mm,n/.style={text width=16mm,fill=blue!10},draw=purple](sel){
        |[n]|A\\
        |[n,t]|C \\
        |[n]|B\\
      };
  \path (-5,-5) (5,5);
  \end{tikzpicture}
\end{document}


text:
Q: Java mongodb driver and tomcat5.5 permission I am using mongodb java driver r2.10.1
I used to test it with à java web application and tomcat5.5, with java 6 on Windows and Ubuntu.
Everything worked perfect until I test it out on Debian.
Here is a part of my stack trace error (removed stacktrace must remain private)
15:17:25 [TP-Processor10] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/epowerplant].[TechnicalVisitApi]  - "Servlet.service()" pour la servlet TechnicalVisitApi a généré une exception
java.security.AccessControlException: access denied (java.util.logging.LoggingPermission control)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.util.logging.LogManager.checkAccess(LogManager.java:930)
    at java.util.logging.Logger.checkAccess(Logger.java:255)
    at java.util.logging.Logger.setLevel(Logger.java:1131)
    at com.mongodb.Bytes.<clinit>(Bytes.java:48)
    at com.mongodb.DBTCPConnector.<clinit>(DBTCPConnector.java:32)
    at com.mongodb.Mongo.<init>(Mongo.java:193)
    at com.mongodb.MongoClient.<init>(MongoClient.java:138)
    at com.mongodb.MongoClient.<init>(MongoClient.java:126)
    at com.mongodb.MongoClient.<init>(MongoClient.java:115)
    at com.common.business.bdd.MongoResource.getClient(MongoResource.java:79)
    at com.common.business.bdd.MongoResource.<init>(MongoResource.java:48)
    at com.common.business.bdd.MongoResource.getInstance(MongoResource.java:28)
    at com.commonTools.MongoConnector.getPool(MongoConnector.java:41)
    at ... (private)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at sun.reflect.GeneratedMethodAccessor165.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:262)
    at org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:171)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at com.commonTools.web.filter.CharsetFilter.doFilter(CharsetFilter.java:25)
    at sun.reflect.GeneratedMethodAccessor164.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:218)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationFilterChain.access$0(ApplicationFilterChain.java:192)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:171)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:167)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:775)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:704)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:897)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:662)

I could make it work only if I edit the tomcat application policy
vim /etc/tomcat5.5/policy.d/myapp.policy
and add permission java.security.AllPermission;
then the application will work, but the system admin will refused to use this in production, how the hell can I find which permission needs mongodb to work  ? (I did google it)


text:
Q: Google OAuth 2.0 invalid_request, Missing Scheme I cannot authorize Google OAuth on ios, safari always say
400 That's an error.
Invalid parameter value for redirect_uri:
Missing scheme: com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8

I have checked API Key, Client_ID, client_secret on Google Console page many times and also create url scheme in the xcode.
Here are my Swift code:

oauthswift = OAuth2Swift(
                  consumerKey:    "xxxxx-3lmlrubo9345ng4qhtf62ud1i02m6ta8.apps.googleusercontent.com",
                  consumerSecret: "xxxtg6qslUOC2np1sBg0hnWgBcpZb4",
                  authorizeUrl:   "https://accounts.google.com/o/oauth2/v2/auth",
                  responseType:   "token"
          )
          let handle = oauthswift.authorize(
                  withCallbackURL: URL(string: "com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8")!,
                  scope: "profile", state:"GOOGLE",
                  success: { credential, response, parameters in
                      print(credential.oauthToken)
                      // Do your request
                  },
                  failure: { error in
                      print(error.localizedDescription)
                  }
          )

Could you help me ?

A: It is pretty simple fix for this issue:
just set prefix before your schema.
Example:
your schema parameter:
com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8

the identifier of your iOS application:
net.the-red-queen.www

so, value for your redirect URI parameter is:
net.the-red-queen.www:com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8

A: I think the actual issue is that you didn't specify a full URI. (The schema doesn't have a colon and then a path.) Try making your redirect_uri look something like the following (properly encoded, of course):
com.googleusercontent.apps.984813079630-3lmlrubo9345ng4qhtf62ud1i02m6ta8:/oauth

A: You should probably recheck the Google Dev Console. Your clientID might be wrongly registered for Javascript Web Apps rather than Mobile Apps

A: I'm writing an Android client, and this information helped, but wasn't quite what I needed.  I found that I had to make the redirect uri a little differently.
Take the uri that you're using as a target on the phone (usually the package name, but it can be different if re-defined in the applicationId in the app's build.gradle file).
Append this at the end of the target: :/oauth2callback
So my package is com.fooboy.testapp3.  Add the above bit and the redirect uri becomes:
com.foobly.testapp3:/oauth2callback.
There are a lot of other things that need to be just right (especially in the google api console), but this was the final trick for me.
Good luck (you'll need it)!


text:
Q: Warning: "Safe call on a non-null receiver will have nullable type in future releases" due to nullable variable in buildvariants I'm developing an android app using Kotlin.
I have two different build-variants - VariantA and VariantB - both containing a configuration-File:
// VariantA
object ConfigEnvironment {
    val SOME_PARAMETER: String? = null
}

// VariantB
object ConfigEnvironment {
    val SOME_PARAMETER: String = "This is a config"
}

In my code i'm calling:
ConfigEnvironment.SOME_PARAMETER?.let { Log.d("tag", "$it" }

When building VariantB the Compiler throws a warning:
Safe call on a non-null receiver will have nullable type in future releases

While this is correct for this variant, it's somewhat impractical - since i need the nullability in the other variant.
Can i safely supress this lint?
(And how do i do that? My IDE didn't suggest any fixes)

A: It should be safe to suppress this warning since you do not call something which expects a non-nullable expression for it inside the let.
You can suppress the warnung like this:
@Suppress("UNNECESSARY_SAFE_CALL")
ConfigEnvironment.SOME_PARAMETER?.let { Log.d("tag", "$it") }

IntelliJ can help you with that. Just move the cursor to the ?. and type your shortcut for Quick Fix (you can look it up in the Keyboard settings):


text:
Q: Switching +12VDC by arduino I am new to electronics, so please bear with me. I have next task to do:
I have programmed Arudino Mega 2560 to provide some arbitrary digital signals on predefined pins. This is to provide some kind of simulation that will bring signals to ICP DAS device DIs, so that it can count them. This simulation works, pins do change their state from HIGH to LOW and vice versa. ICP DAS DIs require +10+VDC, and will draw no more than 20mA current.
Logically, I need some NO switch that will allow +12VDC to ICP DAS Input when Arduino output is HIGH. I have been advised to buy a logic-level MOSFTET. By looking at the examples on internet, P-channel MOSFET is always used to switch the positive DC terminal for load, and N-channel MOSFET is always used to switch the ground (0VDC) for load.
For this reason I have bought p-channel tsm3401cx> I connected Arduino output to pin 1, +12VDC to pin 2, and pin3 to my voltmeter. When I measure voltage from arduino, I can see that it periodically jumps to 5VDC, and returns to 0V. When I connect transistor, as soon as I bring signal to source, no matter if signal on gate is LOW or HIGH, switch closes immediately. I have come to understanding that this is because of the difference between in polarity between the gate and the source (Vgs), which is always larger than the gate threshold.
So, how can I achieve what I need (switch +12VDC by +5VDC signal)? What kind of transistor do I need?
Edit:
Transistor output should be connected to ICP DAS digital input:
Contact: Wet Contact
Sink/Source (NPN/PNP): Sink/Source
On Voltage Level+10 VDC ~ +50 VDC
Off Voltage Level+4 VDC
Max.Input Impedance10 kΩ

A: Thank you for clarification! Then this simplified circuit is reliable:

simulate this circuit – Schematic created using CircuitLab
M1 is not IRF530, it is any N channel Logic Level MOSFET with max drain to source voltage 20 V or more. R2 must be rated for dissipation of 72 mW, it is two 0402 SMD resistors or one 0603 or larger SMD resistor with rated power 80 mW, or almost any leaded resitor.
Same circuit with BJT:

simulate this circuit
Q1 must be a switching BJT with transition frequency 200-400 MHz, current transfer ratio h21 no smaller than 50 at collector current 10 mA and max collector - emitter voltage higher than 20 V. Plenty of BJTs are suitable.

A: This should do it.
The TP0610K is capable of over 100mA load current (see the datasheet) and the 2N7002K will turn on properly in a 5V system.

simulate this circuit – Schematic created using CircuitLab
When the logic input to M1 goes high, M1 turns on, pulling the drain to (very close) to ground.
This pulls the gate of M2 low, turning it on in a low impedance state, powering up the switched power system.


text:
Q: Export Graph SAIKU REST API I would like to export created ThinQuery as graph(Pie, Line...) by calling this API route, but don't know what to send for "svg" param.
Please, help me with one "svg" param example.
/**
 * Export PDF with chart
 * @summary Export PDF with Chart.
 * @param queryName The query.
 * @param svg The SVG string
 * @return A response with a PDF file
 */
@POST
@Produces({"application/pdf" })
@Path("/{queryname}/export/pdf")
public Response exportPdfWithChart(
        @PathParam("queryname")  String queryName,
        @PathParam("svg")  @DefaultValue("") String svg)
{
    return exportPdfWithChartAndFormat(queryName, null, svg, null);
}


text:
Q: Can I run a .net core app with non-core dependencies on a different OS? I am new to .NET Core Framework. I am building a .NET Core 2.0 console application that references the following two dependencies:

*

*System.Configuration.ConfigurationManager built for .NET Framework 4.5 downloaded from NuGet.

*A project from the same solution which is a .NET Framework 4.5 class library project

Since the Core Framework is cross-platform, I want to publish the application and run it on Linux. Should it work even though the two dependencies are not build for .NET Core? Or do I have to care during development that all of my dependencies are explicitly published for .NET Core?
In other words: Is a .NET Core app only cross-platform portable if all of it's dependencies are .NET Core?


text:
Q: Expected usage of move constructor not happening This is my class and my program:
class A {
    public:
        int x;
        int* v;
        A() : x(5), v(new int[5]) {cout<<"default ctor. "; for (int i=0; i<x; i++) v[i]=rand()%10;}
        A(const A& a) : x(a.x), v(new int[x]) {cout<<"copy ctor. "; for (int i=0; i<x; i++) v[i]=a.v[i]; }
        A(A&& a) : x(a.x), v(a.v) {cout<<"move ctor. ";a.x=0;a.v=0;}
        A& f() {return *this;}
        A g() {return *this;}
};

int main() {
    srand(time(0));
    cout<<"A a --> ";A a;cout<<endl;
    cout<<"A b(A()) --> ";A b(A());cout<<endl;
    cout<<"A c(a.f()) --> ";A c(a.f());cout<<endl;
    cout<<"A d(a.g()) --> ";A d(a.g());cout<<endl;
    cout<<"A e(A().g()) --> ";A e(A().g());cout<<endl;
}

I would expect the objects b, d and e to use the move constructor, however the output I get is:

A a --> default ctor.
A b(A()) -->
A c(a.f()) --> copy ctor.
A d(a.g()) --> copy ctor.
A e(A().g()) --> default ctor. copy ctor.

If in all three cases r-values are the arguments of the constructors, why isn't the move constructor being used?
Obviously I am compiling with the -std=c++11 option.

A: With b, you've hit the "most vexing parse." b is a function declaration, not an object.
Take the expression
A b(A());

Let's do some name changes and semantic-preserving transformations:
int foo(int (*p)());

Now, I think it's pretty clear that foo is a function (returns int and takes pointer to int() function as parameter). Now substitute back A for int, b for foo and remember functions get implicitly converted to pointer-to-function. You'll see it's the same thing.
To get around this, you can use brace initialisation (thanks to @MikeSeymour for pointing that out):
A b{A()};

With d, I think you're the "victim" of copy elision. The "copy ctor" output is probably from initialising the return value with *this; the move from the return value to d is completely elided.
With e, it's the same story as d.


text:
Q: Draw WICBitmap to window? I have a WICBitmap that contains an image in my MFC program.  Is there any way to draw this bitmap onto a device context?
void DrawBitmap(IWICBitmapSource source, HDC targetDC, int X, int Y, int cx, int cy)
{
   //source: The Bitmap to draw
   //TargetDC: The HDC to draw onto (e.g. a printer or screen DC)
   //X,Y: The location on the DC to draw the bitmap

}

A: There are a number of samples on MSDN that show how to display a WIC bitmap using, for example, GDI, GDI+, Direct2D etc.

*

*MSDN: Image Decoding Samples (archive)

*Introduction to WIC: How to use WIC to load an image, and draw it with GDI? (archive)

Microsoft provides a WIC Image Viewer Using GDI Sample (GitHub mirror)
The basic idea is:

*

*convert IWicBitmapSource into a standard Windows BITMAP (CreateDibSectionFromBitmapSource)

*draw using the BITMAP using your standard tools

A: The file can be edited separately as bmp file, and after you can load WIC object as you can see in How to Load a Bitmap from a File.


text:
Q: Icon flashing when clicked. Is it possible to stop this? I have set up a sidebar that upon hovering, reveals the menu item name. The menu item also goes green when the user goes on that particular page.
The problem is that upon clicking the menu item, the icon flashes for a split second (see below gif). I would like to stop this from happening and just have the text turn green with no flash of the icon.
I was wondering if anybody had any suggestions as to how I could make this stop happening?

Im using Gatsby.js (very similar to React.js). Below is a simplified version of my code:
My JS:
import React from "react"
import {
  TiHomeOutline,
  TiSocialSkypeOutline,
  TiSocialLinkedin,
  TiSocialFacebook,
} from "react-icons/ti"
import { FiSettings, FiUser, FiMail } from "react-icons/fi"
import { IoIosCode } from "react-icons/io"
import { FaWhatsapp } from "react-icons/fa"

import { Link } from "gatsby"
import "./sidebar.css"
const Sidebar = props => (

        <Link to="/">

            {`  develop
            with
            tom
            .com
            `}

        </Link>

              <Link to="/" activeClassName="user-link">

                  <TiHomeOutline size={22} className="user-icon" />

HOME

              </Link>

              <Link to="/about" activeClassName="user-link">

                  <FiUser size={22} className="user-icon" />

ABOUT

              </Link>

              <Link to="/skills" activeClassName="user-link">

                  <FiSettings size={22} className="user-icon" />

SKILLS

              </Link>

              <Link to="/work" activeClassName="user-link">

                  <IoIosCode size={22} className="user-icon" />

MY WORK

              </Link>

              <Link to="/contact" activeClassName="user-link">

                  <FiMail size={22} className="user-icon" />

CONTACT

              </Link>

                <TiSocialSkypeOutline size={18} className="social-icon" />

                <FaWhatsapp size={18} className="social-icon" />

                <TiSocialLinkedin size={18} className="social-icon" />

                <TiSocialFacebook size={18} className="social-icon" />

)

export default Sidebar

My CSS:
.sidebar {
  background: #2e2e2e;
  width: 60px;
  height: 100%;
  position: absolute;
  top: 0;
  z-index: 3;
  overflow-wrap: break-word;
}

.sidebar h4 {
  font-family: "Open Sans", sans-serif;
  font-size: 0.7em;
  text-align: right;
  margin-right: 4px;
  color: #9a9a9a;
}

.menu_list {
  position: absolute;
  top: 33vh;
  text-align: center;
  width: 100%;
}

.social_list {
  position: absolute;
  bottom: 1vh;
  text-align: center;
  width: 100%;
  color: #676767;
}

.social_list a {
  color: #676767;
}

.social_list li {
  padding: 0.5vh;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu_list li {
  padding-bottom: 3vh;
}

.sidebar_button {
  /* border: 1px solid #fff; */
  /* height: 50px;
  margin-top: 50px;
  border-radius: 5px; */
  text-align: center;
  /* padding: 10px; */
  /* font-weight: 700; */
  font-size: 0.65em;
  background: transparent;
  position: relative;
}

/* .contactbutton a,
.contactbutton a:link,
.contentbutton a:visited {
  color: #fff;
} */

.sidebar_button p {
  opacity: 0;
  -webkit-transition: all 1s ease 0s;
  -moz-transition: all 1s ease 0s;
  -o-transition: all 1s ease 0s;
  transition: all 1s ease 0s;
}

.sidebar_button a i {
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  height: 25px;
  margin: auto;
}

.sidebar_button a:hover p {
  opacity: 1;
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
}

.sidebar_button a:hover i {
  opacity: 0;
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
}

.user-icon {
  color: #9a9a9a;
}

.user-text {
  color: #9a9a9a;
}

.user-link .user-icon {
  color: #97b27b;
}

.user-link .user-text {
  color: #97b27b;
}

A: The problem occurs when you're still hovered over one of the icons after setting one of them to active. It still triggers your CSS here:
.sidebar_button a:hover p {
  opacity: 1;
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
}

.sidebar_button a:hover i {
  opacity: 0;
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
}

We can try overriding that styling by adding classes with higher specificity now that .user-link has been added when you activate an icon:
.sidebar_button .user-link:hover i {
  opacity: 1;
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
}

.sidebar_button .user-link:hover p {
  opacity: 0;
  -webkit-transition: all 0.5s ease 0s;
  -moz-transition: all 0.5s ease 0s;
  -o-transition: all 0.5s ease 0s;
  transition: all 0.5s ease 0s;
}


text:
Q: .findOne / .findById keep running if no result is found I face an issue that i can't resolve alone.
I have a MongoDB collection, in this collection i have 1 document atm.
When i use .findById(_id) or .findOne({_id : id}) with the right _id, everything works.
When i use .findById(_id) or .findOne({_id : id}) with the wrong _id (for test purposes), i have no response (no undefined, no null, nothing) from the DB and my request keep running.
Ty for your time, take care !
EDIT :

*

*Document :

export interface OrderDocument extends mongoose.Document {
  user: UserDocument['_id'];
  asset_bought: AssetDocument['_id'];
  asset_b_symbol: string;
  asset_sold: AssetDocument['_id'];
  asset_s_symbol: string;
  exchange: ExchangeDocument['_id'];
  exchange_name: string;
  is_draft: Boolean;
  amount: number;
  atm_price: number;
  date: Date;
}

*

*Collection's schema :

const orderSchema = new mongoose.Schema(
  {
    _id: { type: mongoose.Schema.Types.ObjectId },
    user: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'users',
      required: true,
    },
    asset_bought: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'assets',
      required: true,
    },
    asset_b_symbol: {
      type: String,
      required: true,
    },
    asset_sold: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'assets',
      required: true,
    },
    asset_s_symbol: {
      type: String,
      required: true,
    },
    exchange: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'exchanges',
      required: true,
    },
    exchange_name: {
      type: String,
      required: true,
    },
    is_draft: { type: Boolean, default: false },
    amount: { type: Number, required: true },
    atm_price: { type: Number, required: true },
    date: { type: Date, required: true },
  },
  { timestamps: true }
);

*

*Service

export async function findAndPopulateOrders(
  searchType: 'id' | 'one' | 'many',
  query: FilterQuery<OrderDocument>,
  _collections: Array<string>
) {
  const collections = _collections.join(' ');

  if (searchType === 'id') {
    return await OrderModel.findById(query).populate(collections);
  } else if (searchType === 'one') {
    return await OrderModel.findOne(query).populate(collections);
  } else if (searchType === 'many') {
    return await OrderModel.find(query).populate(collections);
  } else {
    return {};
  }
}


text:
Q: How to test Actors values with a factory as receiver Let say I have an actor called TestedActor wich is able to save an Int value and send it back as follow:
class TestedActor extends Actor {
  override def receive = receive(0)

  def receive(number: Int): Receive = {
    case new_number: Int => context.become(receive(new_number))
    case ("get", ref: ActorRef) => ref ! number
  }
}

In my test, I would like to be able to get this Integer and test it.
So i've been thinking about creating something like:
class ActorsSpecs extends FlatSpec with Matchers {

  case class TestingPositive(testedActor: ActorRef) extends Actor {
    override def receive = {
      case number: Int => checkNumber(number)
      case "get" => testedActor ! ("get", self)
    }

    def checkNumber(number: Int) = {
      number should be > 0
    }
  }

  implicit val system = ActorSystem("akka-stream")
  implicit val flowMaterializer = ActorMaterializer()

  val testedActor = system.actorOf(Props[TestedActor], name = "testedActor")
  val testingActor = system.actorOf(Props(new TestingPositive(testedActor)), name = "testingActor")

  testingActor ! "get"
}

This way, i'm able to create this TestingPositive actor, to get the number in the TestedActor and test it in checkNumber.
It seems to be working well, my problem is :
When the test fail, it raise an exception in the actor thread, I can see what went wrong in the console, but it is still saying that all my tests succeeded. Because (I think) the main thread is not aware of this failure.
Does someone knows an easier way than all of this TestingActor stuff?
Or any solution to tell the main thread that it failed?
Thank you

A: Take a look at using TestKit docs here.  You can write a much simpler test for your actor.  See how you like this test:
import akka.actor.{Props, ActorSystem}
import akka.testkit.{TestProbe, TestKit}

import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, ShouldMatchers}

class ActorSpecs extends TestKit(ActorSystem("TestSystem"))
  with FlatSpecLike
  with ShouldMatchers
  with BeforeAndAfterAll {

  override def afterAll = {
    TestKit.shutdownActorSystem(system)
  }

  def fixtures = new {
    val caller = TestProbe()
    val actorUnderTest = system.actorOf(Props[TestedActor], name = "testedActor")
  }

  "The TestedActor" should "pass a good test" in {
    val f = fixtures; import f._

    caller.send(actorUnderTest, 42)
    caller.send(actorUnderTest, ("get", caller.ref))
    caller.expectMsg(42)
  }

  "The TestedActor" should "fail a bad test" in {
    val f = fixtures; import f._

    caller.send(actorUnderTest, 42)
    caller.send(actorUnderTest, ("get", caller.ref))
    caller.expectMsg("this won't work")
  }
}

Also, you should know about sender.  While your get certainly works, a cleaner approach might be to reply to the sending actor:
def receive(number: Int): Receive = {
  case new_number: Int => context.become(receive(new_number))
  case "get" => sender ! number
}

And the test becomes:
"The TestedActor" should "pass a good test" in {
  val f = fixtures; import f._

  caller.send(actorUnderTest, 42)
  caller.send(actorUnderTest, "get")
  caller.expectMsg(42)
}

And finally, I'll shamelessly plug my recent blog post about maintaining an akka code base with my team. I feel morally obligated to give a new hAkker an opportunity to read it. :)


text:
Q: If I choose "something else" for installing Ubuntu 20.04, in which partition should I install it and how large should be this partition? First, let me make clear that I have gone through the answers to similar questions and still have decided to post my own because: i) no answer seemed specific enough for a relative novice like me, and ii) in any case, an answer updated to the size of Ubuntu 20.04 would likely be  helpful to  others as well.
Now to elaborate a little on my title. As mentioned there, I have chosen the "something else" option for the installation. The 'swap' and 'home' partitions present no difficulty but exactly what partition should I create/choose for installing  Ubuntu 20.04? And what should be the size of this partition so as to comfortably accommodate not only the OS  now but also the future updates,etc? Is it the 'root' partition and does the installation automatically choose it? In that case the 'root' partition has to be allocated a suitable size.
Secondly, a main concern of mine is to keep the additional software installed by me as well as my documents (text, images, videos, etc.) untouched in the event of a re-installation of the OS. So I am concerned to know where exactly this kind of data are to be stored. In the 'home' partition, or in a separate partition created out of the remaining free space? If it's  the 'home' I will have to make it sufficiently large, and if it's a separate partition/partitions I would like to know its/their mounting point(s).
I shall be grateful for all precise, clear-cut advice.

A: The simple answer is 25GB for /, 1.01 × RAM for swap, and the rest for /home. System updates will only affect /, and if you later do a reinstall, you can tell the installer not to format /home.

A: Honestly, I don't see anything in your proposed usage that requires "Something Else". Your proposed use looks very default-settings. Everybody wants their data and locally-installed software protected. Everybody wants some swap.
Advice: Make your first install successful rather than perfect. A success --sticking to the default installer settings-- takes only about 45 minutes or so.
After you know what success looks like, you can re-install with more complex settings. Another 45 minutes.

*

*Protecting your data and locally-installed software is the job of regular backups. A separate /home can be overwritten by an admin mistake or simple typo during a re-install. We all think we won't make that typo...but we do.

*The Ubuntu installer creates a swap file nowadays instead of a swap partition. You can indeed specify a separate swap partition if you wish, but most folks have no need for that customization. The file is easier to grow/shrink if your swap needs are wildly different than expected. The partition is needed for hibernation.

A: Follow this guide for more details : https://www.tecmint.com/install-ubuntu-alongside-with-windows
If you choose something else:-
note:- 1. all your software are gonna store in root directory

*all your pictures, downloads and movies and other stuff you download you can save it on home partition

*Swap partition is basically for support your system's ram
Now make sure to allot more than 20Gb in root partition because every software are gonna store there
note:- steam games can be saved in the home directory
And that's it.
Installation steps
1. create root partition with / sign with 20+gb
2. create a home partition with /home written
3. create swap partition according to you system ram

note:- make sure to make all these partitions in logical type not in primary


text:
Q: Get URL of a specific tab? In Google Chrome, how would I get the URL of the page being shown on a specific tab?

A: This depends on how you define specific tab. There are numerous functions to get a tab, which in turn give you back a Tab object. This object has a url attribute.
Let's take the current selected tab for example. You get a handle on it with chrome.tabs.getSelected. Where null is a WindowID, and defaults to the current window.
chrome.tabs.getSelected(null, function(tab) {
    alert(tab.url);
})

For more information I suggest you have a look at the documentation of the API.

A: According to the Google Chrome Extensions documentation, you can retrieve a tab's url by calling the chrome.tabs.get(integer tabId, function callback) method to get a Tab object containing the following fields:

id ( integer )
  The ID of the tab. Tab IDs are unique within a browser session.
index ( integer )
  The zero-based index of the tab within its window.
windowId ( integer )
  The ID of the window the tab is contained within.
selected ( boolean )
  Whether the tab is selected.
pinned ( boolean )
  Whether the tab is pinned.
url ( string )
The URL the tab is displaying
title ( optional string )
  The title of the tab. This may not be available if the tab is loading.
favIconUrl ( optional string )
  The URL of the tab's favicon. This may not be available if the tab is loading.
status ( optional string )
  Either loading or complete.
incognito ( boolean )
  Whether the tab is in an incognito window.

The "tabs" element also needs to be added to the permissions section of the manifest.
  "permissions": [
    "tabs"
  ],


text:
Q: JDBC Connection concurrency suffety I want create multhi-threading part of program (with GUI) for load data from very large DB table (over 30kk rows) by using Fork/Join Framework and RecursiveAction class, because many little query's execute faster then one large, checked experimentally.
For example every fork load 50 rows from needed 1000. Something like this:
class ForkLoader extends RecursiveAction{

    private static Connection con;
    private Map<Integer, Double> map; //In our case ConcurrentHashMap
    private final static int seqThreshold=50;
    private List<Integer> id; //List with id_field in DB table

    int start,end;

    {
        try {
            con=DriverManager.getConnection("jdbc:mysql://some_ip/some_db","username", "password");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public ForkLoader(Map<Integer, Double> map, List<Integer> id,int start, int end){
        this.map=map;
        this.start=start;
        this.end=end;
        this.id=id;
    }

    @Override
    protected void compute() {
        if((end-start)<seqThreshold){
            try {
                Statement stmt=con.createStatement();
                for(int i=start;i<end;i++){
                    String query="text of some query" + id.get(i);
                    ResultSet rs=stmt.executeQuery(query);
                    map.put(id.get(i), /*some double form result set*/);
                }
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        } else {
            int middle=(start+end)/2;
            invokeAll(new  ForkLoader(map, id, start, middle), new  ForkLoader(map, id, middle,end));
        }
    }

}

Is it thread safety use one static connection for all forks? If you know better way to solve this task, show it

A: Usually this kind of applications do it with a Connection Pool, in this way every Thread can use one connection exclusively, and if you have more Threads than connection at the same time, the Threads that doesn't have a connection assigned must wait.
If you want a framework for implement Connection Pool you can check these:

*

*Apache Commons DBCP http://commons.apache.org/proper/commons-dbcp/

*C3PO http://sourceforge.net/projects/c3p0/

*Apache jdbc-pool http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html (thanks to MRalwasser)

In the other hand maybe you want delegate all the Thread and connection management to an EJB container,  basically you can implement the same with EJBs and Connection Pool managed by some container, you can check the following containers:

*

*Apache TomEE http://tomee.apache.org/

*Oracle Glassfish https://glassfish.java.net/

*Apache OpenEJB if you want only the EJB container without the full Java EE platform

A: In general, java.sql.Connection instances (JDBC connections) are not thread-safe; you should not use the same Connection object from multiple threads at the same time.
Create a separate Connection for each thread instead.


text:
Q: Form or div for conditionally editable content This is more of a "best practice" question: I have a one-page website and for the admin I want to make the page editable. I am using angularjs + nodejs and once the admin is logged in I am rendering the page with input fields afters each paragraph and connecting them through my controllers.
Now my question is: should I use forms to display the content and hide/not render the submit button with the edit fields if the user is not logged in as admin or I should use div/p tags to enclose my content and add a simple button (conditioned by log-in state as well as the input fields) and fire an ajax call on ng-click.

A: I would suggest to use 2 different layouts/views/directives, not to messed up presentation


text:
Q: How can I use Eclipse without the Android Debug Bridge? I'm building a Java project with Eclipse and I get the common error "Sending Tracking request failed", which is discussed in ADB Crashing in Eclipse. However, I wonder ... Why should Eclipse get ADB involved even for non-Android projects, just because it is configured with ADT plugin?
My actual question: Can ADT/ADB be disabled when working with non-Android projects?

A: One way to do it is by separating your Android and non-Android projects into two workspaces. After which ADT can be disabled by:
Window --> Preference to get into preference window, then go to General --> Startup and Shutdown and deselect Android Development Toolkit:


text:
Q: 70s-80s SF book, a series of short stories each set X years ahead. In first one aliens placed domes over cities before wiping out everyone else I read this years ago, most likely this would be a young adult book, maybe from the 1970s or 1980s.  I swear the title was "The Turning Point: Tales of a Future Past" but I've never been able to find it under that name so I may be remembering something wrong.
In the first story aliens put domes on cities and eventually the domes expand, destroying anything and anyone not in a dome.  I think this was called "the sweep".  Each story was set farther into the future, showing some of the repercussions of the earlier story.

A: The Turning Place: Stories of a Future Past, a 1976 collection by Jean E. Karl in her Clordian Sweep series.

Review by Charles N. Brown in Isaac Asimov's Science Fiction Magazine, Spring 1977, available at the Internet Archive:

The biggest joy in reviewing books is to come across something very good but obscure. My 'discovery' this year is Jean Karl's The Turning Place, subtitled Stories of a Future Past. Although packaged as a juvenile collection of science fiction stories, it's actually a novel, since each story builds upon the one before it. In the first story, an alien race destroys civilization and nearly wipes out humanity. Each successive story, set several generations later, shows how people have changed, adapted, and set up a new social order which is better than the old one. Some stories are straight juveniles, others are not — especially the later, complex ones. The quality of the writing, as with most juveniles, is quite good.

From a comment by DavidW:

Google Books has a preview of the first story: a dome appears in the desert, the protagonist and a few others are trapped inside, and then the dome expands out over the countryside, leaving nothing behind for them to find.


text:
Q: operator method? non-autonomous differential equation. Professor told me that solving:
$\ddot{\theta}+\dot{\theta} +f(\theta) = c_0 \times \delta(t)$
can be done by taking a limit
$\lim_{e \to 0} \int_{-e}^{e} \left ( \ddot{\theta}+\dot{\theta} +f(\theta) \right) dt  = c_0\lim_{e \to 0} \delta(t)$,
$$\lim_{e \to 0} \int_{-e}^{e} \left ( \ddot{\theta}+\dot{\theta} +f(\theta) \right) dt  = c_0,$$
(where in the right part dirac - delta function goes to 1.)
But how can I receive on the left part of the equation?:
$[\dot\theta]$, so that
$[\dot\theta] = c_0.$ <- it was said that this is the answer.
Here is professors handwriting:

Only thing I can guess is that, and it is only a guess, that
$\lim_{e \to 0} \int_{-e}^{e} f(\theta) = 0$

Dear  grdgfgr Thank you. Still some unclear questions: 1) what do you
  mean by writing wrt t? 2) what is the dirac delta derivative? Does it
  exist ? If I look on the definition, I see that it equals infinity at
  0, and 0 else, that is why I suppose it is not defined.. 3) I did not
  understand how you say that the jump can be only in $\ddot{\theta}$
  case. BUT! While writing this question I think, I have realized, could
  you be pleased, to say am I right?
I got that $\dot{\theta(e)} - \dot{\theta(-e)}$ or $\theta(e) -
> \theta(-e)$ or $F(\theta(e)) - F(\theta(-e))$ should have somewhere
  the value $c_0$ to be consistent with LHS.
If I look at the condition that $e \to 0$, I understand that all this
  3 differences are going to be equal 0.  But I go from the last one. I
  assume that function is smooth enough therfore $F(\theta(e)) -
> F(\theta(-e)) = 0$, as well as   $\theta(e) - \theta(-e) = 0 $,
  however, what I think is:
differnce $\dot{\theta(e)} - \dot{\theta(-e)}$ can be the jump,
  because, when I have a saddle point, or a peak, the values of the
  derivatives of some variable at  $e$ and $-e$ positions can be very
  different especially in 2 close positions.    Is this the logic, why
  you say that the jump can be only in $\dot{\theta}$?

A: I don't like this question but I think this is what is supposed to happen:
$$\ddot{\theta}(t)+\dot{\theta}(t) +f(\theta(t)) = c_0 \times \delta(t)$$
Integrate both sides wrt t
$$\int^{\epsilon}_{-\epsilon}\bigg(\ddot{\theta}(t)+\dot{\theta} (t)+f(\theta(t))\bigg) dt=\int^{\epsilon}_{-\epsilon} c_0 \times \delta(t)dt$$
Integral of $\delta$ is $1$. $F(\theta(t))$ is the antiderivative of $f(\theta(t))$. We get:
$$\dot{\theta}(\epsilon)-\dot{\theta}(-\epsilon)+\theta(\epsilon)-\theta(-\epsilon)+F(\theta(\epsilon))-F(\theta(-\epsilon))=c_0$$
Now since $\epsilon$ is so small, normally the left side should have been 0. But this indicates one of those functions must have a jump. Jump has to be caused by a delta in $\ddot{\theta}(t)$ since if it were caused by, for example, $\dot{\theta}(t)$, then $\ddot{\theta}(t)$ would contain a dirac delta derivative, which we dont see on RHS.
Update:
wrt : with respect to.
dirac delta derivative is complicated to explain, but if you had the derivative of dirac delta, you would certainly need to take that into account. But we don't see such a think on the RHS (right hand side) so we can say that neither $\dot{\theta}(t)$ nor $\theta (t)$ may contain dirac delta.

you can consider delta to be the derivative of this step function. And the integral of delta to be this step function.
so $\dot \theta$ in this example looks like the step function above.
This is a 1D function, it can't have a saddle point. We also are not concerned by peaks.


text:
Q: Using find, how to classify like ls -F ? (directories with a trailing slash) I use find to get a list of files, then I grep it to do a path matching :
$ find pc* | grep -i arthur
pc6/arthurv/untitled-2.py
pc6/arthurv/untitled-3.py
pc6/arthur.py
pc9/Arthur 4C
pc9/Arthur 4C/untitled-1.py
pc9/Arthur 4C/untitled-2.py

I would like to do like in ls -F and append a / for each directory.
Alternatively, how do I get find to show all directories matching case insensitive arthur ?

A: You can use disjunctions in find expressions to implement conditional processing; with GNU find:
find pc* -type d -printf "%p/\n" -o -print

will find everything in paths starting with the files and directories matching "pc*", and print their names, followed by a "/" if they're directories.
The way this works is as follows:

*

*pc* specifies the paths to start from;

*-type d matches directories;

*-printf "%p/\n" prints the path to the currently-processed file, followed by "/" and a newline; because it follows -type d, it is only executed if -type d matched (there's an implicit conjunction);

*-o introduces a disjunction: the expression following it will be evaluated if the expression preceding it did not match (and the expression preceding it is -type d -printf "%p/\n" here, because conjunctions have higher precedence than disjunctions);

*-print prints the path to the currently-processed file.

Showing all directories matching case-insensitive "arthur" can be done using other find expressions:
find . -type d -iname "*arthur*"

A: find has a huge amount of options and details. Another variant is to use -printf with %y
$ find . -printf "%p:%y\n"
./dir:d
./file:f

where %y adds a "d" or a "f" just like ls -l
$ find . -printf "%p%y\n" | sed 's!d$!/! ; s!f$!!'

A: Just to add onto the answers here to list all files and directories:
cat <(find old.files -type d -printf "%p/\n") <(find old.files -type f)

output:
dir1/dir2/
dir1/test.txt
dir1/dir2/test2.txt

Where previously the issue dir1/dir2 not having a trailing slash:
dir1/dir2
dir1/test.txt
dir1/dir2/test2.txt

Ultimately for being able to compare a tar file and directory.
diff <(tar tf old.files.tar | sort -u) <(cat <(find old.files -type d -printf "%p/\n") <(find old.files -type f) | sort -u)


text:
Q: Taking Screenshot of Current screen I am working on an application on Android which will share the screen to another android device.This app will run in background as service.
I want to capture the screen (current screen),save it as JPEG and continously send it over UDP to other Android device.
But my problem is how to capture the current screen by capturing framebuffer .
Please help.

A: The Android framebuffer (and on other linux systems) is accessed by opening the /dev/graphics/fb0 device. This requires root access and even with root access it won't work properly on all devices. Most devices use a pair of framebuffers and toggle between them. The bigger problem is that even with a rooted phone, the Dalvik machine's user ID does not have the privilege to access the frame buffer (fb0) device. This means that you will never be able to open and read from the fb0 device directly from Java code. You will need to run a native linux application as root and it will be able to access fb0 (after the user gives permission). I succeeded in making this work and it is quite challenging and also frowned upon by Google. I still may potentially turn this into a commercial application, but the limitations and incompatibilities put the probability quite low.

A: You can take the screenshot of a layout by enabling
setDrawingCacheEnabled(true);

of the view.
Check this link


text:
Q: API request works from local machine, not on server I have an interesting situation when calling the Shopify API. I use the standard procedure for calling the url and get the data, like this:
define('SHOPIFY_SHOP', 'myteststore.myshopify.com');
define('SHOPIFY_APP_API_KEY', 'xxxx');
define('SHOPIFY_APP_PASSWORD', 'yyy');
$shop_url = 'https://'.SHOPIFY_APP_API_KEY.':'.SHOPIFY_APP_PASSWORD.'@'.SHOPIFY_SHOP;
$response = Requests::get($shop_url.'/admin/products.json');

And I correctly get the response, parse the data and all works great. Now, when I put it to the actual server (Ubuntu 12.04), I noticed a weird message from the Spotify API:
[API] Invalid API key or access token (unrecognized login or wrong password)

I tried creating a new app, but still its the same. So the same file and the same set works on my machine, but not on the server. (only difference in the file is the path to requests library, require_once './Requests/library/Requests.php'; for Linux and require_once '..\Requests\library\Requests.php'; for Windows) As stated, I use the requests library and I assume there has to be some trick where the library (or something else) rewrites the URl and it doesn't get to Shopify correctly.
I tried using CURL with the URL directly, and it works that way as well. Can anyone point me what might be causing this?
Update: I moved to another library which solved the issue, but would like to know what was causing this since I had great experience with Requests up to this point.

A: I'm starting to use the same lib, and I stumbled upon something relevant right after finding this question:
https://github.com/rmccue/Requests/issues/142#issuecomment-147276906
Quoting relevant part:

This is an intentional part of the API design; in a typical use case,
  you won't necessarily need data sent along with a request. Building
  the URL for you is just a convenience.
Requests::get is a helper function designed to make GET requests
  lightweight in the code, which is why there's no $data parameter
  there. If you need to send data, use Requests::request instead

$response = Requests::request( 'http://httpbin.org/get', $headers, $data, Requests::GET, $options );
// GET is the default for type, and $options can be blank, so this can be shortened:
$response = Requests::request( 'http://httpbin.org/get', $headers, $data );

A: I couldn't figure why is this happening, it appears the Requests library is stripping the parameters from GET requests, so I moved to unirest library and this solved the issue.


text:
Q: Safari JS cannot parse YYYY-MM-DD date format? In a project I am working on, I need to validate a date entered into an <input type="date">
With Safari 4/5 (on Mac OSX) the Javascript fails to parse dates of the format YYYY-MM-DD, returning NaN instead of the expected epoch timestamp.
I am using the following technique to validate the field just before the form is submitted:
//value = '2010-06-21'
var stamp = Date.parse(value);
if (isNaN(stamp)) {
    //notify user
} else {
    value = new Date(stamp).format_mysql();
}

Where format_mysql() is a prototype function that formats the date (correctly) into MySQL Date-Time format (YYYY-MM-DD).
Replacing the -'s with /'s (YYYY/MM/DD) yields a "correct" timestamp.
I should note that the field should accept any date format, not just YYYY-MM-DD, and that though I would like to, I cannot use libraries like Date.js
How can I fix this, or is there a better way to parse/validate a date?

A: The behavior of the Date.parse method is implementation dependent, on ECMAScript 5, this method can parse ISO8601 formatted dates, but I would recommend you to make the parsing manually.
Some time ago I've made a simple function, that can handle a format specifier argument:
function parseDate(input, format) {
  format = format || 'yyyy-mm-dd'; // default format
  var parts = input.match(/(\d+)/g),
      i = 0, fmt = {};
  // extract date-part indexes from the format
  format.replace(/(yyyy|dd|mm)/g, function(part) { fmt[part] = i++; });

  return new Date(parts[fmt['yyyy']], parts[fmt['mm']]-1, parts[fmt['dd']]);
}

parseDate('06.21.2010', 'mm.dd.yyyy');
parseDate('21.06.2010', 'dd.mm.yyyy');
parseDate('2010/06/21', 'yyyy/mm/dd');
parseDate('2010-06-21');

Also you could detect the ECMAScript 5 behavior to parse ISO formatted dates, you can check if the Date.prototype.toISOString is available, e.g.:
if (typeof Date.prototype.toISOString == "function") {
  // ES5 ISO date parsing available
}

A:
the field should accept any date format

You don't mean what you think you mean.

*

*It's difficult to reliably distinguish between M/D/Y (US) and D/M/Y (UK). D.M.Y is more common in the UK, but by no means universal.

*Good luck with dates before around 1600 — the Gregorian (solar) calendar was introduced in 1582, and was only (mostly universally) adopted in the 20th century (Wikipedia gives 1929). February 30 was a valid date Sweden.

*OS X gives you a choice of 13 (!) calendars, though the default is Gregorian.

Instead, I recommend using a calendar widget. I think JQuery has one, but ICBW.

A: Generally DD-MM-YYYY format is not support in safari.
value =  2010/06/21 ; //should work.
(or)
value  = new Date('2010-06-21'.replace(/-/g, "/"));

A: You can get an unambiguous date from input,
but you still need to check it, so a user doesn't give you April 31.
<fieldset id= "localdate">
<select id= "monthselect" size= "1">
<option selected= "selected"> January</option>
<option> February</option>
<option> March</option>
<option> April</option>
<option> May</option>
<option> June</option>
<option> July</option>
<option> August</option>
<option> September</option>
<option> October</option>
<option> November</option>
<option> December</option>
</select>
<label> Date: <input name= "inputdate" size= "2" value= "1"> </label>
<label> Year: <input name= "inputyear" size= "4" value= "2010"> </label>
</fieldset>

shortcut for document.getElementsByName
function byName(s, n){
    n= n || 0;
    return document.getElementsByName(s)[n];
}
function getDateInput(){
    var day, y= parseInt(byName('inputyear').value),
    m= byName('monthselect').selectedIndex,
    d= parseInt(byName('inputdate').value);

    if(!y || y<1000 || y> 3000) throw 'Bad Year '+y;
    if((!d || d<1 || d> 32) throw 'Bad Date '+d;
    day= new Date(y,m,d);
    if(day.getDate()!= d) throw 'Bad Date '+d;
    value= day.format_mysql();
}

you can preset the fields to reflect the current date onload
onload= function(){
    var now= new Date();
    byName('inputyear').value= now.getFullYear();
    byName('monthselect').selectedIndex= now.getMonth();
    byName('inputdate').value= now.getDate();
}


text:
Q: How can I force dnscmd.exe to provide its output in English? How can I force dnscmd.exe to provide its output in English?
I have automation that parses the output of various dnscmd commands, such as dnscmd /info > dnsInfo.txt.  I'm using PowerShell to execute those dnscmd commands, and I have no direct access to these servers (locally executed on my behalf by the server owner).  99% of the MS DNS servers that I encounter, regardless of their home country, are installed using the English edition.  However, a handful are installed with a non-English edition, and it appears that dnscmd.exe uses different descriptive text fields when that scenario occurs.  This breaks my parsing logic, and I'd love to avoid adding language specific regex each time.
For example, here are the first few words from running dnscmd /info on a non-English (Moroccan French) server:
Résultat de la requête :

Informations sur le serveur
    nom du serveur

Alternatively, is there a way to instruct PowerShell to setup its environment under a different language?  That might convince dnscmd.exe to change its output.
Update, This did not work:
function Set-Culture([System.Globalization.CultureInfo] $culture)
{
  [System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
  [System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
}
Set-Culture "en-US"
dnscmd.exe /info


text:
Q: (selector).attr doesn't work in chrome browser
my code works in mozilla but not in chrome browser.

what is the solution?

my code (using jquery latest version):
$(document).ready(function () {
    $("#busd").click(function () {
        $("#unit").attr('name','busdUnit')
    })
    $("#bnb").click(function () {
        $("#unit").attr('name','bnbUnit')
    })
})

A: Ok based on your html you can't set a click event on the select option so u need to set a change event on the select and get the the attribute id for set it as attribute where needed
$(document).ready(function () {
    $("#myselect").on('change',function(){
      var id = $(this).children(":selected").attr("id");
      $("#unit").attr('name',id);
     });
})


text:
Q: How to specify what comes first when reading time values in pandas (hour, minute, seconds, day, month, year)? I have the following time data:
0        08/01/16 13:07:46,335437
1        18/02/16 08:40:40,565575
2        14/01/16 22:23:23,606399
3        18/01/16 12:12:46,114231
4        18/01/16 17:09:11,477728
5        20/01/16 12:56:20,432586
6        18/01/16 21:12:53,645333
7        25/01/16 17:29:34,540325
8        16/02/16 10:03:08,698522
9        16/02/16 13:49:54,977352
10       25/02/16 12:17:01,271601

This data is in european time format. (day, month, year). I want to tell pandas to read the dates in that order, the problem is that when i try pd.to_datetime(format = "%d/%m/%Y") it won't work, it says that my data is not in that format, i suppose that this is because i have also the hours minutes and seconds and i'm not telling pandas anything about how to read it. But i can't figure it out.
My question is simple, how can i read my data in this format??
My desired time format is days, month, year, hours, minutes, seconds.
Thank you very much in advance

A: Use parameter format in to_datetime, parameters is possible find in http://strftime.org/:
df['date'] = pd.to_datetime(df['date'], format='%d/%m/%y %H:%M:%S,%f')

Explanation:
%d - match day
%m - match month
%y - match year in format YY
%H - match hour in 24h format
%M - match minute
%S - match second
%F - match microsecond


text:
Q: Como desabilitar a resolução de nomes de domínio (hostnames) da JVM? Uma aplicação está tentando acessar um EJB remoto. Independente se a configuração usa o endereço servidor.empresa.com.br ou um IP para acessar o serviço, ocorre um erro:
weblogic.utils.NestedError: This address was valid earlier, but now we get: .
    at weblogic.rjvm.JVMID.address(JVMID.java:565)
    at weblogic.rjvm.RJVMManager.record(RJVMManager.java:153)
    at weblogic.rjvm.RJVMManager.findOrCreateInternal(RJVMManager.java:292)
    at weblogic.rjvm.RJVMManager.findOrCreateRemote(RJVMManager.java:139)
    at weblogic.rjvm.ConnectionManagerServer.handleIdentifyResponse(ConnectionManager
    Truncated. see log file for complete stacktrace
Caused By: java.net.UnknownHostException: servidor
    at java.net.InetAddress.getAllByName0(InetAddress.java:1158)
    at java.net.InetAddress.getAllByName(InetAddress.java:1084)
    at java.net.InetAddress.getAllByName(InetAddress.java:1020)
    at java.net.InetAddress.getByName(InetAddress.java:970)
    at weblogic.rjvm.JVMID.address(JVMID.java:558)
    Truncated. see log file for complete stacktrace

Ao que parece, independente do hostname e do IP a JVM está fazendo uma consulta ao DNS e, por alguma razão, está ignorando o .empresa.com.br, usando apenas o nome do servidor.
Existe algum meio de dizer à JVM "esqueça o DNS, use apenas o IP!"?
Observações:

*

*Uma alternativa proposta em alguns fóruns é editar hosts (ambiente windows) apontando o servidor (sem o .empresa.com.br para o respectivo IP, mas me parece mais uma gambiarra

*Versão da JDK: 1.6

*Versão do Weblogic: 10

A: Verifique duas coisas:
Adiciona no hosts da máquina o IP e nome, e desablita o verifcation name do servidor.
Se for um server do domínio coloque no server:  ServerName->ServerStart->Arguments
-Dweblogic.security.SSL.ignoreHostnameVerification=true
Se for o AdminServer, tem que ser no script SetDomainEnv.sh:  JAVA_OPTIONS="Dweblogic.security.SSL.ignoreHostnameVerification=true"
Export JAVA_OPTIONS
Espero ter ajudado ;)

A: Pesquisando pela mensagem de erro:

This address was valid earlier, but now we get ...

É perceptível que ela só ocorre com quem usa Weblogic em algum tipo de ambiente específico, geralmente corporativo com firewalls e proxies.
Não há muitos resultados para o erro e nenhum dos que existem apontam uma causa ou solução específica, a não ser um workaround que é adicionar o nome do servidor sem o seu domínio ao arquivos "hosts" do sistema operacional:

*

*Windows: %SystemRoot%\system32\drivers\etc\hosts

*Outros: /etc/drivers


text:
Q: How to get product details, links, image for Amazon products I am trying to develop an app that will display Amazon products to the user. When they click on the product, they are redirected to the Amazon website so that they can make a purchase. I signed up through Amazon affiliate program.
https://developer.amazon.com/mobile-associates
I can generate links to their products, but how do I get product details, image, reviews, ect? Is there another Amazon service I should be using?

A: You need an API that sends you the product details, product image, reviews from Amazon.Find a way where you can get the API which sends details of product in several formats like JSON and XML.


text:
Q: Wher to look for custom teplate tag in django I'm trying to understand how netbox application is working (https://github.com/netbox-community/netbox). In a template "sidenav.html" it uses a custom tag "nav" this way:
{% load nav %}
{% nav %}

Can you tell me what's behind that and where or how can I find it?


text:
Q: Bash variable calling so I'm translating a bash script to php.  I wrote none of the original bash and am learning php as I go.
In the bash script, I've come across something like
echo -en "To: \"${thisEmailName}\" <${thatEmailName}>\nFrom: \"${fromThisEmail}\" <${fromThisEmailName}>\nSubject: ..."

Now I think I have a grasp on what \"variable\" is doing, in my understanding it is just doing an escape character so it shows up as "variable" in the output (please tell me if I'm wrong).  But my major problem is the  as I have absolutely no idea what it is doing.
Thanks for everything in advance.
-SH


text:
Q: VS Code: "Flow is type checking"... Forever I'm running VS Code 1.28.2 on Windows 7 Pro.
I have an existing project that I'm trying to add Flow to. This project already has many installed dependencies and devDependencies.
I have...

*

*Installed flow-bin (0.83.0).

*Installed the Flow Language Support VS Code extension.

*Created a .flowconfig file.

*Restarted VS Code

The first code I'm trying to add types to looks like this (an extract):
// @flow
async function actionAttributesFilteredToShop (stateData: {}, { tables, products }: {}): Promise<any> {
  return {}
}

Now, not much is happening in terms of type checking my code, and I think it's because Flow is running and possibly trying to type check all my dependencies, which right now is about 17,000 files in node_modules.
I see this in the bottom left-hand corner in VS Code (the \ is a loading spinner):

Never-ending "Flow is type checking"...
What is it type checking!? Is there a way to see the files that are currently being type checked..?
How long should it take..?


text:
Q: Associativity, Precedence and F# Pipe-forward The F# pipe-forward can be expressed as:
let (|>) x f = f x

For example:
let SimpleFunction (a : typeA) (b : typeB) (c : typeC)=
    printf "OK."

// No problem here.
SimpleFunction a b c

// Using pipe-forward
c |> SimpleFunction a b
// No problem here. Interpreted as the same as above.

However, according to the documentation, the pipe-forward operator is left-associative.
https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/
So, I expected the pipe-forward statement:
// Original Expression
c |> SimpleFunction a b

// to be equivalent to:
(c |> SimpleFunction) a b

// Which is equivalent to:
SimpleFunction c a b
// Error!! SimpleFunction takes typeA, then typeB, then typeC.

Why does the compiler not "interpret" the pipe-forward expression as the error expression? Do I have any confusion about the operator precedence/associativity?

Additional Sources:
http://theburningmonk.com/2011/09/fsharp-pipe-forward-and-pipe-backward/
What is associativity of operators and why is it important?
https://en.wikipedia.org/wiki/Operator_associativity

A: The associativitity of a binary operator only matters when you have two or more occurrences of the same operator. When you have different operators (here: |> and juxtaposition), what matters is their relative precedence.
Juxtaposition has a higher precedence than |>, therefore
c |> SimpleFunction a b

is parsed like
(c) |> (SimpleFunction a b)

so, by the definition of |>, it's equivalent to
(SimpleFunction a b) (c)

which would usually be written
SimpleFunction a b c

That last equivalence is due to juxtaposition being left-associative.
The fact that |> is left-associative means that an expression like
x |> f |> g

is parsed as
(x |> f) |> g

which is equivalent to
g (f x)

i.e. chains of |> express function composition — successive pipeline steps — and not passing more arguments to a function.

A: Functions are curried by default, you original expression is actually like this:
c |> (SimpleFunction a b) which then becomes (SimpleFunction a b) c. For this to work function application will have to have precedence.


text:
Q: Xcode 8 Constraints in TableViewController I have an issue with constraints in my TableViewController. I have put all necessary constraints (I think so), but when I run my app - it looks like a mess. It's really strange for me, because I have one ViewController where I put two table views in one time, used similar constraints and they work pretty fine on different devices. But here is a mess when I run it anywhere.
Here is screenshot of my constraints:

And here is how it looks like when app is running:
What am I doing wrong? I've checked several questions on stackoverflow, but didn't get it.

A: Add a distance constraint between the text and Name of the item. Then add a constraint from Name of item to the top of the cell.
EDIT
Try to put the text and Name of the item inside a vertically UIStackView and set the certain constraints for it. I think this will solve your problem

A: Looks like I have found solution, but not the root cause.
I have removed my TableViewController and created new one, put there labels, segues and so on. Then I have added constraints. And... it works! It looks like some XCode bug or something like that.
Previously I have an issue with Navigation Controller and Back button disappearance. And by re-adding Navigation Controller and some views and segues issue was resolved.


text:
Q: Display month and date only in bootstrap datetimepicker I am facing two problems in date time picker.
I want to display date as 18th January or January 18, but now it is displaying as 18-1. Documentation on datetimepicker says "MM" will give textual representation of month. But I am not getting that.
Also I am getting years in date dropdown.
My code is like this:
$(".date").datetimepicker({
    viewMode: 'months',
    format: 'DD MM'
});

A: Instead to use MM you can use MMM. For more info see format

$(".date").datetimepicker({
    format: 'Do MMM'
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet"
  href="https://rawgit.com/Eonasdan/bootstrap-datetimepicker/master/build/css/bootstrap-datetimepicker.min.css">

                    <input type='text' class="form-control"/>


text:
Q: Shell Script to change Jenkins build description picking bogus old description I have a shell script to remotely change the Jenkins build description. It uses Jenkins' RESTful API to return a JSON string that contains the old description. This allows me to  prepend or append the new description to the old description. For example, when we deploy to a QA or production machine, I put the deployment information in the build:
deployed to PROD on foolb02-ext
deployed to QA on barlb02QA-test

The first line is the last deployment which was to a production machine. The second line was the first deployment which was to a QA.
The complete description.sh script and other similar scripts are located in Github.
I noticed when I have my script to change the description as part of my deployment script, and the old build description is blank, I was getting this:
deployed to QA on barlb02QA-test
{"description":null}

I traced that {"description":null} to me using the RESTful API for the build to fetch the old blank description:
old_description=$(curl -s --user "$USER:$PASSWORD" --data "tree=description" \
    "$jenkins_url/job/$job_name/$build_number/api/json")

When I run my description.sh script by itself, and the description is blank, the above syntax will set $old_description as:
 {"description":""}

And, I parse this to strip off the JSON stuff syntax:
old_description=${old_description#*:\"} #Remove JSON garbage
old_description=${old_description%\"\}} #Remove JSON garbage

However, when I run my description.sh script inside another shell script (like my deploy.sh script), $old_description is set as this:
 {"description":null}

and my parsing syntax doesn't affect this.
I can change my description.sh script to handle this, but what I'm really curious about is why the Jenkins API seems to be returning two different results depending whether or not I'm running my shell script in another script or not.

A: I always see the null result for descriptions that haven't been set (in Jenkins 1.517). The difference that @DavidW sees is that null is used for unset descriptions and "" (the empty string) is used for a description that had a value that was cleared.


text:
Q: Android ProgressBar makes app to work slower I am making to show progressbar on postexecute and to be not visible in postExecute,  and it works, but makes the app to work very slow, what is the reason is there any simple way to make it work normal(not slowly)?
This is my code:
bar = (ProgressBar) this.findViewById(R.id.progressBar);
getInfo extends AsyncTask<void, void, void>{
    protected void onPreExecute() {
        bar.setVisibility(View.VISIBLE);
    }
    protected void doInBackground(String... params)
                  do smth}
    protected void onPostExecute(Boolean results) {
              bar.setVisibility(View.GONE);
    }
}

A: Are you using a custom progress bar and are you showing the progress bar at the initial screen of your application?
If you are using a custom progress bar then it might take some time to load during the initial startup of your app. I had a similar issue and the issue was due to the android:type="sweep" in the custom progress bar. EG: below
    <shape>
        <gradient
            android:startColor="#000001"
            android:centerColor="#ffffff"
            android:centerY="0.5"
            android:type="sweep"/>
    </shape>

Not sure why the type="sweep" could cause the issue but, after removing it, the application seemed to start up pretty quick


text:
Q: Stop vertical scroll I need to prevent a div from scrolling vertically, but allow it to scroll horizontally...
basically add "vertical position:fixed" and "horizontal position:absolute"
I would prefer to do it with CSS or JavaScript...
This is the div i need to fix vertically...

#logo{
    z-index: 50;
    top: 16px;
    margin:0px auto 0px auto;
    -webkit-filter: invert(100%);
    position: absolute;
    width: 124;
    height: 56;
}
Thank you very much

A: I've just added a container div with position:relative and changed the logo div position to fixed, and it worked...
thanks anyway for your help everybody!
#container{
height: auto;
width: 76%;
position: relative;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}

#logo{
z-index: 50;
top: 16px;
margin:0px auto 0px auto;
-webkit-filter: invert(100%);
position: fixed;
width: 124;
height: 56;
}

best regards


text:
Q: How to do sorting in mvc contrib grid i want to do sorting in the mvc contrib grid....so far i have i used this coding in
homecontroller.cs
public ActionResult Sort(GridSortOptions Sort)
    {
        using (ProductsDataContext db = new ProductsDataContext())
        {
            var categories = db.Products.ToList();
            if (Sort.Column != null)
                categories =categories.OrderBy(Sort.Column, Sort.Direction);
            ViewData["sort"] = Sort;
            return View(categories);

        }

    }

Here i am getting a error:

Cannot implicitly convert type
  'System.Collections.Generic.IEnumerable'
  to
  'System.Collections.Generic.List'.
  An explicit conversion exists (are you
  missing a cast?)

A: Either change this line:
var categories = db.Products.ToList();

to this:
var categories = db.Products;

Or change this line
categories =categories.OrderBy(Sort.Column, Sort.Direction);

to this:
categories =categories.OrderBy(Sort.Column, Sort.Direction).ToList();


text:
Q: Mismatch between python version in Spark worker and Spark driver Exception: Python in worker has different version 2.7 than that in driver 3.5, PySpark cannot run with different minor versions.Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set.
How do I change the python version in my worker? (I'm using Spark in Standalone Mode)

A: Install correct python version (Python3) on the worker node, and on the worker add python3 to path and then set PYSPARK_PYTHON environment variable as "python3", now check if pyspark is running python2 or 3 by running "pyspark" on terminal. This will open up a python shell. Notice the python version on the top of the python shell.

A: If the corresponding variables were set, but the error is still there, then edit or create ./conf/spark-defaults.conf files (copy spark-defaults.conf.template) in both master and worker and add the following line there:
spark.pyspark.python /usr/bin/python3

Then restart master and worker.

A: It must be because of your system python is pointing to 3.5. You should Ideally set your PATH variable before running script to point to PySpark Python like PATH=your anaconda or cloudera bin path:$PATH and everything will be automatically in Sync. Dont use system python for executing pyspark job as inconsistency may come up in driver and executor.


text:
Q: Trying to get back the JasperPrint as return Type form Server I have a server side code as
    @POST
    @Path("/getJasperPrint")
    public  JasperPrint getReport(ReportMapper reportMapper,@Context HttpServletRequest request,@Context  HttpServletResponse response) throws Exception{
jasperPrint = JasperFillManager.fillReport(jasperReport, reportMap,
                        DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb" + "?user=" + "admin" + "&password=" + "admin"));
return jasperPrint ;
}

I am trying to access this with RestTemplate as
  RestTemplate abc = new RestTemplate();
    JasperPrint jasperPrint = abc.postForObject("http://localhost:8008/report/getJasperPrint", objectA, JasperPrint.class);

It gives the error
no suitable HttpMessageConverter found for response type [class path to jasperPrint].

Anything I need to do here .

A: Spring Source Blog Post

Objects passed to and returned from the methods getForObject(), postForLocation(), and put() and are converted to HTTP requests and from HTTP responses by HttpMessageConverters.

What i think is you need to write your own convertor in order to get response as jasperprint


text:
Q: Dynamically change displayed angular child component I have a parent component in which I have set up an array of child components (each extending BaseChild).  I use an *ngFor to loop through the children and display their name. I would like to click on the name of the child and insert the html of the child into the parent.  However I don't want to hardcode a lot of *ngIf={{child1ShouldBeDisplayed}} in the parent html - there will be a lot of children and things will get very ugly.
I've tried using ng-content as suggested here but it seems that this is for injecting parent html into the child (from here).  I've read through a description of ng-template, ng-container etc here but it doesn't seem to meet my needs.
Here is a StackBlitz which sets up the basic code.  I'm not sure how to continue.  Is there a way to choose which child to display in the parent without the use of loads of *ngIf statements?

A: There is a great tutorial for this on the official Angular site, with a stackblitz example.
Summary
You need to create a directive. You'll apply your components dynamically through this directive:
@Directive({
  selector: '[dynamic-stuff]',
})
export class DynamicStuffDirective {
  constructor(public viewContainerRef: ViewContainerRef) { }
}

You need a reference to this element (<ng-emplate dynamic-stuff></ng-template>):
@ViewChild(DynamicStuffDirective, {static: true}) dynamicStuff: DynamicStuffDirective;

You have to create a component factory for your component:
const componentFactory =
  this.componentFactoryResolver.resolveComponentFactory(selectedComponent);

You have to apply it through the viewContainerRef of the directive:
this.dynamicStuff.viewContainerRef.clear();
this.dynamicStuff.viewContainerRef.createComponent(componentFactory);

Good luck, I hope I could help.


text:
Q: How to reconcile Babel plugins with Jest and Webpack in my project? I am using Jest (my preferred testing framework) for testing .jsx files in a frontend React project.
This command was used to install Jest: npm i --dev jest babel-jest @babel/preset-env @babel/preset-react react-test-renderer
These are the installed dependencies from the package.json file:
  "dependencies": {
    "@babel/preset-env": "^7.13.15",
    "@babel/preset-react": "^7.13.13",
    "babel-jest": "^26.6.3",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "jest": "^26.6.3",
    "net": "^1.0.2",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-router-dom": "^4.1.2",
    "react-test-renderer": "^17.0.2",
    "rootpath": "^0.1.2"
  },
  "devDependencies": {
    "@types/node": "^8.0.29",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-0": "^6.24.1",
    "file-loader": "^6.2.0",
    "html-webpack-plugin": "^3.2.0",
    "path": "^0.12.7",
    "webpack": "^4.15.0",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.11.2"
  }

In order to run the project which relies on Webpack, the .babelrc file looks like this:
{
  "presets": [
      "react",
      "env",
      "stage-0"
  ]
}

However, I need to change the presets to the following so that Jest will work with test cases.
{
  "presets": ["@babel/preset-env", "@babel/preset-react"]
}

If I run the project with the above presets, I receive this message on the localhost server:

Error: Child compilation failed:   Module build failed (from
./node_modules/babel-loader/lib/index.js):   Error: Requires Babel
"^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a
compatible ver  sion of @babel/core, it is likely that something in
your build process is loading the wrong version. Insp  ect the stack
trace of this error to look for the first entry that doesn't mention
"@babel/core" or "babe  l-core" to see what is calling Babel. (While
processing preset: "C:\GIT\TypeORMcar\frontbackTypeORMcar
\frontend\node_modules\@babel\preset-env\lib\index.js")


text:
Q: Disallow using comma operator I never use the comma operator.
But sometimes, when I write some recursions, I make a stupid mistake: I forget the function name. That's why the last operand is returned, not the result of a recursion call.
Simplified example:
int binpow(int a,int b){
    if(!b)
        return 1;
    if(b&1)
        return a*binpow(a,b-1);
    return (a*a,b/2); // comma operator
}

Is it possible get a compilation error instead of incorrect, hard to debug code?

A: Yes, with a caveat. The gcc has the -Wunused-value warning (or error with -Werror). This will take effect for your example since a*a has no effect. Compiler result:
test.cpp: In function 'int binpow(int, int)':
test.cpp:6:43: warning: left operand of comma operator has no effect [-Wunused-value]

However, this won't catch single-argument calls and calls where all arguments have side effects (like ++). For example, if your last line looked like
return (a *= a, b/2);

the warning would not be triggered, because the first part of the comma statement has the effect of changing a. While this is diagnoseable for a compiler (assignment of a local, non-volatile variable that is not used later) and would probably be optimized away, there is no gcc warning against it.
For reference, the full -Wunused-value entry of the manual with Mike Seymours quote highlighted:

Warn whenever a statement computes a result that is explicitly not used. To suppress this warning cast the unused expression to void. This includes an expression-statement or the left-hand side of a comma expression that contains no side effects. For example, an expression such as x[i,j] will cause a warning, while x[(void)i,j] will not.

A: gcc lets you specify -Wunused-value which will warn you if the LHS of a comma operator has no side effects.