text:
Q: Should I include LifecycleOwner in ViewModel? LifecycleOwner is currently needed in order for me to create an observer.
I have code which creates an Observer in the ViewModel so I attach the LifecycleOwner when retrieving the ViewModel in my Fragment.
According to Google's documentation.
Caution: A ViewModel must never reference a view, Lifecycle, or any class that may hold a reference to the activity context.
Did I break that warning and If I did, what way do you recommend me to move my creation of an observer for data return?
I only made an observer so I'm wondering if it's still valid. Since also in Google's documentation it also said.
ViewModel objects can contain LifecycleObservers, such as LiveData objects.
MainFragment
private lateinit var model: MainViewModel

/**
 * Observer for our ViewModel IpAddress LiveData value.
 * @see Observer.onChanged
 * */
private val ipObserver = Observer<String> {
    textIp.text = it
    hideProgressBar()
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    model = ViewModelProviders.of(this).get(MainViewModel::class.java)
    model.attach(this)
}

override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? =
        inflater?.inflate(R.layout.fragment_main, container, false)

override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    buttonRetrieveIp.setOnClickListener {
        showProgressBar()
        model.fetchMyIp().observe(this, ipObserver) //Here we attach our ipObserver
    }
}

override fun showProgressBar() {

    textIp.visibility = View.GONE
    progressBar.visibility = View.VISIBLE
}

override fun hideProgressBar() {

    progressBar.visibility = View.GONE
    textIp.visibility = View.VISIBLE
}

MainViewModel
private var ipAddress = MutableLiveData<String>()
private lateinit var owner: LifecycleOwner

fun attach(fragment: MainFragment) {
    owner = fragment
}

/**
 * For more information regarding Fuel Request using Fuel Routing and Live Data Response.
 * @see Fuel Routing Support
 * @see Fuel LiveData Support
 * */
fun fetchMyIp(): LiveData<String> {

    Fuel.request(IpAddressApi.MyIp())
            .liveDataResponse()
            .observe(owner, Observer {

                if (it?.first?.statusCode == 200) {//If you want you can add a status code checker here.

                    it.second.success {

                        ipAddress.value = Ip.toIp(String(it))?.ip
                    }
                }
            })
    return ipAddress
}

Update 1: Improved ViewModel thanks to @pskink suggestion for using Transformations.
private lateinit var ipAddress:LiveData<String>

/**
 * Improved ViewModel since January 23, 2018 credits to pskink <a href="
 *
 * For more information regarding Fuel Request using Fuel Routing and Live Data Response.
 * @see Fuel Routing Support
 * @see Fuel LiveData Support
 * */
fun fetchMyIp(): LiveData<String> {

    ipAddress = Transformations.map(Fuel.request(IpAddressApi.MyIp()).liveDataResponse(), {

        var ip:String? = ""

            it.second.success {

                ip = Ip.toIp(String(it))?.ip
            }
        ip
    })

    return ipAddress
}

A: No. If you wish to observe changes of some LiveData inside your ViewModel you can use observeForever() which doesn't require LifecycleOwner.
Remember to remove this observer on ViewModel's onCleared() event:
val observer = new Observer() {
  override public void onChanged(Integer integer) {
    //Do something with "integer"
  }
}

...
liveData.observeForever(observer);

...
override fun onCleared() {
    liveData.removeObserver(observer)
    super.onCleared()
}

Very good reference with examples of observe LiveData.

A: Assumptions:

*

*Fuel refers to your ViewModel

*Fuel.request(IpAddressApi.MyIp()) is a method in your ViewModel

*IpAddressApi.MyIp() does not have a reference to your LifecycleOwner,

If all are true,then you are not violating it. So long as you are not passing a LifecycleOwner reference to the ViewModel you are safe!
LifecycleOwner - relates to an Activity or Fragment as it owns the various Android Lifecycles e.g onCreate, onPause, onDestroy etc

A: in Kotlin this can be something like:
val mObserver = Observer<List<QueueTabData>> { myString->
// do something with myString
}

A:
Should I include LifecycleOwner in ViewModel?
Ans: No

The purpose of viewmodel is to hold UI data, so that it survives across configuration changes.
And the reason for the following

Caution: A ViewModel must never reference a view, Lifecycle, or any class that may hold a reference to the activity context.

Is because the viewmodel survives configuration changes whereas activities don't. They are destroyed and re-created on configuration change. So, if you have any activity context references in viewmodel they would refer to previous activity that got destroyed.
So this leads to memory leak. And hence it is not recommended.
Furthermore,
If you have repositories that act as your data source we should avoid using LiveData for such purposes as mentioned here in the paragraph just above the code block.
This is because LiveData are handled on MainThread that may lead to UI freeze.
We should use kotlin flows for such purposes.


text:
Q: wso2 Api management configure corporate proxy I managed to get wso2-AM to work on my local machine.
However, I can't integrate an API if it's only reachable using a corporate proxy.
I got a tomcat application HTML page when I try to invoke the API.
ERROR - APIProviderHostObject Error occurred while connecting to backend : https://mypage.mydns:8443/oidc-client/, reason : The host did not accept the connection within timeout of 4000 ms

Of course from the host that runs the server I can do a
wget https://mypage.mydns:8443/oidc-client/

and it works.
However, when I do it without proxy set in the environment variable
wget --no-proxy https://mypage.mydns:8443/oidc-client/

I get a timeout.
My question is, how do I configure wso2 AM to use a corporate proxy to access a remote backend.
Thanks for any clue.
If I find a way, I'll post the answer.

A: Add the following system parameters to wso2server.sh with your proxy settings.
-Dhttps.proxyHost='10.46.12.63' \
-Dhttps.proxyPort='3128' \
-Dhttp.proxyHost='10.46.12.63' \
-Dhttp.proxyPort='3128' \
-Dhttp.nonProxyHosts="127.0.0.1,localhost,*.wso2.com" \

redpajama_set_name: RedPajamaStackExchange


text:
Q: React Native/ES6 - unexpected token, expected ";" error I'm working on trying to only render a header when a collections is present and to not render it when it is empty. A simple fix but I've been receiving this Unexpected Token syntax error and I can't seem to find the issue. Any help would be greatly appreciated as this is my first time posting and using react-native!
const collectionsHeaderHandler = ({ favorites }) =>
  {favorites.meta.collections} ?
  {copyDek.FavoritesLayout.collectionsHeader} :
  "";

const FavoritesLayoutCollections = ({ favorites, onPressHandlers }) => (
  <FavoritesLayoutCollectionsWrapper>
    <FavoritesLayoutCollectionsHeader>
      {collectionsHeaderHandler}
    </FavoritesLayoutCollectionsHeader>
    <FavoritesCollections
      collections={favorites.meta.collections}
      onPressCollection={onPressHandlers.onPressCollection}
    />
  </FavoritesLayoutCollectionsWrapper>
);

A: You need to remove brackets in ternary operator to validate your js at first:
const collectionsHeaderHandler = ({ favorites }) =>
favorites.meta.collections ?
copyDek.FavoritesLayout.collectionsHeader :
"";

Edit for reduce linter error
const FavoritesLayoutCollections = ({ favorites, onPressHandlers }) => (
 <FavoritesLayoutCollectionsWrapper>
   <FavoritesLayoutCollectionsHeader>
     {collectionsHeaderHandler({favorites})}
   </FavoritesLayoutCollectionsHeader>
   <FavoritesCollections
     collections={favorites.meta.collections}
     onPressCollection={onPressHandlers.onPressCollection}
   />
 </FavoritesLayoutCollectionsWrapper>
);


text:
Q: How to handle/queue multiple same http requests with RxJs? I am making an Angular 4 app. Components are subscribing Observable. Sometimes Observable call the same url. For example 'refresh Access Token' if needed before any http request. But if I  make different 3 http requests, it will "refresh if needed" 3 times the refresh token.
So how to make only one http get to get a refreshed access token, and make the other observables 'wait' for the first one ? (I know 'wait' is not the good word for Observables).
        public get(url: string, options?: RequestOptionsArgs): Observable<Response> {
            return this.getAccessToken().mergeMap(accessToken => {
              return this.http.get(url, options);
            });
          }

// And
this.get('www.myapi.com/one').subscribe(data=>console.log('one',data))
this.get('www.myapi.com/two').subscribe(data=>console.log('two',data))
this.get('www.myapi.com/three').subscribe(data=>console.log('three,data))

A: It seems like you can use the share() operator that makes sure there's always only one subscription to the source Observable.
However this will require you to restructure your code because all observers need to use the same instance of share():
const sharedToken = this.getAccessToken().share();

public get(url: string, options?: RequestOptionsArgs): Observable<Response> {
  return sharedToken.mergeMap(accessToken => {
    return this.http.get(url, options);
  });
}

A: Use an operator called forkJoin. If you are familiar with Promises this is very similar to Promise.all(). The forkJoin() operator allows us take a list of Observables and execute them in parallel. Once every Observable in the list emits a value the forkJoin with emit a single Observable value containing a list of all the resolved values from the Observables in the list
please go through the below example:
Import:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/forkJoin';

Let assume you have to get three pages
var pages:number[] = [1, 2, 3];

Or var pages:number[]=new Array(10).fill().map((v,i)=>i+1);
and then  map them into an array of observables and forkJoin
Observable.forkJoin(
   pages.map(
      i => this.http.get('www.myapi.com/' + i)
        .map(res => res.json())
   )
).subscribe(people => this.people = people);

Please go Stack or forkJoin for more info.


text:
Q: Laplace equation solution for electrical potential I'm trying to simulate a lightning in a programming language and I started to read how it can be done, and I found that it could be done by using the Laplacian Growing Model. My experience with mathematics is limited.
I think I understood the algorithm described here in section 4.1. My problem is that I don't know how to solve the Laplacian equation for the lightning model seen at (b) Lightning configuration.
I tried to catch something up from here but that configuration is a rectangle and the lightning configuration seems like a triangle or maybe a circular arc.
I know my boundary conditions would be the potential at the origin and the potential at the ground but I really don't know how to translate this in mathematical language and how to resolve the laplace for it.
Can you help me with a solution (along with an explanation) or a tutorial "for dummies"?

A: Hmm.. maybe I am 2 years late to the party, but what the heck.
You can also pose this as a Global Linear Optimization. Setting up a matrix $L_2$ norm minimization problem: $$\min({\bf v})\left\{{\bf C}\|{\bf v}\|_2 + \|{\bf L(v+d)}\|_2\right\}$$ where $\bf C$ contains a binary diagonal matrix mask like the one nomnom called "boundary condition", the $\bf d$ is a vectorization of boundary condition values. So $\bf v+d$ is the result, and the $\bf L$ is a matrix representation of the laplacian operator, typically some suitable discrete filter. First term punishes changes to boundary conditions. Second term punishes laplacian of result from differing from 0.

So why bother doing all this instead of just taking the first numerical scheme we can find? It is because it is very convenient framework if we want to attack bigger and more involving problems. There is no limit as to how many terms we can have and we can have any constraints we like as long as we can express them as matrix operations on the data. Also as there exist so many numerical methods to solve linear optimizations we are not restricted to one specific numerical method but can use the whole arsenal of linear solving techniques.

A: Here's a description of how to solve the laplacian equation for an arbitrary $2$-D grid with boundary conditions using the so-called "iteration method":

Initialization:
Create a matrix $M$ representing each point on the grid, with one entry per "pixel".  So, for example, to work with a $7\times 7$ grid, we would set
$$
M =
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}
$$
We then set permanent boundary conditions that won't be changed as we improve our approximation. To get something kind of circular, we could set
$$
M =
\begin{bmatrix}
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1\\
\mathbf1 & \mathbf1 & 0 & 0        & 0 & \mathbf1 & \mathbf1\\
\mathbf1 & 0 & 0 & 0        & 0 & 0 & \mathbf1\\
\mathbf1 & 0 & 0 & \mathbf0 & 0 & 0 & \mathbf1\\
\mathbf1 & 0 & 0 & 0        & 0 & 0 & \mathbf1\\
\mathbf1 & \mathbf1 & 0 & 0        & 0 & \mathbf1 & \mathbf1\\
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1
\end{bmatrix}
$$
The bold entries remain constant, while the rest will update as we improve our approximation.
We then normally put in some non-zero initial guess for each point to be computed, just a very rough approximation.  For instance, in this case we could put
$$
M =
\begin{bmatrix}
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1\\
\mathbf1 & \mathbf1    & 0.66 & 0.66        & 0.66 & \mathbf1 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & 0.33        & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & \mathbf0    & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & 0.33        & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & \mathbf1 & 0.66 & 0.66 & 0.66 & \mathbf1 & \mathbf1\\
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1
\end{bmatrix}
$$
We are now ready to begin the iterative process

Iteration:
What we use now (and will justify later, maybe) is the fact that on a $2$D plane where $\phi$ is a function satisfying
$$
\nabla^2\phi=\frac{\partial^2\phi}{\partial x^2}+\frac{\partial^2\phi}{\partial y^2}=0
$$
the following is approximately true:
Suppose that $\phi(x_0,y_0)=\phi_0$
Let $\Delta x$ and $\Delta y$ be "sufficiently small" and define:
$$
\phi_{x^+}=\phi(x_0+\Delta x,y_0)\\
\phi_{x^-}=\phi(x_0-\Delta x,y_0)\\
\phi_{y^+}=\phi(x_0,y_0+\Delta y)\\
\phi_{y^-}=\phi(x_0,y_0-\Delta y)
$$
Then we have
$$
\phi_0 \approx \frac14(\phi_{x^+}+\phi_{x^-}+\phi_{y^+}+\phi_{y^-})
$$
In other words, we could calculate the potential at a point by averaging the potential at the four neighboring points. We do exactly that, using the improved values as we go.
For our matrix $M$, let's begin with the first changeable point in the upper-left corner.
$$
\begin{align}
\phi_{2,3}
&=\frac14(\phi_{2,4}+\phi_{2,1}+\phi_{1,3}+\phi_{3,3})
\\&= 0.25\cdot(0.66 + 1 + 1 + 0.33)
\\&= 0.7475
\end{align}
$$
Making the new matrix
$$
M =
\begin{bmatrix}
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1\\
\mathbf1 & \mathbf1    & 0.7475 & 0.66        & 0.66 & \mathbf1 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & 0.33        & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & \mathbf0    & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & 0.33        & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & \mathbf1 & 0.66 & 0.66 & 0.66 & \mathbf1 & \mathbf1\\
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1
\end{bmatrix}
$$
In fact, if we know that we will be using a symmetrical configuration, we could make things more efficient by updating all points that will have the same outcome.  That is, we could update $M$ to get
$$
M =
\begin{bmatrix}
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1\\
\mathbf1 & \mathbf1    & 0.7475 & 0.66        & 0.7475 & \mathbf1 & \mathbf1\\
\mathbf1 & 0.7475 & 0.33 & 0.33        & 0.33 & 0.7475 & \mathbf1\\
\mathbf1 & 0.66 & 0.33 & \mathbf0    & 0.33 & 0.66 & \mathbf1\\
\mathbf1 & 0.7475 & 0.33 & 0.33        & 0.33 & 0.7475 & \mathbf1\\
\mathbf1 & \mathbf1 & 0.7475 & 0.66 & 0.7475 & \mathbf1 & \mathbf1\\
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1
\end{bmatrix}
$$
We would then proceed to the next point
$$
\phi_{2,4}=0.25\cdot(0.7475+0.7475+1+0.33)= 0.5194
$$
And update the matrix accordingly
$$
M =
\begin{bmatrix}
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1\\
\mathbf1 & \mathbf1    & 0.7475 & 0.5194        & 0.7475 & \mathbf1 & \mathbf1\\
\mathbf1 & 0.7475 & 0.33 & 0.33        & 0.33 & 0.7475 & \mathbf1\\
\mathbf1 & 0.5194 & 0.33 & \mathbf0    & 0.33 & 0.5194 & \mathbf1\\
\mathbf1 & 0.7475 & 0.33 & 0.33        & 0.33 & 0.7475 & \mathbf1\\
\mathbf1 & \mathbf1 & 0.7475 & 0.5194 & 0.7475 & \mathbf1 & \mathbf1\\
\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1 &\mathbf1
\end{bmatrix}
$$
Proceed in such a fashion until each changeable value is updated once (in this case, that will take $4$ steps if you take advantage of symmetry, $20$ if you make no such simplifications), then repeat.  Do this enough, and eventually the updates won't significantly change the value.  When that happens, you've reached the final approximation and can stop the process.  You now have an approximate solution to the Laplacian equation, given the boundary conditions of your matrix.
A similar method to this one is the relaxation method, which is faster for systems with relatively few pixels and slightly more accurate.

EDIT:
I found this derivation of the iteration method (apparently, also known as the finite difference method) if you want a mathematical justification for the process.

A: Solving Laplace's equation for a rectangular boundary on which the values are known is easy. When the values are known on the boundary,  this is called "Dirichlet boundary conditions"
Often however,  the values are known on some parts of the boundary but only the derivative is known on other parts. The latter is known as Neumann boundary conditions. If you have both,  it is called mixed boundary conditions. An example of the latter is finding current flow in a printed circuit track that has one voltage on a boundary at one end and another voltage at a boundary at the other end but all we know about the rest of the boundary is that no current flows off the sides.
When the shapes of the boundaries are arbitrary you are going to need an irregular grid and this is a seriously difficult problem.


text:
Q: PHP Appending a link to a string I am trying to add a "Read More" system on my site and right now I have the text stopping after 150 words, but I can't seem to get the link right at all.
This is what I have at the end of my shortening loop:
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... Read More';

When I look at my site the link points to this:
/posts.php?id=7%3ERead%20More%3C/a%3E...%3C/div%3E%3Cp%3EPosted%20on:%2030-09-14%2003:55:08in%20%3Ca%20href=

Its basically taking everything that comes after this (date and stuff) and putting it in my URL for some reason. If I just echo the post['post_id'] by itself I am getting the correct output. Any idea what I am doing wrong?

A: Try to change the link and add this missing closing double quotations on the markup:
$stringCut = 'aaaaaaaaaaaaaadddddddddddddddddadddddr ffff';
$post['post_id'] = 1;
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... Read More';
                                                                                ^^
echo $string;

Without closing quotes
With closing quotes


text:
Q: Show Gui over Fullscreen I have made a GUI:
Gui +AlwaysOnTop

I not only want it to be alwaysontop, but also always showing over fullscreen applications. In this case it works for Chrome Fullscreen, but if I try the same with Edge it doesn't appear anymore. How can I change this?


text:
Q: RFID + Android --> where do I start? I've heard that the Google Nexus S has RFID capabilities. I'd like to start learning about RFID and programmatically doing things. Where should I start? Good tutorials or code examples are what I'm after. (or hardware if it's not Android I suppose).
Doesn't have to be Android, could be python or java libraries as well. Preference for Android.
I see this as the future, and I want to get in on it :)

A: Buy a Nexus-S, buy some tags.
Then take a look at the code of the 'Tags' application that comes with android. Play with it, modify it. Write some tags with your own application.
Learn what Ndef is and how you craft your own messages/records. Learn how to use the transceive function to do direct communication to the tags. This will open up a world on it's own (aka you can write-protect tags that are not write protectable by Android itself etc).
All in all that can be done in two weeks. The Android NFC/RFID subsystem is easy to use. Most of the the hard stuff is hidden from you.
Afterwards write your own little application, show it to advertising agencies that do Android apps and get a high payed job. NFC experience is highly sought after at the moment.


text:
Q: How do I format the Key in my boto3 lambda function to update dynamodb? I need help with figuring out how to format my Key in lambda to update an item in DynamoDB. Below is the code I have but I can't figure out how to format the Key.
My table looks as follows:

'''
import json
import boto3
dynamodb = boto3.resource('dynamodb')
client = boto3.client('dynamodb')
def lambda_handler(event, context):
response = client.update_item(
    TableName='hitcounter',
    Key={????????},
    UpdateExpression='ADD visits :incr',
    ExpressionAttributeValues={':incr': 1}

)

print(response)

'''
ERROR MESSAGE:
'''
{
  "errorMessage": "'path'",
  "errorType": "KeyError",
  "stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 11, in lambda_handler\n    Key={'path': event['path']},\n"
  ]
}
'''

A: The AWS docs provides an example for Updating an item:
table.update_item(
    Key={
        'username': 'janedoe',
        'last_name': 'Doe'
    },
    UpdateExpression='SET age = :val1',
    ExpressionAttributeValues={
        ':val1': 26
    }
)

I'm not sure from your question, if the AWS examples are unclear or what is the issue specifically?


text:
Q: How to get columns data types from arbitrary SQL select? I need to obtain column types from arbitrary SQL query. It's certainly possible, PgAdmin3 does it.
For example, given a query:
SELECT src.col, CAST(src.col AS varchar)
FROM (SELECT 'anything' AS col) AS src;

PgAdmin3 returns:

As you can see, column types are displayed basing on executed query, not on table schema.  How to obtain data types of columns in the result set programmatically?

A: Use the system catalog information function pg_typeof().

A: The corresponding function in the C client library is PQftype. It provides the type of any field from a query, as described in Retrieving Query Result Information, with other functions that apply on result fields, such as PQftable or PQfsize.
No EXPLAIN is needed, this information is shipped with every set of result coming back to a SQL client.

PQftype
Returns the data type associated with the given column number.

The integer returned is the internal OID number of the type. Column
  numbers start at 0.
   Oid PQftype(const PGresult *res,
               int column_number);

You can query the system table pg_type to obtain the names and properties
  of the various data types. The OIDs of the built-in data
  types are defined in the file src/include/catalog/pg_type.h in the
  source tree.

Additionally the OIDs of all types of a database can be obtained with:
select oid, typname from pg_type;

Other languages generally base their postgres support on libpq library, so they can call this function. They may or may not expose it depending on how complete their implementation is.
In the case of ruby, the ruby-pg driver apparently does it through PGResult's
ftype(column_number)  instance method. I don't know if this is of any help with ActiveRecord. Database-agnostic APIs tend to leave out functions that can't be easily abstracted across all the databases they support.


text:
Q: Is it possible to couple an odd number of Dirac fermions, at finite density, to a massless gauge field in 2+1d? In a beautiful paper by A. N. Redlich (PRL $\bf{52}$, 18 (1984)) on the parity anomaly, the author indicates that an odd number of Dirac fermions can never be coupled to a massless gauge field in 2+1d due to the necessity of introducing background Chern-Simons terms to maintain gauge invariance

"The induced topological term $\pm W[A]$ in $I_\mathrm{eff} [A]$ is known to produce a mass for the gauge fields.  Not only must parity conservation be violated in odd-dimensional theories with an odd number of fermions, but
  the gauge fields must become massive as well",

where $W[A]$ is the Chern-Simons term and $I_\mathrm{eff} [A]$ the effective action obtained by integrating out the fermion degrees of freedom.
My question is whether this is still true if the fermions are at a finite density, i.e. one adds a chemical potential such that there is a whole Fermi surface of excitations (in this case, it's my understanding that one cannot simply integrate out the fermions to get $I_\mathrm{eff} [A]$). Is it possible to couple an odd number of Dirac fermions, at finite density, to a massless gauge field in 2+1d?


text:
Q: How can I iterate through a list of these elements as such? I have a List of elements of type
public class AnswerInfo
{
    public string SectionTitle { get; set; }
    public string SubsectionTitle { get; set; }
    public int QuestionId { get; set; }
    public string QuestionText { get; set; }
    public int? AnswerId { get; set; }
    public int? AnswerVal { get; set; }
}

which when I retrive it will correspond to retriving rows from a database like
-- =========================================================================================================================
--   section_title     |  subsection_title  |  question_id |            question_text            |  answer_id | answer_val
-- =========================================================================================================================
--  'Partner Planning' | 'Target Markets'   |       1      | 'Have you defined the target ...?'  |     1      |    24
--  'Partner Planning' | 'Target Markets'   |       2      | 'Have you identified the .......?'  |     2      |    50
--  'Partner Planning' | 'Target Markets'   |       3      | 'Have you built a market .......?'  |     3      |    90
--  'Partner Planning' | 'Target Markets'   |       4      | 'Have you built the revenue ....?'  |    NULL    |   NULL
--  'Partner Planning' | 'Target Customers' |       5      | 'Have you defined the ideal ....?'  |    NULL    |   NULL
--          .                   .                   .                         .                        .            .
--          .                   .                   .                         .                        .            .
--          .                   .                   .                         .                        .            .
--          .                   .                   .                         .                        .            .
--  'Partner Growth'   | 'Getting Traction' |       61      | 'Have you defined the ideal ....?' |    NULL    |   NULL

I retrive it by means of the stored procedure
CREATE PROCEDURE GetAnswersByPartner
    @pid UNIQUEIDENTIFIER -- Partner id
AS
BEGIN
    SELECT Sections.title AS section_title,
    Subsections.title AS subsection_title,
    Questions.id AS question_id,
    Questions.qtext AS question_text,
    Answers.id AS answer_id,
    Answers.val AS answer_val
    FROM Partners
    INNER JOIN Questions ON 1 = 1
    INNER JOIN Subsections ON Subsections.Id = Questions.subsection_id
    INNER JOIN Sections ON Sections.Id = Subsections.section_id
    LEFT JOIN Answers ON Answers.partner_id = Partners.Id
            AND Answers.question_id = Questions.Id
    WHERE Partners.Id = @pid
END

and on the C# side of things,
List<AnswerInfo> Answers = new List<AnswerInfo>();
using ( SqlCommand cmd = new SqlCommand("GetAnswersByPartner", this._Conn) )
{
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@pid", pid);
    this._Conn.Open();
    using ( SqlDataReader dataReader = cmd.ExecuteReader() )
    {
        while ( dataReader.Read() )
        {
            Answers.Add(
                new AnswerInfo
                {
                    SectionTitle = dataReader.GetString(0),
                    SubsectionTitle = dataReader.GetString(1),
                    QuestionId = dataReader.GetInt32(2),
                    QuestionText = dataReader.GetString(3),
                    AnswerId = dataReader.GetInt32(4),
                    AnswerVal = dataReader.GetInt32(5)
                }
           );

        }
    }
    this._Conn.Close();
}

Now the issue is that to construct my View I'd like to be able to iterate through my List<AnswerInfo> like
[pseudo-code]
for each section title
    for each subsection title
        for each { question id, question text, answer id, answer val }

How can I rejig my List<AnswerInfo> that way? Better yet, can I create the needed data structure upfront and then directly add the titles to it in when I iterate through each resulting row like
while ( dataReader.Read() )
{
   // Add info to better-organized structure
}

A: Assuming you have the List<Answer> in a variable called list, you can use GroupBy like this:
var section_title_groups = list.GroupBy(x => x.SectionTitle);

foreach(var section_title_group in section_title_groups)
{
    var section_title = section_title_group.Key;

    var sub_section_title_groups = section_title_group.GroupBy(x => x.SubsectionTitle);

    foreach(var sub_section_title_group in sub_section_title_groups)
    {
        var sub_section_title = sub_section_title_group.Key;

        foreach(var answer in sub_section_title_group)
        {
            //Access answer here
        }

    }
}


text:
Q: Dependencies problem with x2go I need help with my Ubuntu Server 12.04 64-bit. I can't update Ubuntu, because I always have problems with x2go. See message below:
dependency problems prevent configuration of openssh-server:
  openssh-server depends on openssh-client (= 1:5.9 p1-5ubuntu1.2); however:
  Version openssh-client 1:5.9 p1-5ubuntu1.3 is installed.
dpkg: error processing openssh-server (- configure):
  dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of x2goserver:
  x2goserver depends on openssh-server; however:
  The openssh-server package is not configured yet.
dpkg: error processing x2goserver (- configure):
  dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of x2goserver-extensions:
  x2goserver x2goserver-dependent extensions (> ~ 842 = ~ 4.0.1.14-0 ubuntu12.04.1); however:
  X2goserver the package is not configured yet.
  x2goserver x2goserver-dependent extensions (<< 4.0.1.14-0 ubuntu12.04.1.1 ~ ~ ~ 842)

I think there may be a conflict between the new and old version of x2go.

A: it looks like the underlying issue is with the OpenSSH packages, which X2Go depends on. Specifically, it looks like openssh-client is being upgraded from p1-5ubuntu1.2 to p1-5ubuntu1.3, but openssh-server is not being upgraded from p1-5ubuntu1.2. They need to both be upgraded at the same time to the same version.
Try running "sudo apt-get update" and seeing if your still have the problem. There may have been a temporary issue with the openssh-server not update being pushed out to your ubuntu apt mirror.
You should then be able to run "sudo apt-get install openssh-server openssh-client" without issue; that command actually upgrades those 2 packages (instead of installing them) because they're already installed. If that command works without issue, then so should "sudo apt-get upgrade". which upgrades every package on the system.
Note: I am an X2Go Developer


text:
Q: iOS10 NSLog is limited to 1024 chars strings In iOS10 the NSlog are limited to 1024 characters has anybody know a workaround to print complete string.

A: try printf then instead of NSLog like,
   printf("%s", [string UTF8String]);

It may works

A: I thinks this is a same question with [ NSLog on devices in iOS 10 / Xcode 8 seems to truncate? Why?, I will also post my answer here, in case you want to use printf instead.
This is a temporary solution,since I think it's a bug.
Just redefine all NSLOG to printf in a global header file.
#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

A: a Swift workaround for this new Xcode8 and Sierra "feature"…
func Log(_ format:String, _ args:CVarArg...) {
    let output = withVaList(args, { (p) -> NSString in
        NSString(format: format, arguments: p)
    }) as String
    print( output )
}

Of course, this won't have the features of NSLog that we may require such as the time stamp, bundle name, and thread stuff (including serialization).


text:
Q: What does "there" refer to?
No matter where people are making new homes and offices, saving energy
  is important. For us humans, the goal can be difficult. But for some of
  our feathered friends, being energy efficient comes naturally. Just
  take a look up there.

What does "there " refer to?

A: It talks about birds, our feathered friends.

Just take a look up there (toward the sky, trees) - and you find them!


text:
Q: Define a LibreOffice Calc custom function in Python I am writing custom functions in LibreOffice Calc.
Such functions must be called in Calc as if they were native
functions,

e.g. as EDATE(), DAYS() etc.

Upto now what I am doing for each custom function is:

*

*Define a Python function

*Define a StarBasic function which invokes its Python correspondant

*Call StarBasic function from Calc.

It works, but it is quite impractical to write each function
in two languages.
My question is: is it possible to write such kind of functions
directly in Python ? Do you have any reference to share ?

A: A Calc add-in is a complete solution, with features such as tooltip popups that Basic user-defined functions cannot provide.
This requires more effort than writing a Basic-Python bridge call.  However, since you are writing many functions, it might not be too much extra work, because all of them can be put into a single .oxt file.
An example of the required files is in my answer at https://ask.libreoffice.org/en/question/133794/how-to-use-develop-addins-in-calc/?answer=133870#post-id-133870.
Other examples and documentation:

*

*https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=83856

*https://ask.libreoffice.org/en/question/10219/writing-user-defined-functions-in-python/

*How can I call a Python macro in a cell formula in OpenOffice.Org Calc?
If you try it and need help, edit the question.  Or post something on ask.libreoffice.org, which allows attachments as long as you have at least a small amount of reputation.


text:
Q: Taylor series leads to two different functions - why? Suppose, I want to find a function such that its Taylor series expansion is
$$f(x) = \sum_{n=0}^{\infty}\frac{x^{n+1}}{(n+1)a^n}$$
I could start with $$\frac{1}{1-x}=\sum_{n=0}^{\infty}x^n$$
Integrate it, substitute $x\rightarrow  \frac{x}{a}$, multiply by $a$ and get
$$F(x) = -\ln|x-1| = \sum_{n=0}^{\infty}\frac{x^{n+1}}{n+1}$$
$$a F\left(\frac{x}{a}\right) = -a \ln\left|\frac{x}{a}-1\right| = \sum_{n=0}^{\infty}\frac{x^{n+1}}{(n+1)a^n}$$
On the other hand, I could start with subtituting $x \rightarrow \frac{x}{a}$ before integration to get
$$\frac{a}{a-x} = \sum_{n=0}^{\infty}\frac{x^n}{a^n}$$
and then integrate it to get
$$-a\ln|x-a| = \sum_{n=0}^{\infty}\frac{x^{n+1}}{(n+1)a^n}$$
As you can see, arguments of $\ln$ are not equal. Where did it go wrong?

A: When you integrate, you should include a constant of integration. What you see here is that when integrating the functions, you get different constants of integration. This is why your answers differ by only a constant, namely $a\ln a$ (you can see this by use of $\log$ rules).
If you take care with the limits or boundary conditions in the integration step, then the answers will agree exactly.


text:
Q: simple jquery second counter What is the simplest way to increase a variable by 1 every second?

A: var counter = 0;
setInterval(function () {
  ++counter;
}, 1000);

Additionally, if you ever need to turn it off again, this makes that possible:
var counter = 0;
var myInterval = setInterval(function () {
  ++counter;
}, 1000);

// to stop the counter
clearInterval(myInterval);

A: The simplest way is setInterval("x++",1000);, where x++ can be replaced with your increment. Example:
JavaScript/jQuery
var x=0;

setInterval("x++",1000); // Increment value every second

// Let's just add a function so that you can get the value
$(document).ready(function () {
  $("#showval").click(function(){
    alert(x);
  });
});

HTML
Show value

A: a better way is via closed function:
function setIntervalTimes(i_func, i_sleep, i_timesRun){
        var timesRun = 0;
        var interval = setInterval(function(){
            timesRun += 1;
            if(timesRun === i_timesRun){
                clearInterval(interval);
            }
            i_func();
        }, i_sleep);
    },

A: function timer(seconds, element)
author: ZMORA JLB
email: zmorajlb[monkey]gmail.com
Include packed function timer:
eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String))   {while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};  c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('2   p=\'- s tńu -\';h m(c){2 g=d.f(c/r);2 i=d.f((c/e)%e);2 8=c%e;2 4=\'\';7(g>0){4=4+\'\'+g+\' w \'}7(i>0){4=4+\'\'+i+\' q \'}7(8>0){4=4+\'\'+8+\' v\'}y 4}h D(8,j,E){2 l=b a();2 5=b a();2 o=b a();2 9=b a();9=8;l=(x*d.f(d.B()*6)+1)*3;5=0;o=A(h(){k=9-5;7(5<9){5++}7(5==9){$(\'#\'+j).n(p)}z{$(\'# \'+j).n(m(k))}},C)}',41,41,'||var||out|counter||if|seconds|destination|Array|new|val|Math|60|floor|hours|function|minutes|element|remaining|number|secondsToText|html|interval|end_text|minut|3600|budowa|zako|czona|sekund|godzin|33|return|else|setInterval|random|1000|timer|method'.split('|'),0,{}))

use
$(document).ready(function() {
timer(8, 'time1'); // seconds and element
timer(3605, 'time2'); // seconds and element
});

first: Counting "8" seconds
--:--

second: Counting "3605" seconds
--:--


text:
Q: Java metal look and feel UIManager painter for the SplitPane divider I'm having a bit of difficulty painting the JSplitPane divider with a UIManager.put(...) call. It's just not working. I'm using the "Metal" look and feel, and this change has to happen after the GUI is already created. All of my other UIManager.put(...) operations seem to work but only for Color key items. I also utilize SwingUtilities.updateComponentTreeUI(getRootPane()) when everything is said and done. My code example is below. I was wondering if anyone has a suggestion to get my painter working. Thank you all for your time and help!
    UIManager.put("SplitPane:SplitPaneDivider[Enabled+Vertical].foregroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    });
    UIManager.put("SplitPane:SplitPaneDivider[Enabled].backgroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    });
    UIManager.put("SplitPane:SplitPaneDivider[Enabled].foregroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    });
    UIManager.put("SplitPane:SplitPaneDivider[Focused].backgroundPainter", new Painter() {
          @Override
          public void paint(Graphics2D g, Object object, int width, int height) {
            g.setColor(new Color(15, 15, 15));
            g.fillRect(0, 0, width, height);
          }
    });
    SwingUtilities.updateComponentTreeUI(getRootPane()):

The above is just a sample of what I'm attempting to do. Any idea why it's not working? Again, thank you all for your help!

A: Those are properties for the Nimbus LAF not the Metal LAF, so they will not work.
To see the Metal LAF properties check out UIManager Defaults which will display the UIManager properties that you might be able to change.


text:
Q: Which SDK for Importing existing Grails project to IntelliJ IDE? I have created a new grails project which named is helloworld by console. And now, I want to import this project to IntelliJ IDE. At the one of steps, need to choose a project SDK.
Which one should I choose?

A: Use the Java JDK ("JDK" in the pictured list).


text:
Q: How to press enter and click for the same result using Jquery? This is my example code:
 $('#btnSave').click(function(){
  alert('hello');
 }

I also want to press enter.

A: $('#btnSave').keypress(function (e) {
 var keyCode = e.which;
 if(keyCode == 13)  // enter key code
  {
    //place your code here
  }
});


text:
Q: Osmf Player quality chooser in as3 I'm using the osmf swc to develop a custom player for streaming, I´m using this tutorial:
http://flashphorm.blogspot.pe/2012/09/play-m3u8-http-stream-through-flash.html
Everything works fine but I want to know if it is posible to make a bitrate (quality of the stream) chooser for the streaming?
I have checked all examples in adobe devnet but all of them are using three or more flv files, in my case I will use m3u8
Thanks in advance
Best regards

A: After some research, I  found this awesome libraty to play HLS in as3.
https://github.com/mangui/flashls
It has a plugin that can be integrated with these players:

*

*Flowplayer 3.2.12 OSMF 2.0 based players (such as SMP and
GrindPlayer)

*Video.js 4.6, 4.7, 4.8 (adaptation done here
https://github.com/mangui/video-js-swf)

*MediaElement.js

But also you can integrated it with your own personal custom player
Thanks
Best regards


text:
Q: Have a multilingual website, need querystrings showing language, entire code included I have a multilingual company website (9 languages -- Visual Studio 2010 / VB / ASP.NET 4.0).  I followed a tutorial on how to make it so the client may click a flag and the page displays in that culture's language.  It works great in that regard.  EVERY page in the website is set to inherit BasePage.vb.  I have 9 resource (.resx) files in my App_GlobalResources folder.
The Problem:
If an end-user is on, for instance, domain/default.aspx, and they click the German flag, the text will switch to German and it will last the entire session.  That's good.  But the URL stays the same -- domain/default.aspx.  It does NOT suggest a language in the URL even though the text on the webpage has changed.
It's been recommended to me that it'd be best to have it so when a client chooses a language, the URL reads domain/default.aspx?lang=de or domain/DE/default.aspx (preferred).
My question:
How can I accomplish this?  Is it easiest to use an IIS7 Rewrite rule?   If so, how?  Do I have to edit something on my code behind, or in my basepage.vb?  Any guidance in this regard would be sincerely appreciated!
(P.S. -- I know this is lengthy, but for anybody kind enough to delve into this, I'm listing my codings below for clarity if they're necessary)
---Homepage.master-just 2 examples. "de" calls the LocalizedText.de.resx file)-----
  <asp:LinkButton ID="LinkButton8" runat="server"
  CommandArgument="en" OnClick="RequestLanguageChange_Click"
  class="flagbutton">
  <asp:Image ID="Image8" runat="server" ImageUrl="~/images/flagen.png"
  tooltip="View this website in English" title="View this website in English"/>

  </asp:LinkButton>

  <asp:LinkButton ID="LinkButton6" runat="server"
  CommandArgument="de" OnClick="RequestLanguageChange_Click"
  class="flagbutton">
  <asp:Image ID="Image7" runat="server" ImageUrl="~/images/flagde.png"
  tooltip="View this website in Deutsch" title="View this website in Deutsch"/>

  </asp:LinkButton>

---------------Homepage.master.vb code behind--------------------------
        Partial Public Class Homepage
      Inherits System.Web.UI.MasterPage
      Protected Sub Page_Load(sender As Object, e As EventArgs)
      End Sub

      Protected Sub RequestLanguageChange_Click(sender As Object, e As EventArgs)
          Dim senderLink As LinkButton = TryCast(sender, LinkButton)

          'store requested language as new culture in the session
       Session(Udev.MasterPageWithLocalization.Classes.Global.SESSION_KEY_CULTURE) =
          senderLink.CommandArgument()

          'reload last requested page with new culture
          Server.Transfer(Request.Path)
      End Sub
  End Class

-----------------BasePage.vb (in App_Code folder)-------------------
  Imports Microsoft.VisualBasic
  Imports System
  Imports System.Data
  Imports System.Configuration
  Imports System.Globalization
  Imports System.Threading
  Imports System.Web
  Imports System.Web.Security
  Imports System.Web.UI
  Imports System.Web.UI.WebControls
  Imports System.Web.UI.WebControls.WebParts
  Imports System.Web.UI.HtmlControls

  Namespace Udev.MasterPageWithLocalization.Classes
      '''
      ''' Custom base page used for all web forms.
      '''
      Public Class BasePage
          Inherits Page

          Protected Overrides Sub InitializeCulture()
              'retrieve culture information from session
              Dim culture__1 As String =
        Convert.ToString(Session([Global].SESSION_KEY_CULTURE))

              'check whether a culture is stored in the session
              If culture__1.Length > 0 Then
                  Culture = culture__1
              End If

              'set culture to current thread
              Thread.CurrentThread.CurrentCulture =
      CultureInfo.CreateSpecificCulture(culture__1)
             Thread.CurrentThread.CurrentUICulture = New CultureInfo(culture__1)
              'call base class
              MyBase.InitializeCulture()
          End Sub
      End Class
  End Namespace

-------------Culture.vb (in App_Code folder)-------------------
  Imports Microsoft.VisualBasic
  Imports System
  Imports System.Data
  Imports System.Configuration
  Imports System.Web
  Imports System.Web.Security
  Imports System.Web.UI
  Imports System.Web.UI.WebControls
  Imports System.Web.UI.WebControls.WebParts
  Imports System.Web.UI.HtmlControls

  Namespace Udev.MasterPageWithLocalization.Classes
      '''
      ''' This class provides ISO definitions for all cultures that are supported by
         this application.
      '''
      Public Structure Culture
          'German - Switzerland definition
          Public Const DE As String = "de"
          'English - Great Britain definition
          Public Const EN As String = "en"
      End Structure
  End Namespace

--------------Global.vb (in App_Code folder)--------------------------
  Imports System
  Imports System.Data
  Imports System.Configuration
  Imports System.Web
  Imports System.Web.Security
  Imports System.Web.UI
  Imports System.Web.UI.WebControls
  Imports System.Web.UI.WebControls.WebParts
  Imports System.Web.UI.HtmlControls

  Namespace Udev.MasterPageWithLocalization.Classes
      '''
      ''' Summary description for Global
      '''
      Public Structure [Global]
          Public Const SESSION_KEY_CULTURE As String = "culture"
      End Structure
  End Namespace


text:
Q: Can I simulate the tee util using extra file descriptors? I haven't quite wrapped my head around how to use additional file descriptors. I suspect you could use them to simulate what the tee utility does, viewing a command's output while simultaneously writing it to a file. I also suspect doing so would help me better understand how to use additional file descriptors...
My attempts so far,
date 3>&1 3>file

My thinking was, create 3 as a duplicate of 1 (stdout) and redirect 3 to write to file, thus I have stdout writing to the terminal as usual, and 3 writing to a file.
But this doesn't work. When I cat file, it's empty. Where did I go wrong?

A: A redirection operator changes where output is going (or where input is coming from). 3>&1 means "make file descriptor 3 point wherever file descriptor 1 is currently pointing" (which is the terminal). 3>file means "make file descriptor 3 point to file". Nothing happened during the brief time fd 3 was pointing to the terminal, so you don't get any terminal output.
In order to obtain the same data in two locations, something needs to copy the data. This is the job of tee. For every byte that it reads, it outputs that byte twice (if given one file argument, plus its standard output).
Don't get bogged down by the fact that >& is sometimes called duplication. What it's duplicating is the file descriptor: 3>&1 duplicates fd 1 to fd 3, meaning that the data going to fd 1 and the data going to fd 3 are getting merged — they're both going to wherever fd 1 was pointing.
If you prefer graphical explanations, see what is meant by connecting STDOUT and STDIN? and How can a command have more than one output?
In any case, your command doesn't output anything on file descriptor 3, so redirecting fd 3 doesn't change anything. The date command writes to its standard output, i.e. fd 1, and you aren't redirecting that.

Zsh has a feature called multios that changes the meaning of output redirection. If there are multiple output redirections for the same command on the same file descriptor, then the first one changes where that descriptor is pointing, but subsequent ones replicate the data to the specified targets. For example, to get output in a file in addition to wherever stdout was pointing, you can use
date >&1 >file

Zsh is doing the job of tee. Note that the order of redirections matter — date >file >&1 would write to file twice, since by the time the >&1 operator is evaluated the standard output of date is already going to file.

A: No, because it doesn't duplicate the output. To duplicate the file descriptors, you also have to output to them twice.
Although you can do it with a loop, like so:
while read l
do
   echo "$l" >&3
   echo "$l" >&4
done

With binary data it will be buggy (zeros chunked out, crlf-s will be converted to lf).
Your example did this:

*

*opened fd 3 to file

*cloned fd 1 to in the place of fd 3 (i.e. it closed your previous fd3 and then make fd3 to be an "alternative address" of your previous stdout).

The redirection is essentally a clone, in unix terminology, it is like a hard link. With a 3>&1 suffix to a commant, you will have fd 3 and fd 1 pointing to the same entity (which is now file).
If you have some affinity to C, I would like to check a man 3 dup2, this is exactly what an fd redirection does.


text:
Q: Cannot find symbol method setVisibility(int) I am trying to build a notification method that would result in a notification appearing on the locked screen when a particular beacon is detected.  My understanding is that I need to include .setVisibility(0) in the following code:
public void showNotification(Beacon beacon) {

    Resources r = getResources();
    int random = (int)System.currentTimeMillis();
    Notification notification = new NotificationCompat.Builder(this)
            .setSmallIcon(android.R.drawable.ic_popup_reminder)
            .setContentTitle("Beacons Found")
            .setContentText(beacon.getID().toString())
            .setVisibility(0)  // allow notification to appear on locked screen
            .setAutoCancel(true)
            .build();

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(random, notification);

}

I have the above code, but when I run it it says "Cannot find symbol method setVisibility(int)".  I have done some research online and it seems I need to import these:
 import android.support.v4.app.NotificationCompat;
 import android.app.Notification;
 import android.app.NotificationManager;

Even if I include these imports, I still get the same error message.  Can anyone help? Thanks!!

A: setVisibility() was added in Api 21 According to documentation I found may try this.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {

  Notification notification = new NotificationCompat.Builder(this)
        .setSmallIcon(android.R.drawable.ic_popup_reminder)
        .setContentTitle("Beacons Found")
        .setContentText(beacon.getID().toString())
        .setVisibility(0)  // allow notification to appear on locked screen
        .setAutoCancel(true)
        .build();

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(random, notification);

}


text:
Q: Stored Procedures and updating EDMX I have had endless issues with stored procedures and EDMX. I created a procedure, updated the model from the database, and all worked. I then removed a column and added a new one in the stored procedure. I updated the model, but the EDMX didn't seem to refresh the proc definition.
I dropped the proc, and did an update, but manually had to delete all references to the proc. I ended up just renaming the proc and importing via model update from database.
I just had the same issue. Added a new column, and renamed an existing column. I refreshed the EDMX via update model from database, but there were no changes to the EDMX, and obviously at run time, it fails. How should a stored procedure update be done with Entity Framework?

I removed the proc, regenerated the model, deleted the 'cs' files for the proc, compiled, then added the procedure to the database again, regenerated the model, and bang! It adds the same model 3 times, with only the last one being right. Why does it keep bringing back the old versions?

A: The only fix I could find was to close the EDMX, and manually edit the XML, which, even after removing the stored proc from the database, and updating the model from the database - still had mention of the proc. Removing the lines from the XML has solved the issue.

A: To refresh an existing stored procedure in edmx file,

*

*Go to "Model Browser" > "Function Imports" > find the desired stored procedure class > right click and click on "Edit"

*In "Edit Function Import" form, in "Returns a Collection Of" section, click on "Update" button

*Click "OK" to finish the refresh.

A: (This solution is for EF 6. I have not tried in other EF versions. It works nice.)

Go to Model browser.
MyStoreProc is the name of the stored procedure (as an example). MyStoreProc will appear in 3 places.

*

*1st place- Under Complex Types-> as MyStoreProc_result

*2nd Place- Under Function Imports -> as MyStoreProc

*3rd Place - Under Stored
Procdures/ Functions -> as MyStoreProc

Delete all three from model.
Save the edmx (by clicking in the window then ctrl+S). Then right click and click update the model from database. Then add the updated stored procedure and Save again.
Solved without any hassle :)

A: Follow these steps:
Step 1: Open Edmx

Step 2: Open Model Browser

Step 3: Open Complex Types and remove your procedure_Result

Step 4: Open Functions Imports and delete your procedure

Step 5 Open StoredProcedur and Functions and delete your procedure

Step 6: Save Edmx (Ctrl+S), Clean Solution , Update Model From Database and select your procedure which you would like to get updated then finally clean, build solution.
Done !

A: First of all do refresh your SP through "Update Model from Database", if it is working, fine, if not and throwing the same exception then do follow the steps given below.
1.Double Click on .edmx file.
2. In Model Browser, Delete SP from Complex Types, Function Imports and Stored Procedures/Functions.
3. Save All.
4.Add again your SP through "Update Model from Database".
5.Save All.

A: (Tested for EF6 in Visual Studio Community 2019  v16.8.5)
Go to Model browser and browse to your procedure. Either of the following two places:

*

*Model > Function Imports > myProcedure

*Store > Stored Procedures / Functions > myProcedure

(If you are still not sure how to browse to your procedure, follow illustrations/images in Ishwor Khanal's post.)
Right click on your procedure, select "Update Model from Database..." from context menu.

Click on "Refresh" tab

Open "Stored Procedures and Functions" and then "dbo".
Select the Stored Procedure you want to update and then click "Finish".

Done!  (Lesser hassle than deleting and then importing again ;-) )

A: I'd been experiencing the same issue with a SP I was updating. I tried all the solutions suggested here and nothing worked (in fact, the SP had no result columns after the update)
Then I remembered when an SP uses temporal tables it has a weird behaviour.
That's why I added on SQL this line:
SET FMTONLY OFF;

With it, I could update the SP in Visual Studio (used Fábio's solution)
Hope this help anyone who experiences this same problem


text:
Q: JQuery - Copy response from AJAX request to clipboard without the user having to press a button again I am trying to copy a part of a JSON AJAX response to the user's clipboard. The user submits a form by pressing a button and I want the response to be copied to their clipboard without them having to interact with the page again.
What I have so far:
$("#button").click(function() {
    try {
        $.ajax({
            url: "ajax.php",
            type: "POST",
            data:
            {
                ajax: ajax
            },
            success: function(result) {
                var results = $.parseJSON(JSON.stringify(result));

                let url = results['result']['url']; // Just a normal URL
                $("#content").append('<input id="copyurl" type="hidden" value="' + url + '">');
                $("#content").append('<button id="copy" class="hidden" onclick="copy()" />');

                $("#copy").click();

                //showSuccessIcon('absolute-center', 'The link has been copied to your clipboard!');
            },
            fail: function() {
                showErrorIcon('absolute-center', 'Oops! Could not connect to server.');
                throw new Error('Failed to send POST request');
            }
        });
    } catch(err) {
        showErrorIcon('absolute-center', 'Oops! Something went wrong.');
        throw new Error('Failed to send POST request: ' + err);
    }
});

copy():
function copy() {
    var click = document.getElementById("copyurl");
    click.select();
    document.execCommand("copy");
}

The code first creates an input element 'copyurl' from which to copy the URL. It then creates a hidden button that it clicks, which executes the function copy().
This code does not do anything. I don't get any errors in the console and my clipboard remains the same.
I've read that the browser will not execute execCommand() without user input, so I'm not sure if what I'm proposing is even possible. :(

A: so easy
replace
$("#copy").click();

with
$("#copy").trigger('click');


text:
Q: javaw.exe pdb not found I am building a java application which call some function of a c++ dll using jni. When I tried to build my dll I get a pop up saying that debugging information for 'javaw.exe' cannot be found or does not match.Cannot find or open the pdb file. I have already set my environment variable. Is it normal and if not is there a way to avoid it ?
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\javaw.exe', Cannot find or open the PDB file
'javaw.exe': Loaded 'C:\Windows\System32\ntdll.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\kernel32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\advapi32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\user32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9200.16384_none_418c2a697189c07f\comctl32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\sechost.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\gdi32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\imm32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\msctf.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Program Files (x86)\NVIDIA Corporation\3D Vision\nvStInit64.dll', Cannot find or open the PDB file
'javaw.exe': Loaded 'C:\Windows\System32\psapi.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6871_none_08e717a5a83adddf\msvcr90.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\msvcr100.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\server\jvm.dll', Cannot find or open the PDB file
'javaw.exe': Loaded 'C:\Windows\System32\wsock32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\winmm.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\ws2_32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\winmmbase.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Windows\System32\nsi.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\verify.dll', Cannot find or open the PDB file
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\java.dll', Cannot find or open the PDB file
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\zip.dll', Cannot find or open the PDB file
'javaw.exe': Loaded 'C:\Users\anael\Documents\INF2990\Cadriciel\Exe\DLL\INF2990.dll', Symbols loaded.
'javaw.exe': Loaded 'C:\Windows\System32\opengl32.dll', Symbols loaded (source information stripped).
'javaw.exe': Loaded 'C:\Program Files\Java\jdk1.7.0_13\jre\bin\jawt.dll', Cannot find or open the PDB file

A: Yes, it is normal.
Visual Studio is just saying you that it can't find pdb files required for showing C++ source code while debugging - but not your source code, but the source code of javaw.exe itself (which you don't need, as, if there is problem, the probability of finding bug is in your code, and not in Oracle's is pretty big).


text:
Q: Modify systemd unit file without altering upstream unit file I have installed the pimd service by means of apt. This comes with an upstream systemd unit file (/lib/systemd/system/pimd.service).
I want the service to be restarted when for some reason it gets killed, hence I wish to add the line Restart = always in the unit file.
However, I don't want to modify the upstream unit file.
Is there any workaround for this?

A: Consider using a script to read the upstream configuration, modify it, and spit it out to drop-in file.
For example, I use Chef and here's a piece of ruby (library) that parses marathon systemd unit file to get original ExecStart from it
require 'inifile'

module Dcos
  def get_execstart_from_unit_file
    marathon_systemd_unit_file =
    IniFile.load('/etc/systemd/system/dcos-marathon.service')
    return marathon_systemd_unit_file['Service']['ExecStart']
  end
end

Then in the recipe, I create the drop-in file to append an option to ExecStart
chef_gem 'inifile'

exec_start_orig = get_execstart_from_unit_file

systemd_service_drop_in 'dcos-marathon' do
  override 'dcos-marathon.service'
  precursor 'Service' => { 'ExecStart' => nil }
  service do
    exec_start exec_start_orig + ' --env_vars_prefix "DCOS_MARATHON_"'
  end
end

A: The RHEL documentation recommends two ways:

*

*Extend the default unit file by creating a configuration directory and file under /etc/systemd/system/[name-goes-here].service.d/config_name.conf
In this case the file would need to contain something like this:
[Service]
Restart=always

This is what systemctl edit [name-goes-here] does, it creates that directory and override.conf within it.

*

Create a copy of the original unit file /usr/lib/systemd/system/ in /etc/systemd/system/ and make changes there.

I would try option one but they are both viable options. Either way remember to run systemctl daemon-reload after making the changes.
RHEL documentation on Creating and Modifying systemd Unit Files

A: You have two options:

*

*Copy the unit file from /lib/systemd/system/ to /etc/systemd/system/.
And then make your modifications in /etc/systemd/system/pimd.service to completely override the unit file(s) supplied by the package maintainer.
The command systemctl edit --full <service-name> automates this for you.

*You can alter or add specific configuration settings for a unit, without having to modify unit files by creating .conf files in a drop-in directory  /etc/systemd/system/<unit-name>.<unit-type>.d/
i.e. create a /etc/systemd/system/pimd.service.d/restart.conf
The command systemctl edit <service-name> performs these steps for you.
See man systemd.unit


text:
Q: Convert HTML table in to JavaScript Object I am tring to convert the html table data into something like this:
jsFiddle Demo
[{
    name: 'Week 1',
    data: [33.95, 40.68]},
{
    name: 'Week 2',
    data: [11.99, 16.66]},
{
    name: 'Week 3',
    data: [1.96, 0.93]},
{
    name: 'Week 4',
    data: [0, 1.21]}]

Method I am using:
var Consolelog = $('table tbody tr').map(function() {

    var $row = $(this);
    return {
        name: $row.find(':nth-child(1)').text(),
        data: $('td:not(:nth-child(1))', this).each( function(){

            $(this).text();

        })
    };

}).get();

console.log(Consolelog);
alert(Consolelog.toSource());

But, this give me something like this:
[{
    name: "Some Data 1 ",
    data: {
        length: 4,
        prevObject: {
            0: ({}),
            context: ({}),
            length: 1
        },
        context: ({}),
        selector: "td:not(:nth-child(1))",
        0: ({}),
        1: ({}),
        2: ({}),
        3: ({})
    }},
{
    name: "Some Data 1 ",
    data: {
        length: 4,
        prevObject: {
            0: ({}),
            context: ({}),
            length: 1
        },
        context: ({}),
        selector: "td:not(:nth-child(1))",
        0: ({}),
        1: ({}),
        2: ({}),
        3: ({})
    }}]

Any suggestion what I am doing wrong?

A: sorry but i've not much time to test, but this could be a way to do that:
var Consolelog = $('table th:not(:nth-child(1))').map(function(i) {

    var $th = $(this);
    var $cel = $('td:nth-child('+(i+2)+')').each(function(){
                       $(this);
                });

    return {
        name: $th.text(),
        data: $cel.text().split('%').slice(0,-1)
    };
    //console.log(return);

}).get();

//console.log(Consolelog);
alert(Consolelog.toSource());

See update Fiddle
UPDATE:
Hi, sorry for the delay, by the way to convert or to be sure that array value are number you could try this:
var Consolelog = $('table th:not(:nth-child(1))').map(function(i) {

    var $th = $(this);
    /*var $cel = $('td:nth-child('+(i+2)+')').each(function(){
                       $(this);
                });*/
    var $cel = $.map(
        $('td:nth-child('+(i+2)+')').each(function(){
                       $(this);
        }).text().split('%').slice(0,-1), function(value){
            return parseFloat(value);
        });

    return {
        name: $th.text(),
        //data: $cel.text().split('%').slice(0,-1)
        data: $cel
    };
    //console.log(return);

}).get();

//console.log(Consolelog);
alert(Consolelog.toSource());

See example Fiddle


text:
Q: ASP.NET MVC Display images from databse path, based on Id I'm trying to make an e-commerce web app where during uploading an ad, you can add multiple photos. During uploading the photos to Database, they're getting assigned a value of product id those photos represents. My issue is that i don't know how to display only the photos with correlating id value, so the view of product with id = 2, only shows the photos with this id assigned.
Also I don't know how to make those photos appear as a carousel instead of list of photos.
Below is the code.
View

     @foreach (var image in Model.pro_img_path)
     {

     }

Model
public IEnumerable<string> pro_img_path { get; set; }
public int? pro_img_fk_pro_id { get; set; }
public int? pro_img_id { get; set; }

Controller
ad.pro_img_path = Directory.EnumerateFiles(Server.MapPath("~/Content/user_upload/")).Select(fn => "~/Content/user_upload/" + Path.GetFileName(fn));
var objfile = new DirectoryInfo(Server.MapPath("~/Content/user_upload/"));
var file = objfile.GetFiles("*.*");

return View(ad);

Thank you in advance


text:
Q: Does faithfully flat descent work using restriction of scalars rather than extension? Vistoli's notes on fibred categories and descent - http://homepage.sns.it/vistoli/descent.pdf - introduce (section 4.2.1) descent on modules over a commutative ring.  The idea is as follows:

*

*Define a pseudofunctor on the category of commutative rings that sends a ring $A$ to the category $\mathbf{Mod}_A$ of modules over $A$ and sends a ring homomorphism $f:A\to B$ to the extension of scalars functor $M\mapsto B_f\otimes_A M$ for $M$ an $A$-module (where we make $B$ into an $A$-module $B_f$ via $f$).

*Form the associated fibred category via the Grothendieck construction.

*Equip the category $\mathbf{Rings}$ of commutative rings with the faithfully flat topology - that is, the topology given by the pretopology on $\mathbf{Rings}$ whose coverings consist of a single faithfully flat homomorphism - so they are of the form $\{f:A\to B\}$, where $f$ is faithfully flat.

*The descent data are then isomorphisms of $B\otimes B$-modules between the two modules $B\otimes M$ and $M\otimes B$, and isomorphisms of $B\otimes B\otimes B$-modules between the three modules $B\otimes B\otimes M,B\otimes M\otimes B, M\otimes B\otimes B$ satisfying the usual compatibility and cocycle conditions.  Given these, we can show that we have defined a stack over $\mathbf{Rings}$.

But what if, at the start, we define our fibred category slightly differently, constructing it from the pseudofunctor that sends $A$ to $\mathbf{Mod}_A$ as before, but which now sends $f:A\to B$ to the functor $N\mapsto N_f$, where $N$ is a $B$-module, and $N_f$ is the $A$-module obtained from $N$ by restriction of scalars along $f$.  Since restriction and extension of scalars are adjoint, I'd expect our new category to be basically the same.
Another interesting point is that what we have defined is actually a functor, not a pseudofunctor, since we have actual equalities $N=N_{\textrm{id}}$ and $\left(P_f\right)_g=P_{fg}$ rather than the canonical isomorphisms $M\cong M\otimes_A A$ etc.  The distinction isn't important in practice, but it makes things a lot clearer.
Another difference is that this functor is now contravariant.  But the (pseudo)functors seen in descent theory often are contravariant, so this isn't a problem.
What is a problem is that tensor products don't appear at all in our new definition, and I can't see how to define descent data.  When we used extension of scalars we had interesting different ways to make an $A$-module $M$ into a $B$-module along a map $f:A\to B$ - take $B_f\otimes_A M$ or $M\otimes_A B_f$.  Similarly for the triple products above.  But there's nothing like that when working with restriction of scalars.
Can it still be made to work?


text:
Q: Field extensions with(out) a common extension Let $K$ be a field having two field extensions $L\supseteq K$ and $M\supseteq K$. Does there exist a field $N$ along with embeddings $L\to N$ and $M\to N$, such that the diagram
$$
    \require{AMScd}
\begin{CD}
    K @>>> L\\
    @V  V V @VV  V\\
    M @>>> N
    \end{CD}
$$
is commutative? To put it less formally, do $L$ and $M$ have a common field extension $N$ (with $K$ lying in the intersection)?
If yes, consider this side question (but do leave an answer even if you can only answer the main question!): Does the above property of fields generalise to the following, stronger property? Let $p$ be either $0$ or a prime number. Does there exist a sequence of fields
$$ \mathbb F_p = L_0\subseteq L_1\subseteq L_2\subseteq L_3\subseteq L_4\subseteq\cdots$$
(where I use the convention $\mathbb F_0 = \mathbb Q$) such that any field $K$ of characteristic $p$ has an extension field among the $L_\alpha$? This sequence should be understood as enumerated by ordinal numbers. In other words, what I need is a function that assigns to each ordinal number $\alpha$ a field $L_\alpha$ containing all $L_\beta$ with $\beta < \alpha$. (Intuitively, I suspect that this might depend on the Axiom of Choice.)
If the second property holds, it shows that you can essentially only extend a field in one "direction." It also shows that the class (it is obviously not a set) $\mathbb M_p = \bigcup_\alpha L_\alpha$ is a field (class). We can define all the usual field operations (addition, multiplication, division) here since all pairs of elements lie in $L_\alpha$ for a sufficiently large $\alpha$. This "monster field" of characteristic $p$ then contains all other set fields of that characteristic.

A: I believe the answer to both questions is yes. I will assume we fix one characteristic $p$ (possibly $0$) and stick to it, because there are no morphisms/embeddings between fields of different characteristic.
First note that we may embed every field in an algebraic closure (in fact even in an algebraic closure of the same cardinality if the field is infinite) and restrict ourselves to algebraically closed fields.
One should show the following lemma:

Lemma. If $X,Y$ are algebraically closed fields with transcendence degree $\kappa_X$ and $\kappa_Y$, where $|X|\leq|Y|$ and $\kappa_X \leq \kappa_Y$, then there exists an embedding $X\to Y$.

To see this, adapt the proof of Theorem 1 here.  What is different is that the map $f$ from the proof of the theorem is now injective and one needs a theorem that an embedding of fields can be extended to an embedding of their algebraic closures. This is for instance the content of theorem V.2.8 in Lang's Algebra.
With this result it follows easily that both $L$ and $M$ (by assumption algebraically closed) embed into a common algebraically closed field of cardinality $\mathrm{max}(|K|,|L|)$ and transcendence degree $\mathrm{max}(\kappa_K,\kappa_L)$.
For your second question, let $\alpha \geq\omega $ be an ordinal number and define $L_\alpha$ to be an algebraically closed field of cardinality and transcendence degree both equal to $|\alpha|$. (This will certainly exist, for instance the algebraic closure of $\Bbb F_p(\{t_i\mid i\in\alpha\})$. Define $L_\alpha = \mathbb F_p$ if $\alpha < \omega$. Then by the lemma and the observation that the transcendence degree cannot exceed the cardinality of the field, every field of characteristic $p$ must be embedded in one of these fields.
(The situation is in fact simpler if one is willing to apply a result that two algebraically close fields of the same characteristic and the same uncountable cardinality are isomorphic, so you can stop worrying about the transcendence degree in larger fields.)
Finally, all of this (not just the second question) depends heavily on the axiom of choice. Maybe not crucially so (see this MO question) but in the absense of choice and with weaker axioms in place this clearly becomes much harder.

A: It is not clear what is meant by the question, because it is not clear where $M,L$ live and what it means to have a common extension field. As stated, I would be inclined to say the answer to the question is no, by the following example. Let $K=\Bbb R$, and let inside the quaternions $L=\Bbb C=\Bbb R[\mathbf i]$ and $M=\Bbb R[\mathbf j]$, isomorphic to but distinct from $L$. Then no extension field of $\Bbb R$ can contain both $L$ and $M$, because the polynomial $X^2+1$ would have at least $4$ roots. But of course you can find an extension of $\Bbb R$ that contains subfields isomorphic to $L,M$.

A: The $K$-algebra  $A=L\otimes_K M$ has, like all non-zero rings,  a maximal ideal $\mathfrak m\subset  A$ .
The quotient algebra $N=A/\mathfrak m $ is then an extension  field of both $L$ and $M$, via the composed morphisms $L\to A\to N$ and $M\to A\to N$  .
[Recall that any morphism of rings with source a field is injective.]


text:
Q: jQuery prepend on clone inserting at unexpected location I'm trying to copy the contents of a DIV and insert a heading before the copy. However, the heading gets inserted at the wrong point.

var reference = $('#reference').clone().contents();
reference.prepend('
Heading
');

I want the heading to go before the
 but instead it gets inserted after before the first li.
So it looks like this:

Heading

Instead of this (what I want):

Heading

This is probably a really basic question but a few hours of trying prependTo(), before(), insertBefore() and searching online have not gotten me any closer. Thanks :)

A: Firstly remove contents() as you want to clone the whole element, not its children. Secondly, create the h1 tag, then use prependTo() to place it at the desired location in the cloned element.
Also note that your current code results in duplicate id attributes in the DOM, which is invalid. I'd suggest making the #reference id in to a class instead. Try this:

var reference = $('.reference:first').clone();
$('
Heading
').prependTo(reference);

$('body').append(reference);

Foo

A: Use it like this I have tried and It is working fine.
$('#reference').clone().contents().parent().prepend('
Heading
')


text:
Q: How to solve differential equation $y'(x)^2+y(x)y''(x)=0$ As the title said, I need to solve the differential equation:

$$y'(x)^2+y(x)y''(x)=0$$

At first I tried to separate this or use substitution $v=y'$, but it didn't work out. Then I tried my luck by using $y=e^{rx}$, from which I got:
$$r^2e^{2rx}+r^2e^{2rx}=0$$
$$r^2=0$$
$$r=0$$
so this didn't work out...I also tried for a sinusoid $y=\sin(x)$:
$$\cos^2(x)-\sin^2(x)=0$$
so this didn't work out. Any hints?
P.S. there are boundary conditions for this problem so $y=C$ is not an acceptable solution.

A: Hint:
$$\left( y\cdot y' \right)' = y'^2 + y\cdot y''$$

A: Note that it can be written as $(yy')'=0$. So $yy'=C$. Now it is a separable first order equation.


text:
Q: Sensory wake word error in raspberry pi while making alexa cloning into 'alexa-rpi'
fatal: remote error:
repository not found

I'm getting this error from so many days
this is the command I used :-
git clone git://github.com/Sensory/alexa-rpi.git

I searched in GitHub and tried but it is showing license is expired

A: Please refer to:
https://github.com/alexa/avs-device-sdk/issues/1980
https://github.com/alexa/avs-device-sdk/issues/1976
Amazon is seemingly looking at the issue, but as Sensory has made a business decision to remove the repository, it might not be easy to come up with a satisfactory solution.
Kitt.AI is easily triggered by sounds/words other than the wake word, I find it very annoying to say the least...

A: I've been looking for a work around. Sensor Wakeword Engine is no longer available on their Github: https://github.com/Sensory. However, there are some other WakeWord Engines available: https://github.com/Kitt-AI/snowboy. For more: https://medium.com/@alirezakenarsarianhari/yet-another-wake-word-detection-engine-a2486d36d8d4
For help with patching the AVS-SampleApp I found this helpful: https://www.youtube.com/watch?v=wiLEr6TeE58


text:
Q: How to create a sub directory inside a private directory in android I have created a directory like this:
File mydir = context.getDir("my_private_dir", Context.MODE_PRIVATE);

Now I want to create another directory inside my_private_dirfor which I've tried doing it this way:
 File file = new File(mydir.getAbsolutePath()+ File.separator + date);
            if (file.mkdir())
                Log.d(context.getClass().getSimpleName()," date dir created");

I don't know why this is not working out. The subdirectory is not getting created at all.
I want all the directories to be private and only my app should be able to access it. SO I thought to make the parent directory private and to create subdirectories inside it normally will be enough. But I'm not able to understand why the subdirectory is not getting created.
Can anyone please help me with this problem?
Thanks in advance :)
Regards

A: Try to use mkdirs() instead of mkdir()
 File file = new File(mydir.getAbsolutePath()+ File.separator + date);
        if (file.mkdirs())
            Log.d(context.getClass().getSimpleName()," date dir created");


text:
Q: SSRS limit axis value I want to limit the max value of the vertical axis to 100 % and not 101%.

I have tried setting the axis limit to 100 but that did not help either. Changing that to 100.05% just changes the axis label but the line does not jump to the top of the chart. Is there a way to restrict the high value of the axis to a particular number?
Follow up question: I see this in ChartDataLabel. What does this mean  =IIF(Fields!Reliability.Value >= 100, "", Fields!Reliability.Value) ?

A: To do what you want, while in design mode, right-click on the axis and choose Vertical Axis Properties. Set the Minimum and Maximum values to what you want.
Now, it sounds like that is something you have already tried, but didn't like the results. Another thing you can do is use the values from the data set, along with an expression, to set the min and max values for the axis. So, instead of setting the min and max values manually, you can try something like the following. This assumes the value you are charting is Fields!Reliability.Value.
Minimum: =Min(Fields!Reliability.Value)
Maximum: =Max(Fields!Reliability.Value)

If you want a little bit of a buffer above and below the value line, then you can add and subtract from those values like this:
Minimum: =Min(Fields!Reliability.Value)*0.95
Maximum: =Max(Fields!Reliability.Value)*1.05

Adjust these as desired.
To answer your follow up question about the ChartDataLabel.
=IIF(Fields!Reliability.Value >= 100, "", Fields!Reliability.Value)

This expression sets the ChartDataLabel to an empty string if the Fields!Reliability.Value from the data set is greater than 100, otherwise it uses whatever value is in Fields!Reliability.Value.
Hope this helps you out.


text:
Q: Test for empty jQuery selection result Say I do
var s = $('#something');

and next I want to test if jQuery found #something, i.e. I want to test if s is empty.
I could use my trusty isempty() on it:
function isempty(o) {
    for ( var i in o )
        return false;
    return true;
}

Or since jQuery objects are arrays, I suppose I could test s.length.
But neither seem quite in the idiom of jQuery, not very jQueryesque. What do you suggest?

A: if($("#something").length > 0 ){
     // Element found
}
else{
    // No element found
}

A: Use the s.length property.
if(s.length == 0) {
    ...
}

[edit] size() deprecated in jquery 1.8
http://api.jquery.com/size/

A: An even more jQueryesque solution for me is:
jQuery.fn.isEmpty = function(fun){ if (this.length === 0) { fun(); } return this; };

This lets me write in typical fashion:
$("#sel").fadeOut(500,afterFade).isEmpty(insteadOfFade);


text:
Q: Contour Integration of $\int_0^\infty \frac{\sin(ax)}{x}$ I am trying to use contour Integration to show $$\int_0^\infty \frac{\sin(ax)}{x}=sign(a)\frac{\pi}{2}$$
I was reading a similar example here of $$\int_0^\infty \frac{\sin(x)}{x}=\frac{\pi}{2}$$
I am trying to think how a negative or positive $a$ would change the problem.
1) Is there a way to not do the integral in two cases? One negative and the other positive a?
2) If the a is negative, do I need to make the contour a semicircle in the third and fourth quadrants instead of the first and second quadrants like in the example?
Thank you for your help and time.

A: Just notice that $\sin$ is a odd function. If $a<0$ then we have
$$\int_0^\infty \frac{\sin(ax)}{x}dx = -\int_0^\infty \frac{\sin(-ax)}{x}dx.$$
So, you just need to calculate the integral when $a>0$. You may also suppose $a=1$ making a change of variable.

A: Notice that
$$I=\int^\infty_0\frac{\sin(ax)}x dx=\frac12\int^\infty_{-\infty}\frac{\sin(ax)}x dx=\frac12\Im\underbrace{\text{P}\int^\infty_{-\infty}\frac{e^{iax}}x dx}_{\text{Let}=J}$$
Let $f(z)=\frac{e^{iaz}}z$.
For $a>0$:
Consider a contour $C$, which is an infinitely large semicircle on the upper half plane, centered at the origin. Also add an infinitely small semicircle indent at the origin.
$$\oint_Cf(z)dz=\underbrace{\int_{\text{arc}}f(z)dz}_{\to0}+\underbrace{\int^\infty_{0^+}f(z)dz+\int^{0^-}_{-\infty}f(z)dz}_{=J}+\int_{\text{indent}}f(z)dz$$
By Cauchy's integral theorem, $$\oint_Cf(z)dz=0$$
Also, $$\int_{\text{indent}}f(z)dz=-\frac12\cdot2\pi i\text{Res}_{z=0}f(z)=-\pi i$$ (the minus sign is due to the clockwise orientation of the indent arc, and the $\frac12$ factor is due to the indent is half of a circle.)
Assembling things, we get $$J=\pi i\implies\color{blue}{ I=\frac{\pi}2}$$
For $a<0$:
Similarly, take an infinitely large semicircle on the lower half plane, centered at origin, with a small indent at the origin.
Here, $$\int_{\text{indent}}f(z)dz=-\frac12\cdot 2\pi i \text{Res}_{z=0}f(z)=-\pi i$$
With similar procedures, by Cauchy's integral theorem, $$-J-\pi i=0$$
Then, we get $$\color{blue}{I=-\frac{\pi}2}$$
Gluing two case together:
$$\color{red}{\int^\infty_0\frac{\sin(ax)}xdx=\text{sgn}(a)\frac{\pi}2}$$


text:
Q: Removes all modifications made to a file in GIT I use a Git server to control my code versions and updates. I've made a lot of changes to some files and did not commit anything. But I wanna clear all modifications made to a single file cause it didn't work as I expected. Example:
Files modificated:
Person.java
Document.java
Address.java
Phone.java

I want to "rollback" modifications made to:
Address.java

There is any way to do it without copying everything from HEAD revision to my current file?
I'm using Git Bash and Eclipse.
Thanks!

A: If I understood your situation right, you should be able to simply checkout the file in question:
git checkout -- Address.java

this will reset the changes only in that file. If you have already staged the file for commit (i.e. used git add) you should reset it first:
git reset Address.java


text:
Q: Powershell export contains breaks and spaces I'm struggling to get a proper output, without any spaces and breaks. However, it automatically seems to add breaks and spaces. I'm using the code below.
Get-Content U:\Syn.txt | % {get-aduser -server blabla.com -f "proxyaddresses -like '*$_*'" -Properties userprincipalname,displayname,enabled,description,proxyaddresses,primarygroup} | fl userprincipalname, proxyaddresses, displayname, enabled, description, PrimaryGroup | out-file U:\output.txt

Below is the output (confidential data has been replaced with "xxxx") I get in return. Please pay attention to the "proxyaddresses" attribute, in which breaks and spaces can be found, due to its lengthy output. See the attachment for the resulted output I get.
userprincipalname : xxxx@xxx.com
proxyaddresses    : {x500:/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=3621dc31ee084f5a91fa8961a2c54033-HLD1LOD,
X500:/o=BSH/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=4b48b969c084441c94b2e75d7ebe53dd-xxxxxxxx,
sip:xxxx@xxx.com, SMTP:xxxx@xxx.com}
displayname       : xxxx@xxx.com
enabled           : True
description       : xxxx xxxx
PrimaryGroup      : CN=Domain Users,CN=Users,DC=xxxx,DC=xxxx,DC=xxxx,DC=com
Requested Result:
My intention is to receive an output without these breaks and spaces. is there an easy way without too much of a coding, that would help me to return an output without breaks and spaces in a single line?
Many thanks in advance for your support.
Export with breaks and spaces


text:
Q: Custom admin module not working I have created a custom module but it's not working, I am unable to see any menu in cms menu.here is my code:-
1.config.xml
<?xml version="1.0"?>
<config>
  <modules>
    <Paras_Missingmeta>
      <version>0.1.0</version>
    </Paras_Missingmeta>
  </modules>
  <global>
    <helpers>
      <paras_missingmeta>
        <class>Paras_Missingmeta_Helper</class>
      </paras_missingmeta>
    </helpers>
    <blocks>
      <missingmeta>
        <class>Paras_Missingmeta_Block</class>
      </missingmeta>
    </blocks>
  </global>
  <admin>
    <routers>
      <missingmeta>
        <use>admin</use>
        <args>
          <module>Paras_Missingmeta</module>
          <frontName>admin_missingmeta</frontName>
        </args>
      </missingmeta>
    </routers>
  </admin>
  <adminhtml>
    <layout>
      <updates>
        <missingmeta>
          <file>missingmeta.xml</file>
        </missingmeta>
      </updates>
    </layout>
  </adminhtml>
</config>

2.adminhtml.xml
<?xml version="1.0" ?>
<config>
    <menu>
      <cms>
        <children>
         <paras_missingmeta module="paras_missingmeta">
        <title>Missing meta keys</title>
        <sort_order>100</sort_order>
        <children>
          <missingproduct module="paras_missingmeta">
            <title>Product Meta Keys</title>
            <sort_order>0</sort_order>
            <action>admin_missingmeta/adminhtml_index</action>
          </missingproduct>
           <missingcat module="paras_missingmeta">
            <title>Category Meta Keys</title>
            <sort_order>10</sort_order>
            <action>admin_missingmeta/adminhtml_cat</action>
          </missingcat>
            <missingcms module="paras_missingmeta">
            <title>CMS Meta Keys</title>
            <sort_order>20</sort_order>
            <action>admin_missingmeta/adminhtml_cms</action>
          </missingcms>
        </children>
      </paras_missingmeta>
        </children>
      </cms>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <missingmeta translate="title" module="missingmeta">
              <title>Missingmeta</title>
              <sort_order>1000</sort_order>
              <children>
          <missingmetabackend translate="title">
            <title>Backend Page Title</title>
          </missingmetabackend>
              </children>
            </missingmeta>
          </children>
        </admin>
      </resources>
    </acl>
 </config>

If need any other files then i can post here.
both files are being loaded i have checked it.

A: i test your code there was not error in that. just check the cache is disabled and your module is listed in system/configuration/advanced and you add the Helper/Data.php class
app/etc/modules/Paras_Missingmeta.xml
<?xml version="1.0"?>

<config>
    <modules>
        <Paras_Missingmeta>
            <active>true</active>
            <codePool>local</codePool>
        </Paras_Missingmeta>
    </modules>
</config>

app/code/local/Paras/Missingmeta/config.xml
<?xml version="1.0"?>
<config>
  <modules>
    <Paras_Missingmeta>
      <version>0.1.0</version>
    </Paras_Missingmeta>
  </modules>
  <global>
    <helpers>
      <paras_missingmeta>
        <class>Paras_Missingmeta_Helper</class>
      </paras_missingmeta>
    </helpers>
    <blocks>
      <missingmeta>
        <class>Paras_Missingmeta_Block</class>
      </missingmeta>
    </blocks>
  </global>
  <admin>
    <routers>
      <missingmeta>
        <use>admin</use>
        <args>
          <module>Paras_Missingmeta</module>
          <frontName>admin_missingmeta</frontName>
        </args>
      </missingmeta>
    </routers>
  </admin>
  <adminhtml>
    <layout>
      <updates>
        <missingmeta>
          <file>missingmeta.xml</file>
        </missingmeta>
      </updates>
    </layout>
  </adminhtml>
</config>

app/code/local/Paras/Missingmeta/adminhtml.xml
<?xml version="1.0" ?>
<config>
    <menu>
      <cms>
        <children>
         <paras_missingmeta module="paras_missingmeta">
        <title>Missing meta keys</title>
        <sort_order>100</sort_order>
        <children>
          <missingproduct module="paras_missingmeta">
            <title>Product Meta Keys</title>
            <sort_order>0</sort_order>
            <action>admin_missingmeta/adminhtml_index</action>
          </missingproduct>
           <missingcat module="paras_missingmeta">
            <title>Category Meta Keys</title>
            <sort_order>10</sort_order>
            <action>admin_missingmeta/adminhtml_cat</action>
          </missingcat>
            <missingcms module="paras_missingmeta">
            <title>CMS Meta Keys</title>
            <sort_order>20</sort_order>
            <action>admin_missingmeta/adminhtml_cms</action>
          </missingcms>
        </children>
      </paras_missingmeta>
        </children>
      </cms>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <missingmeta translate="title" module="missingmeta">
              <title>Missingmeta</title>
              <sort_order>1000</sort_order>
              <children>
          <missingmetabackend translate="title">
            <title>Backend Page Title</title>
          </missingmetabackend>
              </children>
            </missingmeta>
          </children>
        </admin>
      </resources>
    </acl>
 </config>

app/code/local/Paras/Missingmeta/Helper/Data.php
<?php

class Paras_Missingmeta_Helper_Data extends Mage_Core_Helper_Abstract
{

 }


text:
Q: Pandas, Python - How to export data frame as csv within a loop? import json
from glom import glom
import pandas as pd

#selected data, tables assembly, and export as csv.

def table():

    df = pd.DataFrame()

    for i in range(1,10):
        with open(f'{pathway}\calls_{i}.json','r') as json_file:
            data = json.load(json_file)

            specsA=('PreviousDraws',['DrawNumber'])
            draw=((glom(data,specsA)))#list type
            df['DrawNumbers'] = draw

            for j in range(0,5):
                specsB=('PreviousDraws',['WinningNumbers'],[f'{j}'],['Number'])
                number=(glom(data,specsB)) #list type
                df[f'Index{j}'] = number

       return df.to_csv("file1-9.csv", index=False)
       #print(df)

table()

Result without exporting to csv:

From the code above, without exporting csv yet, it successfully shows all nine tables fully assembled in a single run. However, when I tried to export them into csv, only the first table is exported, but not the rest. How can all nine tables within a loop be exported? I had tried moving the indentation, but it wouldn't work. I had also put a new loop, but that would complicate the run.


text:
Q: Letter inside square I would like to create a text like that:

My question is, how can I create it using CSS?
The closest solution I've found was unicode with circles:
①②③

A: Start by simply creating something like the HTML and CSS below:
HTML

 1

 2

 3

 4

CSS
li {
    display: inline-block;
    width: 25px;
    height: 25px;
    text-align: center;
    border: solid 1px #888;
    line-height: 25px;
}
li a {
    display: block;
}

See example here
To add the numbers with CSS before/after selectors-See this example.

A: In my opinion using a span is better than using a custom font because of two reasons

*

*Support across all browsers - Many browsers don't support custom font

*It is one extra resource download (font file) for the browser so it will affect performance and contribute to the overall page load time.

A: Of course you can always style each letter differently by assigning classes individually and applying some specificity but that could be more work than it's worth and very hard to maintain. I would recommend lettering.js and you can find it in Github for free download.
here are some links to get you started.
Ahandling Web Typograhy
Lettering.js
lettering.js download on GitHub