text: Q: How to make table row uneditable but at the same time selectable in Swing? I want to make my Jtable not editable, but at the same time i want it to be selectable. I tried by unchecking the 'enable' function in Jtables property, However this property restricted be from selecting any rows in my table. Is there anyway you can fix this?


text:
Q: How to add LUIS in a existing QnA bot? I have a existing QnA bot (C#, SDK-v4) and now I wan to add LUIS to it without creating a new bot with LUIS template.
my QnABot.cs file -
public class QnABot : ActivityHandler
    {
        private readonly IConfiguration _configuration;
        private readonly ILogger<QnABot> _logger;
        private readonly IHttpClientFactory _httpClientFactory;

        public QnABot(IConfiguration configuration, ILogger<QnABot> logger, IHttpClientFactory httpClientFactory)
        {
            _configuration = configuration;
            _logger = logger;
            _httpClientFactory = httpClientFactory;
        }

        protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var httpClient = _httpClientFactory.CreateClient();

            var qnaMaker = new QnAMaker(new QnAMakerEndpoint
            {
                KnowledgeBaseId = _configuration["QnAKnowledgebaseId"],
                EndpointKey = _configuration["QnAAuthKey"],
                Host = GetHostname()
            },
            null,
            httpClient);

            _logger.LogInformation("Calling QnA Maker");

            // The actual call to the QnA Maker service.
            var response = await qnaMaker.GetAnswersAsync(turnContext);
            if (response != null && response.Length > 0)
            {
                awaitturnContext.SendActivityAsync(
              MessageFactory.Text(response[0].Answer), cancellationToken);
            }
            else
            {
                await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
            }
        }

        private string GetHostname()
        {
            var hostname = _configuration["QnAEndpointHostName"];
            if (!hostname.StartsWith("https://"))
            {
                hostname = string.Concat("https://", hostname);
            }

            if (!hostname.EndsWith("/qnamaker"))
            {
                hostname = string.Concat(hostname, "/qnamaker");
            }

            return hostname;
        }
    }

I know about dispatch tool which can a dispatch LUIS app with knowledge base but I am do not know how to handle Luis intents in this bot.
How can I integrate LUIS in this bot?

A: You can add LUIS to an existing QnA Bot but you'll essentially be copying a lot of code from this sample so it's almost quicker to just start from the sample and copy over any code you want to keep from your existing QnA Bot.
Your OnMessageActivity should go from looking like this where it calls a qnamaker client directly to looking like this where the user's input is passed to a LUIS dispatch app which determines what intent to route the user to.
The routing of the user is handled inside the [DispatchToTopIntent]https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/14.nlp-with-dispatch/Bots/DispatchBot.cs#L51) method, the strings in the case statement match to the intent names under your LUIS app in the portal.
Needless to say there will be some additional packages that you will need to include in your bot Microsoft.Bot.Builder.Ai.LUIS is one, and you will need to create the IBotServices interface and BotServices class in your project along with other changes.
The whole process is documented here.

redpajama_set_name: RedPajamaStackExchange


text:
Q: React - cannot export multiple files from index.js I am creating a styled-components with Atomic Design and I want to separate styled files into one folder and have one index.js to export all files. I have found that can be done like this way: Splitting Styled-Components into multiple files but export them as one file but In my case when I want to export file inside index.js
export StyledClosestMeet from 'styledComponents/StyledClosestMeet.js';

I have error

Declaration or statement expected.ts(1128)

Inside styledComponents folder I have second file:
import styled from 'styled-components';
import variables from 'settings/variables';

const StyledClosestMeet = styled.div`
  color: ${variables.colorMain};
  font-size: 2rem;
  font-weight: bold;
  text-transform: uppercase;
`;

And later I want to import that file inside Atom file:
import React from 'react';
import {StyledClosestMeet} from 'styledComponents/StyledClosestMeet';

const ClosestMeet = () => {
  return <StyledClosestMeet>Najbliższe spotkanie</StyledClosestMeet>;
};

export default ClosestMeet;

I am using jsconfig "baseUrl": "./src"

A: You can create an index.js file to export both files like this:
export { default as Styled1 } from "./styled1";
export { default as Styled2 } from "./styled2";

and then import them like this:
import { Styled1, Styled2 } from "./styled/index";

Check out this example

A: You've to export StyledClosestMeet
import styled from 'styled-components';
import variables from 'settings/variables';

const StyledClosestMeet = styled.div`
  color: ${variables.colorMain};
  font-size: 2rem;
  font-weight: bold;
  text-transform: uppercase;
`;

export { StyledClosestMeet }

And you can export StyledClosestMeet like below.
export { StyledClosestMeet } from 'styledComponents/StyledClosestMeet.js';


text:
Q: neo4j 2 start failes after workings well my neo4j server workings well, but my server restarted and neo4j not started
server : Ubuntu 13.10
jdk: oracle jdk
this is errors:
SEVERE:
org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /var/lib/neo4j/data/graph.db
    at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:209)
    at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:87)
    at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:50)
Caused by: java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /var/lib/neo4j/data/graph.db
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:333)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:63)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:92)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:198)
    at org.neo4j.kernel.impl.recovery.StoreRecoverer.recover(StoreRecoverer.java:115)
    at org.neo4j.server.preflight.PerformRecoveryIfNecessary.run(PerformRecoveryIfNecessary.java:59)
    at org.neo4j.server.preflight.PreFlightTasks.run(PreFlightTasks.java:70)
    at org.neo4j.server.AbstractNeoServer.runPreflightTasks(AbstractNeoServer.java:319)
    at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:144)
    ... 2 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.extension.KernelExtensions@4b9de054' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:310)
    ... 10 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.index.lucene.LuceneKernelExtension@5df0330b' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
    at org.neo4j.kernel.extension.KernelExtensions.start(KernelExtensions.java:118)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
    ... 12 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.index.impl.lucene.LuceneDataSource@3fc9dd8c' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
    at org.neo4j.kernel.lifecycle.LifeSupport.bringToState(LifeSupport.java:411)
    at org.neo4j.kernel.lifecycle.LifeSupport.add(LifeSupport.java:324)
    at org.neo4j.kernel.impl.transaction.XaDataSourceManager.registerDataSource(XaDataSourceManager.java:236)
    at org.neo4j.index.lucene.LuceneKernelExtension.start(LuceneKernelExtension.java:79)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
    ... 15 more
Caused by: java.lang.NullPointerException
    at org.neo4j.kernel.impl.index.IndexProviderStore.<init>(IndexProviderStore.java:66)
    at org.neo4j.index.impl.lucene.LuceneDataSource.newIndexStore(LuceneDataSource.java:301)
    at org.neo4j.index.impl.lucene.LuceneDataSource.start(LuceneDataSource.java:224)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
    ... 20 more

Jan 20, 2014 1:02:28 PM org.neo4j.server.logging.Logger log
SEVERE: Failed to start Neo Server on port [7474]

A: I was previously facing this problem. Later I figured out few points that you need to make sure are properly handled.

*

*Make sure to use one instance at a time if in embedded mode.

*Register shutdown hook properly

*See if the server is still not running indexing while you restart.

*delete tm_tx_log.1 file from the neo4j-db folder and then restart.

Now first 3 are less probable causing your problem, so what I did that I caught the exception thrown then deleted the tm_tx_log.1 file and then initialized the service. Not fool proof but a work around.
     public class GraphDB {

        private static GraphDB graph = null;
        private static final String DB_PATH = "target/neo4j-db";
        private static GraphDatabaseService graphService = null;

        protected GraphDB() {
            try{
            graphService = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
            registerShutdownHook(graphService);
            }catch(Exception e){
                File file = new File(DB_PATH+"/tm_tx_log.1");
                file.delete();
            }
        }

        public static GraphDB getInstance() {
            if (graph == null) {
                graph = new GraphDB();
            }
            return graph;
        }

        public GraphDatabaseService getGraphDbService() {
            return graphService;

        }

        public void clearDb() {
            try {
                // FileUtils.deleteRecursively();
                File files = new File(DB_PATH);
                for(File file : files.listFiles()){
                    FileDeleteStrategy.FORCE.delete(file);
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public void shutDown() {
            System.out.println();
            System.out.println("Shutting down database ...");
            graphService.shutdown();
        }

        private static void registerShutdownHook(final GraphDatabaseService graphDb) {
            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    graphDb.shutdown();
                }
            });
        }
        }

And in your main section while calling handle the case when the graphService is null.
public static void main(String[] args) {
        GraphDB graphDb = GraphDB.getInstance();
        if(graphDb == null){
            graphDb = GraphDB.getInstance();
        }
}


text:
Q: How to icon them at the same level? How to icon them at the same level?

Code:
<button icon-button block (click)="nextpage();"> Palmares
    <ion-icon style="float:right" name="ios-arrow-forward"></ion-icon>
</button>
<button icon-button block (click)="nextpage();" icon-right> Classement
    <ion-icon style="float:right" name="ios-arrow-forward"></ion-icon>
</button>
<button icon-button block icon-right> Cours
    <ion-icon style="float:right" name="ios-arrow-forward"></ion-icon>
</button>
<button icon-button block icon-right> Site Web
    <ion-icon style="float:right" name="ios-arrow-forward"></ion-icon>
</button>

A: actually I don't have any knowledge about Ionic but i'll give it a try with basic inline-css for the buttons.
<button icon-button block (click)="nextpage();"> Palmares
    <ion-icon style="position:absolute;right:20px;" name="ios-arrow-forward"></ion-icon>
</button>
<button icon-button block (click)="nextpage();" icon-right> Classement
    <ion-icon style="position:absolute;right:20px;" name="ios-arrow-forward"></ion-icon>
</button>
<button icon-button block icon-right> Cours
    <ion-icon style="position:absolute;right:20px;" name="ios-arrow-forward"></ion-icon>
</button>
<button icon-button block icon-right> Site Web
    <ion-icon style="position:absolute;right:20px;" name="ios-arrow-forward"></ion-icon>
</button>

This might do the job, good luck!!


text:
Q: Where on earth to spark read local file when running an application in client mode I am deploying a spark Standalone cluster.172.16.133.15 is a Master with two Workers all in one machine, and it's deployed in ubuntu14.10.
As the doc says, I can run applications with both "client mode" or "cluster mode".
My questions is:
1) Where to load file when running an application in client mode (in windows machine)??
SparkConf conf = new SparkConf().setAppName("Test")
                                .setMaster("172.16.133.15")
                                .set("spark.submit.deployMode", "client");
JavaSparkContext sc = new JavaSparkContext(conf);
String path = "file:///C:\\Users\\Me\\Desktop\\demo\\1530699196271";
JavaPairRDD<String, String> rdd = sc.wholeTextFiles(path);

 JavaPairRDD<String, String> transformed = rdd.mapToPair(tuple2 ->{
       String fname = tuple2._1();
       String content = tuple2._2();
       content = YUVSimpleTrans.transform(content);
       return new Tuple2<>(fname, content);
 });
 transformed.saveAsTextFile("file:///C:/Users/Me/Desktop/demo/out");

when I run the codes, I got exception :
Caused by: java.lang.RuntimeException: Error while running command to get
file permissions : java.io.IOException: (null) entry in command string: null ls -F C:\Users\Me\Desktop\demo\1530699196271\split_0.yuv
at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:762)
....
test.sparker4m.Sparker4mApplication.main(Sparker4mApplication.java:51)
...

I don't know why it use "ls -F".
So I build a cifs directory with samba in 172.16.133.15, and upload all files in the direcotry "/usr/local/test/1530699196271", and modify the "path" variable, then it throw an exception:
Caused by: org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/usr/local/test/1530699196271
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:321)
... 31 more

I very confused that what the hell the "client mode" working.

*Does "cluster mode" upload jar file to the Master when use "spark-submit"?

if it's true, if I run my code use "spark-submit" with cluster mode (upload files
 to Master(172.16.133.15) which has two workers ) will it work?

A: From exactly the same place as in any other mode. It is resolved on each node (driver node and each executor node).
Therefore if you use local path each executor will attempt to read a local file on its own file system in a give path. Obviously there is no "file:///C:\\Users\\Me\\Desktop\\demo\\1530699196271" on your Ubuntu nodes - therefore failure is expected behavior.
Either use a distributed file system or homogeneous cluster with copy of the input on each node on the same path (clearly not applicable for mixed Windows and Linux nodes).


text:
Q: Unknown image in my html page i have unknown image in my page:
this is my url:
my page link
unknown image:

how can i find what causing this element?

A: That's not a unknown image , it is a unknown character , you have an unknown icon at the :before pseudo selector

A: I don't know how but you miss the Genericicons font-family.
Here is a snapshot from you code with a reference to this font-family:
@font-face {
  font-family: 'Genericons';
  src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/genericons-regular-webfont.eot');
  src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/genericons-regular-webfont.woff') format('woff'),
    url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/genericons-regular-webfont.eot') format('truetype');
  font-weight: normal;
  font-style: normal;
}

.pagination .next:before {
  content: "\f429";
  right: -1px;
  top: -1px;
}

.pagination .prev:before, .pagination .next:before {
  font-size: 32px;
  height: 53px;
  line-height: 52px;
  position: relative;
  width: 53px;
}

.paginate_button:before {
  font-family:'Genericons';
}

Next

http://output.jsbin.com/tisivu
You need to check why you don't have the reference to the library (maybe the theme not installed well, or bad copy/paste)


text:
Q: Why verdaccio is not supporting arm processors if node do it I'm trying to run verdaccio on my raspberry pi 3. I'm newbe with docker and I'm looking for the answer on my question.
If vardaccio docker image is based on node:12.16.2-alpine which supports linux/arm and linux/arm64, why it does not support ARM processors?
I'm getting an error:
root@DietPi:/home/dietpi/rpi-home-server# docker logs verdaccio
standard_init_linux.go:211: exec user process caused "exec format error"

Are there some required packages for linux which are not compatible with arm, installed using this command?:
https://hub.docker.com/r/verdaccio/verdaccio/dockerfile
RUN apk --no-cache add openssl ca-certificates wget && \
    apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python && \
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
    wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk && \
    apk add glibc-2.25-r0.apk

Or what is the reason of that? And how do you think is it possible to run it using raspberry?

A:
how do you think is it possible to run it using raspberry?

hertzg/verdaccio works fine on my PI 4
If you build the image on your x86 PC you must target the architecture to arm. This could help you https://docs.docker.com/buildx/working-with-buildx.
If you build the image on your PI Its should work. But I've not tested it.
Examples https://verdaccio.org/docs/en/docker.html#docker-custom-builds


text:
Q: Jquery trying to increment the data delay for every child I am trying to increment the delay of every data-attribute inside the div element.
See my code
JQUERY
jQuery(document).ready(function($) {
    var Column = [], startDelayTime, counter;
    Column = $('.col-outside');
    startDelayTime = 300;
    addDelayTime = 25;

    for(var i = 0; i < Column.length; i++) {
        Column.attr('data-sal-delay', startDelayTime + addDelayTime[i]);
    }
});

HTML:

Hopefully someone can explain me what i am doing wrong, or what i have to do.

A: The logic in your loop needs to look like this. I removed the JQuery logic to simplify the example.
var currentDelay = 300;
var addDelayTime = 25;

for(var i = 0; i < 10; i++) {
    // Column.attr('data-sal-delay', currentDelay);
    console.log(currentDelay);
    currentDelay += addDelayTime;
}

A: There are a few problems with your code.

*

*Within your loop, you need to access the single column node using Column[i] in order to set an attribute.

*attr() is a jQuery method, so you need to use it on a jQuery selection like $(Column[i]).attr(name, value). Or you could just use the javascript method setAttribute like Column[i].setAttribute(name, value)

*addDelayTime is an integer so addDelayTime[i] is undefined. What you want to do here instead is multiply addDelayTime by the current array index.  addDelayTime * i
In this example I've fixed the above 3 issues and instead of a for loop I've used jQuery's each to iterate over the columns.

jQuery(document).ready(function($) {
  var startDelayTime = 300;
  var addDelayTime = 25;

  $.each($(".col-outside"), function(index, item) {
    $(item).attr("data-sal-delay", startDelayTime + index * addDelayTime);
  });
});
.col-outside::after {
  content: attr(data-sal-delay);
}

A: This will work:
You need to multiply by i on delayStart to get desired effect.
$(function() {
    var Column = [], startDelayTime, counter;
    Column = $('.col-outside');
    startDelayTime = 300;
    addDelayTime = 25;

    Column.each(function(i, c){
        $(c).attr('data-sal-delay', startDelayTime+ (addDelayTime*i));
    });
});

A: You need to do two things:

*

*Use the current column in your loop (Column[i] rather than Column).

*Increment the value of startDelayTime every time the loop iterates.

Here's your edited code:
jQuery(document).ready(function($) {
    var Column = [], startDelayTime, counter;
    Column = $('.col-outside');
    startDelayTime = 300;
    addDelayTime = 25;

    for(var i = 0; i < Column.length; i++) {
        Column[i].attr('data-sal-delay', startDelayTime + addDelayTime);
        startDelayTime += addDelayTime;
    }
});

Now your code should work. Hopefully this helps!


text:
Q: jquery widget css overrides my own css I'm using jquery tabs and a few  other jquery widget.
Now, inside the tab, all the content is styled according to the jquery CSS. So, the easiest way is just to comment out or change a few of the jquery CSS definitions. But then obviously all the other widgets like autocomplete are not working anymore either.
How do other people solve this problem? My prefered solution would be, if I could leave the jquery CSS as it is, and just have my own default CSS inside the tabs back.
Example:
.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }

This overrides the text color in my tab. It's ok for the other widgets, but looks bad inside tab.

A: I would either use different CSS classes (or start using classes on the elements or a containing element if you aren't already) for your elements, so you aren't conflicting with the jQuery styles.

A: I think the solution is to remove the CSS class file with jquery, like in the example for the buttom tabs:
<script>
    $(function() {
        $( "#tabs" ).tabs();
        $( ".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *" )
            .removeClass( "ui-corner-all ui-corner-top" )
            .addClass( "ui-corner-bottom" );
    });
</script>


text:
Q: BadParcelableException: ClassNotFoundException when unmarshalling I'm pretty new to Serializable and Parcelable. I'm having a hard time passing an instance of this object from an application to a remote service:
public class Event implements Parcelable, Cloneable {

    /** Defines under what Bundle's key architecture events are stored */
    public static final String BUNDLE_KEY = "ZKEvent";

    /** Defines which messages are architecture's events */
    public static final int MSG_WHAT = 0xDEFECABE;

    /** Defines a key to store map under a Bundle to put into a Parcel (oh yeah!) */
    private static final String MAP_KEY = "MAP";

    /** Indicates this event ID. This ID should be the same in the event answer if any */
    private int idEvent = 0;

    /** Indicates this event priority */
    private int priority = EventPriority.EVENT_PRIORITY_LOW;

    /** ID for this event's sender */
    private int idSource = 0;

    /** ID for this event's destination */
    private int idDestination = 0;

    /** Action to be performed */
    private int action = EventAction.DEFAULT;

    public static final Parcelable.Creator<Event> CREATOR =
        new Parcelable.Creator<Event>() {
            public Event createFromParcel(Parcel in) {
            return new Event(in);
        }

        public Event[] newArray(int size) {
            return new Event[size];
        }
    };

    /**
     * Event's data
     * Represented as
     *      key -> parameter;
     *      value -> data
     */
    private Map<String, Object> data = new HashMap<String, Object>();

    /** Default constructor */
    public Event() {};

    /** Contructor with ID of the event */
    public Event(int id) {
        idEvent = id;
    }

    /** Constructor for Parcelable */
    public Event(Parcel in) {
        readFromParcel(in);
    }

    /** Gets event's priority */
    public int getPriority() {
        return priority;
    }

    /** Sets this event's priority */
    public void setPriority(int priority) {
        this.priority = priority;
    }

    /** Gets the ID of this event's sender */
    public int getIdSource() {
        return idSource;
    }

    /** Sets the ID of this event's sender */
    public void setIdSource(int idSource) {
        this.idSource = idSource;
    }

    /** Gets the ID of this event's destination */
    public Integer getIdDestination() {
        return idDestination;
    }

    /** Sets the ID of this event's destination */
    public void setIdDestination(Integer idDestination) {
        this.idDestination = idDestination;
    }

    /** Gets the action of this event */
    public int getAction() {
        return action;
    }

    /** Sets the action of this event */
    public void setAction(int action) {
        this.action = action;
    }

    /** Gets the data of this event */
    public Object getData(String key) {
        return data.get(key);
    }

    /** Sets the data of this event  */
    public void addData(String key, Object data) {
        this.data.put(key, data);
    }

    /** Gets the ID of this event */
    public int getIdEvent() {
        return idEvent;
    }

    /** Sets the ID of this event */
    public void setIdEvent(int idEvent) {
        this.idEvent = idEvent;
    }

    @Override
    public Object clone() {

        Event clone = new Event();

        clone.action = this.action;
        clone.idDestination = this.idDestination;
        clone.idEvent = this.idEvent;
        clone.idSource = this.idSource;
        clone.priority = this.priority;

        for(Entry<String,Object> entry: this.data.entrySet()) {
            clone.data.put(entry.getKey(), entry.getValue());
        }

        return clone;
    }

    @Override
    public int describeContents() {
        // TODO Nothing here
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {

        out.writeInt(idEvent);
        out.writeInt(priority);
        out.writeInt(idSource);
        out.writeInt(idDestination);
        out.writeInt(action);

        Bundle mapBundle = new Bundle();
        mapBundle.putSerializable(MAP_KEY, (Serializable) data);
    out.writeBundle(mapBundle);
    }

    /** Restoring this object from a Parcel */
    public void readFromParcel(Parcel in) {

        idEvent = in.readInt();
        priority = in.readInt();
        idSource = in.readInt();
        idDestination = in.readInt();
        action = in.readInt();

        Bundle mapBundle = in.readBundle();
        data = (Map<String, Object>) mapBundle.getSerializable(MAP_KEY);
    }
}

So I create a new instance of this Event class and pass it to the service like this:
/** Register with service */
private void registerWithService() {
    Event registerEvent = EventFactory.getEvent();
    registerEvent.setAction(EventAction.REGISTER);
    registerEvent.setIdSource(1);

    Bundle data = new Bundle();
    data.putParcelable(Event.BUNDLE_KEY, registerEvent);

    Message msg = new Message();
    msg.setData(data); // Exception thrown here in the Service
    msg.what = Event.MSG_WHAT;
    try {
        outMessenger.send(msg);
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

And here where in the remote service the exception is thrown:
    public void handleMessage(Message msg) {
        if (msg.what == Event.MSG_WHAT) {
            // Get the data bundle
            Bundle bundle = msg.getData();
            // Extract the event from the message
            Event event = (Event) bundle.get(Event.BUNDLE_KEY); // Exception thrown here
            sendEvent(event);
        } else {
            Log.i(TAG, "Received non architecture message, dropping...");
        }
    }

And the stacktrace:
07-09 12:38:10.947: E/AndroidRuntime(2234): FATAL EXCEPTION: main
07-09 12:38:10.947: E/AndroidRuntime(2234): android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.blabla.android.core.event.Event
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Parcel.readParcelable(Parcel.java:1958)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Parcel.readValue(Parcel.java:1846)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Parcel.readMapInternal(Parcel.java:2083)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Bundle.unparcel(Bundle.java:208)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Bundle.get(Bundle.java:260)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at com.blabla.android.core.event.EventManager$EventHandler.handleMessage(EventManager.java:44)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.os.Looper.loop(Looper.java:123)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at android.app.ActivityThread.main(ActivityThread.java:3683)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at java.lang.reflect.Method.invokeNative(Native Method)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at java.lang.reflect.Method.invoke(Method.java:507)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-09 12:38:10.947: E/AndroidRuntime(2234):     at dalvik.system.NativeStart.main(Native Method)

Any help greatly appreciated, thanks!

A: In this method, you never write the Bundle to the Parcel:
public void writeToParcel(Parcel out, int flags) {

    out.writeInt(idEvent);
    out.writeInt(priority);
    out.writeInt(idSource);
    out.writeInt(idDestination);
    out.writeInt(action);

    Bundle mapBundle = new Bundle();
    mapBundle.putSerializable(MAP_KEY, (Serializable) data);
   // You need to actually write the Bundle to the Parcel here...
}

EDIT Added additional solution to the ClassLoader problem:
Set the classloader in handleMessage() in your remote service like this:
Bundle bundle = msg.getData();
bundle.setClassLoader(Event.class.getClassLoader());
Event event = (Event) bundle.get(Event.BUNDLE_KEY);

A: Only solution found so far:
 val bundle = Bundle().apply {
        classLoader = YourClassName::class.java.classLoader
        putParcelable("deepLinkData", YourClassName(param1, param2, param3))
 }

please note, deepLinkData is a key, can be anything
    val myIntent = Intent(Intent.ACTION_VIEW)
    myIntent.putExtra("deepLinkBundle", bundle)


text:
Q: Mapping SQL Server integer to Oracle Datatype Well I know, that an SQL Server integer is best represented by NUMBER(10).
But sometimes I have migrate some maintenance scripts to Oracle and I wonder if I must carefully
map integer to NUMBER(10) or if I can just use the ansi type integer in Oracle.
Is there any reason not to use integer?
EDIT:
I verified it against 10g.
create table BK_int_test(
i_col integer,
f_col float);

insert into BK_int_test values (1, 1);
insert into BK_int_test values (1.1, 1.1);

Select * from BK_int_test;

and got
     I_COL      F_COL
---------- ----------
         1          1
         1        1,1

2 rows selected.

Thanks that saves a lot of work.
The short form int of integer is supported as well.

A: I don't see any reason to not use integer in Oracle. It will be mapped to the approriate Oracle datatype but keeps the DDL at least somewhat portable.
I also always use VARCHAR instead of VARCHAR2 as they are equivalent anyway. Oracle does not recommend this, as in the future this might change, but this has been true since version 6, so I doubt that it will actually change at all ;)

A: The only two reasons I can think of for not just using integer are:

*

*If you plan on porting integer data back to SQL Server from Oracle from those fields at some point: if integers out of the range -2,147,483,648 to 2,147,483,647 have been inserted on the Oracle side, these values will overflow on the return journey

*If some part of an application is relying on integers being in the aforementioned range. Values outside this range might therefore cause an error

Neither of these potential problems would be resolved by using number(10) which allows integers in the range -9,999,999,999 to 9,999,999,999. If it is necessary to constrain the integers to the same range, it would be better to use a check constraint, eg:
alter table my_table add check (val between -2147483648 and 2147483647);


text:
Q: Writing to C program using GO but C program doesn't stop at scanf() In these snippets the go program tries to write to C program's stdin. The problem is that the c program starts an infinite loop after the go loop finishes.
main.c
#include <stdio.h>
#include <stdlib.h>

int main(){
    int age;
    char name[8];

    for(;;)
    {
    scanf(" %s : %d\n",&name, &age);
    printf("%s : %d\n",name, age);
    }
    return 0;
}

run/main.go
func main() {

    proc := exec.Command("../main")
    stdin, err := proc.StdinPipe()
    if err != nil {
        fmt.Println(err)
    }

    defer stdin.Close()

    proc.Stdout = os.Stdout
    proc.Stderr = os.Stderr

    fmt.Println("START")
    if err = proc.Start(); err != nil {
        log.Fatal("An error occured: ", err)
    }

    for i := 0; i < 500; i++ {
        io.WriteString(stdin, fmt.Sprintf("hello : %d\n", i))
        //How to wait here and read from printf()?
    }

    //proc.Process.Kill() Here proc gets killed too fast

    fmt.Println("END")
}

When killed, process doesn't complete it's output
Output
START
END
hello : 497
hello : 498
hello : 499
hello : 499

Output Expected
START
....
hello : 497
hello : 498
hello : 499
END

A: After reading the comments and few more searching I have worked it out.
On C program I removed \n from scanf() and added fflush(stdout) after printf.
According to this page I changed them to these:
int main(){
    int age;
    char name[8];

    int ret;

    for(;;)
    {
    ret= scanf("%s : %d",&name, &age);
    if (ret == -1) {
        break;
    }
    printf("%s : %d\n",name, age);

    fflush(stdout);
    }

    return 0;
}

func main(){
    proc := exec.Command("../main")

    stdin, err := proc.StdinPipe()
    if err != nil {
        fmt.Println(err)
    }

    reader, err := proc.StdoutPipe()
    if err != nil {
        fmt.Println(err)
        return
    }

    scanner := bufio.NewScanner(reader)
    resp := make(chan string)

    go func() {
        for scanner.Scan() {
            resp <- scanner.Text()
        }
    }()

    err = proc.Start()
    if err != nil {
        fmt.Fprintln(err)
        return
    }
    fmt.Println("START")

    for i := 0; i < 500; i++ {
        io.WriteString(stdin, fmt.Sprintf("hello : %d\n", i))

        v := <-resp
        print(v+"\n")

    }

    err = proc.Process.Kill()

    if err != nil {
        fmt.Fprintln(err)
        return
    }
    fmt.Println("END")

}


text:
Q: uinput seems to break while sending inputs in quick succession I have been trying to use the uinput kernel module to send mouseclicks in quick succession to other programs.
This works fine if the delay between the clicks is 25ms or greater but it breaks if it is lower.
When it breaks I can see the events with evtest but not with xinput. Only the first event seems to work normally. (I guess the later events must be somehow lost between those two? Maybe there is a limit that I have missed?)
I have made a small example that reproduces this behaviour. (Most of it is taken from the  kernel documentation)
#include <linux/uinput.h>
#include <unistd.h>
#include <memory.h>
#include <fcntl.h>

#define TIME_BETWEEN_CLICKS (25000) // in µs

void emit(int fd, int type, int code, int val)
{
    struct input_event ie;
    ie.type = type;
    ie.code = code;
    ie.value = val;
    ie.time.tv_sec = 0;
    ie.time.tv_usec = 0;
    write(fd, &ie, sizeof(ie));
}

int main(void)
{
    struct uinput_setup usetup;
    int i = 50;
    int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);

    ioctl(fd, UI_SET_EVBIT, EV_KEY);
    ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);

    memset(&usetup, 0, sizeof(usetup));
    usetup.id.bustype = BUS_USB;
    usetup.id.vendor = 0x1234; /* sample vendor */
    usetup.id.product = 0x5678; /* sample product */
    strcpy(usetup.name, "Example device");

    ioctl(fd, UI_DEV_SETUP, &usetup);
    ioctl(fd, UI_DEV_CREATE);

    sleep(2);

    while (i--) {
        emit(fd, EV_KEY, BTN_LEFT, 1);
        emit(fd, EV_SYN, SYN_REPORT, 0);
        emit(fd, EV_KEY, BTN_LEFT, 0);
        emit(fd, EV_SYN, SYN_REPORT, 0);
        usleep(TIME_BETWEEN_CLICKS);
    }
    sleep(1);

    ioctl(fd, UI_DEV_DESTROY);
    close(fd);

    return 0;
}


text:
Q: Provisioning Windows 8/10 tablets How do you automate the deployment of software and configuration (users etc) on tablets?
The context is a number of Linx and Surface tablets that will be sent out to sites where they will be put on a LAN without internet access. We don't need or want remote management or AD, we just want to do one-time setup. And then later potentially reformat/reinstall any units that are returned as faulty.
Previously, for regular PCs, we've made sysprepped disk images using volume license keys for Windows 7, but you can't physically pull and reimage disks on tablets and we haven't arranged any Win10 volume license keys. We would like to continue using the licenses that ship with the tablets.

A: Microsoft provide a business targeted version of their store which will allow you to provision and manage software for the tablet OS
windows 10 provides built in functionality for reverting the system to its original state.
https://www.microsoft.com/en-gb/business-store/
https://support.microsoft.com/en-gb/help/12415/windows-10-recovery-options


text:
Q: How do I write a function with two long arguments? Most tutorials I find online tend to use the following format:
Method 1
$functionargument = <long_argument_goes_here>;
function($functionargument);

I personally find this hard to read. I know I won't have a choice if I ever start working for a team with a style guide, but I prefer:
Method 2
function(
    <long_argument_goes_here>
);

I don't know the name of these two methods, but I do know that method 1 is easier to find reference material for, and method 2 is the one I find easier to read, especially as the code gets more and more complex. If I don't see it physically nested, I forget where it came from.
One situation I've never seen in method 2 before is:
Style 1
$functionargument1 = <long_argument_goes_here>
$functionargument2 = <different_long_argument_goes_here>
function($functionargument1,$functionargument2);

I have a guess as to what the method 2 approach should be, but I'm not sure:
Style 2
function(
    <long_argument_goes_here>
,
    <different_long_argument_goes_here>
);

I've never seen a comma floating in the middle of code like that before, but it just feels right to me.
What is the correct name of "method 1" and "method 2"? I'd like to research this further, but I don't have the correct keywords to find it.

A: You could use the PSR-2 standard, there is a section about methods.
It allows you to use
public function foo($arg1, &$arg2, $arg3 = [])
{
    // method body
}

and if your function names or parameter names are longer:
public function aVeryLongMethodName(
    $functionargument1,
    $functionargument2,
    $functionargument3
) {
    // method body
}


text:
Q: Why ♯$(o/I)^×=NI-1$ holds? Let $K$ be a imaginary quadratic field and $K$ has class number one.
Let $o$ be ring of integers of $K$. Let $I$ be prime ideal of $o$.
My pdf reads ♯$(o/I)^×=NI-1$・・・①
(My pdf is Rubin's 'Tate Shafarevich groups of elliptic curves with complex multiplication').
My question :
What is $N$ ? There is no explanation about this in my pdf, and why does such a equation ① holds ? Thank you for your help.

A: Since $o$ is an integral extension of $\mathbb{Z}$, it follows that $I\cap\mathbb{Z}$ is a nonzero prime ideal $(p)$ of $\mathbb{Z}$.

Then $o/I$ is a finite integral extension of $F_p$, so $o/I$ is a finite field.

By definition, $N(I)=\text{#}(o/I)$, hence, since $(o/I)^{\times}=(o/I){\setminus}\{0\}$, we get $\text{#}(o/I)^{\times}=N(I)-1$.


text:
Q: Wordpress Form Validation using jquery.validate.min.js not working I have a custom built form in Wordpress (I considered using a form plugin but it is a 3 step form and none of the plugins I saw seemed suitable).  I am trying to implement a form validation plugin following the steps here: http://www.problogdesign.com/wordpress/validate-forms-in-wordpress-with-jquery/
Here's what I've got in my wordpress template:
<form name="lpsOrderForm" id="lpsOrderForm" method="post" class="contact-form" action="/payment-information/">
<input name=action type=hidden value=lps_calc>
<input name=page type=hidden value=2>
<input name=size type=hidden value=2>

Paper

<select name=paper id=paper onchange="lps_calcprice()">
<option value=4 >70# Gloss</option>
<option value=5 >7 Pt Reply/Uncoated</option>
</select>

Ink

<select name=ink id=ink onchange="lps_calcprice()">
<option value=6 >Full Color Both Sides</option>
<option value=7 >Full Color One Side</option>
</select>

Bleed

<select name=bleed id=bleed onchange="lps_calcprice()">
<option value=8 >Yes Bleed</option>
<option value=9 >No Bleed</option>
</select>

Fold

<select name=fold id=fold onchange="lps_calcprice()">
<option value=0>None</option>
<option value=10 >Half-Fold</option>
<option value=11 >Quarter-Fold</option>
<option value=12 >Tri-Fold</option>
<option value=13 >Double Parallel-Fold</option>
</select>

Bindery

<select name=bindery id=bindery onchange="lps_calcprice()">
<option value=0>None</option>
<option value=14 >One Perf</option>
<option value=15 >Two Perfs</option>
<option value=16 >Three Perfs</option>
<option value=17 >Four Perfs</option>
<option value=18 >Five Perfs</option>
<option value=19 >L Perf</option>
</select>

Quantity

<select name=quantity id=quantity onchange="lps_calcprice()">
<option value=0>0</option>
<option value=20 >1000</option>
<option value=21 >2000</option>
<option value=22 >3000</option>
<option value=23 >4000</option>
<option value=24 >5000</option>
<option value=25 >10000</option>
<option value=31 >15000</option>
<option value=26 >25000</option>
<option value=27 >50000</option>
<option value=28 >75000</option>
<option value=29 >100000</option>
</select>

Company/Name:

<input class="fws4" type="text" name="lps_deliveryname" id="lps_deliveryname"/>

Address Line 1:

<input class="fws4" type="text" name="lps_deliveryadd1" id="lps_deliveryadd1"/>

Address Line 2:

<input class="fws4" type="text" name="lps_deliveryadd2" id="lps_deliveryadd2"/>

City:

<input class="small-tbox" type="text" name="lps_deliverycity" name="lps_deliverycity" id="lps_deliverycity"/>

State:

Zip:

<input class="small-tbox" type="text" name="lps_deliveryzip" id="lps_deliveryzip"/>

    <input class="checkout-button-blue" type="submit" /></fieldset>

</form>

You'll notice a call for onchange in the selects.  The function calculates a price and displays via AJAX and is working properly.  It is enqueued and localized in my plugin with proper add_action calls.  Here is the javascript file for the lps_calcprice function:
function lps_calcprice(){
jQuery.post(myAjax.ajaxurl, jQuery("#lpsOrderForm").serialize()
,
function(response_from_the_action_function){
    jQuery("#lps_price").html(response_from_the_action_function);
}
);

}
And here is the plugin file, which I call trace_validate_form:
<?php
/**
 * Plugin Name: Trace Validate Form
 * Description: Validate form data instantly with jQuery. Uses jQuery Form Validation plugin by Jörn Zaefferer.
 * Version: 1.0
 * Author: Pro Blog Design
 * Author URI: http://www.problogdesign.com/
 * Lic
*/

/**
 * Add jQuery Validation script on posts.
 */
function trace_vc_scripts() {
//  if(is_single() ) {
        wp_enqueue_script( "jquery-validate",     WP_PLUGIN_URL.'/trace_validate_form/js/jquery.validate.min.js', array('jquery') );
    wp_enqueue_style(
        'jquery-validate',
        plugin_dir_url( __FILE__ ) . 'css/style.css',
        array(),
        '1.0'
    );
//  }
}
add_action('init', 'trace_vc_scripts');

/**
 * Initiate the script.
 * Calls the validation options on the comment form.
 */
function trace_vc_init() { ?>

<?php }
add_action('wp_footer', 'trace_vc_init', 999);
?>

When I don't put anything in the fields and click Submit, it just moves on to the next page.  I am fairly new to Wordpress so its very possible this is a simple fix.  I suspect it has something to do with the form action, but I'm not sure what to change it to to get the form validation to work.  When I view the source, I see the JS files in the head and I don't get any errors in Firebug.  Any input would be greatly appreciated!
*Note: I removed the state input intentionally as it was loading from inside a php evaluator plugin in Wordpress and I didn't want to make it any more confusing.

A: I went on to other things I needed to finish for this project and just got back to validating the form.  Turns out I needed to add "class=required" to the inputs.  Works like a charm now!  Silly...


text:
Q: Jquery defferd - AngularJS doesnt load Currently I am working on a Bluemix app with an Angular frontend.
I use an conf.json to declare some settings. I need that because my cústomer wants a white-label application which he can configure via an JSON file
So I need to load the config.json. I use ajax for that.
My file to load it is conf.js:
var promise = $.Deferred();
$.getJSON("config.json", function (configjson){
        promise.resolve(configjson);
        return configjson;
    });

I want to be sure, that the conf is loaded, when I start angular, because it uses some stuff out of it.
myApp.js starts Angular:
var myApp = angular.module("myApp",
    ['ui.router','diaNavbar','ngMaterial','dashboard']);

promise.done(function(config){
    console.log("Config: ",config);
    myApp.config(['$stateProvider','$urlRouterProvider','$logProvider','$mdThemingProvider',
               function($stateProvider,$urlRouterProvider,$logProvider,$mdThemingProvider) {
          // configure Angular with Conf.json
      }]);
    });

So my concept is, that the promise variable (jQuery) indicates, when the config is loaded. When I remove the promise.done function it works, but trows the errors, because config ist not loaded yet. The console.log throws out the config, so that works too. But in combination it doesnt work.
Working Environment: Bluemix, Node.JS Express 4, AngluarJS, JQuery,
I would appreciate any help on this


text:
Q: increase space for existing home directories I'm running ubuntu server Ubuntu 18.04.2 LTS.  When I originally installed my operating system I set up home directory and user accounts on a particular hard drive nvme1n1.  Recently I installed, partitioned, and mounted two new ssd drives sda and nvme0.  I added the new ssd drives because I was running out of space on my old hard drive.  I would like to share the space in the new drives across my user home accounts.  Is there a way to do this without having to wipe out my existing user accounts home directories?
I was reading online about volume groups, but it seems like those need to be created before you create home directories, in order to increase space using volume groups in the home directories.  Is that correct?
Is it possible to just move my home directories and all their data and programs (python, spark...) to one of the new ssd drives?  Any tips are greatly appreciated.
output:
df -h

Filesystem      Size  Used Avail Use% Mounted on
udev             16G     0   16G   0% /dev
tmpfs           3.2G  1.7M  3.2G   1% /run
/dev/nvme1n1p2  228G  216G  299M 100% /
tmpfs            16G   12K   16G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/loop1       94M   94M     0 100% /snap/core/8935
/dev/nvme1n1p1  511M  6.1M  505M   2% /boot/efi
/dev/loop2       94M   94M     0 100% /snap/core/9066
/dev/sda1       916G   77M  870G   1% /mnt/data/sda
/dev/nvme0n1    916G   77M  870G   1% /mnt/data/nvme0n1
tmpfs           3.2G     0  3.2G   0% /run/user/1000

A: Indeed raid setups would allow to seamlessly treat different drives as if it were a single volume, but that cannot be implemented without erasing the current data.
Otherwise, it is indeed easy enough to just selectively move some of the user's home folders to new drives, and replace the original data by a symbolic link pointing to the moved data.
You need to copy the user's files preserving all file attributes. This can be done with rsync with the -aH (archive) option. You need the -H option only if the user's data contains hard links to files (i.e., files having the same inode, i.e, pointing to the same data) that exist under the folder structure that is being copied. That option recreates hard links in the destination, but requires significantly more time. Without that option, hardlinks will be copied as independent files (having a different inode) on the destination.
After you verified that the copy is successful, you may delete the original data and place a symbolic link with the same name that points to the new location. The user will not be aware of this change (unless, perhaps, the new drives are slower or faster).


text:
Q: Method of characteristics for the PDE $xu_x +y u_y = 0$ with an initial condition on a circle How to solve this Cauchy problem?
$$xu_x +y u_y = 0$$
$$u(x,y) = x\quad \text{on}\quad x^2 + y^2 = 1$$
My attempt:
$$\dfrac{dx}{x}=\dfrac{dy}{y}=\dfrac{du}{0}$$
Using this we have $\dfrac{y}{x}=c_1 $ and $u=c_2$
Now Consider $c_2=G(c_1)$ $\implies$ $u=G(\dfrac{y}{x})$
My doubt is that how to use initial condition in this type of question?
I am confused with $x^2 + y^2 = 1$. How to use it here?

A: Functions of the form $u(x,y)=G(y/x)$ satisfy the PDE, but there are others. For one thing, there is nothing wrong with $x=0$ here... so I would rather use notation $u(x,y)=g(\theta)$ where $\theta$ is the polar coordinate. After all, the PDE $xu_x+yu_y = 0$ simply says  that $\partial u/\partial r = 0$ in polar coordinates. Any function that is independent of radial coordinate $r$ solves the PDE. And not every such function is of the form $G(y/x)$ since this form requires $u(-x,-y)=u(x,y)$ which need not be the case.
When $r=1$, you want $u(x,y) = x$, which is $\cos\theta$. So, $u(x,y)=\cos \theta$ it is. It can be expressed in $x,y$ coordinates, of course.

A related question is The integral surface of the pde $xu_x+yu_y=0$ satisfying the condition $u(1,y)=y$ is given by:

A: After finding the general solution $u=G\left(\frac{y}{x}\right)$ or equvalent $u=H\left(\frac{y^2}{x^2}\right)$  the condition $u(x,y)=x$ on $x^2+y^2=1$ must be applied :
$$x=H\left(\frac{1-x^2}{x^2}\right)$$
Let $\frac{1-x^2}{x^2}=t$
$x^2=\frac{1}{t+1}$
$$\sqrt{\frac{1}{t+1}}=H(t)$$
Now, the function $H$ is known.
$$u=H\left(\frac{y^2}{x^2}\right)=\sqrt{\frac{1}{\frac{y^2}{x^2}+1}}$$
$$u=\frac{x}{\sqrt{y^2+x^2}}$$
Note : The sign $\pm$ is omitted behind the radicals because only the signe $+$ is consistent with the condition $u(x,y)=x$ on the circle.

A: i want to see if changing to polar coordinates helps. we will make a change of variable $$x = r\cos \theta, y = r \sin \theta,  \frac{d}{dx} = \cos \theta\frac{d}{dr} -\frac{\sin \theta}r\frac{d}{d\theta}, \frac{d}{dy} = \sin \theta\frac{d}{dr} +\frac{\cos \theta}r\frac{d}{d\theta} $$
we can transform $$0=xu_x + yu_y = r\cos \theta\left(\cos \theta u_r-\frac{\sin \theta}ru_{\theta}\right)+r\sin \theta\left(\sin \theta u_r+\frac{\cos \theta}ru_{\theta}\right) = ru_r$$ to $$u_r = 0, u(1, \theta) = \cos \theta  \tag 1$$ the solution to $(1)$ is $$u(r, \theta) = \cos \theta = \frac{x}{\sqrt{x^2+y^2}}.$$


text:
Q: Topology of Fermi surface In The universe in a Helium droplet, Grigory Volovik  relates the stability of a fermi surface to topology of a Green function.
There he gives the example of a Fermi gas and says that the Green function for Fermi gas has form
$$G=\frac{1}{iw-v_{f}(P-P_{f})}$$ which has a singularity at $iw=0$ and $P=P_f$. The  Volovik proposes that a topologial invariant for a Fermi surface can be found by calculating the winding number about this singularity using the invariant formula
$$N_1=\frac{1}{2\pi i}\oint dl G^{-1}\partial_lG $$
where $l$ corresponds to contour winding the singularity.
My questions is that singularity of Green function corresponds to the pole of a Green function, so if this is the case then $N_1$ also will not be zero for insulators. I cannot understand this.

A: The Green function you gave above is not the Green function for an insulator, which should generically has no pole if there is no Fermi surface.
The Volovik argument is a bit circular, since you know from the beginning that $p=p_{F}$ is the Fermi momentum, defining the Fermi surface. When $p\approx p_{F}$ you can infer the form of the Green function as you wrote in your question, and then from complex analysis you can write $N_{1}$. Then you realise $N_{1}$ is topologically non trivial since a perturbation $G=G_{0}+\delta G$ in $N_{1}$ will let it invariant (say differently $\delta N_{1}=N_{1}\left(G_{0}+\delta G\right)-N_{1}\left(G_{0}\right)=\mathcal{O}\left(\delta G^{2}\right)$ has no term linear in $\delta G$). So you promote $N_{1}$ to characterise the Fermi surface. In the case you gave $G^{-1}\left(z\right)=z+v_{F}\left(p-p_{F}\right)$ most certainly $N_{1}=\pm 1$ am I correct ?
I'm now wondering about the generic form of the Green function for an insulator. I feel it's something like $G^{-1}\left(z\right)=1$, but I do not understand why right now. I'd say it should be something sufficiently trivial analytically to have no density of state. The simplest way is to have no pole at all on the real axis. Clearly $N_{1}=0$ in this case.

Edit: Well, I wanted to see this in more details in fact. So let us try a simplistic model when a gap separates electron and hole bands.
A simple model
Suppose the Hamiltonian
$$H=\tau_{3}\left(p^{2}+\Delta\right)-\mu$$
with $p$ the momentum (instead of $p/\sqrt{2m}$), $\Delta$ a gap and $\mu$ a parameter (when going to many-body, it becomes the chemical potential). One sees that there is two bands (I adopt the condensed-matter terminology), say for electron and hole, both having the same effective mass and separated by the gap $\Delta$, which I suppose always positive. When $\mu>\Delta$, the Fermi surface is of electronic nature, whereas for $\mu<-\Delta$ only holes are present at the Fermi surface.
The associated Green functions are
$$G_{\sigma}\left(z\right)=\dfrac{1}{z-\sigma\left(p^{2}+\Delta\right)+\mu}$$
with $\sigma=\pm$ representing the electron/hole ambivalence. Usually in condensed-matter, we prefer to discuss energy with the chemical potential taken as a reference, so we introduce $z=\omega-\mu$ (I drop $\hbar$). Then the Fermi surface is defined as the locus of the $p$'s lying at the chemical potential $\omega=\mu$. By construction, these loci are the pôles of $G_{\sigma}\left(z=0\right)$ above. One finds easily
$$\hat{p}_{\sigma}^{\pm}=\pm\sqrt{\sigma\mu-\Delta}$$
for the pôles. The $\pm$ distinctions comes from the quadratic dispersion, so for each right-moving particle we have  a left-moving one. This doubling is obviously essential in order to preserve the Galilean invariance, but it has nothing to do with the gap and the difference between metallic and insulating behaviour, so I drop the $\pm$ distinction from now.
Now we see the essential: for $\sigma = +1$ and $\mu>0$, there is no pôle along the real axis when $\mu<\Delta$. The same is true for $\mu<0$ and the hole sector $\sigma = -1$ if $\left|\mu\right|>\Delta$. In conclusion there is no pôle along the real axis in the gap. There are pôles along the real axis in the usual situation when the chemical potential lies above the gap $\mu > \Delta > 0$ in the electron sector and $-\mu>\Delta>0$ in the hole sector.
This is a generic argument : the Green function associated to an insulator has no pôle along the real axis, since the chemical potential lies inside a gap of forbidden momentum by construction. The Green function might have imaginary pôle inside the gap (as above in fact) which requires the momentum to be ill-defined (i.e. the momentum becomes imaginary). This can only happen by imposing boundary conditions since the "wave-function" is then evanescent. Such states are called for this reason edge states, or surface states.
Now to come back to the $N_{1}$ construction, we should define a generalised $N_{\sigma}$ which select whether we calculate the $N_1$ in the question using $G_{+}$ or $G_{-}$, and we will have
$$\begin{cases} \left|N_{1}\right|=+1\;;\;N_{-1}=0 & \mu>\Delta\\ N_{1}=N_{-1}=0 & \left|\mu\right|<\Delta\\ N_{1}=0\;;\;\left|N_{-1}\right|=+1 & \left|\mu\right|>\Delta \end{cases}$$
The sign in the metallic sector is of no real importance, it depends how one turns around the pôle. The important point is that $N_{\sigma}=0$ in the insulator sector, as is trivial the hole invariant when the chemical potential lies in the electron sector, and vice-versa $N_{1}=0$ when $\left|\mu\right|>\Delta$.

On the pôles of the Green functions
It seems the following remark is welcome (see the comment below from Meng-Cheng).
Usually, the spectrum properties of the system are obtained from the pôles of the Green function, taken as a function of $z=\omega-\mu$. For instance the Green function above $G_{\sigma}\left(z\right)=\left(z-\sigma\left(p^{2}+\Delta\right)+\mu\right)^{-1}$ has only one pôle $\hat{\omega}_{\sigma}=\sigma\left(p^{2}+\Delta\right)$ along the $\omega$-axis which corresponds to the eigen-energies of the system (the dispersion relation), and appears in the so-called spectral properties of the Green function [Economu]. As also remarked by Meng-Cheng, the difference between insulator and metal is then given by the possibility to have arbitrary low energy excitations. In the example, when $\Delta>0$ the lowest energy is $\Delta$ (i.e. $\hat{\omega}_{\sigma=1}\left(p=0\right)=\Delta$, which goes to zero for ungapped system (so for a normal metal).
In contrary, all the machinery developed in the previous section are concerned with the pôles of  the function $G_{\sigma}\left(z=0\right)$ with respect to $p$. Only these later pôles of $G_{\sigma}\left(z=0\right)$ with respect to $p$ are associated to the Fermi surface [Horava].
References

*

*E. N. Economou, Green's Functions in Quantum Physics, 3rd-rd ed. (Springer, 2006).

*P. Hořava, Stability of Fermi Surfaces and K Theory Phys. Rev. Lett. 95, 016405 (2005) or arXiv:hep-th/0503006


text:
Q: Android shared element to dialog actvitiy I've got one activity with an image in a toolbar and an activity that is themed like a dialog with the same image in big. These are the layout files:
my_activity.xml:
...

<com.makeramen.roundedimageview.RoundedImageView
    android:id="@+id/my_image"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:scaleType="centerCrop"
    android:src="@drawable/my_drawable"
    android:transitionName="@string/my_image_transition"
    app:riv_oval="true" />

...

my_dialog_activity.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@id/my_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/my_drawable"
        android:tint="@color/accent"
        android:transitionName="@string/my_image_transition" />

</LinearLayout>

The dialog activity becomes a dialog by applying this theme in the manifest:
<style name="MyDialogActivity" parent="Theme.AppCompat.Light.Dialog.MinWidth">
    <item name="windowNoTitle">true</item>
    <item name="android:windowMinWidthMajor">@dimen/abc_dialog_min_width_major</item>
    <item name="android:windowMinWidthMinor">@dimen/abc_dialog_min_width_minor</item>
</style>

Both the activity and the dialog look exactly how I want them to look like.
Now I want to implement a shared element animation with these ImageViews: When the user clicks on the first activity's image, it has to grow and move into the middle of the screen so it fits the bigger dialog's image.
So I wrote this code:
Intent intent = new Intent(MyActivity.this, MyDialogActivity.class);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
        MyActivity.this, v, getString(R.string.my_image_transition)
    );
    startActivityForResult(intent, 999, options.toBundle());
} else {
    startActivityForResult(intent, 999);
}

The animation does actually happen, but the moved image is only visible inside of the dialog's area. So you see an image that comes from the dialog's upper left corner, but you don't see it moving from the first activity outside of the dialog.
Here's a HTML version of how it should look like and what it currently looks like: https://jsfiddle.net/wutqdh9d/1/

A: The Share Element Animation was drawn in the second activity. As you use the Theme.AppCompat.Light.Dialog.MinWidth theme, the second activity's window size is smaller than the drawing area of animation.
Hence, just get rid of using the dialog theme. To change this below:
<style name="MyDialogActivity" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:backgroundDimEnabled">true</item>
</style>

The second activity layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">

<ImageView
        android:id="@id/my_image"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:scaleType="centerCrop"
        android:src="@drawable/your_icon"
        android:transitionName="@string/my_image_transition"/>

Then it will be this effect(http://gph.is/1UzZZzV).
Hope it help.
Reference: https://stackoverflow.com/a/28508306/3171537

A:  <style name="dialog_style_activity">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>

Above style is work for me. Reference this style in manifest.xml.


text:
Q: Please help me understand the solution to this graph I have a function
$$f(t) =
\begin{cases}
0,  & \text{0≤t<1} \\[2ex]
2, & \text{1≤t<2}
\end{cases}$$
According to the solutions manual, the period is 2

this is an odd function so I add $$-f(-t)$$
And get
$$f_o(t) =
\begin{cases}
0,  & \text{0≤t<1} \\[2ex]
2, & \text{1≤t<2}  \\[2ex]
-2, & \text{-2≤t<-1}  \\[2ex]
0, & \text{-1≤t<0}
\end{cases}$$
I have trouble extending the graph. The period is 2, so initially I thought the graph of f(t) should repeat itself for every 2 units and the graph of -f(-t) should repeat itself for every 2pi, but thats not the case.
So if the function f(t) repeats itself every 2 units. The first period is from x=0 to x=2. And after x=2 the function should start again right?
For instance y=0 is between x=0 and 1, y=2 is between x= 1 and 2. If the function repeats itself after every two units, that means the function should continue after x=2 and we should get the new lines, y=0 between x=2 and 3, and y= 2 between x= 3 and 4. But looking at the solution, that clearly isnt the case.

Can someone please explain whats going on?
Edit:
Problem:

Solution:

A: Thank you for the extra information.
a) You are asked to determine the period and the frequency. Based on the information you are given, the best choice is a period of 2.
The graph with period 2 should look like this:

b) You are asked to express the function f as a Fourier Sine Series. Because the sine function is an odd function, we pretend that your function is also odd!
Rotating your initial function about the origin gives us:

Taking this element and repeating it gives us the periodic function with period $T=4$ as plotted in the solutions manual.

A: The conditions you are given on the function are inconsistent.  If you are told the function is odd and period $2$ you should only specify it over a range of $1$, such as $[0,1]$. You can use the fact that it is odd to extend that to $[-1,1]$, then use the fact that it is period $2$ to extend it over the whole real line.  Alternately, you are given the values over $[0,2)$.  You can extend it as period $2$, but it will not be odd.  You can extend it to be odd, giving values over $(-2,2)$, and then extend it as a period $4$ function (though you will not have values for $2+4k$ if you do this.


text:
Q: Getting Emacs Tabs to Indent 2 ( Using Emacs Live ) What I want:
Tabs to be a length of 2.
What I have:
Tabbing moves me several spaces. Ether 2 spaces or 6. Seemingly randomly.
And they are spaces, literally, it seems. In that if press tab then I move up 6 characters, I press backspaces and it moves me back 1 ( to the 5th position).
So tabs move me to either a mod 2 or a mod 6 location all via spaces.
I want it to move me two at a time via tabs.
I have hacked around with different commands to no avail. = (
Thank you
Edit:
Also why the heck is this article titled tabs are evil when it says they are necessary...
http://www.emacswiki.org/emacs/TabsAreEvil


text:
Q: Finite groups of order $n$ having exactly $n$ subgroups Is it known a characterization of finite groups of order $n$ having exactly $n$ subgroups?
A supplementary question: are there abelian groups other than the trivial group and $\mathbb{Z}_2$ with this property?

A: There are finite groups of order $n$ having exactly $n$ subgroups
for $n = 1$, $2$, $6$, $8$, $28$, $36$, $40$, $40$, $48$, $54$, $72$,
$\dots$, and this list is exhaustive for $n < 96$.
The structures of the groups of order $< 96$ which satisfy the condition
are as follows:

*

*$1$,

*${\rm C}_2$,

*${\rm S}_3$,

*${\rm C}_4 \times {\rm C}_2$,

*${\rm D}_{28}$,

*${\rm C}_6 \times {\rm S}_3$,

*$({\rm C}_{10} \times {\rm C}_2) \rtimes {\rm C}_2$,

*${\rm C}_2 \times ({\rm C}_5 \rtimes {\rm C}_4)$,

*$({\rm C}_3 \times {\rm Q}_8) \rtimes {\rm C}_2$,

*$(({\rm C}_3^2) \rtimes {\rm C}_3) \rtimes {\rm C}_2$, and

*${\rm C}_6 \times {\rm A}_4$.

The GAP SmallGroups Library Id numbers of these groups are as follows:
[ [ 1, 1 ], [ 2, 1 ], [ 6, 1 ], [ 8, 2 ], [ 28, 3 ], [ 36, 12 ],
  [ 40, 8 ], [ 40, 12 ], [ 48, 17 ], [ 54, 5 ], [ 72, 47 ] ]

The existence of a general non-trivial "characterization" of such groups
seems rather unlikely to me.


text:
Q: MATLAB File Association in Visual Studio 2015 / TFS I'm using TFS in Visual Studio 2015, and have a question about MATLAB file associations. For .m files, there is no association to MATLAB, as seen here:

Confusingly, there is an association for .fig and .mat files, so VS must recognise that MATLAB "exists". If I double click one of these file types, it opens it in MATLAB as it would from within an Explorer window. This is the behaviour I want for .m files.

As a minimum, I'd like to have the MATLAB icon for .m files so that they're easy to spot in a directory. As an ideal solution, these files would also open in MATLAB (not the VS text editor) from TFS.
I have tried the "File Extension" option inside of Options > Text Editor, but MATLAB isn't an option for me in the Editor list.

It's worth noting that my work network is pretty strict on software installs, so the fewer external add-ins the better (ideally none). Suggestions appreciated.

A: There's a utility that I often use to fix OS-level association problems with MATLAB-related files - associateFiles from FEX.
You should probably call it with associateFiles('deleteadd','.m'), which would generate a registry file named MatlabFileAssocFix.reg that has the following contents (obviously the MATLAB path is generated according to your system):
Windows Registry Editor Version 5.00

;FIXES MATLAB FILE ASSOCIATIONS

;REMOVES M FILE ASSOCIATIONS

[-HKEY_CLASSES_ROOT\.m]

[-HKEY_CLASSES_ROOT\MATLAB.m.9.1.0]

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.m]

;ADD SHELL OPEN

[HKEY_CLASSES_ROOT\Applications\MATLAB.exe\shell\open\command]
@="\"C:\\D\\Program Files\\MATLAB\\R2016b\\bin\\win64\\MATLAB.exe\" \"%1\""

;ADD M FILE ASSOCIATIONS

[HKEY_CLASSES_ROOT\.m]
@="MATLAB.m.9.1.0"
"Content Type"="text/plain"
"PerceivedType"="Text"

[HKEY_CLASSES_ROOT\.m\OpenWithProgids]
"MATLAB.m.9.1.0"=""

[HKEY_CLASSES_ROOT\.m\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\.m\Versions\MATLAB.m.9.1.0]
"FileVersionMS"=dword:00090001
"FileVersionLS"=dword:00000000

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0]
@="MATLAB Code"
"FriendlyTypeName"="@C:\\D\\Program Files\\MATLAB\\R2016b\\bin\\win64\\matlab.exe,-58"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\DefaultIcon]
@="C:\\D\\Program Files\\MATLAB\\R2016b\\bin\\win64\\m.ico,0"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Open]
@="Open"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Open\command]
@="\"C:\\D\\Program Files\\MATLAB\\R2016b\\bin\\win64\\matlab.exe\""

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Open\ddeexec]
@="uiopen('%1',1)"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Open\ddeexec\application]
@="ShellVerbs.Matlab.9.1.0"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Open\ddeexec\topic]
@="system"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Run]
@="Run"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Run\command]
@="\"C:\\D\\Program Files\\MATLAB\\R2016b\\bin\\win64\\matlab.exe\""

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Run\ddeexec]
@="run('%1')"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Run\ddeexec\application]
@="ShellVerbs.Matlab.9.1.0"

[HKEY_CLASSES_ROOT\MATLAB.m.9.1.0\Shell\Run\ddeexec\topic]
@="system"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.m\OpenWithProgids]
"m_auto_file"=hex(0):
"MATLAB.m.9.1.0"=hex(0):

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.m\OpenWithList]
"a"="MATLAB.exe"
"MRUList"="a"

When you import this file, it deletes whichever association exists for .m and associates it with MATLAB.
I don't know if this is applicable to your problem, but I thought it should be mentioned.

A: So after a long time, I've found a reasonable workaround for this.
You can set the "Open With" default for .m files, but this seems to open a new instance of MATLAB for every file - not ideal! Suggested by SACn below their answer.

A better option is to use Visual Studio's "External Tools".
Go to Tools > External Tools, then as this documentation shows, create a new tool. Use the following parameters:
Title:     Your Title Here
Command:   cmd.exe
Arguments: /c "$(ItemPath)"

Tick "Close on exit". This opens the command prompt with the /c (terminate after command) flag, and runs the file name of the file which you have open in VS. On Windows systems, this will open the file in an open instance of MATLAB, or launch a new one if none exist.

This can be run many ways... Assign a keyboard shortcut, run from the Tools menu, add it to the Toolbar, add it to the context menu.
Now there is one click / key press to launch an open .m file as desired. It still lacks the MATLAB file association (and corresponding icon in the file browser) but does the main job!

A: Be advised: MATLAB is written in Java and not based on NET or Visual Studio extensions so if we're trying to open MATLAB Editor as plugin this is not a good idea for now.
Now to edit .m files you've to define new (external) default editor for a file type.
And if MATLAB license is not present use Notepad++, Sublime and other free editors which support .m file syntax highlighting.

A: If I understand correctly, you want to integrate MATLAB with VS (It seems your issue is not TFS related).
There is not such extension for Visual Studio, but there is a MatLab extension for Visual Studio Code.
=========================================================================
From the comment, it seems you want to use team explore in MATLAB to enable integrated use of Team Foundation Version Control. I'm afraid your requirement can't be achieved at this moment. MATLAB doesn't support team explorer or TFS MSSCCI Provider.
I have submitted a user voice at website below, you can vote it:
https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/18325612-enable-integrated-use-of-team-foundation-version-c.

A: OK, here's how I did it:
I have VS code installed, and as such, it creates an association in my default programs like this:

Then you can just point your VS program at this extension:


text:
Q: spotipy query does not return resultset from spotify I have the following code, but there is an empty response, while the combi title / artist is in spotify.
Is there anybody who can help me?
If i do the same for one of us / abba as track / artist it gives results.
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import sys
import pprint

artist = 'karel gott'
track = 'eine liebe ist viele tranen wert'

if len(sys.argv) > 1:
    search_str = sys.argv[1]
else:
    search_str = 'artist:{} track:{}'.format(artist, track)

sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
result = sp.search(q=search_str)
pprint.pprint(result)

A: By default the API will search through songs in the US market, that means songs that can legally only be listened by US customers.
I found that the song you are looking for is available in countries across Europe. For that song I get results in the GB as well as FR markets, and even more results in the german one.
So, just specify the market where you are using Spotify from:
sp.search(q=search_str, market="DE")

Unfortunately I am not aware of an easy way to search through all markets at once.

A: Thx Stéphane, that was the solution. I'll keep it in mind  for my spanish songs


text:
Q: Do we need to call dev.off() after creating a pdf file? When I call dev.off() my pdf gets created but I get the following message "null device 1".
I don't get any warning when I remove dev.off and my pdf gets created so why do I need to call dev.off for?
plot(x # independent variable (population_density)
, y # dependent variable (case_fatality_rate)
, main = "ScatterPlot - Case Fatality Rate vs Population Density Per Square Mile" # chart
title
 , xlab = "Population Density Per Square Mile" # x-axis label
, ylab = "Case Fatality Rate" # y-axis label
, pch = 19 # point shape (filled circle)
, frame = T # surround chart with a frame
, xlim = c(0, 1200), ylim = c(0, 3)
)
model <- lm(y ~ x, data = dataset) # compute the linear model
abline(model, col = "blue") # draw the model as a blue line

hist(y # depandant variable (case_fatality_rate)
, main = "Histogram - Case Fatality Rate Frequency" # chart title
, xlab = "Case Fatality Rate",
ylab = "Frequency",
col = "#f0ffff",
breaks = 15,
freq = FALSE,
prob = TRUE,
xlim = c(0.5,2.5),
ylim = c(0.0,2.0)
)

lines(density(y, adjust=1.2),  col="blue", lwd=2)

grid(nx = NA, ny = NULL,
 lty = 1, col = "gray", lwd = 1)

dev.off()


text:
Q: c binary tree insert function pointer I am trying to make a binary tree program where each tree node contains a struct of 'inventory'.
I am currently getting an error in my insert function that causes compile to fail.
The error I am getting is:
left of '.invPartNo' must have class/struct/union
type is 'inventory *'
did you intend to use '->' instead?

These are my structures:
//inventory definition
typedef struct inventory
{
    char invName[36];
    int  invPartNo;
    int  invQOH;
    float invUnitCost;
    float invPrice;
}item;

//tree definition
struct btree {
    item *data;
    struct btree *left;
    struct btree *right;
} ;

And this is my insert code, where I did use ->, so I don't understand the error I'm getting. Any help/explanation would be greatly appreciated.
struct btree *Insert(btree *node, inventory *i)
{
    if(node == NULL)
    {
        btree *temp;
        temp = (btree *)malloc(sizeof(btree));
        temp->data = i;
        temp->left = temp->right = NULL;
        return temp;
    }
    if(i.invPartNo > node->data->invPartNo) //error here
    {
        node->right = Insert(node->right, i);
    }
    else if(i.invPartNo < node->data->invPartNo) //error here
    {
        node->left = Insert(node->left, i);
    }
    return node;
}

A: Type of i is inventory * so you should replace i.invPartNo with (*i).invPartNo or equivalent i->invPartNo to resolve your error.
operator . is applicable for struct objects and not pointers to struct object. Operator * dereferences the pointer and dereferenced type is same struct object enabling the use of . here. But (*i).memb is noicy, so C language syntax provide a shortcut equivalent for the same as i->mem.


text:
Q: python import processing speed
Basically, I want to know if importing standard libraries in every module is better/worse than just importing the standard module once in a module and reusing it in other modules. In other words, I wanted to know if there is any speed/performance difference between the following two codes:
"""
One way - Just importing time module only once
"""
# /usr/bin/python
# mytime.py
import time

def get_time():
    return time.time()

# /usr/bin/python
# usingtime.py
import mytime

print (mytime.time() - mytime.time.time())

"""
Another way - importing time module as needed
"""
# /usr/bin/python
# mytime.py
import time

def get_time():
    return time.time()

# /usr/bin/python
# usingtime.py
import time
import mytime

print (mytime.time() - time.time())

Which code is better? or does it really matter?

A: There's no reason to re-import time in the second example, which is effectively what you're doing. For elegance, you should only import a module in the same module that (directly) uses it.
Imagine having imports 3 levels deep (one module imports another module which imports another module...) and keeping track of all those imports in the first, top-level module! It would be a nightmare to maintain.
As far as speed, I believe there will be a negligible performance hit by re-importing. The Python interpreter doesn't do a full re-import when importing more than once.

A: From: http://docs.python.org/reference/simple_stmts.html#the-import-statement

The first place checked is sys.modules, the cache of all modules that
  have been imported previously. If the module is found there then it is
  used in step (2) of import.

Modules loaded via import are essentially singletons.  On the first import of the module, code in module global scope will get executed (initialization of the module) and the module instance is added to sys.modules.  The next import in any other module will just refer to this initialized instance.  The cost is negligible.
Trivial example:
a.py
print "HELLO"

b.py
import a
import c

c.py
import a

In the interactive interpreter:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import b
HELLO
>>>

(notice how "HELLO" is printed only once)


text:
Q: Creating View FROM existing View I have to solve this problem as quickly as possible but i am a newbie to Transact-SQL.
I have a view vStockSerialsTemp:
  Serial StockCode ActionPrice  StockName      Warehouse   ActionType
    123    P-0304    350          Galaxy S4      Centeral    Income
    456    P-0305    450          Iphone 5s      Centeral    Income
    567    P-0305    450          Iphone 5s      Centeral    Income
    123    P-0304    350          Galaxy S4      Centeral    Expense
    235    P-0304    350          Galaxy S4      Centeral    Income
    567    P-0305    450          Iphone 5s      Centeral    Expense

So, based on this view, I have to create a new View that will count the balance of each stock with the same Serials. We subtract rows with ActionType
Expense from ActionType Income with identical Serials. Thus the view should look like:
 Serial StockCode ActionPrice  StockName      Warehouse   ActionType
    123    P-0304    350          Galaxy S4      Centeral    Income
    456    P-0305    450          Iphone 5s      Centeral    Income
    567    P-0305    450          Iphone 5s      Centeral    Income
    123    P-0304    350          Galaxy S4      Centeral    Expense
    235    P-0304    350          Galaxy S4      Centeral    Income
    567    P-0305    450          Iphone 5s      Centeral    Expense
    -----------------------------------------------------------------
    456    P-0305    450          Iphone 5s      Centeral    Balance
    235    P-0304    350          Galaxy S4      Centeral    Balance

CREATE vStockSerials as
SELECT * FROM [dbo].[dbo.vStockSerialsTemp]
UNION
// Here is the problem indeed

How can I select rows from vStockSerialsTemp here?

A: I do not know if this is the best way. But you could do this:
SELECT
    vStockSerialsTemp.Serial,
    vStockSerialsTemp.StockCode,
    vStockSerialsTemp.ActionPrice,
    vStockSerialsTemp.StockName,
    vStockSerialsTemp.Warehouse,
    vStockSerialsTemp.ActionType
FROM
    vStockSerialsTemp
UNION
SELECT
    vStockSerialsTemp.Serial,
    vStockSerialsTemp.StockCode,
    vStockSerialsTemp.ActionPrice,
    vStockSerialsTemp.StockName,
    vStockSerialsTemp.Warehouse,
    (
        CASE vStockSerialsTemp.ActionType
        WHEN 'Income'
        THEN 'Expense'
        ELSE 'Income'
        END
    )AS ActionType
FROM
    vStockSerialsTemp

A: Like three product came in (Income), Two spent (Expense). Income - Expense is remaining row (Balance)... with that Try this:
SELECT Serial, StockCode, ActionPrice, StockName, Warehouse
FROM [dbo].[dbo.vStockSerialsTemp] Where ActionType = 'INCOME'
EXCEPT
SELECT Serial, StockCode, ActionPrice, StockName, Warehouse
FROM [dbo].[dbo.vStockSerialsTemp] Where ActionType = 'EXPENSE'

I hope It will work. You can apply the count. To print the count side by side google for Derived table or CTE

A: Something like this after union:
select a.Serial, a.StockCode, (a.ActionPrice - b.ActionPrice) as ActionPrice,
a.StockName, a.Warehouse, 'Balance' as ActionType
from [dbo].[dbo.vStockSerialsTemp] a
inner join [dbo].[dbo.vStockSerialsTemp] b
on a.Serial = b.Serial
and a.ActionType = 'Income'
and b.ActionType = 'Expense'

Joining same view to itself. One with all Expenses, the other with all Incomes.

A: Based on your desired outcome, I assume you don't want to show data for serials with a balance of zero.
SELECT
    Serial,
    StockCode,
    ActionPrice,
    StockName,
    Warehouse,
    ActionType
FROM
    vStockSerialsTemp
UNION ALL
SELECT
    Serial,
    StockCode,
    sum(CASE WHEN ActionType = 'Income' THEN ActionPrice ELSE -ActionPrice END),
    StockName,
    Warehouse,
    'Balance'
FROM
    vStockSerialsTemp
GROUP BY
    Serial,
    StockCode,
    StockName,
    Warehouse
HAVING
    sum(CASE WHEN ActionType = 'Income' THEN ActionPrice ELSE -ActionPrice END) <> 0
ORDER BY
    ActionType DESC


text:
Q: looking for these spring security message names to customize them I have an application that uses ldap (bind authenticator) for login. I need to find the particular keys for these messages thrown by SPRING_SECURITY_LAST_EXCEPTION.message in order to "customize" them. I already got the "Bad Credentials" one done using BindAuthenticator.badCredentials, just need the rest.

*

*Empty Password

*Empty Username

*Customer not found with specified username

That last one is weird, could it be thrown by the ldap server itself?
Another thing I'm not getting is the label of another localization/language. All my spring message files work out in my application except the error ones at login. I have two property files:

*

*spring-security-messages_en_US.properties

*spring-security-messages_es_ES.properties

It's pulling all my messages regardless of loc/language from the en_US property file. The code on my Jsp is the following:
<c:if test="${param.error==true}">
    <div class="error">
         <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>
    </div>
</c:if>

Not sure if I have to use the <spring:message> tag here or it won't use the other property file. I tried using it but unsure on how to pass the exception to it.
Thanks a lot!

A: LDAP clients should use the LDAP operation code (an integer) that is contained in the response transmitted from the server. The message text can be customized per server and per API.
The result codes are standardized and listed at the result code section of the RFC.


text:
Q: how to merge 2 excel files with the same name in different folders?    from collections import defaultdict
from glob import glob
from itertools import chain, groupby
import pandas as pd
from pandas import ExcelWriter
from pathlib import Path
from pprint import pprint, pformat
from textwrap import indent
import os
import os.path
ca_2015= "D:\master concordia\DYD\Ecobee DYD\canada\Canada 2015"
ca_2016= "D:\master concordia\DYD\Ecobee DYD\canada\Canada 2016"
ca_2017= "D:\master concordia\DYD\Ecobee DYD\canada\Canada 2017"
ca_2018= "D:\master concordia\DYD\Ecobee DYD\canada\Canada 2018"
ca_2019= "D:\master concordia\DYD\Ecobee DYD\canada\Canada 2019"
files_2015 = os.listdir(ca_2015)
files_2016 = os.listdir(ca_2016)
files_2017 = os.listdir(ca_2017)
files_2018 = os.listdir(ca_2018)
files_2019 = os.listdir(ca_2019)
df_total= pd.DataFrame()

i=0
for file in files_2017:
    os.chdir("D:\master concordia\DYD\Ecobee DYD\canada\Canada 2017")
    if file in files_2018 and file in files_2019:
        df_file= pd.read_csv(file)
        df_total= pd.concat([df_file], ignore_index=True)
        for f in files_2018:
            os.chdir("D:\master concordia\DYD\Ecobee DYD\canada\Canada 2018")
            if f in files_2017 and f in files_2019:
                df_f= pd.read_csv(f)
                df_total= pd.concat([df_f], ignore_index=True)
                for ffile in files_2019:
                    os.chdir("D:\master concordia\DYD\Ecobee DYD\canada\Canada 2019")
                    if ffile in files_2017 and f in files_2018:
                        df_ffile= pd.read_csv(ffile)
                        df_total= pd.concat([df_ffile], ignore_index=True)
                        df_total.to_csv(("thermostat"+str(i)+".csv"),(output_folder))
                        i +=1

I'm trying to write a code to combine 5 excel files with the same name but in different folders, this is what I got so far the problem is it only read the first file, can someone please tell me how to fix it?


text:
Q: VBA convert date to a number based on text box input I have a userform I am making. An input box will open and the user will enter a month. Then The userform will open, inputting that month into textbox3. I want text box 1 to be 1&the number form of that month. I have tried several types of code but i am fairly new to vba.
Help would be appreciated.
Here is the code i have tried.
TextBox1=MONTH(DATEVALUE("1"&TextBox2.value))

A: With December in TextBox2, use,
 TextBox1 = "1" & Month(DateValue("1-" & TextBox2.value))

TBH, I really wouldn't trust my users to spell the month name correctly but have them select from a list instead.


text:
Q: Smooth vector fields on a surface modulo diffeomorphisms Let $\Sigma$ be a two-dimensional connected smooth manifold without boundary.  (Feel free to assume it is compact and orientable.)
Let $\mathcal{X}(\Sigma)$ denote the smooth vector fields on $\Sigma$ and let $\operatorname{Diff}(\Sigma)$ denote the group of diffeomorphisms of $\Sigma$.  Clearly $\operatorname{Diff}(\Sigma)$ acts on $\mathcal{X}(\Sigma)$.
I would expect naively that the space of orbits $\mathcal{M}:=\mathcal{X}(\Sigma)/\operatorname{Diff}(\Sigma)$ would be finite-dimensional.  Is this actually the case?
Question
What can one say about $\mathcal{M}$ in general?
Any references where I could read about this question would be appreciated.

A: This is not finite dimensional. For example, consider non-vanishing vector fields on $T^2=\mathbb R^2/\mathbb Z^2$, transversal to vertical circles. Any such field defines a  self diffeo $S^1\to S^1$ on a vertical circle, called the return map. Suppose that such a diffeo $\varphi$ has $n$ fixed points $x_i$ (they correspond to closed orbits of the field). Then for each fixed point $x_i\in S^1$ we have a linear map on the tangent space $d\varphi: T_{x_i}S^1\to T_{x_i}S^1$ given by multiplication by $\alpha_i\in \mathbb R^*$. Such $\alpha_i$ is an invariant of a vector field under diffeomorphisms. And since the number of closed orbits can be arbitrary and these $\alpha_i$'s are independent, we see that the dimension is not finite.
If you want something which is finite-dimensional, one can restrict to area-preserving vector fields which are same thing as closed $1$-forms. Now the spaces of minimal closed $1$-forms on a closed genus $g$ surface is indeed finite-dimensional by a theorem of Calabi. Each such form is the real part of a holomorphic $1$-form for a certain complex structure on the surface. (the reference is: E. Calabi, An intrinsic characterization of harmonic 1-forms, Global Analysis, Papers in Honor of K. Kodaira, 1969)


text:
Q: Why I get "Operator '||' cannot be applied to operands of type 'bool' and 'int'" error? int UserA;

Console.WriteLine("What is 5 + 5");
UserA = Convert.ToInt32(Console.ReadLine());
if(UserA == 10) {
    Console.WriteLine("Correct!");
} else if(UserA == 9 || 11 ) {

}

Why am I not able to use the OR operand here. I know its simple but I am quite stuck.

A: It supposed to be:
UserA == 9 || UserA == 11


text:
Q: what are windows synchronization routines other than critical_section? I am reading through the msdn articles about windows synchronization. It is really good & thorough material. At the same time is very time consuming. I am more interested in a quick comprehensive guide on the same topic. Any pointers?

A: This is a list of the concepts that I use in my native (unmanaged, Win32) application.  I've added some relevant function names between parenthesis):

*

*CriticalSection (InitializeCriticalSection, TryEnterCriticalSection, LeaveCriticalSection, ...)

*Mutex (CreateMutex, WaitForsingleObject, ReleaseMutex, CloseHandle, ...)

*Semaphore (CreateSemaphore, WaitForSingleObject, ReleaseSemaphore, CloseHandle, ...)

*Event (CreateEvent, SetEvent, ResetEvent, WaitForSingleObject, CloseHandle, ...)

Besides these you could also use a file to implement locking (e.g. between processes running on different machines):

*

*Simply create the file using CreateFile, use FILE_FLAG_DELETE_ON_CLOSE, and don't specify any of the sharing flags.

*If a process already created the file, the CreateFile will fail.

*To unlock, close the file using CloseHandle.

A: This might be a good starting point:
Synchronization Functions: http://msdn.microsoft.com/en-us/library/ms686360%28v=VS.85%29.aspx


text:
Q: Spring Data JPA projection with ManyToOne I have the following two entities:
@Entity
public class Author {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String userName;
    // Getters/setters
}

@Entity
public class Comment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "author_id")
    private Author author;

    private String comment;
    // Getters/setters
}

I want to generate a JPQL query in a Spring Data JPA repository which gives me the authors with all their comments. My projection is
public interface AuthorProjection {
    String getUserName();
    List<String> getComments();
}

and my JPQL query is
public interface AuthorRepository extends JpaRepository<Author, Long> {

    @Query(value= "SELECT a.id as id, \n" +
            "    a.userName as userName,\n" +
            "    c.comment as comments\n" +
            "from Author a \n" +
            "left join Comment c on c.author = a")
    List<AuthorProjection> authorsWithComments();
}

public interface CommentRepository extends JpaRepository<Comment, Long> {
}

This generates the following raw SQL query via Hibernate (Underlying DB is PostgreSQL):
select author0_.id as col_0_0_, author0_.user_name as col_1_0_,comment1_.comment as col_2_0_ from author author0_ left outer join comment comment1_ on (comment1_.author_id=author0_.id)

My test data consists of one Author with two Comments. Unfortunately, when I run this, I always get two authors (which is actually the same Author) with one comment each. This is of course how the DB returns each row (the raw SQL looks nice and how it should be). Is it possible for either Hibernate or Spring Data JPA (or whichever is responsible) to merge all comments into the list, or do I need to write Java code which merges the rows based on the author id?
If possible, I would like to have the DB perform all the data transformation already and have a nicely structured Projection as output from the query.
My test for demonstration is:
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@Transactional(propagation = Propagation.NOT_SUPPORTED)
class JpatestApplicationTests {

    @Autowired
    private AuthorRepository authorRepository;

    @Autowired
    private CommentRepository commentRepository;

    @Test
    void contextLoads() {
        var author = new Author();
        author.setUserName("John Doe");
        var savedAuthor = authorRepository.save(author);

        var comment1 = new Comment();
        comment1.setComment("First comment").setAuthor(savedAuthor);
        commentRepository.save(comment1);

        var comment2 = new Comment();
        comment2.setComment("Second comment").setAuthor(savedAuthor);
        commentRepository.save(comment2);

        authorRepository.authorsWithComments().forEach(
                projection -> System.out.printf("%s, %s\n", projection.getUserName(), projection.getComments())
        );
    }
}

which gives the following output:
John Doe, [First comment]
John Doe, [Second comment]

And run directly in PostgreSQL, it gives:
 col_0_0_ | col_1_0_ |    col_2_0_
----------+----------+----------------
        1 | John Doe | First comment
        1 | John Doe | Second comment
(2 rows)

My expected Java output is:
John Doe, [First comment, Second comment]

Is this even possible with JPA?

A: Use relation in Author entity to fetch comments of author.
@OneToMany(mappedBy = "author")
private List<Comment> comments = new ArrayList<>();

Then query this way
@Query(value= "SELECT a.userName as userName, a.comments as comments from Author a")
List<AuthorProjection> authorsWithComments();

And projection like
public interface AuthorProjection {
    String getUserName();
    List<Comment> getComments();
}

A: You get all the comments by just query the authors. You need to add extra List in Author class.
@OneToMany(mappedBy = "author", fetch=FetchType.LAZY)
private List<Comment> comments = new ArrayList<>();

Then, you can use JAP Reposity
@Repository
public interface AuthorRepository  extends CrudRepository<Author, Long> {

}

CrudRepository already implement many useful API, such as findAll(), findById(), you don't need to write any sqls.