text:
Q: Can I get objdump --full-contents to only print the raw text? I have an object file which with a section containing proper ASCII (or Latin-1?) text. So, if I write:
$ objdump -s my_file.so --section=.rodata

looks like this (only presenting a few lines from the middle, it's obviously very long):
 070a80 656d3b0a 73697a65 5f742073 68617265  em;.size_t share
 070a90 644d656d 50657242 6c6f636b 3b0a696e  dMemPerBlock;.in
 070aa0 74207265 67735065 72426c6f 636b3b0a  t regsPerBlock;.
 070ab0 696e7420 77617270 53697a65 3b0a7369  int warpSize;.si
 070ac0 7a655f74 206d656d 50697463 683b0a69  ze_t memPitch;.i
 070ad0 6e74206d 61785468 72656164 73506572  nt maxThreadsPer
 070ae0 426c6f63 6b3b0a69 6e74206d 61785468  Block;.int maxTh

My question: Can I get objdump to just print the text, without the line indices and the hexadecimal values? And to print at least all the printing characters properly (e.g. a newline for 0x0a)? Or - must I perform a bunch of text processing to correlate the dots to their values, replace them with the proper characters, cut the line prefixes, drop the artificial newlines etc?

A: Use xxd
Using xxd will avoid cuting and awking, and is your best solution short of a objdump flag.
Saving your formatted hexdump to file temp, we can pipe the result to xxd -r, (which expects such a formatted hexdump):
$ cat temp | xxd -r
em;
size_t sharedMemPerBlock;
int regsPerBlock;
int warpSize;
size_t memPitch;
int maxThreadsPerBlock;
int maxTh

If you need to pass in a hex string with no line numbers or ascii representation instead, use xxd -r -p.


text:
Q: NaN When trying to print json values I was trying to parse a json which I got as a response of querying connections in linked in.
when I do JSON.stringify in an array as a whole I can see values in console.log
but when I try to take individual values inside array I get NaN.
Why can I not get Individual values when I can see the array as a whole.
here is the code
  var response = jQuery.parseJSON(data);
  var person = response.person[0];

in the above code I am getting data as a response of an ajax call
person is an array inside, I can stringify the array as a whole.
if I do
console.log(JSON.stringify(person));

I will get
{"id":"someId","first-name":"someName","last-name":"someName, DMC-E, DMC-D","picture-url":"https://soempicture"}

but When I try to take it individually
console.log(person.first-name);

I get NaN , and trying to strigify it results in Null
am I missing something, should I do string split to get the values?
Thank you

A: You can't access the first-name property using period notation, as the name contains a dash.
The code will be interpreted as person.first - name, i.e. the person.first property minus the name variable.
Use the bracket notation for any property where the name can't be an identifier:
console.log(person['first-name']);

A: To access a key that contains characters that cannot appear in an identifier (-), use brackets, i.e.:
person["first-name"]

redpajama_set_name: RedPajamaStackExchange


text:
Q: Intellij Save workspace settings for multiple instances I need to work on two different projects have different setup for maven, formatting, etc. Right now i can start two instances of intellij and also put different settings in them, but this lasts only until i close the instance.
When i restart my idea and open open the projects in different windows, again the same set of workspace settings appear for both of them.
Anybody has solution for this?

A: IntelliJ IDEA Maven settings are project specific. Once you configure Maven for a project, it will be used only for this project and another project can have a completely different Maven version. The same is for JDK and almost any other setting that may need to differ.
Code style settings also allow you to store the formatting with the project instead of using the global IDE code style common for all the projects.


text:
Q: How to type narrow JSX.Element I'd like to have a variable that can be either a React component or a string, like this:
function MyComponent(): JSX.Element {
  let icon: JSX.Element | string = "/example.png";  // (simplified)

  return
{typeof icon === "JSX.Element" ? icon : }
;
}

however TS complains about my condition saying:

TS2367: This condition will always return 'false' since the types '"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"JSX.Element"' have no overlap.

What should I do?

A: The typeof operator cannot return "JSX.Element". It can only return the string types listed in that error message:
"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"

Which means that you will need to check against something in that list, like "string".
function MyComponent(): JSX.Element {
  let icon: JSX.Element | string = "/example.png";

  return
{typeof icon === "string" ?  : icon }
;
}

A: The accepted answer is the best for my simplified question.
If for some reason, you do want to type narrow against the element, rather than against string, apparently you can also use React.isValidElement, which type narrows.
You'd have to change the type JSX.Element to ReactElement:
function MyComponent(): JSX.Element {
  let icon: ReactElement | string = "/example.png";  // (simplified)

  return
{React.isValidElement(icon) ? icon : }
;
}

If changing to JSX.Element is unacceptable, you could create your own user-defined type guard, which interrogates the object to determine if it is indeed a JSX.Element (see here).


text:
Q: How can I detect if there is a webcam connected to the PC? I have the source code for taking a picture via webcam, but I need to know if there's a webcam connected to the PC. If there's no webcam, the program won't call the function for taking photos. If necessary, I need to know which window's Api I have to use in this case.
Language: Visual Basic 6 using windows Apis.

A: The problem with the WIA is that not all devices are compatible. But I found the solution myself:
SendMessage and capCreateCaptureWindowA work together. If there's no camera, SendMessage returns a "0". This is the code:
mCapHwnd = capCreateCaptureWindowA("WebCap", 0, 0, 0, m_Width, m_Height, Me.hwnd, 0)
DoEvents
If SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0) <> 0 Then
Call SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0)
DoEvents
Call SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0)
Else
MsgBox "No Camera Detected"
End If

I hope somebody can find this useful :)

A: I think there's a flash app for that, if you're working on a website.  Otherwise you might want to look into the Windows Image Acquisition API.


text:
Q: Save updatable variable into another that will not change maybe it's very stupid question, but i can't figure it out yet.
def check(url):
    response = requests.get(url)
    html = response.text

    soup = BeautifulSoup(html, 'html.parser')

    value = soup.find_all('td')
    valstr = str(value)
    ssp = valstr.split("$")
    ssp2 = ssp[1].split(" ")

    check.price = float(ssp2[0])
    check.price_old = check.price

    return check.price

in this code i want to save price_old so when price will update from 15 to 18 i want price_old to remain 15, when price will update from 18 to 21 price_old must be 18 an so on.
what should i do?

A: Python by default uses references to assign one object to another, in most cases it's acceptable. In your case when you wan to have independent copy use deepcopy():
import copy
...
check.price_old = copy.deepcopy(check.price)
...

Now price_old will keep its value until next assignment. Any change to price wont affect price_old.


text:
Q: indexOf give alternate return from same value after using splice I make a function that checks if an array has a certain value.
If yes, then move it to the first element.
If no, write that value as the first element.
I use splice as a mean to both remove and add the value at the same time.
var ary = [6, 7, 8, 9];
var val = 5;

function myFunction() {
  var idx = ary.indexOf(val);
  ary.splice(0, 0, idx<0 ? val : ary.splice(idx,1));
}

It works well, but after further input of the same value, indexOf started to return value alternatively between 0 and -1.
I know how splice works, and I'm pretty sure that's not the problem.
I'm not asking about the answer to my problem. I just want to know what's wrong with my method.

A: Array#splice returns an array with the removed items.
You need to take the item of the array.

var ary = [6, 7, 8, 9, 5];
var val = 5;
var idx = ary.indexOf(val);
ary.splice(0, 0, idx < 0 ? val : ary.splice(idx, 1)[0]);
//                                                 ^^^

console.log(ary);


text:
Q: Sphinx parent class in another package: how to disable single backtick reference warnings I am working on implementing a Python package that inherits from networkx. Networkx seems to use numpydoc, but also wraps certain parts of their docstrings in single backtick characters: `. This normally in rst files denotes italics, but in numpydoc this attempts to create a reference.
So when I have a file like the following where I use autodoc's autosummary directive:
.. currentmodule:: pywhy_graphs.classes.timeseries

.. autosummary::
   :toctree: generated/

   TimeSeriesGraph
   TimeSeriesDiGraph
   TimeSeriesMixedEdgeGraph

I get the following errors (I copy-pasted only 3 examples for the sake of space):
/Users/adam2392/Documents/pywhy-graphs/pywhy_graphs/classes/timeseries/timeseries.py:docstring of networkx.classes.graph.Graph.to_undirected:33: WARNING: py:obj reference target not found: G = nx.DiGraph(D)
/Users/adam2392/Documents/pywhy-graphs/pywhy_graphs/classes/timeseries/timeseries.py:docstring of networkx.classes.graph.Graph.update:25: WARNING: py:obj reference target not found: edges is None
/Users/adam2392/Documents/pywhy-graphs/pywhy_graphs/classes/timeseries/timeseries.py:docstring of networkx.classes.graph.Graph.update:25: WARNING: py:obj reference target not found: nodes is None

These come for example from docstrings like: https://github.com/networkx/networkx/blob/83948b6dc61f507adb4cd1a71561eac9ed3b72ec/networkx/classes/graph.py#L1183.
Questions

*

*If I am using numpydoc, why am I getting this error, but networkx does not when building docs with sphinx?

*How do I disable, or workaround this error?

*I don't understand what is going on. If someone can help elaborate what I should do and why, that would be very helpful in learning Sphinx/numpydoc.


text:
Q: PHP disabling ouput buffering I've turned off the output buffering in PHP by setting output_buffering = off in php.int but when runnng the simple code like that:
<?php
echo "Hello ";
sleep(3);
echo "World";

I get the full output - Hello World at once, after 3 secs not like I expected first Hello- 3 secs - World Why doesn't it works like that?
PS.
I've check it both in the browser and using the Curl.

A: Try adding  flush() and ob_flush() see at php.net
will look something like this
<?php
echo "Hello ";
ob_flush();
flush();
sleep(3);
echo "World";
?>

A: Ok, It seems that I've resolved the issue. The secret was setting implicit_flush to On in php config file. But that raised a question for me. In such a case what's output_buffering option for since it doesn't work as in my example?


text:
Q: Making Cell as Non-Editable in HandsonTable
*

*How to make a cell in Handsontable non-editable?

*I have a column in handsontable as custome render type in which I'm invoking javascript function with parameter.

I guess this might lead to security issue which means dispDetails functions can be invoked with passing invalid values. How to avoid the above stated risk?

A: Have a look at the cell options: https://github.com/handsontable/handsontable/wiki/Options#cell-options
The "readOnly" option might what you are looking for.
There is also a settings which needs to be used as well called:
"disableVisualSelection"
This needs to be applied to the table itself.


text:
Q: What SPN do I need to set for a net.tcp service? I have a wcf application hosted in a windows service running a local windows account. Do I need to set an SPN for this account? If so, what's the protocol the SPN needs to be set under? I know how to do this for services over HTTP, but have never done it for net.tcp.

A: Change the service account to an AD account and register the SPN's as shown. Use your own service name e.g. fooservice

setspn -A fooservice/servermachinename domain\serviceAccountName
  setspn -A fooservice/servermachinename.fullyqualifieddomainname
  domain\serviceAccountName

In the client config set:
<identity>
    <serviceprincipalname value="fooservice/servermachinename" />
</identity>

A: By default (i.e. out of the box) net.tcp services are unsecured and don't perform any authentication at all. So you won't need (and in fact can't) set a service principal name.
If you need to authenticate, then check the net.tcp security modes on MSDN. The best way to understand the different combinations is to experiment!


text:
Q: Auth login with email or mobile Cakephp I am working on cakephp 2.x.i have a table in my database name user and it has 4 fields id, email, password and mobileNo
i have two fields in my login.ctp
 <?php

 echo $this->form->create();

echo $this->form->input('email');
echo $this->form->input('password');

echo $this->form->end('submit');
 ?>

what i want is i want to login the user from his mobileNo too(if he typed mobile number rather then email address) just like facebook has done ..he can either login with hi email address or mobileno .i dont want to create another input field.. i dont know how can i do this here is my code
AppController
 class AppController extends Controller {
 public $components = array(
'Session',
'Auth'=>array(
'loginRedirect'=>array('controller'=>'users', 'action'=>'admin'),
'logoutRedirect'=>array('controller'=>'users', 'action'=>'admin'),
'authError'=>"You can't access that page",
'authorize'=>array('Controller'),
  'authenticate' => array(
   'Form' => array(
    'fields' => array('username' => 'email')
    )))
    );
 )
 );

public function isAuthorized($user) {
 }

 public function beforeFilter() {
 $this->Auth->allow('index');
 }
}

UserController
 public function login()
  {
 if ($this->request->is('post')) {
   if ($this->Auth->login()) {
    $this->redirect($this->Auth->redirect());
} else {
    $this->Session->setFlash('Your email/password combination was incorrect');
   }
  }
  }

A: i found the solution here https://github.com/ceeram/Authenticate
i used plugin to implement this functionality and it works fine ..

A: Use this code in app controller in beforefilter();
AuthComponent::$sessionKey = 'Auth.User';
  if ($this->request->is('post') && $this->action == 'login') {
      $username = $this->request->data['User']['email'];
      if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
          $this->Auth->authenticate = array(
                  'Form' => array(
                      'fields' => array(
                          'username' => 'email', //Default is 'username' in the userModel
                          'password' => 'password'), //Default is 'password' in the userModel
                      // 'scope'=>array('User.status' => '1'),
                      'userModel' => 'User'
                  )
              );
      }else{
       $this->Auth->authenticate['Form']['fields']['email'] = 'mobile';
          $this->request->data['User']['mobile'] = $username;
          unset($this->request->data['User']['email']);
    $this->Auth->authenticate = array(
                  'Form' => array(
                      'fields' => array(
                          'username' => 'mobile', //Default is 'username' in the userModel
                          'password' => 'password'), //Default is 'password' in the userModel
                      // 'scope'=>array('User.status' => '1'),
                      'userModel' => 'User'
                  )
              );

      }
  }

$this->request->data['User']['email'] is my form field in which I am sending email or mobile.


text:
Q: invite facebook button gives an error I added a button to my website where, if the user clicks it, a windows open. It should be filled with him/her friends in order to be able to invite them to visit that website. Instead of the friends the following error appears:
Game Requests are only available to games.

Here is the code I'm using:

Invite Facebook Friends


text:
Q: How to get the email from https://www.googleapis.com/plus/v1/people/me call using a google+ token? i want to get also the email from https://www.googleapis.com/plus/v1/people/me call. I receive a lots of informations, but not the email. Can anyone help?
HttpGet request = new HttpGet("https://www.googleapis.com/plus/v1/people/me?scope=https://www.googleapis.com/auth/userinfo.email");
request.setHeader("Authorization", "Bearer <access_token>");
HttpResponse response = client.execute(request);

A: EDIT: Updated as part of the improved Google+ Sign-In options in December 2013 - you now can get the email address with the Google+ profile response.
You will get the email from this endpoint as long as you have the email or https://www.googleapis.com/auth/plus.profile.emails.read scopes. See https://developers.google.com/+/web/people/#retrieve_an_authenticated_users_email_address for details.
var request = gapi.client.plus.people.get( {'userId' : 'me'} );
request.execute(function(person) {
  if(person['emails']) {
    console.log(person['emails'][0].value);
  }
});

A: I found the answer.
My aim was also this.
And We can do it successfully :)
U need:

*

*https://www.googleapis.com/auth/userinfo.email consent

*accessToken
and after above two just make HTTP GET request to https://www.googleapis.com/oauth2/v2/userinfo
BUT with added header "Authorization: Bearer <accessToken>"
U can do it by many ways.
My way is customised REST call
package com.google.plus.samples.photohunt.custom;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class NetClientGet {

// http://localhost:8080/RESTfulExample/json/product/get
public static void makeRequest(String access_token) {

  try {

    URL url = new URL("https://www.googleapis.com/oauth2/v2/userinfo");

    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Authorization", "Bearer "+access_token);
    conn.setRequestMethod("GET");
    conn.setRequestProperty("Accept", "application/json");

    if (conn.getResponseCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
                + conn.getResponseCode());
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(
        (conn.getInputStream())));

    String output;
    System.out.println("REST call made. Output from Server .... \n");
    while ((output = br.readLine()) != null) {
        System.out.println(output);
    }

    conn.disconnect();

  } catch (MalformedURLException e) {

    e.printStackTrace();

  } catch (IOException e) {

    e.printStackTrace();

  }

}

}


text:
Q: Artifactory environment variables on CentOS I'm going mad.
/usr/lib/jvm/

has
java-1.7.0-openjdk-1.7.0.65.x86_64
java-1.7.0-openjdk-1.7.0.79.x86_64

Last night at the most unfortunate possible time, the contents of #65, which artifactory was apparently using, disappeared.  Java disappeared.  Maybe it was already gone, but the new Linux guys were 'upgrading' the machine, so it's suspicious.
Now, the issue is that artifactory cannot forget about version 65.
If I type in env or set, we're golden. No mention of v65.  But artifactory lives in its own world.
[root@me]# service artifactory check
Checking arguments to Artifactory:
ARTIFACTORY_HOME     =  /var/opt/jfrog/artifactory
ARTIFACTORY_USER     =  artifactory
TOMCAT_HOME          =  /opt/jfrog/artifactory/tomcat
ARTIFACTORY_PID      =  /var/opt/jfrog/run/artifactory.pid
JAVA_HOME            =
JAVA_OPTIONS         =  -server -Xms512m -Xmx2g -Xss256k -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseG1GC

[root@me]# service artifactory start
Starting Artifactory tomcat as user artifactory...
Max number of open files: 32000
Using ARTIFACTORY_HOME: /var/opt/jfrog/artifactory
Using ARTIFACTORY_PID: /var/opt/jfrog/run/artifactory.pid
Using CATALINA_BASE:   /opt/jfrog/artifactory/tomcat
Using CATALINA_HOME:   /opt/jfrog/artifactory/tomcat
Using CATALINA_TMPDIR: /opt/jfrog/artifactory/tomcat/temp
Using JRE_HOME:        /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre
Using CLASSPATH:       /opt/jfrog/artifactory/tomcat/bin/bootstrap.jar:/opt/jfrog/artifactory/tomcat/bin/tomcat-juli.jar
Using CATALINA_PID:    /var/opt/jfrog/run/artifactory.pid

env and set shows
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64
JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64/jre

PATH is correct too.
ls -l shows
lrwxrwxrwx  1 root root   34 Jun 24 22:38 java-1.7.0-openjdk.x86_64 -> java-1.7.0-openjdk-1.7.0.79.x86_64

So it's pointing to the right place.  Where in the hell is the artifactory user getting 65 from?  If I try su artifactory, i go to bash-4.1$ indicating that artifactory isn't a user in the traditional sense, but even so, env and set are correct.
I finally managed to get it working by compromising.
/opt/jfrog/artifactory/bin

I edited artifactory.default and put my export JAVA_HOME in there, and started artifactory from that folder, instead of as a service.  This will do until the next time the Linux team mess up my server.
But anyone know how I can get it running as a service?

A: Take a look in /etc/init.d/artifactory, which is the script that runs when you call "service artifactory ..." - it looks like something in there (possibly another script that is sourced in) is setting JRE_HOME to the old version.
You could also try
sudo su - artifactory; env | grep JRE

to make sure that the artifactory user's environment doesn't set JRE_HOME to the old version.

A: I had a similar issue after. Installed Artifactory 5.3.2 and months later ran a yum update on my Linux server. I saw the msg: "error artifactory tomcat server did not start in 60 seconds" The issue started after a I ran a yum update. The update impacted my version of java as noted below.
Verify Error Log
vi /var/opt/jfrog/artifactory/logs/catalina.out

--> /opt/jfrog/artifactory/tomcat/bin/catalina.sh: line 433: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/bin/java: No such file or directory
vi /opt/jfrog/artifactory/tomcat/bin/catalina.sh
export JRE_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64
cd /opt/jfrog/artifactory/tomcat/bin/

restart catalina
./catalina.sh

artifactory will restart and should show updated JRE_HOME


text:
Q: log4net across appdomains I have an application which initializes log4net from one appdomain and needs to use it in another appdomain. Is it supported?
If not, should I initialize log4net from each appdomain? Is there a risk in multiple initializations in the same application? Should I use the same log4net.config?

A: Although the question is several years old - maybe it helps someone:
It is possible to use the loggers configured in the parent AppDomain.
What needs to be done is route the LoggingEvents from the child AppDomain to the parent AppDomain. For this you need to create a custom Appender that forwards the records out of the Child domain...
/// <summary>
/// Represents an <see cref="IAppender"/> implementation that forwards a <see cref="LoggingEvent"/> to a given Receiver.
/// Instances of this class should be created in the child domain.
/// </summary>
public class CrossDomainOutboundAppender : AppenderSkeleton
{
    private readonly CrossDomainParentAppender crossDomainParentAppender;
    public CrossDomainOutboundAppender(CrossDomainParentAppender crossDomainParentAppender)
    {
        if (crossDomainParentAppender == null)
        {
            throw new ArgumentNullException("crossDomainParentAppender");
        }
        this.crossDomainParentAppender = crossDomainParentAppender;

    }

    protected override void Append(LoggingEvent loggingEvent)
    {
        LoggingEvent copied = new LoggingEvent(loggingEvent.GetLoggingEventData());
        crossDomainParentAppender.Append(copied);
    }
}

, a custom class that receives the forwarded LoggingEvent and appends them to available IAppenders ...
/// <summary>
/// Represents a Receiver that sends Log4Nets <see cref="LoggingEvent"/> to all available <see cref="IAppender"/>s.
/// Instances of this class should be created in the ParentDomain.
/// </summary>
[Serializable]
public class CrossDomainParentAppender : MarshalByRefObject
{
    public void Append(LoggingEvent loggingEvent)
    {
        foreach (IAppender usedAppender in LogManager.GetRepository().GetAppenders())
        {
            usedAppender.DoAppend(loggingEvent);
        }
    }
}

and finally a setup class that ties the two and configures log4net:
public class CrossDomainChildLoggingSetup : MarshalByRefObject
{
    private CrossDomainParentAppender parentAppender;

    public void ConfigureAppender(CrossDomainParentAppender crossDomainParentAppender)
    {
       parentAppender = crossDomainParentAppender;
       CrossDomainOutboundAppender outboundAppender = new CrossDomainOutboundAppender(parentAppender);
       log4net.Config.BasicConfigurator.Configure(outboundAppender);
    }
}

Now - when you setup up your AppDomain you can add the following code...
CrossDomainParentAppender crossDomainParentAppender = new CrossDomainParentAppender();
Type crossDomainType = typeof(CrossDomainChildLoggingSetup);
CrossDomainChildLoggingSetup crossDomainChildLoggingSetup = (CrossDomainChildLoggingSetup)domain.CreateInstanceFrom(crossDomainType.Assembly.Location, crossDomainType.FullName).Unwrap();
crossDomainChildLoggingSetup.ConfigureAppender(crossDomainParentAppender);

...and everything logged in the child domain turns up in the parent domains log.
(Please note: I used CreateInstaceFrom(assemblyFilePath,...) - depending on your setup you may not require loading by filePath)
Although I haven't found any bugs or problems: If you see any flaws or problems that could arise please let me know.

A: The logger should be initialized once per app-domain.

A: Agree with darin, once per app domain. If you're looking to have these applications use consolidated logging, you'll want to choose a logging target that won't be subject to contention (i.e. not FileAppender or RollingFileAppender).

A: The log4net-user mailing list has an answer that works with RollingFileAppender. Add the following line to the appender in log4net.config:
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

A: My answer adds to Linky 's answer.
To answer, Jack Allan 's question. You can solve this by solving the changing the CrossDomainOutboundAppender class:
/// <summary>
/// Represents an <see cref="IAppender"/> implementation that forwards a <see cref="LoggingEvent"/> to a given Receiver.
/// Instances of this class should be created in the child domain.
/// </summary>
public class CrossDomainOutboundAppender : AppenderSkeleton
{
    private readonly CrossDomainParentAppender crossDomainParentAppender;
    public CrossDomainOutboundAppender(CrossDomainParentAppender crossDomainParentAppender)
    {
        if (crossDomainParentAppender == null)
        {
            throw new ArgumentNullException("crossDomainParentAppender");
        }
        this.crossDomainParentAppender = crossDomainParentAppender;

    }

    protected override void Append(LoggingEvent loggingEvent)
    {
        LoggingEvent copied = new LoggingEvent(loggingEvent.GetLoggingEventData(FixFlags.All));
        crossDomainParentAppender.Append(copied);
    }
}

Notice the FixFlags.All
The current version of the .... has a flaw causing all appenders to log the message, thats like defeating the purpose of log4net, since different loggers can log at a different level for example. My improved version of the class:
/// <summary>
/// Represents a Receiver that sends Log4Nets <see cref="LoggingEvent"/> to all available <see cref="IAppender"/>s.
/// Instances of this class should be created in the ParentDomain.
/// </summary>
[Serializable]
public class CrossDomainParentAppender : MarshalByRefObject
{
    public void Append(LoggingEvent loggingEvent)
    {
        LogManager.GetRepository().Log(loggingEvent);
    }
}

This distributes the log to the logmanager, this will find out where to place the log, which logger is responsible etc.


text:
Q: Null reference error while inflating a textview I'm adding a textview as a header to a listview, in a Xamarin Android app.
Following the instructions in ericosg's answer to this SO question, I put the textview in a separate axml file, and then tried to add it as a header to my list view.
Running the app gets the following error at the line where the activity tries to inflate the textview:
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Android.Content.Res.Resources+NotFoundException: Exception of type 'Android.Content.Res.Resources+NotFoundException' was thrown.
.
.
.
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] android.content.res.Resources$NotFoundException: Resource ID #0x7f050006 type #0x12 is not valid
[MonoDroid]     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2250)
etc.

Here is my code:
In the Activity .cs file:
myListView = FindViewById<ListView>(MyApp.Resource.Id.MyList);

        Android.Views.View myHeader =
            this.LayoutInflater.Inflate(MyApp.Resource.Id.QuestionText, myListView);

        myListView.AddHeaderView(myHeader);

ListView definition:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ListView
        android:id="@+id/MyList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" />
    </RelativeLayout>

Header definition:
<?xml version="1.0" encoding="utf-8"?>
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/QuestionText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:drawableTop="@+id/MyImage" />

A: A few things:
You are attempting to inflate an ID resource instead of a layout:
 Android.Views.View myHeader = this.LayoutInflater.Inflate(MyApp.Resource.Id.QuestionText, myListView);

The Inflate call for LayoutInflater only accepts Resource.Layout elements. Change it to:
Android.Views.View myHeader = this.LayoutInflater.Inflate(Resource.Layout.Header, myListView);

Secondly, in your Header.xml layout file, TextView android:drawableTop does not accept id references so it will throw an InflateException when the LayoutInflator attempts to build the layout.
From the docs:

android:drawableTop
The drawable to be drawn above the text.
May be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".
May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

Change this to either a reference to a valid color or drawable (@drawable/MyImage) or an inline color declartion (#fff).
Lastly, you can't add child views or header views to the ListView without using an adapter:

*

*https://stackoverflow.com/a/7978427/1099111

*https://stackoverflow.com/a/7978427/1099111
Consider re-reading the Xamarin docs for ListViews and Adapters to better understand the subject.


text:
Q: List items alignment I have a list and in Firefox it looks like this: http://cl.ly/2Og9 but in Safari it looks like this: http://cl.ly/2PLT
Here's the code for the list. Very simple:
#footerwrap #footer-left li {
    background: url(images/common/list-item.gif) no-repeat 0px 10px;
    padding: 4px 10px 8px 15px;
    font: normal 12px Verdana;
}

What do I need to do to get it to align properly like it does in Firefox? Thanks!

A: Nevermind it was a stupid thing. The list didn't have a ul tag around the li's. Thanks!


text:
Q: Error: Cannot pass NA to dbQuoteIdentifier() in sqldf package in R Error: Cannot pass NA to dbQuoteIdentifier()

In addition: Warning message:
In field_types[] <- field_types[names(data)] :
  number of items to replace is not a multiple of replacement length

This is the error message i am getting upon trying to run anything with sqldf package today.the same queries which ran yesterday dont run today, what am i doing wrong?

A: I had the same problem:
Error: Cannot pass NA to dbQuoteIdentifier()
In addition: Warning message:
In field_types[] <- field_types[names(data)] :
number of items to replace is not a multiple of replacement length

after some research, I noticed I selected the same column twice in one table:
table1<- sqldf("select columnA,
                       columnA,
                       keyA
                from tableA")
table2<- sqldf("select columnB,
                       keyB
                from tableB")

problematicMerge<- sqldf("select a.*,
                                 b.*
                          from tableA a join
                               tableB
                          on a.keyA = b.keyB")

this was solved by altering table1 to remove the duplicate column (see below: --I suspect aliasing one of the columns to have a different name will also do the trick):
table1<-sqldf("select columnA,
                      keyA
               from tableA")

Hope this helps

A: I had the same problem yesterday when I was suddenly unable to upload a table from R to an SQLite db on my remote desktop.
lghdb <- dbConnect(SQLite(), 'lgh.db'
dbWriteTable(lghdb, 'SrtrRisks', SrtrRisks)
Error: Cannot pass NA to dbQuoteIdentifier()...

After muddling around for a while, I realized that this error was due to the addressed SQLite database being "locked" due to an uncompleted (not committed) transaction, related to my simultaneous work using the SQLite Browser.  The problem disappeared once I committed the pending transaction.
I guess that you must have figured this out, too, since there has been no follow-up to your post.  It might be nice for the RSQLite folks to see whether they can return a more helpful error message under these circumstances.
Larry Hunsicker

A: I too encountered the same error:
    ## step1: encountered the error as below while joining two tables
    screens_temp_2 = sqldf("SELECT a.* , b.ue as 'sp_used_ue' , b.te as
    'sp_used_te'  from screens_temp a left outer join sp_temp b on
    a.screen_name = b.screen_name ")
    Error: Cannot pass NA to dbQuoteIdentifier()
    In addition: Warning message:
    In field_types[] <- field_types[names(data)] :
    number of items to replace is not a multiple of replacement length
    ##  step2: while checking the column names , this is what i found
   colnames(screens_temp)
     [1] "screen_name" "usv"         "tsv"         "20_ue"       "20_te"
    [6] "40_ue"       "40_te"       "60_ue"       "60_te"       "80_ue"
    [11] "80_te"       "100_ue"      "100_te"      "sp_load_ue"  "sp_load_te"
   [16] "sp_load_ue"  "sp_load_te"

The above result  shows that  sp_load_ue and sp_load_te are repeated.
    ## below i corrected the column names:
    colnames(screens_temp) <- c("screen_name", "usv", "tsv", "20_ue", "20_te", "40_ue"   ,    "40_te"   ,    "60_ue"   ,    "60_te"    ,   "80_ue" ,  "80_te"     ,"100_ue"  ,    "100_te"   ,   "sp_load_ue" , "sp_load_te" , "sp_used_ue" , "sp_used_te" )
     write.table(screens_temp, "screens_temp_corrected.csv",  row.names = FALSE ,col.names = TRUE, sep = ",")

    ## again i ran step 1, it worked fine.

Note: I think there is a bug in sqldf due to which it allows column names to be repeated while assigning output to a dataframe. It should throw an error/warning while assigning the output to a dataframe so that the user can rename the columns appropriately.

A: Had same issue with sqldf inside a loop. Solved it by putting it inside data.frame call: data.frame(sqldf(..)).


text:
Q: keep for loop from executing in Javascript Currently for loop gets executed till the end even though the function it calls hasn't finished executing. I want to make it such that, when startloop function is called until it is executed completely for loop shouldn't move forward.. How to do that? I tried simulating goto but it didn't work..
Here's my code:
function startLoop(i) {
  console.log("startloop function start");
  var centerX = xObj[i];
  var centerY = yObj[i];
  var radius = 10;

  var alpha = 1, /// current alpha value
    delta = 0.01; /// delta = speed
  var flag = 0;
  var num = 0

  function loop() {
    console.log("inside loop " + centerX + " " + centerY);
    alpha -= delta;
    if (alpha <= 0) {
      //console.log("heya_amigoes");
      num = 2;
      return;
    }
    //console.log("hi1");
    /// clear canvas, set alpha and re-draw image
    ctx2.clearRect(0, 0, 1000, 600);
    ctx2.globalAlpha = alpha;
    ctx2.beginPath();
    ctx2.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
    ctx2.fillStyle = "#FF0000";
    ctx2.fill();
    ctx2.lineWidth = 1;
    ctx2.strokeStyle = '#003300';
    ctx2.stroke();

    //console.log("hi2");
    //requestAnimationFrame(loop); // or use setTimeout(loop, 16) in older browsers
    setTimeout(loop, 16)
    console.log("Outside function loop");
  }

  loop();

  /*
     LABEL1: do {
          if(num==2)
              {
              num=0;
              break LABEL1;
              }
          if(num!=2)
              continue LABEL1;
      }while(1);
  */

  console.log("startloop function stop");
}

for (i = 0; i < xObj.length; i++) {
  console.log("for loop running " + i);
  startLoop(i);
  console.log("outside loop func");
}

A: A for loop will not wait for your task. To achieve this task, you will have to use recursion.
Logic:

*

*Call a function and pass a callback in it.

*On execution completion, run passed callback.

*Now since we have to chain same function again and again, pass same callback to next iteration again and have a check(threshold limit) and stop on breach.

var count = 0

function test1(i, cb){
  console.log("In Test " + i)
  if(i < 10)
    setTimeout(cb.bind(null, ++count, cb), 2000)
}

test1(count, test1)

Explanation:
My approach mimics behaviour of a do..while loop. It has 4 parts:

*

*Initialisation: This will initialise the iterator variable. This variable will be use to check for termination condition and to check the current iterator's value. In my Case: count = 0

*Execution of Code block: This will execute the code defined inside {...}. In my case: test1(count, test1)

*Termination condition: This check if next iteration should be performed or not? In my case: if(i<10). If condition is satisfied, start next iteration: setTimeout(cb.bind(null, ++count, cb), 2000)

*Increment Value: This updated value of iterator to point to next value. In my case: ++count

This is the final JSFiddle

A: I think that the problem going to be with your for loop. startLoop function always going to get the xObj.length-1.
You can read more about this problem: JavaScript closure inside loops – simple practical example

The variable i, within each of your anonymous functions, is bound to
  the same variable outside of the function.

Solution with ES6 let feature:
for (let i = 0; i < xObj.length; i++) {
  console.log("for loop running " + i);

  startLoop(i);

  console.log("outside loop func");

}

Solution without ES6:
var funcs = [];

for (var i = 0; i < xObj.length; i++) {
  funcs[i] = startLoop(i);
}

for (var i = 0; i < xObj.length; i++) {
  console.log("for loop running " + i);

  funcs[i]();

  console.log("outside loop func");

}


text:
Q: Rotation schedule for 6 persons and 2 locations I like to make a rotation schedule for a dinner party where everyone is new, so the idea is that everyone gets a chance to meet as many new people as possible.
Setup:
I have 6 persons attending (lets name them A to F).
I have 2 locations (tables) with each location able to seat 3 persons.
3 rounds are held (so we switch places 2 times).
Rules:
Each person sits together with every person at least once.
Each person sits together with someone for at most two times.
Example of round 1:
Table 1: A  B   C
Table 2: D  E   F

Now I tried several combinations but I keep ending up with people not sitting together in any round. Like this faulty try:
A   B   C
D   E   F

A   D   E
B   C   F

A   F   E
B   C   D

Any good way to make a schedule?
PS: Now if it is impossible to have everyone sit with each other, what is the closest alternative to it?

A: It is impossible, as illustrated in your attempt in the question, which also represent one kind of as-near-as-possible attempt.
Consider A. There are five other people to sit with, so the groupings for A can be ABC, ADE, AFX where X is to be determined.
However this forces the other table on the first two occasions to be DEF and BCF. This means that both B and C have never sat with either D or E, and we cannot fulfill that in one sitting. One of the four has to sit with AF, which means that person will have missed out on sitting with two different people.
We could aim to arrange things so that no-one misses out on more than one pairing:
$\begin{array}{c}
ABC & DEF \\
ABD & CEF \\
ACE & BDF \\
\end{array}$
In this version everyone misses out on sitting with exactly one person.

In terms of graph theory, this should be related to some sort of clique edge cover problem (depending on the size of the set and the tables). Here we're looking to cover as many edges as possible with a set of disjoint $K_3$ covers of $K_6$.

I like playing with words also, so I attempted to name your characters...they are now Abe, Bea, Ced, Dee, Edd and Fae. ;-)

A: Analysis with Python shows that rule 1 is impossible to satisfy and furthermore for any valid schedule, if the schedule satisfies rule 2 then it must have 12 unique pairings (out of 15). I.e. all schedules satisfying rule 2 are equally good alternatives. I would image that the relationship is an iff since allowing more non-unique pairings would decrease the number of unique pairings, but did not check it going the other way.
import itertools

persons = [0, 1, 2, 3, 4, 5]
possible_tables = list(itertools.combinations(persons, 3))
possible_arrangements = list(itertools.combinations(possible_tables, 2))

def valid_arrangement(table1, table2):
    for person in table1:
        if person in table2:
            return False
    return True

def generate_schedules(arrangements):
    possible_schedules = []
    for i in arrangements:
        for j in arrangements:
            for k in arrangements:
                possible_schedules.append([i, j, k])
    return possible_schedules

valid_arrangements = [a for a in possible_arrangements if valid_arrangement(*a)]
possible_schedules = generate_schedules(valid_arrangements)

def generate_meetings(arrangement):
    meetings = []
    for table in arrangement:
        meetings += [(table[0], table[1]), (table[0], table[2]), (table[1], table[2])]
    return meetings

def evaluate_schedule(schedule):
    unique_meetings = 0
    met = {}
    for arrangement in schedule:
        for pair in generate_meetings(arrangement):
            if pair[0] > pair[1]:
                pair = pair[::-1]

            if pair in met:
                met[pair] += 1
            else:
                met[pair] = 1

    for v in met.values():
        if v > 2:
            return
        else:
            unique_meetings += 1

    print("Found valid schedule with " + str(unique_meetings) + " unique meetings: ")
    print(schedule)
    print(met)

    #if unique_meetings != 12:
    #   print("Found valid schedule with != 12 unique meetings")

for s in possible_schedules:
    evaluate_schedule(s)


text:
Q: Check: $\sum_{n=1}^{\infty}a_n$ converges, $\sum_{n=1}^{\infty}a^2_n$ diverges, then $\sum_{n=1}^{\infty}|a_n|$ diverges Please do check my proof, and in case, tell me how to make it more professional.
Additionally I'm not sure if the statement ($A$ if $B$) means $A\implies B$ or $B\implies A$.
Problem:
Let $\sum_{n=1}^{\infty}a_n$ be a convergent series. Show that $\sum_{n=1}^{\infty}|a_n|$ diverges if $\sum_{n=1}^{\infty}a^2_n$ diverges.
My Solution:
Since $\sum_{n=1}^{\infty}a_n$ converges, it must be true that $\lim_{n\to \infty}a_n=0.$ Then for some $n_0$: for all $n>n_0$, $|a_n|<1$.
Then it is true that $a^2_n<|a_n|$ for all $n>n_0$.
Hence $\sum_{n=n_0+1}^{\infty}a_n^2 < \sum_{n=n_0+1}^{\infty}|a_n| \implies \sum_{n=n_0+1}^{\infty}|a_n|$ diverges.

A: To answer your first question, $A$ if $B$ means $A\impliedby B$, i.e. $B\implies A$.
Secondly, your proof looks fine, and your idea is great. Here, however, it would probably also be a good idea to include what theorem you used for the comparison at the end, i.e. the comparison test for positive series. The main reason here is that your inequality is not completely justified in it's own right. So consider
$$\sum_{n=n_0+1}^N a_n^2 < \sum_{n=n_0+1}^N \left| a_n\right|.$$
This is all fine because you're dealing with finite sums. However if you want to take this to the limit as $N\to\infty$, this strict inequality becomes nonstrict, as the two could potentially be equal in the limit (and in fact here they are equal, as both are infinite).


text:
Q: Installing (and deploying) Mono ASP.Net to Redhat I have an Asp.Net app (built in mono) that I am trying to deploy to a Linux Redhat 6 environment.  I tried following the instructions on the mono website:
http://www.mono-project.com/docs/web/aspnet/
http://www.mono-project.com/docs/getting-started/install/linux/
I was able to get nginx installed and setup; however it appears I don't have fastcgi-mono-server4 installed.  I've been googling all over the place trying to find how to install that on Redhat with no luck. I thought I'd try the apache instructions instead but I'm having no luck getting mod_mono installed. I tried to install mono-devel using yum but I keep getting the following errors:
 Error: Package: libgdiplus0-3.12-1.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libpng15.so.15()(64bit)
 Error: Package: libmonosgen-2_0-1-4.0.3.20-0.xamarin.4.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libc.so.6(GLIBC_2.15)(64bit)
 Error: Package: libgdiplus0-3.12-1.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libtiff.so.5()(64bit)
 Error: Package: mono-core-4.0.3.20-0.xamarin.4.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libc.so.6(GLIBC_2.16)(64bit)
 Error: Package: libgdiplus0-3.12-1.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libtiff.so.5(LIBTIFF_4.0)(64bit)
 Error: Package: mono-devel-4.0.3.20-0.xamarin.4.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libc.so.6(GLIBC_2.15)(64bit)
 Error: Package: libgdiplus0-3.12-1.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libc.so.6(GLIBC_2.14)(64bit)
 Error: Package: libgdiplus0-3.12-1.x86_64 (download.mono-project.com_repo_centos_)
       Requires: libpng15.so.15(PNG15_0)(64bit)

I'm kind of at a loss here.  Can anyone point me in the right direction to get mono installed on redhat and get my Asp.Net application properly deployed using either nginx or apache?

A: I had the same problem. I needed to reproduce the production environment (Fedora 17) and I was not able to install mono because of many references errors, similar to the issues mentioned in the question.
The only way to fix this was to download mono's source code and follow the steps he mentions.
I will copy-and-paste the procedure mentioned at: http://help.octopusdeploy.com/discussions/problems/39756-install-mono-on-centos-66
$ sudo yum -y install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget
$ cd /usr/local/src
$ sudo wget http://download.mono-project.com/sources/mono/mono-4.4.0.182.tar.bz2
$ sudo tar jxf mono-4.4.0.182.tar.bz2
$ cd mono-4.0.1
$ sudo ./configure --prefix=/opt/mono
$ sudo make
$ sudo make install

after everything is finished:
$ vi ~/.bashrc

add the following lines:
export PATH=$PATH:/opt/mono/bin
export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig

After that, I was able to correctly compile mono files on Fedora 17.
By the way, I used the latest version of Mono, found at:
http://download.mono-project.com/sources/mono/
Edit:
1) To see the effects of having mono on the path of a root terminal, close all terminal windows and log in again. The effects of changing ~/.bashrc are not seen immediately.
2) To be honest, I would like to be able to run mono from a non-root terminal. To achieve this, the idea is to edit ~/.bashrc from a non-root terminal. The process is the same as above but add "sudo" to edit the bash config for your (non-root) user.

A: It's been more than a month, if you are still looking for the answer, I found few links which seems to be useful.
http://help.octopusdeploy.com/discussions/problems/39756-install-mono-on-centos-66
http://www.linuxquestions.org/questions/linux-software-2/installing-mono-error-requires-libc-so-6-glibc_2-15-64bit-4175540534/
Even I facing the same problem, trying to fix this, will update if I manage to fix :)

A: I never did find a solution to this with Redhat 6.  We ended up wiping the server and installing Redhat 7.  From there, we were able to install and configure mono running on nginx and it works beautifully. I think the Redhat 6 repositories are just too far out of date to handle mono.  I would recommend using Redhat 7+.


text:
Q: c - How to delete \n?
Possible Duplicate:
How to go to the previous line in a C code

I want to delete the last \n in
for(i = 0; i < 10; i++)
     printf("****\n");

It seems \b doesn't work on this.
What should I do?

A: Best solution would be not to print it at all:
for(i = 0; i < 10; i++) printf("****%s", ((i!=9)?"\n":""));

Or alternatively use two printfs(has the same effect, just in a bit more code and easier to read):
for(i = 0; i < 10; i++) {
  printf("****");
  if (i != 9 ) {
    printf("\n");
  }
}

A: printf("****");
for(i = 0; i < 9; i++)
     printf("\n****");

A: This is bascially the same answer as Ivaylo gave, but instead of checking the condition for each iteration you could just move it out altogether:
for(i = 0; i < 9; i++)
    printf("****\n");

printf("****");

Now, whether you need such micro-optimizations or not is another matter.

A: There is no character sequence, defined by the C standards, for cursor positioning moving the cursor up a line (or to previous text buffers). So there is no 100% portable way to do this.
However, depending on your platform, most terminal consoles support ANSI escape codes in which case you can do something like:
for(i = 0; i < 10; i++)
    printf("****\n");
printf("\033[A\033[C\033[C\033[C\033[C");

This uses the escape sequences for moving the curser up one line (\033[A) followed by moving it forward one character (\033[C) done 4 times to move past your 4 asterisks. Thus you'll get the effect of moving "backwards" over the newline.
In a slightly cleaner sense, you can put this in a #define:
#define BACKUP_NEWLINE "\033[A\033[C\033[C\033[C\033[C"

for(i = 0; i < 10; i++)
    printf("****\n");
printf("%s", BACKUP_NEWLINE);

A better solution (less hardcoded at least) might be using the curses library or some equivalent on Windows.

A: There is no well-defined portable way to do that, you can only change characters of the current line, as the standard says:

\b (backspace) Moves the active position to the previous position on the current line. If the active position is at the initial position of a line, the behavior of the display device is unspecified.

Other answer already proved different ways to do what you need.

A: Alternate method:

*

*If you are on ansi compliant terminal, &

*your printf DOES NOT use any white space character other than ' '(space), (e.g. \t,\n,\v etc),

you can use below code :-)
int t;
for(i = 0; i < 10; i++)
   t=printf("****\n");      // t would hold number of characters printed.
printf("\033M\033[%dC",t-1);

It uses 2 escape characters:

*

*<ESC>M : Move on previous line, but first column

*<ESC>[<num>-C : Move right by <num> locations.

If your printf happens to contain other whitespace characters, like \n,\t etc, you need to calculate using some logic, to find the horizontal cursor position.
Another method is:
for(i = 0; i < 10; i++)
   printf("****\033[s\n");      // \033[s would save column number
printf("\033M\033[u");

More details on ANSI escape characters here :-)


text:
Q: Testing if two matrices are unitarily equivalent So im kind of self teaching here and am a bit lost on unitary equivalence for matrices, my understanding is that two matrices unitarily equivalent if their linear transformations are unitarily equivalent, ie there is a unitary linear transformation u such that g=u^-1.f.u, where f and g are the matrices.
Im a bit lost on the process though, can someone outline whats the standard efficient way to do questions such as these for example?
$\begin{bmatrix}1 & 1\\0 & 1\end{bmatrix}$ and $\begin{bmatrix}0 & 0\\1 & 0\end{bmatrix}$, Answer: Not unitarily equivalent
$\begin{bmatrix}0 & 0 & 2\\0 & 0 & 0\\2 & 0 & 0\end{bmatrix}$ and  $\begin{bmatrix}1 & 1 & 0\\1 & 1 & 0\\0 & 0 & -1\end{bmatrix}$ , Answer: Not unitarily equivalent
$\begin{bmatrix}0 & 1 & 0\\-1 & 0 & 0\\0 & 0 & -1\end{bmatrix}$ and
$\begin{bmatrix}-1 & 0 & 0\\0 & i & 0\\0 & 0 & -i\end{bmatrix}$ , Answer: Unitarily Equivalent
I suppose just some standard protocol one would follow would be awesome if someone could let me know :)

A: The first two matrices have distinct traces, and therefore they are not unitarily equivalent. The same argument applies to the third and fourth matrices. Finally, diagonalize the fifth matrix, and you will get something really close to the sixth one.
Also (although this is not needed for these pairs of matrices), if two matrices are unitarily equivalent, then they have the same characteristic polynomials.


text:
Q: Issue with Visual Studio authentication for SharePoint app I am working on a SharePoint app in visual studio and am running into issues when attempting to debug.
I press start and as expected the Connect to SharePoint window pops up asking me for my credentials. I enter them and attempt to proceed but instead of continuing to the debug site it goes to the root web of the site in the Connect to SharePoint window and freezes.
What could be causing this? What can I do to resolve it?
Edit: It was working ~two weeks ago when I last worked on this project but since I came back to it yesterday it won't let me debug.

A: The issue turned out to be with the Office 365 authentication through VS. The server which controls our domain had been down for a few days the previous week and when it was brought back up the clock was running a few hours wrong. I took my computer off the domain and it authenticated fine.


text:
Q: PDF of $Y = \cos(\pi X)$ I've run into a practice problem where $Y = \cos(\pi X)$, and $X$ is uniform on $[0, 1]$, and I'm supposed to prove that the PDF of $Y$ is $1/(\pi\sqrt{1 - y^2})$. I know that for derived distributions, you plug in the the equation for $Y$ in terms of $X$ into the PDF of $X$, integrate up to $y$, and then differentiate with respect to $y$. However, when I do this, I get the PDF of $Y = -1/(\pi\sqrt{1 - y^2})$.
I'm sure that the problem here is that there's some property of the cosine and its inverse that I don't know, so if someone could point out how to do this, that would be great, thanks!

A: If $Y=\cos \pi X$, $X\sim U(0,1)$, then the probability (for $y\in[-1,1]$)
$$\Pr(Y<y) = \Pr\left(X > \frac{\arccos y}\pi\right) = \int_{\frac{\arccos y}\pi}^{+\infty}f_X(x)\ dx = \int_{\frac{\arccos y}\pi}^{1}\frac{1}{1-0}dx = 1 - \frac{\arccos y}\pi$$
Then the PDF of Y is (for $y\in(-1,1)$)
$$f_Y(y) = \frac d{dy}\Pr(Y<y) = 0-\frac1\pi\cdot\frac{-1}{\sqrt{1-y^2}} = \frac{1}{\pi\sqrt{1-y^2}}$$
I am not sure which negative sign you have missed.

If you choose to jump a few steps between integration and differentiation,
$$f_Y(y) = \frac d{dy}\int_{\frac{\arccos y}\pi}^{+\infty}f_X(x)\ dx = -f_X\left(\frac{\arccos y}\pi\right)\cdot\frac d{dy}\frac{\arccos y}\pi = \frac{1}{\pi\sqrt{1-y^2}}$$
(for $y\in(-1,1)$)


text:
Q: Adding json to new line I am using MSSQL localDb with PHP for creating json to show json data on javascript.
But label's text shown as "blaaa \n blaa"  My basic codes as below;
MSSQL
SELECT field1 + ' \n ' + filed2 FROM table1

PHP Script
....
$PdoStatement=$PdoObject->prepare($SqlQuery);
$PdoStatement->execute();
$PdoResultToArray=$PdoStatement->fetchAll(PDO::FETCH_ASSOC);
$JsonPdoResultArray = array("Datas"=>$PdoResultToArray);
$Json=json_encode(array_merge($JsonSystemArray, $JsonPdoResultArray));
echo $Json;

A: you could make it like this
SELECT CONCAT_WS('\n', field1, filed2) as concatenatedFeild FROM table1

and when you need to use it you call this
concatenatedFeild
see this also it could help a lot
this
UPDATE
SELECT (field1 + CHAR(13) + field2) as concatenatedFeild from table1

A: I solved my problem as below,
MSSQL
SELECT CONCAT(field1, '_Newline_', filed2) AS ConcatedFiled FROM table1

PHP
....
$JsonPdoResultArray = array("Datas"=>$PdoResultToArray);
$Json=json_encode(array_merge($JsonSystemArray, $JsonPdoResultArray));
$Json = str_replace("_Newline_","\\n", $Json);
echo $Json;

A: Try concatenating with char(13) like so:
SELECT field1 + char(13) + filed2 FROM table1


text:
Q: front end vs. back end definition In IT school and am getting conflicting answers on exactly what the front end and the back end in software development are. I have searched the web including this site, and have asked several knowledgeable people, and the core answer I get is that anything that runs on a web server is the front end, while anything that runs on the application server or the database server is the back end. So front end = how the site looks and back end = making the site work, but I get conflicting answers if .net windows forms and asp.net forms are all front end development or a combination of front end and back end.
To ask a specific question, with asp.net forms, is the aspx code the front end and the c# code behind the back end in these applications? Or is asp.net all front end? Thank you.

A: In a web application, I typically use the following definitions:
Front-end: Runs on client (users) computer
Back-end: Runs on server
In a traditional ASP application all of the markup (Razor) gets converted into HTML on the back-end before being sent to the client, so the vast majority of the work is done there. The actual HTML parsing (done by the browser) and any JavaScript is still part of the front-end though.
In general, a front-end is the UI and its logic, and the back-end is the rest of the program/system (Business logic, data access, etc)

A: In general - everything that runs on the server is considered back-end and everything that runs on the browser is front-end.
Usually - the back end code generates a code the will run on the browser, which is a front end code.
asp.net is considered back end, and if it generates html/css/javascript - these will run on the browser and thus they are front end.

A: It depends on several things. I.e. what application are you referring to (i.e. desktop app, web app, API, mobile app) since each of those may group-in slightly different things under the front-end / back-end categories.
In web apps we refer to any UI (client exposed) portion of the application code as front-end. So for example all HTML, jS, css and other user interface (view) related files should be under the umbrella of the front-end (hence the front-end developer - the guy/girl who is pulling his/her hair over cross-browser compatibility :) etc.)
The business logic, data manipulation and processing (models, controllers, db objects, etc.) are commonly refereed to as back-end.
You may check out Wikipedia (https://en.wikipedia.org/wiki/Front_and_back_ends)


text:
Q: Private viewers using the YouTube API Has anyone been able to set who can view a private video on YouTube using the API?

A: The API isn't designed for this, so it's either very difficult or impossible.
You can only share a private video with 25 of your friends, so you have to first be friends with them, then give them access, which means the api would have to do all of these actions and once you hit 25 people you'd have to stop anyway.
You should probably use a different service or make your own if you want private videos.

A: Well you could try to load the FLV to your own website. Do a login system and use flowplayer to show it.

A: I've worked with the YouTube API which is pretty nice and works very smooth with jQuery and Ajax - but as the others have already mentioned there is no built-in feature for that.
You could probably find some sort of work-around as you could integrate you own authentication and login capabilites - but obviously that would not prevent your users not being able to watch the "restricted" video.


text:
Q: How to evaluate the page at multiple points during execution of a Nightmare test? I'm trying to write a Nightmare.js test that asserts/evaluate() things at multiple points during its execution.
it("should return to home page when quit button is pressed", function (done) {
    var username = 'sinbad';
    new Nightmare({ show: true })
      .goto(url)
      .type('#choosenickname', username)
      .click('#write-btn')
      .wait('div.game')

      .evaluate(function () {
        return document.querySelectorAll('#write-btn').length;
      })
      .then(function (result) {
        // No 'write' buttons found
        result.should.eql(0);
      })
      // Everything after this point doesn't work
      .click('#quit-btn')
      .wait('div.home')
      .evaluate(function () {
        return document.querySelectorAll('#write-btn').length;
      })
      .then(function (result) {
        // After quitting, we should have a write button
        result.should.eql(1);
        done();
      });
  });

When I run this, I get
TypeError: (intermediate value).goto(...).type(...).click(...).wait(...).evaluate(...)
                                 .then(...).click is not a function

A: According to this sample, the answer seems to be composing then()s like so:
it("should return to home page when quit button is pressed", function (done) {
    var nightmare = loginPlayer('sinbad')
    nightmare
      .evaluate(function () {
        return document.querySelectorAll('#write-btn').length;
      })
      .then(function (result) {
        // No 'write' buttons found
        result.should.eql(0);
      }).then(function () {
        return nightmare
          .click('#quit-btn')
          .wait('div.home')
          .evaluate(function () {
            return document.querySelectorAll('#write-btn').length;
          })
      })
      .then(function (result) {
        // After quitting, we should have a write button
        result.should.eql(1);
        done();
      });
  });


text:
Q: Comparing numeric strings From the question Type-juggling and (strict) greater/lesser-than comparisons in PHP
I know PHP interpret strings as numbers whenever it can.
"10" < "1a"  => 10 less than 1      expecting  false
"1a" < "2"   => 1 less than 2       expecting  true
"10" > "2"   => 10 greater than 2   expecting  true

But in the case of "10" < "1a" php returns true.
I am not understanding the concept please help me to clarify it.
Edit:
But when I add "10" + "1a" it returns 11 that means php interprets "10" as 10 and "1a" as 1. Is that correct?

A: A comes after 9. You can see this in this string, sorted from low to high.
0123456789abcdefghijklmnopqrstuvwxyz

So 10 is lower than 1a.

A: It's easy 1a is not numeric. So PHP compares string(2)"10" against string(2)"1a" and numbers are before alpha characters in the most text encoding tables (have a look at the ASCII or UTF-8 character tables).
So 1 of 10 is equals 1of 1a and 0 of 10 is lower than a of 1a. That results in 10 is lower than 1a.

A: If you want to be sure, that you comparing numbers, put (type) before variable:
(int)"10" < (int)"1a"
(int)"1a" < (int)"2"
(int)"10" > (int)"2"

A: Maybe you first need to use regular expressions?
For example:
$str = '1a';
$str = preg_replace ("/[^0-9\s]/","", $str);
var_dump((int)$str); // int 1

A: Read at this link to get what happens when comparing value of two different data types.
Use type juggling to compare values of two different data type.
(int)"10" < (int)"1a"  result will be false
(int)"1a" < (int)"2"  result will be true


text:
Q: Adding more than one author with the same affilaition I am writing  a paper with a coauthor who is at the same institution. What is the standard way to add affiliation (which is the same for both) and email addresses for the document in the article class format?
Thanks!

A: The article class has no particular provisions for multiple authors, affiliations etc. How this information is arranged, is usually defined by the publisher or editor, who in most cases also provides a class file that takes care of typesetting the header. Otherwise it is you, the author, who decides how this information should be arranged. Just look around at different publications, choose a design that you like, and then try to imitate it (or ask how to do it).
E.g., with the article class you could do it like that (I have cut down the image a bit, so the length of the page does not correspond to the code):
\documentclass{article}
\begin{document}
\title{The Title of the Paper}
\author{X. First\thanks{Email: x.first@some.where}~
   and Y. Second\thanks{Email: y.Second@some.where.else}\\
   The Common Affiliation}
\date{September 2016}
\maketitle
\end{document}


text:
Q: Changing text selection colour
Possible Duplicate:
Change color of selection

How does this site manage to make text selection pink, rather than my browser default of blue?

A: It seems to be defined through the ::selection pseudo-element:
::selection {
background: #FF5E99;
color: white;
text-shadow: none;
}

See http://www.quirksmode.org/css/selection.html

*

*IE9 supports it, prior IE's don't

*Firefox supports it through ::-moz-selection

*Chrome and Safari seem to support it fully.

A: use ::selection and ::-moz-selection  selector to style your selection.
::selection{background:black; color:white}
::-moz-selection{background:black; color:white}

You need two separate rules for moz and standard.
Docs: https://developer.mozilla.org/en/CSS/%3A%3Aselection
Note that there is no ::-webkit-selection rule

A: In one of the CSS files of the page whose link you gave,
found this:
::-moz-selection{background:#ff5e99;color:#fff;text-shadow:none}

Hope that's self explanatory.


text:
Q: How can I use state across multiple components? I currently am storing user login in local storage and am rendering the appropriate nav bar depending. However, The page does not re-render upon sign-in or sign-out. I need to manually refresh the page to make it work. How can I use state in this scenario across several components?
import React, { useState } from "react";
import { Link } from "react-router-dom";
import { Navbar, Nav, Button } from "react-bootstrap";
import SignInModal from "././SignIn/SignInModal";

const NavBar = () => {
  return localStorage.getItem("auth-token") ? <SignedIn /> : <SignedOut />;
};

const SignedIn = () => {
  return (
    <Navbar className="justify-content-around main-navbar">
      <Nav.Item>
        <Link className="link" to="/">
          Signed Out
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Link className="link" to="/mainsignedin">
          Sign In
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Link className="link" to="/searchpage">
          Our Dogs
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Link className="link" to="/mypets">
          My Pets
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Button type="submit" onClick={localStorage.clear()}>
          Sign Out
        </Button>
      </Nav.Item>
    </Navbar>
  );
};

const SignedOut = () => {
  return (
    <Navbar>
      <Nav.Item>
        <SignInModal />
      </Nav.Item>
    </Navbar>
  );
};
export default NavBar;

A: Here is code.
import SignInModal from "././SignIn/SignInModal";
import {useEffect, useState} from 'react';
const NavBar = () => {
  const [isLogedIn,setIsloggedIn] =useState(false);
   useEffect(()=>{
      const auth_token = localStorage.getItem("auth-token") ;
     setIsloggedIn(auth_token ? true:false);
   },[])
   const handleSignOut=()=>{
     localStorage.clear()
     setIsloggedIn(false);
   }
  return isLogedIn ? <SignedIn onSignOut={handleSignOut} /> : <SignedOut />;
};

const SignedIn = ({onSignOut}) => {
  return (
    <Navbar className="justify-content-around main-navbar">
      <Nav.Item>
        <Link className="link" to="/">
          Signed Out
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Link className="link" to="/mainsignedin">
          Sign In
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Link className="link" to="/searchpage">
          Our Dogs
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Link className="link" to="/mypets">
          My Pets
        </Link>
      </Nav.Item>
      <Nav.Item>
        <Button type="submit" onClick={onSignOut}>
          Sign Out
        </Button>
      </Nav.Item>
    </Navbar>
  );
};

const SignedOut = () => {
  return (
    <Navbar>
      <Nav.Item>
        <SignInModal />
      </Nav.Item>
    </Navbar>
  );
};
export default NavBar;

A: You can use the useState hook to keep track of state in a React functional component.
You can use a Context to provide state to its children. Then, you can use the useContext hook within those children to access the state.
import React, { createContext, useContext } from 'react'

const MyContext = createContext({})
const MyContextProviderComponent = MyContext.Provider

const MyInnerComponent = () => {
    const myValue = useContext(MyContext)
    return <p>{myValue}</p>
}

const MyOuterComponent =() =>{
    const [myValue, setMyValue] = useState('Hello world!')
    return (
        <MyContextProviderComponent value={myValue}>
            <MyInnerComponent></MyInnerComponent>
        </MyContextProviderComponent>
    )
}


text:
Q: How to avoid ecllipse juno failed to start? while starting Eclipse Juno frequently, I am getting server failed to start..I deleted .snap and temp folders also but I am getting same problem frequently.
If I change work space some times it runs some times it is not starting.why it is coming how to avoid that?
Please,clear my problem I am getting it very frequently.
console error:

    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sample]]
    at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sample]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 7 more
Caused by: java.lang.IllegalArgumentException: The servlets named [DisplayServlet] and [com.sensiple.DisplayServlet] are both mapped to the url-pattern [/DisplayServlet] which is not permitted
    at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:335)
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sample]] so no cleanup was performed for that container
javax.naming.NamingException: No naming context bound to this class loader

A: You already did the first thing to try, which is to switch to a different workspace.
This is basically impossible to debug.  If I were you, I'd remove your installed version of Eclipse and reinstall the latest version, which is Kepler (4.3.1) now.


text:
Q: How to make repeating notifications with different content I need to show repeating notifications to the user with different content.  I use BroadcastReceiver and set notifications via AlarmManager.
I know that I can use AlarmManager.setRepeating, but it shows the same content every time.
For example, I need to show notifications one time a week depending on the selected week by the user. And in every notification, I need to show current Week and some different text. I didn't find a solution on StackOverflow.
Here is the relevant code
long timeInMills = mSharedPreferences.getLong("key_millis", 0);

Calendar alarmCalendar = Calendar.getInstance();
alarmCalendar.setTimeInMillis(timeInMills);
alarmCalendar.set(Calendar.HOUR_OF_DAY, 10);
alarmCalendar.set(Calendar.MINUTE, 0);

int currentWeek = (int) Utils.getTotalWeeks(timeInMills);

if (currentWeek <= 20) {
    AlarmHelper alarmHelper = AlarmHelper.getInstance();
    for (int i = currentWeek + 1; i < 21; i++) {
        alarmCalendar.add(Calendar.DATE, 7 * (currentWeek + 1));
        long time = alarmCalendar.getTimeInMillis();
        alarmHelper.setWeekAlarm(getApplicationContext(), WeekReceiver.class, time, i, i);
    }
}

And the AlarmHelper class is the following.
public class AlarmHelper {

    private static AlarmHelper instance;

    public static AlarmHelper getInstance() {
        if (instance == null) {
            instance = new AlarmHelper();
        }

        return instance;
    }

    public void setWeekAlarm(Context context, Class<?> receiver, long time, int week, int req_code) {

        Intent intent = new Intent(context, receiver);
        intent.putExtra("week_title", "your week " + week);
        intent.putExtra("req_code", req_code);

        //cancel already existed alarm
        cancelWeekAlarm(context, receiver, req_code);

        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, req_code, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);
    }

    public void cancelWeekAlarm(Context context, Class<?> receiver, int req_code) {
        Intent intent = new Intent(context, receiver);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, req_code, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        alarmManager.cancel(pendingIntent);
        pendingIntent.cancel();
    }
}

The problem is that if the user is on the first week, so 20 notifications will be created and I think my approach is not very good and maybe you can help me find another solution?

A: I am not quite sure what is the purpose of your code, as I did not understand the question clearly. However, I think I found a problem in your code which I think I should share.
While you are adding a Calendar event, I think you are trying to add weeks incrementally in different weeks. However, in your code looks like you are setting all the events in a certain week.
I am referring to the following code. Please see the comments in the code.
if (currentWeek <= 20) {
    AlarmHelper alarmHelper = AlarmHelper.getInstance();
    for (int i = currentWeek + 1; i < 21; i++) {

        // I think the following line should contain currentWeek + i instead of currentWeek + 1
        // alarmCalendar.add(Calendar.DATE, 7 * (currentWeek + 1));

        alarmCalendar.add(Calendar.DATE, 7 * (currentWeek + i)); // Like this to create events in consecutive weeks.

        long time = alarmCalendar.getTimeInMillis();
        alarmHelper.setWeekAlarm(getApplicationContext(), WeekReceiver.class, time, i, i);
    }
}

Let me know if that helps!


text:
Q: What are the conditions for the string of a pendulum to become slack? Suppose the bob of a stationary pendulum is given a sharp hit to impart it some horizontal speed. Now what are the conditions for the string to become slack after rotating a particular angle?

*

*resultant centripetal force should be zero.
-tension in the string should be zero
Or what?
And when the string becomes slack, does it have GPE only or GPE and KE both?


text:
Q: Jumbotron color and background won't change trying to change the background and color of my jumbotron and nothing happens.
The padding works, but the background does not.
My CSS:
.jumbotron {
    padding:70px 30px 70px 30px;
    margin:0px auto;
    background: #7986CB ;
    color:blue;
}

.row-header{
    margin:0px auto;
    padding:0px auto;
}

My :

Header

bla bla

Why won't the collor change to blue, or the background to #7986CB?
The inclusion of the CSS is ok, since changing the paddings does affect the jumbotron.

A: Because you're directly overriding Bootstrap's CSS, you'll need to use the same syntax as they do:
.jumbotron {
  background-color: #7986CB;
}

Alternatively, you can add !important to force the override, but this is not recommended.
Using Developer Tools it's easy to see which CSS is applied and to which rules. Valid rules that are not applied are crossed out.

A: use:
    background-color : #222 !important;

Update:
This is not a good way to override a style as it overrides every other background-color (except those that are specified in the inline style attribute). Try increasing the specificity of the CSS selector rather than using !important.
Read more about specificity here:
https://css-tricks.com/specifics-on-css-specificity/

A: Your CSS Link has to be below the Bootstrap Link.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <--Bootstrap-->
 <link rel="stylesheet" href="app.css"> <--User_Defined-->

A: The way I see it,  it should work so make sure your css link is below the bootstrap or else the default bootstrap styles would keep overriding your css.

A: Use a custom class for specificity if need be, you don't need to use !important for something so simple. See MDN Specificity.
Working Example:

.jumbotron.jumbotron-blue {
  background: #7986CB;
  color: blue;
  padding: 70px 30px;
  margin: 0;
}
.jumbotron.jumbotron-blue h1 {
  margin: 0;
}
.heading-paragraph {
  padding-top: 70px;
  margin: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

This is a Heading

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It

Hello


text:
Q: Strategy for establishing the triangle inequality of a seminorm One proof that the $p$-norm  $\| x\|_p  = (|x_1|^p + \ldots + |x_n|^p)^\frac{1}{p}$ satisfies the triangle inequality exploits the fact that
$ x \mapsto |x_1|^p + \ldots + |x_n|^p$ is a convex function on $\mathbb{R}^n$. I abstracted the ideas of this proof into the following proposition.

Proposition: Let $X$ be vector space over $\mathbb{R}$. Let $\| \cdot \|$ be a function on $X$ satisfying all the axioms for a norm, except possibly the triangle inequality. To be precise:

*

*$\| t x\| = |t| \|x\|$ for all $t \in \mathbb{R}$, $x \in X$ (positive homogeneity).

*$\|x\|  \geq 0$ for all $x \in X$, with equality if and only if $x=0$  (positive definiteness).

  Then, the following are equivalent:

*

*$\|\cdot\|$ is a norm.

*$\| \cdot \|$ is a convex function.

*There exists a strictly increasing  function $f : [0,\infty) \to [0,\infty)$ such that $x \mapsto f(\|x\|)$ is a convex function.

  Proof: It's easy to check that even a seminorm is convex, so (1) implies (2). If (2) holds, then (3) holds with $f(t)  = t$. Suppose, then, that $f$ is as in (3). Let $x,y \in X$. We want to establish the triangle inequality,  $\|x+y\| \leq \|x\| + \|y\|$. If either of $x,y$ is zero, this holds trivially, so assume $x$ and $y$ are both nonzero. Define $u = \frac{x}{\|x\|}$, $v = \frac{y}{\|y\|}$ and observe $\|u\| = \|v\| =1$. Define $s = \frac{\|x\|}{\|x\| + \|y\|}$, $t = \frac{\|y\|}{\|x\| + \|y\|}$ and observe $s,t \in [0,1]$ with $s+t=1$. Observe $su+tv = \frac{x+y}{\|x\|+\|y\|}$. Thus, from $f(\|su+tv\|) \leq sf(\|u\|) + tf(\|v\|)$, we get
  $$f(\frac{\|x+y\|}{\|x\|+\|y\|}) \leq s f(1)+tf(1) = f(1).$$
  Since $f$ is strictly increasing, this shows that $\frac{\|x+y\|}{\|x\|+\|y\|} \leq 1$, which is the triangle inequality. QED.

To apply this proposition to the $p$-norm, simply note that $f(t) = t^\frac{1}{p}$ is a strictly increasing function such that $x \mapsto f(\|x\|_p) = |x_1|^p + \ldots + |x_n|^p$ is a convex function.

Question: Is the naïve anlalog for seminorms of this result valid? To be precise, suppose $X$ is a vector space over $\mathbb{R}$. Let $\| \cdot \| : X \to [0,\infty)$ be any positive homogeneous function. Is it true that the following are equivalent?

*

*$\|\cdot\|$ is a seminorm.

*$\| \cdot \|$ is a convex function.

*There exists a strictly increasing  function $f : [0,\infty) \to [0,\infty)$ such that $x \mapsto f(\|x\|)$ is convex.

Some observations:

*

*The proofs that (1) implies (2) implies (3) go through unchanged. So, we just need to assume that an $f$ as in (3) exists and check that $\|x+y\| \leq \|x\| + \|y\|$ for all $x,y \in X$.

*If $\|x+y\| = 0$, nothing needs to be said.

*If $\|x\|$ and $\|y\|$ are  both nonzero, then the proof given above works.

*If $\|x\| = \|y\|=0$, then we can argue as follows:
$$ f(\|\frac{x+y}{2}\|) \leq \frac{f(\|x\|) + f(\|y\|)}{2} = f(0)$$
so, since $f$ is strictly increasing, we get $\frac{x+y}{2} \leq 0$. Thus, in this case, both sides of the triangle inequality are zero.

The remaining case to consider is when, say, $\|x\|$ and $\|x+y\|$ are both nonzero, but $\|y\|=0$. Thanks for reading!

A: OK I managed to figure this out. I'll post my argument here.

Proposition: Let $X$ be a vector space over a field $\mathbb{F} \in \{\mathbb{R}, \mathbb{C}\}$ and let $\| \cdot \| : X \to [0,\infty)$ satisfy $\|\lambda x\| = |\lambda| \|x\|$ for all $\lambda \in \mathbb{F}$ and all $x \in X$. Thus, $\| \cdot \|$ is a seminorm if and only if it satisfies the triangle inequality. Then, the following are equivalent:

*

*$\| \cdot \|$ is a seminorm.

*$\|\cdot\|$ is a convex function.

*There exists a strictly increasing function $f:[0,\infty) \to [0,\infty)$ such that $x \mapsto f(\|x\|)$ is convex.

Proof: A simple calculation shows that seminorms are convex, so (1) implies (2). Trivially, (2) implies (1), since we may take $f$ to be the identity map. Thus, we assume that (3) holds. Let $f : [0,\infty) \to [0,\infty)$ be a strictly increasing map such that $x \mapsto f(\|x\|)$ is convex. The goal is to prove that $\|x+y\| \leq \|x\| + \|y\|$ where $x,y \in X$.
Case 1: $\|x\| >0$ and $\|y\| >0$. Then, we may proceed exactly as in the question statement above.
Case 2: $\|x\| = \|y\| =0$. Then, we have
$$ f( \frac{\|x+y\|}{2}) = f( \| \frac{x+y}{2} \|) \leq \frac{ f(\|x\|) + f(\|y\|)}{2} = f(0)$$
which implies $\frac{\|x+y\|}{2} \leq 0$ so that $\|x+y\| =0$, and the triangle inequality holds.
Case 3: $\|x\|=0$, but $\|y\| > 0$. Let us note that there is no loss of generality to assume that $f(0)=0$ (since, otherwise, we can replace $f$ with $x \mapsto f(x) - f(0)$, which is still strictly increasing and whose composition with $\|\cdot\|$ is still convex). Let $a>0$ be arbitrary. Define
\begin{align*}
u = \frac{x}{a} && v = \frac{y}{\|y\|} && s = \frac{a}{a+\|y\|} && t = \frac{\|y\|}{a+\|y\|}
\end{align*}
and observe that $su+tv = \frac{x+y}{a+\|y\}}$. We have
$$ f( \frac{\|x+y\|}{a+\|y\|}) = f(s u + tv) \leq s f(u) + t f(v) = 0 + t f(1) \leq f(1)$$
so that, since $f$ is strictly increasing,
$$\frac{\|x+y\|}{a+\|y\|} \leq 1.$$
Letting $a \to 0$, we get $\|x+y\| \leq \|y\|$, so the triangle inequality holds in this last case.


text:
Q: Assigning events in Javascript to appear in the HTML Inspector I'm having some trouble with events, i'm relatively new to all this so it may of already been answered and if so apologies!
I am trying to create an interactive GUI on a website, and at the moment, i have objects instantiating. when those objects are instantiated, their html and events are built and assigned entirely in Javascript. i then use JQuery UI to enhance some of those features, which works fine on chrome, but im trying to debug for firefox and am trying various things.
What i want to ask is:
Is there a way to assign an event to a specific element in javascript, and have it so that it appears in the HTML inspector as if you inline wrote that event in HTML?
<div id="test" onmousdown=function(event)>
why i ask is because, my events/functions that are working ok, are triggered this way.
At the moment im trying addEventListener, but it instantly listens to the button i clicked to instantiate the object and nothing else, and executes that function immediately.
Similarly, using the below didnt work either, it instantly fires the function whichever way i choose.
Myobject.Onclick = function(event);
The desired is result, is for the function to only execute when that specific element is clicked after it is instantiated.
function newPostIt() {
    let newDiv = document.createElement("div");
    newDiv.id = "DraggableItem";
    newDiv.className = "PostIt PostItDiv";
    newDiv.addEventListener("mouseover", MyDrag);
    newDiv.addEventListener("mouseout", MyDragOut);
    var subjectText = document.createElement("div");
    subjectText.id = "tb1";
    subjectText.name = "tbSubject";
    subjectText.innerHTML = "Subject:";
    var messageBody = document.createElement("div");
    var message = document.createElement("span");
    message.id = "messagePI " + divCounterPostIts
    messageBody.id = "messageBodyPI";
    message.innerHTML = "this is just a test to see how the text wraps across the post it";
    var newDivEle = document.createElement("img");
    newDivEle.src = "Images/StickyNote.png";
    newDivEle.alt = "Nothing";
    newDivEle.className = "PostItImage " + divCounterPostIts;
    let newDivEle2 = document.createElement("img");
    newDivEle2.src = "Images/ExitIcon.png";
    newDivEle2.alt = "Nothing";
    newDivEle2.className = "ExitIcon " + divCounterPostIts;
    divCounterPostIts++;
    var Board = document.getElementById("Board");
    newDiv.appendChild(newDivEle);
    newDiv.appendChild(newDivEle2);
    newDiv.appendChild(subjectText);
    messageBody.appendChild(message);
    newDiv.appendChild(messageBody);
    Board.appendChild(newDiv);
    Draggables.push(newDiv);
    messageBody.onclick = ChangeText(event);
}

A: The problem was caused by adding parentheseses and passing an event in to the functions as they were set up in the listener.
newDiv.addEventListener("mouseover", MyDrag);

Even though MyDrag takes an event parameter, it works just as it is supposed to.
So, the bottom function ChangeText(event) is now added to an event listener like addEventListener(onclick, ChangeText) and it works as it should


text:
Q: How can you rebase to SVN without rewriting history in Git? I work on a project that uses an SVN repo as the main repo. They make tags, the tags are what gets posted to the live environment.
So I cloned this both into an SVN working copy and into a local git repo. I track all my local changes using commits in my local git repo. When I've made substantial progress I go to the OS X Finder and drag-copy all the code directories from my local git repo, replacing the ones in my local SVN working copy. Then I SVN add the changes and commit that to the remote. That way all my millions of local commits don't end up on the remote server and I don't have to do any rebasing. (See below diagram.)

But still, I'd like to find a simpler solution. I read about how git has SVN support built-in, but Git's site says, "it's generally best to keep your history as linear as possible by rebasing your work". OK so I tried this, I did a pull from the remote and had to do a rebase. The rebase involved about 20 conflicts I had to resolve, and then when it finished, all my commits were gone. Yeah, it's nice and linear now, but NO, that's not what I want, because I want to keep my local history. Furthermore then if I git svn dcommit, it's going to push multiple commits (two in the diagram, for brevity's sake) instead of just the one I want. (See next diagram.)

See, what I want to do is, I want to be able post the current state of my git repo as a single commit to SVN, and automatically have that reverse-fetch itself from the SVN server back to my git repo onto the Remote Branch. I don't want to have to do any rebasing, ever. If any other developers contribute something to the SVN, I'll merge those changes back into my master branch. (See final diagram.)

How do I accomplish what's pictured in this final diagram? Is it possible...?
When phrasing your advice, bear in mind, I'm still relatively new to both git and SVN. I use SourceTree and SmartSVN primarily but I am not afraid of the command line if that's the only way to accomplish what I need to do. For any dangerous operations, I tend to use the command line unless I'm 100% sure I know what my GUI tool is doing. But both of these still confuse me in certain ways. Thanks for any help.


text:
Q: Ubuntu 16.04 and mapnik - Python argument types in did not match C++ signature I have to install mapnik/mapnik-python on Ubuntu 16.04 (existing server)
Both libraries compiled without any problem but python mapnik module doesn't work. After importing mapnik module i get error:
/home/user# python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mapnik/__init__.py", line 1075, in <module>
    register_plugins()
  File "mapnik/__init__.py", line 1057, in register_plugins
    DatasourceCache.register_datasources(path)
Boost.Python.ArgumentError: Python argument types in
    DatasourceCache.register_datasources(str)
did not match C++ signature:
    register_datasources(std::string)
>>>

Module is linked against libboost 1.58:
/usr/local/lib/python2.7/dist-packages/mapnik-0.1-py2.7-linux-x86_64.egg/mapnik# ldd _mapnik.so
        linux-vdso.so.1 =>  (0x00007ffc3f7fb000)
        libmapnik.so.3.0 => /usr/local/lib/libmapnik.so.3.0 (0x00007f093ad96000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f093ab7c000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f093a977000)
        libboost_python-py27.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0 (0x00007f093a72b000)
        libboost_thread.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0 (0x00007f093a505000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f093a2fc000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0939f7a000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0939c71000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0939a5a000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f093983d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0939474000)
        /lib64/ld-linux-x86-64.so.2 (0x000055969793c000)
        libboost_system.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0 (0x00007f093926f000)

C++ code defined as:
void register_datasources(std::string const& path)
{
    mapnik::datasource_cache::instance().register_datasources(path);
}

Python code:
def register_plugins(path=None):
    """Register plugins located by specified path"""
    if not path:
        if 'MAPNIK_INPUT_PLUGINS_DIRECTORY' in os.environ:
            path = os.environ.get('MAPNIK_INPUT_PLUGINS_DIRECTORY')
        else:
            from .paths import inputpluginspath
            path = inputpluginspath
    DatasourceCache.register_datasources(path)

I studied a boost library manual and found that std::string const& is a correct type declaration. It looks like this is a boost library bug.
Is there any way to get it working ?
Is there any way to downgrade libboost_python in Ubuntu16.04 ?
Update: I looked into compiled _mapnik.so file using nm -C and found this:
U mapnik::datasource_cache::register_datasources(std::string const&, bool)
There is one more parameter in function added. Is it normal ?


text:
Q: TexMaker (Ubuntu 12.04) Cannot open a style file I am trying to compile a document in TexMaker with the following document class
\documentclass[aps,prl,showpacs,twocolumn]{revtex4-1}

I am using bibtex to display my bibliography. I have created a file 'ferroelectrics.bib' and use the following command at the end of my document
\bibliography{ferroelectrics}

When I try to compile this document using latex -> bibtex, the process exits with errors and the following error is reported in the .blg file that is generated:
I couldn't open style file apsrev4-1.bst

What's weird about this error is that when I compile using only the command line, I get no such error and the document compiles just fine. I have been doing various google searches all day trying to figure this out, but to no avail. What can I do to enable TexMaker to open apsrev4-1.bst?
Thanks!


text:
Q: What's so special about $p=2$ for the $L^p$ spaces? The Banach space dual of $L^p$ is $L^q$, where $q=\frac{p}{p-1}$, but I don't really understand the motivation behind this. In particular, I find it kind of surprising that the only $L^p$ space whose dual is isomorphic $L^p$ is for $p=2$. So I guess I'm wondering what's so special about the number 2 in the context of $L^p$ spaces, or rather, where the formula $\frac 1 p + \frac 1 q = 1$ originally comes from / is motivated from.
Edit: I understand that $p=2$ gives the only Hilbert space, but I'm wondering whether there's any sort of deeper reason behind the relationship between $p$ and $q$ --- does $\frac 1 p + \frac 1 q = 1$ arise naturally out of integration theory in a more satisfactory way than "it just happens to be like that"?

A: I elaborate on a remark in one of the other answers.
Consider a measure space $(X,\mathcal{M},\mu)$ which has sets of arbitrarily small measure and sets of arbitrarily large measure. (Here I think of the Lebesgue measure on the real line.) Let $1 \leq q < \infty$ and choose
$$g \in L^q \setminus \bigcup_{p \in [1,\infty), p \neq q} L^p.$$
This is messy, but doable. $f \in L^1$, but $f \not\in L^p$ for all $p > 1$ handles the case $q=1$, and given my assumption about the measure space, you can do something similar to get higher $q$. Let $\phi(f) = \int_X fg d \mu$.
Now let us consider a function in $L^p$ which makes $\phi(f)$ "large". Specifically we take $f=|g|^{q/p} \text{sign}(g)$. The point is that this is automatically in $L^p$ since $g \in L^q$, but it is also big exactly where $g$ is big.
Now if $\frac{q}{p} + 1 = q$ then $\phi(f)=\| g \|^q_{L^q}$. Yet otherwise $\phi(f)$ is infinite! That is, $\phi$ is only bounded on $L^p$ if $\frac{1}{p}+\frac{1}{q}=1$.

A: To expand a bit on the standard answer ("$p=2$ is a Hilbert space and Hilbert spaces are nice"), let's talk about why Hilbert spaces are nice.  One of the key feature of Hilbert spaces is that they are self dual.  This is expressed through the Riesz representation theorem, which says that if I want to define a bounded, linear map $\phi:L^2\rightarrow \Bbb{C}$, I just have to find the right function $g_\phi\in L^2$, and then I'll have the expression
$$
\phi(f) = \langle f,g_\phi\rangle = \int_{\Bbb{R}^n} f(x)\bar{g}_\phi(x)dx
$$
The conjugate exponent expression
$$
\frac{1}{p}+\frac{1}{q} = 1
$$
comes from wanting to compute expressions that look just like $\langle f,g\rangle$:
$$
\int_{\Bbb{R}^n} f(x) \bar{g}(x)dx
$$
but in the case where $f\in L^p$ for any $p$, not necessarily 2!  The reason we do this is that we also want to define bounded linear maps $\phi:L^p\rightarrow\Bbb{C}$, but if $f\in L^p$, the expression
$$
\phi(f) = \int_{\Bbb{R}^n}f(x)\bar{g}(x)dx
$$ will only define a bounded linear map (i.e. the product will be an $L^1$ integrable function for all $f\in L^p$) when $g\in L^{q}$ where $p$ and $q$ satisfy the conjugate exponent equation.  Another way of expressing this is that the dual of $L^p$ is $L^q$, where $1/p+1/q = 1$, i.e. a version of the Riesz representation theorem holds for $L^p$, but $g_\phi\in L^q$ instead of $L^p$.
See also Holder's inequality.

A: I think part of it is because of Holder's inequality, which dictates that
$$
|fg|_{1}\le |f|_{p}|g|_{q}
$$
But the other reasons goes into this is much deeper. For example, this duality is "structural" as it holds regardless of the measure space is $\sigma$-finite. And this has to do with concepts like uniform convexity. I used to wondering the same thing when I was learning the subject. For some related questions on this, see:
How should I prove the duality?
If $f$ is measurable and $fg$ is in $L^1$ for all $g \in L^q$, must $f \in L^p$?
If $\sum a_n b_n <\infty$ for all $(b_n)\in \ell^2$ then $(a_n) \in \ell^2$
Is there a constructive proof of this characterization of $\ell^2$?

A: It's the only Hilbert space. That is, the norm comes from an inner product. Hilbert spaces have a lot of nice properties. For instance they are self-dual. They have a concept of orthogonality and angle.


text:
Q: Is it possible to generate a dependency graph of files included via RequireJS? In Magento 2 lots of JavaScript files are loaded via RequireJS.
Those files, themselves, can also require more JavaScript files, and so on.
This can make it difficult to determine where a specific .js file actually comes from.
Is there a way we can view a hierarchical-style depdency tree of RequireJS calls, to see which file called require on the file currently being loaded?