How to make custom URLs on LAN

Question: i've been trying to find a solution to this for a long time... what i wish to do is create custom URLs on LAN against which users can easily access to some site without using the actual URL e.g.
if the user types : http:searchme in the browser then he/she will be redirected to http:google.com
similarly, http:checkmail in the browser and he/she will be landed on http:gmail.com
I read somewhere that such thing is possible by editing the Rhosts or hosts file on the server.
Any help here would be appreciated!
Answer: " create custom URLs on LAN " - just create a shared HTML page  with 2 links:
 searchme
 checkmail
Which are links to websites and PC on LAN can make it their home page. That would be simple way to do it.

How to make custom URLs on LAN


Creating chart labels of two different Manipulated data sets in BarChart

Question: I want to add chart labels to different datasets that are chosen via manipulate.
I have a hierarchical data set that I imported from excel and broke down into subgroups using nested associations. There are three different campaign types (manual, auto, brands), each of which has three search types (PP,RoS,Top) and each of those search types holds 13 metrics. Below is an example of the manual campaign organizational structure:
manualPlacement = Association[  "PP" -> Association[
101520 -> Association[
  Impressions -> data101920[[22 ;; 25, 3]],
  Clicks -> data101920[[22 ;; 25, 4]],
  Cpc -> data101920[[22 ;; 25, 5]],
  Spend -> data101920[[22 ;; 25, 6]],
  Sales -> data101920[[22 ;; 25, 7]],
  ACoS -> data101920[[22 ;; 25, 8]],
  RoAS -> data101920[[22 ;; 25, 9]],
  Orders -> data101920[[22 ;; 25, 10]],
  Units -> data101920[[22 ;; 25, 11]],
  Conversion -> data101920[[22 ;; 25, 12]],
  CTR -> data101920[[22 ;; 25, 13]
    ]]],

This organizational structure is used for manual (PP,RoS,Top), and repeated for auto and brands. In order to compare two data sets side by side on one graph, I created a duplicate of the entire structure labeled "manualPlacement2" etc. The campaigns are organized by
campaign =Association[
"ManualCampaign" -> manualPlacement,
"AutoCampaign" -> autoPlacement,
"BrandCampaign" -> brandPlacement]

The names of the campaign names (the labels I want to put in the graph) are stored as the first value of each element which are stored by
labels = Association[
ManualLabel -> data101920[[10 ;; 13, 1]],
AutoLabel -> data101920[[2 ;; 5, 1]],
BrandsLabel -> data101920[[6 ;; 9, 1]]]

labels2 was also created to label the second set of data categorized by campaign2.
The metric data I want to access can be retrieved by
campaign[campaignType("ManualCampaign","AutoCampaign","BrandCampaign"),
placementType ("PP","RoS","Top"),
dateRange (the week of the data imported, theres only one week for test purposes),
metric (impessions,clicks,etc.)]

The goal of this whole ordeal is to create an interactive graph using Manipulate to be able to substitute the plotted datasets via drop down menu, which can be achieved by the code below. The only problem is the labeling I used is applied to both datasets, and the only way to differentiate them that I could think of was to use a legend for the second data set, however this gets confusing to look at as there is the incorrect label on the bottom of the second dataset.
Manipulate[
 BarChart[{
   campaign[campaignType, placementType, dateRange, metric],
   campaign2[campaignType2, placementType2, dateRange2, metric2]},
  ChartLabels -> {labelType},
  ChartLegends -> {labelType2}
  ],
 {campaignType, {"ManualCampaign", "AutoCampaign", "BrandCampaign"}},
 {placementType, {"PP", "RoS", "Top"}},
 {dateRange, {101520}},
 {metric, {Impressions, Cpc, Clicks}},
 {labelType, {labels[ManualLabel], labels[AutoLabel],
   labels[BrandsLabel]}},
 {campaignType2, {"ManualCampaign", "AutoCampaign", "BrandCampaign"}},
 {placementType2, {"PP", "RoS", "Top"}},
 {dateRange2, {101520}},
 {metric2, {Impressions, Cpc, Clicks}},
 {labelType2, {labels2[ManualLabel], labels2[AutoLabel],
   labels2[BrandsLabel]}},
 ControlType -> PopupMenu
 ]

When this is run, the output chart looks like this:

As you can see, the labelyType is displayed for both sets of data below the bars, and the only way to differentiate the second dataset is using the legend. Is there a way to label the datasets individually on the bottom without having to use the legend? Additionally what is a good method to making a chart title that auto-updates when the metrics are changed? Thanks in advance.
Answer: Perhaps something like:
ds = Dataset @ AssociationThread[{"Manual", "Auto", "Brand"},
       AssociationThread[{"52TD", "54SQ", "54TD", "54Vee"}, #] & /@
          {{1, 2, 3, 4}, {5, 6, 7, 3}, {4, 3, 2, 1}}]

Manipulate[BarChart[ds[{campaignType1, campaignType2}],
    LabelStyle -> 16,
    ImageSize -> Large,
    ChartLabels -> {{campaignType1, campaignType2}, Normal@Keys[ds[campaignType1]]},
    PlotLabel -> Row[{campaignType1, campaignType2}, "Vs."]],
 {{campaignType1, "Manual"}, Normal @ Keys[ds]},
 {{campaignType2, "Auto"}, Normal @ Keys[ds]},
 ControlType -> PopupMenu]


Vlookup between 2 Microsoft List

Question: I have 2 sharepoint/microsoft list files.
I want to create a reconciliation of two columns( x and y) in 2 separate files/lists(a and b) and spit out the differences into a new file or in a new column in List b.
I thought a vlookup type of function may be able to help with this.
Can anyone help me do this? Please inform me if I am in the wrong exchange.
Answer: Based on your description, I understand that there are lists A and B in the SharePoint. You want to a column Z in the list B to store differences between column  X in the list A and column Y in the list B. Is it right?
First, Vlookup column is not supported in the SharePoint. You can only display column X in the list B through lookup column. You cannot calculate differences between two columns.
Create a lookup column in the list B.

Vlookup between 2 Microsoft List


How to apply multiple clustering algorithms to same dataset and make comparison?

Question: I've a dataset and I want to implement K-Means, Fuzzy C Means, Gaussian Mixture Model, Spectral Graph. After that, I want to see the clusters that I get from different methods. What is the proper way to do that? Or should I only stick one algorithm and try to maximize correctness of that clustering?
Answer: Have a look at the scikit learn API, they have a section dedicated to this topic.
If you want to go further, have a look at chapter 3 "Unsupervised Learning and Preprocessing" of the book Introduction to Machine Learning with Python: A Guide for Data Scientists, there is a section on clustering methods (they also mention the evaluation of clustering methods which is very insightful)
Comment: Thanks, I'll check it out.


When we are estimating the table size for mySQL table, why do we add primary key twice?

Question: When we are estimating the table size for mySQL table, why do we add primary key size twice?
I saw this post How to estimate/predict data size and index size of a table in MySQL , and I noticed that the size of primary key is already in the row size.  Why do we add the primary key size again?
Comment: See [_this_](https://dba.stackexchange.com/a/253041/1876) for a better estimate.
Answer:
why do we add primary key twice?

This is an effect of InnoDB index structure.
MySQL 8.0 Reference Manual  /  ...  /  Clustered and Secondary Indexes

All indexes other than the clustered index are known as secondary indexes. In InnoDB, each record in a secondary index contains the primary key columns for the row, as well as the columns specified for the secondary index.

In table structure shown in the thread there is 2 indices: primary (by ID) and secondary (by CountryCode). The PK expression value is included in both - explicitly in PK and implicitly in SI. It is described in RolandoMySQLDBA's answer.
If there were three indexes in the table, the size of the primary index would be counted three times. 4 indexes - 4 times. And so on...
If no PK / UK in the structure then InnoDB adds inner 6-byte record number as a PK, and you must add 6 * (1 + indices count) bytes to each record's indices storage size.


Shimano STx rc 8515 rd mc38 rear derailleur , what replacement jockey wheels will fit on this

Question: As they do not make the pulley wheels for this derailleur  anymore because it's old can you please tell me what  modern Shimano pulley wheel will fit this.
Answer: You can use any jockey wheels with the same number of teeth from the Shimano range or an aftermarket replacement. I believe these had 9 tooth pulleys but usually 10 tooth will work very nicely as a replacement too.


Is SOA as a concept intended to function within code or between machines over a network?

Question: As the question states:  When implementing "SOA", is it a concept intended for communication between systems over a network or is it intended as a concept that operates within the language as a pattern?
Answer: Service Oriented Architecture is an architecture, so the answer is neither.
It's not a design pattern within a language because it governs decisions far, far outside of the program design - notably, how all your business data is organized into services, which has a close relationship with your organizational structure. Even some of the technical concepts like fire-and-forget messaging are generally language-agnostic.
And it's not specifically related to communication between systems over a network because you could implement an entire SOA in a single process if you wanted to. The preferred method of service interaction in an SOA is in-process, and data or messages should only cross process boundaries when you specifically need to scale out. Even then, SOA is concerned with the logical rather than physical deployment. If you have a "billing service", the architecture says nothing about where that service is located, and parts of it may in fact be located in several different physical endpoints.
SOA lends itself well to distributed systems because of some of the other technical constraints it tends to impose, such as asynchrony and loose coupling. Distributed systems generally behave better when they treat the network as a network (i.e. don't depend on low latency/high bandwidth) and when components can all operate autonomously. But that's an outcome of SOA, not its goal.
An SOA is very simply the opposite of a canonical data model; in other words, each Service is like a little dictatorship that guards its data ferociously and won't share anything with any other service except what it absolutely needs in order to function. You can implement that in any programming language, and with (almost) any physical infrastructure.
Comment: @Omega: Not trying to be condescending here, but you're not even in the right ballpark. Have you read anything about SOA? And if so, then what? A service is a conceptual boundary around a set of business functions and data. It's not an *object* and you don't "write" a service - not the kind of "service" that SOA refers to. What you're talking about is something like a "web service" which in SOA terminology is actually just an *endpoint*. As for "domain data", I'm not even sure what you mean; all of your data is domain data.
Comment: So if a service is written and used in-process, it should only return domain data and nothing else?  Any chance you could check this question out: http://programmers.stackexchange.com/questions/219305/is-this-any-form-of-service-pattern-some-other-pattern-soa-or-just-an-anti-pat
Comment: Oh, none taken! This actually isn't about me, I'm trying to get better explanations to assist others with understanding SoA and that it isn't a software design pattern to be implemented with a base class.  Your reaction is in fact helpful and telltale.
Answer: If you use it within a language as a pattern, you won't need some of the features of SOA:

loose coupling
mediated communication option
asynchronous communication (fire & forget messages)

So if you just want to have a clean contract between components, you can also do it without SOA. Write a design document instead.
If you suspect  that you will need to replace some components with 3rd party components later, SOA is a viable way. However, because of the performance impact of the XML serialization/deserialization, you might need to consider using a shortcut option for internal communication. That can be done within a wrapper which uses the shortcut for internal and SOA for external communication.
Comment: In my company, we even have internal standards which forbid that business logic is included in a interface layer. So transport logic is in the API layer, no matter if SOA or whatever. THe common businness logic shall not care about the transport form. However, there is still some dependency mainly because of performance reasons: if you have an API which only returns one field from a complex business object, then the business logic layer might need to support that instead of reading the whole fat object.
Comment: When creating an SoA, do the classes implementing business logic themselves need to be aware of any form of transport, or is it still important to keep that separation within the process?  Take a look at this question to get a better idea of what I'm asking: http://programmers.stackexchange.com/questions/219305/is-this-any-form-of-service-pattern-some-other-pattern-soa-or-just-an-anti-pat
Answer: In SOA your business logic is broken down into logical components where each component is exposed as a service. Hence why it's an architectural concept. It's common for these components to be distributed across multiple physical devices, but it doesn't have to be that way. You may have multiple services running on a single machine.
SOA allows for horizontal scalability, as opposed to just vertical scalability (more horse power). SOA is often applied when working with enterprise applications. Imagine a large organization with multiple unrelated applications written in various programming languages. In order for you to get these applications talking to each other (integrate), you might want to expose their functionality through services.
A range of service standards is available on the internet: http://en.wikipedia.org/wiki/List_of_web_service_specifications#Web_Service_Standards_Listings
Development frameworks such as .NET hide the complexity of these standards by offering you tools such as ASMX web services and WCF (http://keithelder.net/blog/archive/2008/10/17/WCF-vs-ASMX-WebServices.aspx)
To summarise, it would be very difficult to integrate enterprise applications if standards and frameworks that I have mentioned above didn't exist.


How can I do A/D conversion with isolation?

Question: I have to sense a voltage range of 0-25V dc and send to the ATMEGA 32 microcontroller. I want to use a voltage divider for sensing the voltage. But the problem is isolation is required between the microcontroller and the sensing side. For isolation I cant use optocoupler since the output of the optocoupler is not proportional to the input sensing side, other than using sensors any other ideas for isolation?
Comment: How much power is available on the isolated side?  One obvious answer is to convert to digital on the isolated side and send the data digitally via opto to the micro.
Comment: I edited the title of the post because the previous title was meaningless. All questions on the site should be about "electronic design". If the new title doesn't fit your meaning, please edit it to make it reflect the question you actually want answered.
Comment: http://www.mbridgetech.com/pdfs/Opto-isolation.pdf has some worthwhile discussion.
Comment: Depending on the response speed you need, you could do a voltage-to-frequency (or pulse width) conversion, pass the resulting digital signal through the opto-isolater and measure it with the microcontroller.  This isn't necessarily any better, cheaper, or easier to implement than Olin's microcontroller-opto-microcontroller idea, but it's conceptually simpler which may be eiser to explain to some audiences.
Answer: There are a few ways to do this.
1) Convert to a digital signal and isolate that. You'd need an A/D converter of some kind on the signal-side of your isolation barrier. I've done this with CANbus and a full-scale microprocessor on the signal side, but that may be overkill for your purposes. I've also done it with SPI, which all ATMEGA 32 models I see have, and a stand-alone A/D converter. I used Microchip MCP3004, but Digikey lists hundreds that may work for you.
2) Use an analog optocoupler, like HCNR200 or LOC110. They require some external op-amps to run properly, so it's got a sizable footprint per signal. We found that the HCNR200 line held its linearity much better with temperature than the LOC110 did.
3) Use an isolation amplifier. I've only ever used the HCPL-7800, which gives output centered at 2.5V. That makes it problematic for DC purposes, but for AC it's quite nice. I couldn't comment on other varieties that might be out there.
4) Convert the analog signal to a PWM signal, and isolate that with a digital opto. I did this once, but then the fever broke. It's probably not worth the trouble given the other options.
My suggestion would be 1) or 2), depending on constraints like footprint, power consumption, and parts cost.
Answer: If you need the ucontroller and the signal on different sides of the isolator, there are analog linear isolators you can use, like the HCNR200 line.  These are LEDs packaged with a pair of matched photoreceptors, and you use feedback tricks with external opamp circuits to provide a linear isolated signal.
I'm a bit concerned about the voltage range of 0V to 25V.  That will certainly influence your choice of external op amps, but I'll leave the work of checking the HCNR200 current and voltage limits to you.  You might have to attenuate a bit.
With these devices, the complications usually come when you need to isolate a bidirectional signal, which doesn't apply to your case.


Some community user can't post on chatter, while admin user can

Question: in my org if I log in to the community as a system admin I am able to see post option whereas another community user can only see chatter feed and an option to comment on posts but can't see the option to post to chatter. Can anyone provide a resolution to this?
Also, I want to point that the user can post on any account's record's chatter but not on any other object's record.
Comment: I found the answer to this. when you add feed publisher on community page you need to select whether you want the post to be global or related to a record. If you select a "record" then it won't be available for community user.
Answer: I was having the same issue.
I resolved by adding on Community the Feed component that shows the chatter feed and also the Feed Publisher component to post/start conversation on chatter (related to a record option worked for me).
I have to note that Community is configured for Partner Community users.
Hope this helps.


What is the name of the song that plays in Noragami Aragoto Episode 10 during the Okinunishi scene?

Question: Does anyone know the name of the song from Episode 10 of Noragami Aragoto which plays at 14:55 when Okuninushi told that lady to move? I really want to know what the name of that song is.
Answer: The song is from Disc 1 Track 15.
Its name is 大国譚 ("Daikokutan"), although I don't know if there's any official English translation of the same.
You can listen to it here.
Comment: thanks, i really wanted to know the name of the song so bad.
Comment: @Azurakai No problem. If this answers your question, you can select the tick mark/check mark beside the answer to indicate that this question has been answered.


Best REGEX for first/last name validation?

Question: Looking to stop people putting initials in the First / Last name fields, plus any special characters that you would not associate with a name. I've got something, although it is coming unstuck on names like McGowan or MacGowan. I understand why although I'm stumped to provide a solution.
This is what I have:
AND(
$User.ProfileId <> '00e30000001jDdz',
OR(
LEN(FirstName ) <=1,
MID(FirstName ,2,1) = " ",
NOT(
    REGEX(
          FirstName,
          '([A-Z][a-z]*)([\\s\\\'-][A-Z][a-z]*)*'
         )
      )
   )
)

The UserProfile is to let a System Admin do what they want. The Len & Mid bits are to stop initials, or people putting in "S J ".
There is probably a more elegant way of doing this but I'm rather fresh to REGEX.
Any suggestions on how to better this?
Thanks,
Comment: [Be careful when "validating" names](http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/). Anything more than verifying a reasonable length (1kb?) for names will be too restrictive.
Comment: **Related:** [Regex use vs. Regex abuse](http://blog.codinghorror.com/regex-use-vs-regex-abuse/) **&** [When you should NOT use Regular Expressions?](http://programmers.stackexchange.com/a/113243/4942)
Comment: Thanks to the huge amount of feedback so far. Interesting can of worms this opens up.
Comment: Know that there are people registered with a lastname of only 1 letter/character.
Answer: Yes! Let's validate some names with RegEx.
After all, we know that all people must have a first and last name, right? And no single person has more than three or four names total? And no doubt the same person will forever be identifiable by the same name?
Plus, we know that no modern culture uses patronymic naming and people in the same nuclear family must have the same last name, right?
Well, we can at least assume that people do not have single character names, right? And there are no names that use special characters, symbols, or apostrophes?
I think your choice of RegEx to validate names is missing the point: this is a huge unwieldy problem and, even if you massively restrict the scope of names you allow, you will forever suffer the risk of false negatives and you will be turning away people from other cultures and languages. In other words, I don't think that even attempting to validate names is worth your time.
Comment: yes, when faced with a similar problem to detect bogus leads, the best I ended up with to prevent false negatives was to screen out names with 4+ consecutive repeated letters or names from a limited set of keyboard noise strings (`asdf' and the like). I wasn't very satisfied with the results in terms of screening spam leads but I did avoid false negatives.
Comment: I think it's a bad idea too, for a lot of the reasons Jonathan does. No need to be mean about it though, Jon!  :P
Comment: I get what you are saying here. On the whole, the database is made up with paid for data, which is wonderfully clean. However, I would rather manage what the users are adding to the database and deal with exceptions rather than let free reign in here. Of the two evils, it appears to be the lesser one, evidenced by the sheer lack of care that is being taken as it stands.

Far too many entries being entered as "L" or "??" or "XX" or "(secretary)". Completely negates the one customer picture push.
Answer: The reason it's breaking on names like McGowan is because you're second character class doesn't allow for Capitalized characters.
Use the below regex to match names with Capitalization after the first character.
([A-Z][a-zA-Z]*)

Answer: From my experience, working in a multi lingual company, you'd probably be better off validating against characters you don't want to allow.
On our EComtract docs we have used something similar to this:
^[^±!@£$%^&*_+§¡€#¢§¶•ªº«\\/<>?:;|=.,]{1,20}$

Mainly because London works VERY close with some of the Scandinavian countries but because we are global and something like a Chinese name won't match the RegEx that you are looking to implement.
Answer: REGEX(
      FirstName,
      '([A-Z][a-z]*)([\\s\\\'-][A-Z][a-z]*)*'

In the above, the first * is a 'greedy match', meaning it

* Matches 0 or more of the preceeding token. This is a greedy match, and
  will match as many characters as possible before satisfying the next
  token.

which would be where you have the \\s\\ that represents a whitespace.
So, I don't think you want the * there if you want to prevent single characters using Regex. The same would apply to the * you have following the second set of alpha characters.
It appears that you've also escaped an apostrophe with the \'. Is that something you also don't want to allow? The - following it isn't applicable in terms of a range of characters and thus would likely only apply when it follows an apostrophe; meaning Regex would look for '-. I'm not totally certain of that, but I believe that would be the case.
The final * before the last closing parens would again be a 'greedy match` that due to it's placement I believe would cause the entire pattern search to repeat. From your description, I don't think that's what you desire.
I highly recommend you visit Regxr and use the on-line Regex expression builder there to create and test your expression. to ensure you're creating what you desire as its unclear to me from what you've posted. There's a quick YouTube tutorial on how to use the builder. There's even a library of RegEx patterns on the site available that users have submitted which are available for your use to help you create your own custom patterns if one doesn't already meet your needs.
Comment: So, say, Swedish people like Björn Borg will not be able to use this...
Comment: RegEx supports the use of unicode characters and those from other languages. As I said in my answer, its not entirely clear what @44f wanted to accomplish with the RegEx code he posted. Its much easier to look for something you're expecting than it is to screen out all the potential things that are possible for an external party to enter. I'll add that I was answering his specific question and not commenting on the validity of his use case.
Answer: This will match "James Woods", "Henry Ian Cusack" (first_mid will be "Harry Ian", last will be "Cusack"), "John McGlynn", "Raymond J Reynolds", etc.
It will also match "foo Manchu".  Use ucfirst to force initial capitalization.  There's no way to both enforce lowercase trailing letters and preserve internal caps (like McGlynn), so it's best to simply accept what the user submitted (like "Sarah McGilBertA".
(?P<first_mid>\p{L}{2,}( \p{L}+)+)(?P<last>\p{L}{2,})

Comment: While this appears to be a valid regex at a glance capturing groups aren't supported in formula expressions, which seems to be what the question is going for.
Answer: ValidationExpression="^[a-z A-Z]+$" just set this property of regural expression it will only get the character and string..
for example:-
<asp:RegularExpressionValidator  runat="server" ID="rev1" ControlToValidate="txtfirstname" ErrorMessage="Your First Name May Consist Only Character" ForeColor="#cc0000" SetFocusOnError="true" ValidationExpression="^[a-z A-Z]+$"></asp:RegularExpressionValidator>

Answer: I created this for names - it allows Capitalized characters after the first one, intervals, " . , - " and numbers - everything other like " @ # ! $ % etc. " won't be accepted
^[a-zA-Z][0-9a-zA-Z .,'-]*$.


Auto populate list items with values from another field or list

Question: I have a SP2010 standard list that serves as a checklist with 100 items. These items do not change and are fixed other than a few fields that the user changes such as the target data and actual date. One of the columns is named 'Responsibility' and by default is empty. I want this column to feed from another list or field for example: the column will contain the regional director or regional sales person as we have several regions I cannot simply pre-populate the column. What I want is to template this list and then upon deploying get the regional director to enter the names of a) the director and b) the sales person. This would then populate all 100 items 'responsibility' columns and display the actual name of the user instead of job role.
Hope this makes sense
Comment: Sorry I should add that I know I can do this with Workflow but would prefer something instant. Regards
Comment: Ended up using a simple workflow in the end
Answer: Ended up using a simple workflow in the end as I could not find an alternative option!


Travel to Sweden after work permit is approved

Question: I am from Asia and I have applied for work permit for Sweden which is approved by Swedish agency. Last week I gave biometrics for UT card and now I am waiting for UT card to be dispatched to me. But mean while I need to travel for some very urgent business meeting. So question is - is there any temp visa I can get while wait for my UT card to arrive. I know UT card only takes few days to arrive but I need to travel ASAP. Thanks in advance.
Comment: What passport do you hold/what country are you a citizen of?
Answer: If you would not require a visa to visit the Schengen Area, then you can fly to Sweden and enter on your passport. In this case, notify Migrationsverket that you've already arrived, so you can collect the residence permit in Sweden.
If you require a visa, however, you're not getting in without your permit, nor will airport check-in staff let you on a plane to Sweden.


how to separate program logic form design in swing and swt

Question: I have decent knowledge in J2EE frameworks such as Spring,Hibernate and got inspired by the separation of concerns . I am a starter in desktop development in java. Things are going somewhat fuzzy in swing. In VB, Form design will be kept as a separate one, and our form will only contains event listeners. But when I am started in swing many stuffs are loading in a single class making things difficult. I am unable to find where I am wrong. Similar thing continues when I started for alternatives such as SWT.
Sample SWT code I got from internet
import java.awt.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import edu.umd.cs.piccolox.swt.PSWTCanvas;
import edu.umd.cs.piccolox.swt.PSWTPath;
import edu.umd.cs.piccolox.swt.PSWTText;
public final class SWTBasicExample {

/**
 * Create and open a new shell on the specified display.
 *
 * @param display display
 * @return a new shell on the specified display
 */
public static Shell open(final Display display) {
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    // create a new SWT canvas
    final PSWTCanvas canvas = new PSWTCanvas(shell, 0);

    // create some SWT nodes
    //    and add them as child nodes to the canvas' camera's first layer
    PSWTPath rect = PSWTPath.createRectangle(25, 25, 50, 50);
    rect.setPaint(Color.RED);
    canvas.getLayer().addChild(rect);

    rect = PSWTPath.createRectangle(300, 25, 100, 50);
    rect.setPaint(Color.BLUE);
    canvas.getLayer().addChild(rect);

    PSWTPath circle = PSWTPath.createEllipse(100, 200, 50, 50);
    circle.setPaint(Color.GREEN);
    canvas.getLayer().addChild(circle);

    circle = PSWTPath.createEllipse(400, 400, 75, 150);
    circle.setPaint(Color.YELLOW);
    canvas.getLayer().addChild(circle);

    PSWTText text = new PSWTText("Hello World\nMultiline");
    text.translate(350, 150);
    text.setPenColor(Color.GRAY);
    text.setBackgroundColor(Color.BLACK);
    canvas.getLayer().addChild(text);

    text = new PSWTText("Goodbye World");
    text.translate(50, 400);
    text.setPenColor(Color.MAGENTA);
    canvas.getLayer().addChild(text);

    shell.open();
    return shell;
}

public static void main(final String[] args) {
    final Display display = new Display();
    final Shell shell = open(display);
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}
}

Here everything is messing up so our business logic and the design are on single class. I studied that a method can have up to 10 lines to make it less complex and reusable. Is it applicable only to logic not desktop development.
Meanwhile, I heard Swing is an MVC framework. So, I want neat separation of logic, design and control. I want good engineering practices being followed in swing and swt to ease desktop development in java. Since I am using eclipse SWT will be preferable for me.
Thanks,
Comment: How long are you working with J2EE frameworks that you have decent knowledge? (no offence, just asking)
Answer: As for Swing vs. SWT, I have used both (but mainly Swing).  At least back when I was looking into SWT (~5 years ago) the documentation for SWT was very poor compared to Swing.  Even though I liked many design aspects of SWT, and it is simpler than Swing, IMO, Swing is the one to learn because, IMO, it has far far better documentation, examples, etc.  And it is used in many more places.
As for general design ideas, one technique, if your major JPanels (or whatever your Component is) are modal, is to have a Model / DataObject / BusinessObject  associated with each JPanel.  The JPanel will have methods named something like panelToModel() and modelToPanel().  The former creates (or updates) a model corresponding to what the user has changed, and the latter takes a model and updates the GUI to match.  Now, personally, I hate modal anythings, but this is a fairly simple way to get started.
Comment: 5 years are long way ;].. You're right that SWT documentation wasn't so good, but for now I cannot imagine to write code without something so great as [SWT snippets](http://www.eclipse.org/swt/snippets/) definitely are. I miss this type of documentation for Swing so much!
Comment: That would have helped me a lot.  Anybody got a time machine?  :-)
Answer: In Swing the components itself follow the MVC pattern - most of the time. They are based on models, the visual representation can be replaced easily. For a larger scope you have to implement this yourself. Some approaches for separation of concerns exist, like the usage of Actions. But it is in no way a ready to use application platform, it is a GUI toolkit. There exist projects for application frameworks, like JSR 296 - "Swing Application Framework". But this one doesn't get finalized for years. Another notable platform based on Swing is the Netbeans platform, but this is a level higher.
SWT components are not designed with MVC concepts. JFace brings this concept to SWT. Ontop of this you can use Eclipse RCP which is an application framework similar to the Netbeans platform in functionality.
So if you are programming "raw" Swing you get some support but still have to do a lot of work by yourself. SWT asks for more basic effort (and discipline) from your side. But for both exist platforms that implement the MVC ideas.
Comment: I am wondering, how software  is built without separation of concerns. Can we maintain the software without proper separation. Eager to know what will be the industry standard:)
Answer: Spring (and other mentioned technologies/frameworks) have absolutely another purpose than GUI frameworks. You may not require same thing from two so different technologies. Desktop is not web, there aren't same rules as we speak.
If you want use MVC like patterns with SWT (especially for data binding) learn JFace.
Comment: Yes, I will accept your point. One thing we can add Apache Foundation and springsource organization and Jboss community helped java developers by giving handful of framework for Web development. But, it is not the case in Desktop development in Java. But, I don't know the reason behind that. Thanks, for spending your valuable time :D
Comment: I meant that web is made on totally different basis than desktop. Client server pattern is not common in desktop development. That's why most frameworks don't use any similar approach. When you'll try to use something like that in GUI, you'll have to write huge amount of boilerplate code..


Deferred scripts and DOM

Question: I need to run script only when DOM is ready as script does some rewriting of certain attributes of certain tags.
Currently I use document.addEventListener on DOMContentLoaded or if not available document.attachEvent  on onreadystatechange and if both not given I use window.onload functionality.
I read about defer tag for scripts that should be executed after document is parsed.

Does this mean that by setting defer attribute I can easily execute my script when DOM is ready?
Is there some hidden stuff I may miss?
How well is supported i.e. Opera, WebKit, Firefox, IE?

Edit: I'm aware of libraries like JQuery but I can't use them as I need very small script so I need a low level solution.
Comment: Opera doesn't support it (says [MDN](https://developer.mozilla.org/en-US/docs/HTML/Element/script)). May I ask why you need to be able to put it anywhere?
Comment: The simplest way to guarantee that the document is loaded before the script is run is to just place the `
Comment: @jfriend00 I need my script to be able to be in any place.
Answer: A proper implementation of the defer attribute will automatically run the script after the DOM has finished parsing so any code in the script does not have to do it's own logic for when the DOM is loaded.  You can read this Mozilla article for more details.
However, the defer attribute is not supported in all older browsers so you have to decide what browsers you want to support and what your strategy is for any that don't support defer.  You can read the history of browser implementation in this SO post.  In a switcheroo, it was implemented first in IE, then in Firefox, then in Safari and Chrome.  Judging by the dates/versions in that post, it looks like it's pretty safe to rely on it now except for Opera, but you'll have to dive into the details in that post to be sure it meets your requirements.
Here's a chart that shows browser support for defer: http://caniuse.com/script-defer.
As best I can tell, the main controversy with defer is whether multiple defer scripts execute in order or not (they are supposed to execute in order) and how they interact with scripts that use async.  The standards and implementations are now clear, but were not always.  But, if you just have one stand-alone defer script that you only care about executing after the DOM is parsed, you should be safe.
Answer: If you are amenable to using JQuery ( http://jquery.com/ ) then you can use:
$(document).ready(
    function(){
    //do something here, the DOM is ready!
    }
);

For the full details visit http://api.jquery.com/ready/
The .ready function will load after the DOM is ready and I believe (though I could be mistaken) that the JQuery team have largely taken care of anything which you (or I) might miss.
While you can tackle this without the overhead of JQuery, in my (novice) experience, the headache isn't worth the hassle. Also, JQuery has a lot of other nifty tools too. :)
Comment: jquery uses event listening similar to what I described above. Also I don't want jqery

Deferred scripts and DOM


preventing duplicate table inserts using jdo in android connected appengine

Question: I would like to know how to prevent duplicate inserts when doing an RPC call from an Android client connected to app engine. Below is my code and what I tried at the back-end but when I do this I get an "Internal Server Error".
public void createentity(userentity e) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    //to go through the records and and check for duplicates
    Query q = pm.newQuery("select from" + userentity.class + "where Country=='" + e.getCCNumber() + "'");
    List < userentity > s = (List < userentity > ) q.execute();
    //if the size is equal to to null means there is no duplicate
    if (s.size() == 0) {
        //insert the value
        try {
            pm.makePersistent(e);
        } finally {
            pm.close();
        }
    }
}

Comment: @SachinD When you edit a post, make sure that you fix the whole post, including code formatting ( http://jsbeautifier.com can be used in many cases), removal of greetings/signatures, and removal of chatty words.
Comment: When you reply to another comment, reply to the correct name ;) In this case, use `@Rob` or `@RobW`. For details, see [Meta: How do comment replies work](http://meta.stackexchange.com/questions/43019/how-do-comment-replies-work). *I replied to the previous editor of your post, to teach him how to edit.*
Comment: Thank you for guiding me.I will Remember that.Thank you once again.
Answer: A couple of potential issues I see. First you should also be checking that your list isn't null. If it's null, your attempt to access the size will result in a null pointer exception. Secondly, in your query string remove the double equals. You only need single equals there. And secondly, add a spaces at the end and beginnings of your string literals. You're creating an invalid string. For instance, "select from ". And lastly, you shouldn't need to wrap the e.getCCNumber() in string literals.
Query q = pm.newQuery("select from " + userentity.class + " where Country= " + e.getCCNumber());


The height of the levels of Minas Tirith

Question: In LOTR, Minas Tirith in Gondor is described as having seven levels.  What was the average difference in height between levels?
Comment: IIRC, the only thing that's said is that the overlook in front of the palace is 700 feet above the plain.  Assuming the bottom level is at the level of the plain, that's an average (arithmetic mean) of 116 feet 8 inches between each level.
Comment: @FlaStorm32 if I remember correctly, in the _Return of the King_ movie shows (Gandalf + Pippin) on Shadowfax riding from the main gate up to the courtyard of the White Tree; later, during the siege, there is a scene at the second gate with Gandalf speaking to Pippin. I think both scenes are only in the exented edition of the movie.
Comment: Did the movies show any of the gates of the city besides the main one?
Comment: See *The Art of the Lord of the Rings*, pages 141-160 for all of Tolkien's drawings of Minas Tirith. A number of them are in profile, and you can see the height of the levels relative to other features.
Answer: The Return of the KIng, Book v, Chapter 1 "Minas tirith":

For the fashion of Minas Tirith was such that it was built on seven levels, each delved into the hill, and about each level was a wall, and in each wall was a gate.

From the rear of the courtyard behind the gate in the first wall, a bastion of stone rose up.

Up it rose, even to the level of the topmost circle, and there was crowned by a battlement; so those in the Citadel, might, like mariners in a mountainous ship, look frm its peak sheer down upon the gate seven hundred feet below. The entrance to the Citadel also looked eastward, but was delved in the heart of the rock; thence a long lamp-lit slope ran up to the seventh gate.  Thus men reached at last the High Court and the Place of the fountain below the the feet of the White Tower: tall and shapely, fifty fathoms from its base to the pinnacle, where the banner of the Stewards floated athousand feet above the plain.

Fifty fathoms is 300 feet, and 300 plus 700 equals 1,000, so everything adds up.
Ths we can be certain that the averge level of MInas Tirith is 100 feet higher than the one below, right?
Except that the number of height differences must be one less than the number of levels.  So the average level must be 116.666 feet above the one below.
That would make it even harder for an enemy to capture each successive level of Minas Tirith.  Storming ladders that can reach 116.666 feet high when leaned agaisnt a wall are even more impossibly tall than ladders that can reach 100 feet high.
The only way for nonflyers to scale the walls would be to use crossbows to shoot grappling hooks with ropes to the tops of rhe walls and climb the ropes, which is easier said than done. I think that it would take very athletic warriors to climb ropes that high without falling to their deaths part way up.  And the defenders on the battlements would be busy cutting the ropes.
The only way to get inside a higher level of Minas Tirith would be to get through its gate.
And the bottom of each gate should be about 116.666 feet above the ground level below it.
So the route up to each gate from the lower level should be a long ramp that curves between the inner and other walls of its level, parallel to those walls, going up, up, up above the streets and houses of the lower level until it reaches the ground level of the level above.  And when the ramp comes even to the gateway, it should make a right hand turn to reach the gateway.  And part of that short right hand length should be empty air, bridged by a drawbridge from the gate, a drawbridge which can be raised to cut off any way to reach the gate.
At least that is the way I would design Minas Tirith to maximize the difficulty of capturing levels where the average height of a wall would be 116.666 feet plus the height of the battlements.
Comment: -1 (not really) for misuse of significant figures
Comment: All this extra detail is unnecessary. All you need is the quote for the total height, and then do the maths.
Comment: Instead of .666 feet, why not just say 8 inches?


Renouncing ownership without implemented function

Question: I already deployed a contract using openzepellin and since it is being used, is it possible to renounce the ownership ? I did forgot to add the renounceOwnership function or transferOwnership.
Thank you
Answer: So ownership only works if you are using the Ownable contract directly or by extending with:
<code>contract MyContract is Ownable {...}
</code>
Only if you are using that or any other form of access control renouncing ownership makes sense since owners usually have some kind of special privileges.
In short, if you are using Ownable, the functions are there, no need to implement. If you are not using it, or any other form of access control, you cannot renounce it because there is no address who "Owns", or has special privileges, in the contract.
Comment: Yes sure 0x7FE65F4C63ce1FEB6a84a30Fa491fA60BA11B1E8
Comment: Thank you for your reply,
I do use the Ownable & I do see my wallet as the owner when i do interact with the contract on ethscan for example, but how do I renounce it when I cannot find the option for it while "Writing Contract" on EthScan ?
Comment: Take another look. It should be there. The Ownable.sol contract has that function by default. I could take a look at the verified contract on etherscan if you want, just need the address
Comment: Verify the contract and you will see it
Comment: I did verify the contract on ethscan, It is Ownable since I did use some ownable functions, but I didnt import the Ownable.sol & I cannot see any option for transferring the ownership unless its a bout transferring tokens function
Comment: If anyone could help me renounce it, i'll gladly pay


Three 'First Post' reviews already reviewed

Question: Title says it all. I just reviewed 3 items that already had a "Welcome to PPCG" comment. Since 2 different people had reviewed them, I assumed that they hadn't forgot to click, "I'm done".
Comment: It takes more than one review to remove something from a review queue.
Comment: Furthermore, how do you know those people did the review? For all you know, those people may have seen the answer while browsing the site, and not through actual review.
Comment: @quartata Really? I never knew that. I have never seen this before.
Comment: @quartata That doesn't seem to be true for the **First Posts** queue.
Answer: First of all, you don't have to assume anything. As soon as you get the privilege of reviewing posts in a specific queue, you can switch to the history tab to see which actions have been taken by whom. For first posts, the history can be found here.
In this history, if you click on the action that has been taken, you're lead to the review task for that specific post. That information is completely public, as long as you have a direct link. For the post from the screenshot, you can find its review here.
As you can see, only one user (you) has reviewed the post, which completed the review task and thus removed the post from the review queue.
While it is possible that there is a bug that doesn't record all reviews, I think it's far more likely that the commenters either forgot to click I'm done (still unlikely) or that they simply found the answers while browsing PPCG and didn't use the review system at all.


Microsoft Windows applications acting as X clients

Question: Well I know that using a X server (e.g Xming) installed on a Windows machine, I can see the graphical output of a remote machine on the Windows box.  This is easy when remote machine is built using X windowing system.  How it will work if both (local and remote) machines are Microsoft Windows machines?  Saying another way can I force my Windows application to display its window on a remote Windows machine while program actually running on a local Windows box?
Answer: If it's XP then you can either use the builtin remote desktop connection software, or use vnc.
Answer: There are a couple of VNC based implementations which allow per Window sharing (which will also work well under X). For example: http://shared-app-vnc.sourceforge.net/


MySQL - Changing DB CHARACTER SET

Question: I have a 30GB MySql DB, made of innoDB tables.
currently the tables character set is: "utf8_unicode_ci" and I want to change it to "utf8_general_ci", what the best way to do it? currently i'm going through each table and running ALTER TABLE some_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; and it takes for ever... is there a better way?
Comment: duplicate: http://dba.stackexchange.com/questions/5920/how-to-convert-mysql-database-charset-to-utf-8
Comment: I don't view this as a duplicate.  OP is asking for alternatives to the straight alter table command.
Answer: I know what you mean. Alter table sometimes has to rebuild the whole table when you use it.
Assuming that the Alter table statement is annoying you because it takes too long AND it locks your table, then you can use 2 tools to make it an "online" alter table.
One if from facebook https://www.facebook.com/notes/mysql-at-facebook/online-schema-change-for-mysql/430801045932
And one is from openark http://openarkkit.googlecode.com/svn/trunk/openarkkit/doc/html/oak-online-alter-table.html (MySQL 5.1+ only)
Both these tools basically create a new table, copy the data over and keep it updated by updating both the old and the new table with new queries until the new table is completed.
This means that you need to have the space available to do this operation.
Hope it helps.
Comment: http://chronicdb.com does this too.
Answer: You might try:

Take a mysqldump w/ -e --no-create-info > source.sql
Truncate all tables
Alter all tables
source source.sql

As with all risky operations, perform in a test environment first to verify the outcome.  When you "source source.sql", if literally running from the mysql prompt don't forget to set names utf8.  If catting into mysql, run mysql w/   --default-character-set=utf8 to avoid charset weirdness from your terminal settings.
Comment: what is `source source.sql`?
Comment: It's a filename. Nothing special about the name, it could very well be called asdf.txt or RandomFileName. The point being you redirect the stdout to that file and run the source command or cat it back into mysql

MySQL - Changing DB CHARACTER SET


What does summation EVEN and summation ODD exactly mean in truth table of IC 74180 which is used as a parity generator and parity checker?

Question:
I was trying to implement parity generator for 8 bit message using IC 74180. I understand the purpose of all the pins but don't what do those two output pins namely summation(Even) and summation(odd) mean? I couldn't find any clear explanation anywhere else.
Comment: it is `sum` ... the sum of `1` bits
Comment: don't forget that the IC is a parity bit generator ... so the output is a parity bit for the input bits
Comment: Doesn't the truth table give it to you?
Answer:
The word-length capability is easily expanded by cascading.

Even and Odd come from a previous 74180 to allow more than 8 bits of parity.
∑Even will be true if all 8 bits AND Even are an even number.  Even true + 00000000 means ∑Even is true.
Even false + 00000001 means ∑Even is true.  Odd parity from previous sections and odd parity in this section means even parity.


Custom keyboard shortcuts to start menu shortcuts work only if some other random item is open first

Question: I've been creating and using custom keyboard shortcuts (Ctrl + Alt + ) to open shortcuts to apps and folders for years. They always worked. Recently, however, they only work if an app or window is already open on the desktop. I'm not referring to the app or window that the shortcut points to, but any random app or window. If the desktop is empty, (except for the usual icons, of course), then none of my shortcuts will work. If I open something, like a browser for instance, then all shortcuts work fine, but if I close everything, no shortcuts will work. Has anyone else had this experience? Windows 10 Pro.
Answer: Found it. It was NVIDIA GeForce Experience which puts it's own Ctrl + Alt + Key(s) shortcut(s) on the desktop.


How do I calculate the average coefficient of variation?

Question: I'm a biochemist and I usually compare the variability of my measurements in terms of coefficient of variation (CV) since I can "visualize" the deviations more easily in terms of percentages deviation from my mean value. Now, I measured an analyte 20 times in a sample in one month, and again 20 times the second month. Now I'd like to calculate the mean CV of those two sets of measurements. I know I can get a pooled sd and then maybe get the arithmetic mean of two means to calculate at the end mean or pooled CV, but I suppose I cannot do that, true? Can I just get mean CV (add, and divide by two?). Statisticians are usually in terms of squares, adding and square-rooting sd-s or variances, am I right? And for what is worth, I suppose also that if I combine all data in one set, I'd probably get different sd and CV?
Comment: I've added the obvious tag, on which there are several good answers (interested party!). https://stats.stackexchange.com/questions/118497/how-to-interpret-the-coefficient-of-variation is one discussion.
Comment: Do you have actual data ? Combining data of two samples and combining the statistic of say two separate samples  is a distinct issue. Pooling of raw data from two samples may give a different coeff. of variation - probabably more representative.
Answer: I don't see any special value to averaging coefficients of variation (CVs).
Ideally your CV is consistent across datasets or groups or variables in which case you can underline that fact by citing a narrow range.
Conversely, if your CV is not at all consistent an average is not informative and how to get it a secondary issue. A wider issue is that the CV is a ratio, SD/mean, and ratios are often volatile and not easily or comfortably averaged. Otherwise put, the point you make that average CVs could be calculated in different ways shows up that the notion of average CV is not well defined.
In the great majority of cases where I have seen coefficient of variation used:

The implication is that you should be working on logarithmic scale.
Or it is not really helping.

Sample data that is real or realistic for you would allow a more specific answer.
In short, getting very different results is likely to be a sign that the data need closer analysis. Ignoring the difference by averaging is going in the wrong direction.
Comment: Thank you Nick for the answer. Yes, indeed, you are right about averaging CVs when they are not so different, as they are mostly in my case, is not a big advantage. I was merely trying to "do it the right way", but I cannot find any logic in my head that would appreciate more one way or the other. My SDs and  means are mostly similar, on one or two occasions I have noticeable differences (I'm measuring set or analytes in my samples) - still clinically irrelevant. That's why I wanted to do it properly, statistically correct because I don't know of any reasons/limitations to either way.
Comment: You need to think in terms of the right model for the data, not reducing puzzling  descriptive statistics to yet more descriptive statistics. The problem could be almost anything, e.g. an outlier or outliers in one dataset not another; CV being an unsuitable reduction any way; a need to think on some quite different scale or using quite different summary statistics.
Comment: Thank you for the tag, I'm reading it right now, interesting stuff... Happy to learn some more!


Server Cloud Monitoring

Question: I'm a consultant that has around 100 clients and I would love to monitor all my clients networks, preferably from the cloud so I can tell if their Internet is down.  I would like for it to offer a lot of the same monitoring features that send alerts (similar to Microsoft's SBS product).  What's out there? Who is the defacto standard when it comes to this?  I just need some options so I can know what is going on at my client's sites!
Answer: There isn't one standard, at all. You need to define what you're monitoring for your clients and how you'll do it. If you're making sure their websites are up, a hosted solution (is that what you mean by "cloud") is probably best. The hosted monitor will hit the websites from one or multiple locations and measure the response times.
If you're doing infrastructure management or "IT Managed Services" for them, then you need to monitor their internal systems, and you probably won't be doing this from "the cloud." (Note last paragraph however.) You need VPN or other private connections to their networks and you will want to run a monitoring and alerting product from your own network. Could be free stuff like Nagios and Big Brother, or could be top-dollar software like HPOV or Cisco Works.
If their internet connection goes down, you'll get red lights all over the place because it will look like every device dropped, so that covers that. The downside is that if your internet connection goes down, you're no longer monitoring anything.
I do understand that there is some software now for Managed Services companies that involve less network requirements and just operate over agents, possibly without a VPN required. Kaseya is a name I've heard, but have no hands-on experience with.
Comment: +1. I came to suggest Nagios installed on a EC2 server, with careful firewall rules that specifically allow it to monitor necessary services for the client. It looks like you already did, in quite a few more words :-)
Comment: GFIMax has some stuff too
Comment: I used to work for an MSP, and we had Orion Solarwinds, HP SIM, and IBM Director all in our colo, monitoring our various clients that were either (or both) in our colo and at their own site(s). We had a really good networks guy :-)
Comment: If you are looking for a solution that will monitor basic networking as well server health (disk space, services, performance, hardware, software, etc.) then I would recommend EventSentry (http://www.eventsentry.com). It's a pretty reasonable price for the features it offers.
Comment: Thanks for the responses! This gives me a great jumping off point!
Answer: I would offer two suggestions for this:
1) Nagios: You can monitor as much or as little as you want for each client.
2) Spiceworks: They have made large strides lately running remote collectors and keeping tabs of network links / sites. This option works without a VPN and runs over SSL.
For either option you can run it on EC2 or which ever cloud provider you wanted.
Comment: Steve, Quick question about Spiceworks, I'm actually using this for a 250 user client of mine and it works pretty well for in house monitoring, do you know if there is a way for me to setup a server at my office and monitor my clients from my server?  I may have to use a VPN?  Thanks
Comment: @msindle yes you can have multiple spiceworks servers sending reports back to your main spiceworks server. I'm actually in the process of working it out myself.
Answer: Have you looked at Cloudkick?
Answer: Do you need to monitor server internals such as CPU or disk space? Then try cloudkick. I did not use it, but they run ads everywhere ;)
If you only need remote website monitoring, then I recommend AlertFox and Pingdom. These are powerful low-cost solutions.
Chartbeat is a good option if you need analytics as well.
Answer: For monitoring system internals (disk space, event logs, etc) PA Server Monitor can monitor a remote client site without needing holes in their firewalls or agents installed on every machine.  It uses a satellite monitoring service (essentially an agent installed on a single computer that monitors the rest of the site), and can report back to your central monitoring system at your office.

Server Cloud Monitoring


How can I download a file (fileme.us) in tor browser?

Question: How can I download a file (fileme.us) in tor browser? Whenever I click "download" does not enter the offerings so that I can complete to perform the download. It is very important if anyone knows, please help me.
Answer: This doesn't depend by Tor Browser. If you try to download a file and the site ask you for an offer there is not so much to do, the fact that the site ask you for an offer has nothing to do with Tor Browser.


Major scale picking

Question: I am practicing major scales on guitar(2 notes per string). Going from String Low E to high E, I move my pick downward for 1st note and upward for 2nd note of the string. My question is what should be the direction(upward/downward) of the pick when I play the scales reverse(from String High E to Low E) ?
Comment: What's the 2 notes per string scale pattern?
Comment: @TIm its just the basic major scale pattern
Comment: I don't know of a major scale pattern with only two notes per string - unless you are meaning major pentatonic, which can easily be picked using alternate picking. And the down/up continues providing you only play each note once, not the highest twice. But if you're talking pentatonic, it  changes the thrust of the question.
Comment: @Tim sry I forgot to mention pentatonic. you are right. Bt its not only with the scale. any time when I play something from high E to low E, I get confused which stroke to do. Its not like I cant play comfortably...I  just fear that I wouldn't end up practicing wrong.
Comment: There's usually a 50:50 with picking. Not a lot of choice. Up or down. And certainly no correct/incorrect. Two players may well do the same phrase in at least two different ways. Part of the fun is finding your own way. (I already said that!) You must give yourself every option, and you'll be a better player for it. Or, get a teacher, who may well say, do it my way - not that it's been thoroughly thought out, so you're non the wiser. No right or wrong, just differences, so get experimenting. And even your own 'rules' are likely to have to vary with each new phrase you play!
Answer: In many beginning techniques the student is taught to keep a steady down - up pattern with the pick, to develop the muscle memory of the regular rhythm. Phrases should always start with a down pick.
To work on this, you should keep playing whatever the next direction of the pick is until you end the phrase, no double picking even on string changes (no up-ups or down-downs).
When starting the scale again on the high E, you should start with a down pick and continue the down-up pattern to the end.
EDIT: for more clarity.
The technique work I'm describing works rhythmic muscle memory of the down - up motion, specifically to build a regular motion and avoid attempts to double down or double up.
You can go up the strings with an up - down pattern as long as you keep the rhythm steady and don't double pick.  You can also work just up-down, the point is to have each pick stroke alternate.
Eventually players will be able to choose whether to switch to up or down picking in a certain passage.
Comment: But I think up-down pattern is comfortable for me starting from high E. So if I go with up-down instead of down-up will I have a problem while learning advanced stuff or playing at high tempo?
Comment: too long for a comment, I edited the answer.   The slow down or inability to have a fast tempo comes in if a student has taught themselves "false" ups or downs.  I usually teach the regular up down pattern until the student has it steady, then add in down-down-up picking for triplets and 6/8 picking.
Comment: Taking a strum pattern like that in 'All my Lovin'' (Beatles),(12/8) alternate sounds so much better, and it's easier to execute. Any other sounds stilted. It just needs a new thought idea that the second and fourth 'beats'of the bar have  accented up stums.
Comment: @Tim  I prefer the accented up strum on 4 for accompanying Jigs in 6/8 time as opposed to the more traditional down down up pattern, too.
Answer: This is something you really need to sort out for yourself. There are going to be anomalies in picking direction at some point in whatever anyone chooses to play. There will be times when the well revered alternate pick routine just needs to be changed, albeit for one stroke.
Part of the fun of learning something is to find your own way, rather than be guided by others. This is one such instance. Try alternatives, and if it works for you, stick with it.
Comment: One of the technique issues I've had to correct in students, especially ones that were self taught, was their having problems with consistent strumming or fast / clean picking.  In these cases the students had learned to aim a pick stroke or strum by following a rhythm pattern using a double down or double up picking without being able to keep a steady up down pattern.  The technical issues usually cleared up after they worked getting a regular pattern in their hand. This is why I advocate that beginners learn a regular steady picking and strumming pattern first, before working the anomalies.
Comment: @AlphonsoBalvenie - I certainly agree with the problem in strumming rhythms, and have had to sort out many that occur with this self-taught concept. However, with individual note picking, the problem may well not be solved by alternate picking, as is is more dependent on which string particular notes are played on - and that can vary as alternative strings can be used, and often, the pick takes the wrong direction for the next note on a string on the wrong side. As a self learner, I spent hours working out best pick sequences, - more often than not, they worked better without alternate picking
Answer: Practise it down up strokes
Practise it up down strokes
Then practise it starting on each of your four LH fingers. There will be different numbers of notes on the strings.
Then you'll be ready for anything.

Major scale picking


Using CountVectorizer in Python Mapper Reducer

Question: I am trying to apply tokenizer using python mapper reducer function. I have following code but I keep getting error. reducer outputs values in a list and I am passing values to the vectorizer.
from mrjob.job import MRJob
from sklearn.cross_validation import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer

class bagOfWords(MRJob):

def mapper(self, _, line):
    cat, phrase, phraseid, sentiment = line.split(',')
    yield (cat, phraseid, sentiment), phrase

def reducer(self, keys, values):

    yield keys, list(values)

#Output: ["Train", "--", "2"] ["A series of escapades demonstrating the adage that    what is good for the goose", "A series", "A", "series"]

def mapper(self, keys, values):
    vectorizer = CountVectorizer(min_df=0)
    vectorizer.fit(values)
    x = vectorizer.transform(values)
    x=x.toarray()
    yield keys, (x)

if __name__ == '__main__':
    bagOfWords.run()

ValueError: empty vocabulary; perhaps the documents only contain stop words
Thank you for any help you guys can provide.
Answer: The CountVectorizer is stateful: you need to fit the same one instance on the full dataset to build the vocabulary hence this is not amenable to parallel processing.
Instead you can use the HashingVectorizer which is stateless (no need to fit, you can call transform directly).


does the orientation of a choke in an LVDS application matter?

Question: I found the diagram below online while looking for information on the orientation of a choke I intend to use in an LVDS application. Does the orientation of the choke matter? The part I intend to use is the 744233121 by Wurth Elektronik. The chokes will be located right before the FPC connector on my PCB to which I connect the off-PCB display module.
Comment: What do you mean by "orientation"? I guess what matters is that the dots are on the same side.
Comment: @DmitryGrigoryev the dots pointing towards the LVDS drivers in (c), or pointing towards "off-board"
Comment: The dots which represent mutual inductance polarity. Quite obviously, the mutual inductance should work against common mode currents.
Comment: @DmitryGrigoryev so is the orientation of the component important or not?
Answer: The dots show the orientation of the two coils relative to each other. When the dots are on the same side, this means that the windings are negatively coupled. This is always the case for a common-mode choke (see this article for details).
The coils are just pieces of wire wound onto a core; the current behaves identically when flowing through them in either direction. (The only thing that matters is whether the currents in the two coils flow in the same or in the opposite direction.)
These dots are shown in the schematic symbol, but are not marked anywhere on the actual device, and the datasheet does not specify how to detect the orientation:

Some datasheets will explicitly say this:

The orientation does not matter, and even if you wanted to, you would not be able to choose any specific orientation.
Comment: Once I had a customer who soldered all CM chokes in 90-degree position, on USB traces. They were complaining that our product doesn't work ... :-)


Unsupervised pre-training for Reinforcement Learning

Question: Since the advent of many unsupervised learning methods, as a pretraining step for the main supervised task (mostly under the name of Deep Learning), it shouldn't be strange to ask, what is the current state of "pretraining and learning from unlabeled data, for Reinforcement Learning"? Any recent/old works on this? Any suggestions for future work?
Answer: I think, you should look into the Learning from Demonstration direction. The idea is pretty simple. Let's say, we want to teach a bot to play a video game. We record a human playing the game, and give the model this data in order to pre-train it then.
There are lot's of possible ways of using this data. If you are interested in the unsupervised pre-training, you should look into the Inverse Reinforcement Learning (IRL) direction. In two words, the method tries to approximate the reward function and does the usual RL with this approximation along the road.
I'm not aware of pre-training in the IRL, but it should be possible and interesting for the investigation, from my point of view. These are some well-known works where you can start: Algorithms for IRL by Andrew Ng and Stuart Russel, and Apprenticeship Learning via IRL by Peter Abbeel and Andrew Ng.
In case you have the reward function in addition to actions, you might do a lot of interesting stuff with it, including pre-training. This work is one of the latest on the topic, and one will find much more interesting stuff in the References.


About the derivation of a composite quaternion

Question: This problem has been bothering me for several days, hence I decided to ask you for help.
I am reading the book "Quaternions and Rotation Sequence" written by Jack B. Kuipers. In section 6.4, the author derives a formula of a composite rotation quaternion. One of the steps of this derivation is difficult for me to understand.
I would like to briefly describe the derivation process as follow:
Consider a tracking problem as in this picture.
(I am sorry I have to use links instead of posting pictures directly because this is the first time I post a question here so I am not eligible to do so yet)
In the picture, XYZ is a global, reference frame. 2 successive rotations are performed:
The first one is a rotation about the Z axis through an angle alpha, transforming frame XYZ into a new frame x1y1z1.
The second one is a rotation about the y1 axis through an angle beta, transforming frame x1y1z1 into a new frame x2y2z2.
The goal is to find a single composite rotation quaternion which is equivalent to the two rotations above.
The author does this as follow. The first rotation can be represented by the following quaternion p:
p = cos(alpha/2) + k*sin(alpha/2) (1)
In this formula, k is a standard basis vector (we have vectors i, j, k in R3 corresponding to the axes x, y, z respectively).
The second rotation can be represented by the following quaternion q:
q = cos(beta/2) + j*sin(beta/2) (2)
The composite quaternion we are looking for is the product of these 2 quaternions: qp. The formula of this product is in this picture.
In order to derive this final formula, the author uses 2 assumptions about the standard basis vectors i, j, k, which are: k.j = 0 and k x j = -i. And this is where I dont understand.
We all know that, for a set of 3 mutually orthogonal vectors i, j, k, these 2 assumptions above are correct. However, vector k in (1) and vector j in (2) don't belong to the same coordinate frame. In other words, k in (1) corresponds to Z in frame XYZ, and j in (2) corresponds to y1 in x1y1z1. And these are 2 different, distinguish frames, so I think the second assumption used by the author is incorrect.
What do you think about this? Any answer would be appreciated. Thank you.
Comment: This question is more for [Math.SE](http://math.stackexchange.com/), not StackOverflow.
Answer: author uses 2 assumptions about the standard basis vectors i, j, k...
it is not assumption!
You not understand cross product and dot product see
http://en.wikipedia.org/wiki/Cross_product
http://en.wikipedia.org/wiki/Dot_product
3 mutually orthogonal vectors i, j, k
orthogonal vectors.... What is it(definition)?
Dot_product... What is it(definition)?
Can we define orthogonal vectors via Dot_product?
You must learn a basic of Linear algebra and Complex analysis  before understand quaternion.


Narrow Gauge HSR

Question: Would it be possible to build a High-Speed Rail on narrow gauge by making it electric (low centre of mass due to battery weight = higher stability) and reducing the friction on the wheels (lubricant?)? Would this help countries Africa integrate all of their territories better (integration = political stability = economic development) at a low cost, so as to not drown them in debt? Also, I realise that for the battery to increase stability in every cabin, each cabin would have to be able to drive independently. (maybe spftware engineering can help make all the train cars start at the same time?)
Comment: How will it deliver the tractive force if you lubricate the wheels?
Comment: This looks like a ['Novel Idea' question](http://meta.engineering.stackexchange.com/q/311/1832). Such questions tend to become moving targets and lead to discussions, neither of which are a good fit for our format. See if you can [edit] your question to make it specific and answerable.
Comment: you're trying to save money on what?  the Sleepers (ties) size?  The reality is that no one is going to build a railroad of a different gauge than the one already in use.
Answer: No need to lubricate the wheels, the rolling resistance of a steel wheel on a steel rail is already very low; the main forces at work are the gradients, inefficiencies the traction system (motor, gears etc.) and air resistance.
Non-standard track gauges mean a reduced carrying capacity, and greater cost of rolling stock, as you no longer have the economies of scale, and access to a vast second-hand market for engines, carriages etc.
As for the stability, the ability of a standard-gauge train to remain on the rails, despite wobbly track, and elderly rolling stock, is quite remarkable; if you were in the UK, I'd refer you to the 1938-vintage trains on the Isle of Wight, which until recently gave a hair-raising ride without coming off the rails, but there will probably be plenty of examples in your country.

Narrow Gauge HSR


Client's Personally Identifiable Information (PII) in the Cloud

Question: Is it safe to put a client's personally identifiable information on Microsoft's Office-365, or another Cloud provider storage?
Comment: Depends on what it is. If it's HIPAA or PCI, you need to do a lot more investigating with the vendor itself than just asking a question on SE. Many of them have special services to address security concerns related to either standard.
Comment: Depends on your location, the location of the data subjects and as such the applicable legislation. E.g. huge difference between Europe and US.
Answer: Cloud services such as Office 365 can be far safer than using your own or a suppliers data centre facilities.
So yes, you can of course put client data on cloud services. But will they be happy? Hmm. And will you be meeting their regulatory requirements?
Well only you/they can answer that.
Look for security certifications related to the regulatory environment your client has to work in. Get buy in from the Information Owners by carefully explaining the benefits, risks and mitigations. Look for other similar organisations that may have followed the same journey. Check with relevant government agencies on their views.

BTW, Office 365 is particularly good at this. Their certifications are second to none and they have world class security processes. Microsoft really understand government and enterprise security requirements.
Comment: Thanks for responding.  This is a federal agency following FISMA.  Sensitive PII is not authorized on our servers.  I know that Microsoft says its O365 servers have encryption but still recommend to the system owner to encrypt that sensitive data.   Peace of mind!    Thanks!
Comment: No problem. Worth also remembering that O365 now offers additional user specified keys for encryption and a data lockbox capability - at some additional cost - but still, it adds extra security if required. Whatever you may think of them, MS have worked hard to capture the government markets and certified security is very high on their list of things to get right. (In case you are wondering, I *don't* work for them).
Answer: It depends on what regulatory requirements you have and whether the cloud hosting provider meets those standards. PII is not a standard, it's a classification of data. As a result, you won't find a cloud offering claiming to be PII Compliant.
Instead, determine the regulatory requirements you need to abide by (PCI-DSS, ITAR, HIPAA, GLBA, ISO27K, etc) and base your decision on whether the provider you're looking at complies with those standards.
You'll also need to determine whether you want dedicated hosting or shared hosting. In other words, some standards require dedicated hardware for your services and applications rather than shared-tenant hardware. Keep that in mind as it may affect your decision and definitely affects your cost.
Comment: See comment above.  Agree with you.  This is not a dedicated hosted site so the sensitive data would be somewhere in the Cloud "La-La-land". If encrypted with strong encryption it would be safe.   I know encryption is a hassle sometimes but it beats losing the data.


Quantifier Notation

Question: What's the difference between $\forall \space x \space \exists \space y$ and $\exists \space y \space \forall \space x$ ? I don't believe they mean the same thing even though the quantifiers are attached to the same variable, but I'm having a hard time understanding the difference. Any examples to make the distinction clear would be appreciated.
Comment: This is definitely not a question about notation.
Comment: Ok my bad, I didn't check if there was a quantifiers tag, so I guess that's what should have been selected.
Comment: @AsafKaragila: I don't see why not? A convention is implied here: one has to read from left to right. If the convention had been different the notation would have had a different meaning.
Comment: @Raskolnikov:  Sure, everything fits the [notation] tag because everything depends on the way you read it...
Answer: Consider this example.
For all $x\neq 0$ there is a $y\neq 0$ such that $xy = 1$.
There is a $y\neq 0$ such that for all $x\neq 0$ you have $xy = 1$.
You can probably see that the one statement is true and the other false.
Answer: One reads "For every $x$, there exists a $y$...", and the other says "There exists a $y$, such that for every $x$..."
An example of the difference can be found by making the (totally non-mathy) statement:
$$\forall x \;\exists y \text{ s.t. $x$ loves $y$}$$
That is, everybody loves at least one other person.
On the other hand:
$$\exists y \;\forall x \text{ s.t. $x$ loves $y$}$$
That is, there is a person that everyone loves.
Does this make the difference a bit more clear?
Answer: Every natural number has a successor. There is no natural number which is the successor of every number.
Answer: A quick summary of the essential parts of what others have written: $\forall x\,\exists y$ allows $y$ to depend on $x$; $\exists y\,\forall x$ requires the same $y$ for all $x$'s.
Answer: $\forall m \exists k  | k>m$   which in plain English means: For any integer, there
is another integer greater than it.
$\exists k \forall m  | k>m$   which in plain English means: There is some integer
that is greater than every integer.
The only difference is the order of the quantifiers, but the meaning
is MUCH changed. In fact, the first is true and the second is false. I
am NOT saying that one is the correct order and one is the incorrect
order.  They are just statements that say different things.
source : Link
Answer: Everybody has a nose, but there is no nose that belongs to everybody.
Answer: You really should read some of Daniel Velleman's How to Prove It, 2nd ed. He discusses this kind of stuff in the beginning of his chapter 2. (Chapter 1 is short, covering sentential logic.)
Answer: There has been a lot of clear examples given as answers.
So, not giving any example but trying to make a stronger sense:
You can regard the quantifiers part of your formula as a bound. Therefore, comparing $\forall x \exists y$ vs $\exists x \forall y$, you should consider the first one as "first bound your formula by $x$ and then relative to $x$, bound it by $y$". For the second one, the matter must be obvious(interchange $x$ and $y$ in the quotation marks). Consequently, these two different ways of bounding are not necessarily the same.
Answer: One is, "for each x there is a y, the other, "there is a (single) y for all x."  It is a "uniformity difference".
Comment: "there exists x" doesn't necessarily require that x be a single, unique entity.
Answer: As others have pointed out one says "for all x, there exists a y such that..." while the other says "there exists a y, such that for all x..."
An operation O on a finite number of elements can get described by its operation table:
<code>  O  a  b  c ...
  k
  j
  l
  .
  .
  .
</code>
with the points where horizontal and vertical lines intersect describing the value of O(x, y) at point (x, y).
Thus, if we have a "for all x, there exists a y such that O(x, y)=z" statement, that means for any input from k, j, l... there exists a single input from a, b, c ... such that O(x, y)=z.  A "there exists a y such that for all x, O(x, y)=z" statement means that for a single input from a, b, c, ... all elements from the k, j, l ... satisfy O(x, y)=z.
To understand this a little more concretely consider this operation table
<code> A  0  1  2
 0  2  0  1
 1  1  0  2
 2  1  0  2
</code>
We have that for all x, there exists a y such that A(x, y)=2.  Here, if x=0, there exists the y=0, such that A(x, y)=2, if x=1, there exists y=2 such that A(x, y)=2, and if x=2, then y=2 such that A(x, y)=2. Similarly, if you have a "for all x, there exists a y such that O(x, y)=z" statement concerning a binary operation, then for each row of its operation table there will exist an element y such that x and y will intersect at element z.  Thus, z will appear at least once in each row.  Symmetrically, if we have a "for all y, there exists an x such that O(x, y)=z" statement, then z will appear at least once in each column.
On the other hand, for operation A we have that there exists a y, such that for all x, A(x, y)=0.  In this case, y=1.  Similarly, if you have a "there exists a y, such that for all x, O(x, y)=z" statement concerning a binary operation, then its operation table will have a single element z which appears throughout at least one column.  In a symmetrical manner, if we have a "there exists an x, such that for all y", then its operation table will have single element z which throughout each row.  See the difference?

Quantifier Notation


Matlab Bayesian Newtork toolbox and continuous values

Question: I have two problems, one about theory and one about implementation:
Theory First I have not fully understood how to work a Bayesian network with continuous values. I have learned that I can approximate P(A) (the probability of node A) with a Gaussian Distribution. But I have a dataset, mean and variance of the Gaussian Distribution is the mean and the variance of the dataset ?
And if I have P(A|B,C), with A and B with continuous values, how I can represent this with a Gaussian Distribution?
The practical problem is that I need to learn a Bayesian Structure from a continuous valued dataset and I use this toolbox for Matlab: http://code.google.com/p/bnt/ (Bayes Net Toolbox for Matlab by Kevin Murphy)
Now how I can use to learn a Bayesian Structure from a dataset (of continuous values) with this tool?
If I use the learn_struct_K2 function I need the order of nodes but where can I get this order? Are there other useful functions in this toolbox that you know of that can aid me with this problem?
Answer: Hope this link will help you,
http://www.mathworks.com/matlabcentral/fileexchange/13562-structure-learning-package-for-bayes-net-toolbox


Lavinia, Azorius Renegade vs Kalia of the Vast and friends

Question: If Lavinia, Azorius Renegade is on the field, and Kaalia of the Vast attacks me, when Kalia's effect puts a creature onto the battlefield from the hand, is it countered by Lavinia's second effect? What happen in case of Mayael the Anima and Golos, Tireless Pilgrim?
Answer: Lavinia affects Golos's activated ability, but not Kaalia's ability or Mayael's.
Both Kaalia and Mayael put creatures onto the battlefield directly. They do not have you cast anything, so Lavinia's ability is never relevant.
Golos's activated ability, on the other hand, allows you to play cards without paying their mana costs. Rule 701.13b defines what exactly that means:

To play a card means to play that card as a land or to cast that card as a spell, whichever is appropriate.

So, if you exile any nonland cards, you can cast them without paying their mana costs. This exactly what Lavinia is looking for, so her last ability will counter any spells cast this way.
Of course, if you exile lands with Golos, you can still play them as lands. In this case you are not casting anything so Lavinia's ability doesn't do anything.

Note that when casting spells without paying their mana costs, players can still pay any additional costs that may apply, and if they pay mana to do so Lavinia's ability will not counter the spell because some mana was spent on it.
Comment: It's important to make *some* assumptions, so that an answer can focus on the core issue of the question. I could spend all day going into detail about targeting, hexproof, the stack, and activating and resolving abilities, but I think I can safely assume that the reader understands most of that, and I think that including it would ultimately detract from the answer.
Comment: I think you should clarify that it affects Golos' second ability. Golos' ETB trigger is not affected.
Comment: OK, I added a mention of that but I think it's pretty clear that Golos's first ability is not relevant here.
Comment: @murgatroid99 never assume always be explicit, when dealing with new players that distinction may not be made.
Comment: Also maybe worth explicitly noting that you can still play land cards via Golos's activated ability.
Comment: And of course, with Protection having made a return, things are influenced by that as well.


Comprehensive overview of loss functions?

Question: I am trying to get a global perspective on some of the essential ideas in machine learning, and I was wondering if there is a comprehensive treatment of the different notions of loss (squared, log, hinge, proxy, etc.).  I was thinking something along the lines of a more comprehensive, formal presentation of John Langford's excellent post on Loss Function Semantics.
Answer: The Tutorial on Energy-Based Learning by LeCun et al. might get you a good part of the way there.  They describe a number of loss functions and discuss what makes them "good or bad" for energy based models.
Answer: Well, there's this and that. Two papers by Cramer and others discussing loss in the context of online learning algorithms.
Answer: The loss function is given by the problem. It could be anything. For example, you could also penalize the used CPU time and space.
In reinforcement learning, the loss function is an unknown non-deterministic function.
You cannot redefine it without changing the problem.
Answer: I know this question is sort of dated, but it is something I am currently interested in.
A very good paper on the topic of convex loss functions and classifier consistency is "Statistical Behavior and Consistency of Classification Methods Based on Convex Risk Minimization" by Tong Zhang.


Does a malware in an android phone have permission to read/modify/delete data of all the apps?

Question: If an android phone is infected with malware/virus, can it access all the apps with modify/delete/read permission? Isn't there any control by an app , say a bank app which can't allow to read data by any other program?
If there is a different answer for an iphone, please share it too.
Answer: Most android malware will steal information or spam your phone with aggressive ads. But they do not necessarily modify any installed apps on the phone. If a phone is rooted, the malware can, however, uninstall apps and replace them with malicious app copies. The following link gives an overview of many of the known android malware capabilities.
http://forensics.spreitzenbarth.de/android-malware/
Answer: Not necessarily
Operating systems in general and Android specifically, implement a privilege model to access data (When you install an app, you can decide which permissions you want to give it. You can also edit those permission later on). If an application is taken over by a malicious piece of code, it will have the same privilege level as the affected application.
If the affected app has permissions to read file content, the malware can definitely access some data of other applications (For e.g. file explorer applications cans show you your whatsapp photos). It is a good practice for applications to avoid storing sensitive data in files but if they do have to, then encrypt it.
Of-course, all of this doesn't stop the malware from exploiting a vulnerability to gain root privileges but that is a different issue.


How do we perceive colors outside our gamut?

Question: Let's take an CIE XYZ color space as an example.  There are many colors that are outside our gamut - how do we see such a color?
Comment: Poss. related: http://physics.stackexchange.com/questions/18557 and http://physics.stackexchange.com/questions/15563. If you're just asking about colour perception this isn't treally a physics question.
Answer: You will see a slightly different colour inside your colour gamut if this is a visible colour, or nothing if it is not.
Consider a monochromatic 300nm light; this is below our 380/400nm lower frequency limit, so it will be invisible. A bichromatic light consisting of 50% 300nm light and 50% 700nm light will just look like a dim red light, as the 700nm light is being absorbed by the red cones in your eye.
All you have to do is calculate the dot product of the colour's spectrum with those of the red, blue and green cone response curves, to get 3 values for the red, green and blue. Normalize and you have a colour index that you can compare to other colours.
You can only see colours inside your colour gamut, by definition. So everything else is either invisible, or turned into something inside that gamut.
There are some interesting effects in low light, when your rods are active, but the only colour you can mix with that greyscale vision is red as rods are insensitive to it. A small proportion of the female population supposedly are tetrachromats, as they have different cone genes on each X chromosome, giving them four types of cone instead of three. Though their gamut would be larger, and have an extra dimension, they too would only see what is inside their gamut.
Answer: Possibly with afterimages.  Near where I live there's a broad bunch of vividly magenta flowers along the sidewalk.   I stare at them for a minute, then look at the surrounding green trees, bushes and grass.  The kinds of green I perceive are probably not reproducible by any physical means without afterimage effects taking place.
Comment: I believe afterimages are simply a result of saturation of the cones, and the resulting lag in their response to intensity changes. The colours you see in an afterimage are still just some combination of red, green and blue, so although it looks strange, it is probably reproducible.
Comment: @PhilH: The R/G/B receptor response curves are not orthogonal, which means that some extreme responses can only be caused by saturating some cones. I.e. here it seems the blue cones are saturated, and then the green surroundings don't trigger them at all.
Comment: @MSalters: Ok, I can believe that there is more to it than independent cone saturation, but regardless of why they are firing or not firing, the signals come from your existing cones, so the brain interprets them as colours just as if there was a light of that colour. My point is that after-images just produce other colours from the same gamut.
Comment: @PhilH: You're still assuming that any brain input could have been created by light of a specific color. That's not true. Simplified: if the R sensitivity at G wavelengths is still 0.1 relative, a brain input of R=0, G=1 cannot be created by pure green light but only by first saturating the red cones and then watching a pure green light. That would be "greener than green" as mentioned in the answer above.
Comment: I see what you're saying now, I didn't get any of that from the answer. Also interesting might be perception of blue without perceiving red, as red cones have a blue peak as well; this could be what we call violet.
Answer: You start by talking about the xyz space. So I assume that you are wondering what kind of colors lie outside of that typical 'horse-shoe' shape.
As Phil H. explains, the XYZ shape is indeed defined by three color response curves (inspired by the human vision). So, the XYZ values are already 'confined' within the limitations of the human visual system.
So, where does that horse-shoe come from then?
Notice how these response curves overlap. In other words: Any wavelength that triggers the green receptors, will also trigger to some extent the blue or red receptors. So, not every XYZ combination can be achieved with a color spectrum. It's this overlap that defines the horse-shoe shape.
Inside the horse-shoe, you have XYZ values for which there exists at least one color spectrum. Outside of that horse-shoe, are XYZ values that could only be reproduced with a spectrum that is (partially) negative: physically impossible colors.


Why didn't Thor show concern for His friends?

Question: In Thor Ragnarok we see that the warriors three were slain, and Lady Sif was absent for other reasons. Being that they were close, why didn't he at least ask for them or show any concern about them; being that He wasn't present to any of the warrior's three deaths.
Comment: The Viking way was to expect death, and revel in it as a gateway to Valhalla, not to mourn the fallen.  Viking culture was modeled after Asgard (internally, or in RL Asgard was modeled after Nordic myth).  Why would we expect Thor to mourn fallen heroes?
Comment: Im asking this because in Thor 2011, we see thier conversation about their numerous journeys and fellowship. Seeing this level of camaraderie shouldn't this be a level of concern for him. One may easily assume Hela may have dealt with them but even after her demise on the ship these are questions He could have regulated to Heimdall.
Comment: This was something that definitely bothered me about the film. It was almost like, why have the Warriors Three at all if you're going to kill them in ten seconds and have no one care about it?
Comment: Because in war people die and Thor knows that
Comment: But He mourned His mother, Father, even Loki when he faked his death. Why it is true that it is expected in the Viking culture; The Viking culture does also mourn but just in a different way. To not mourn his closest friends or not even show the slightest concern was a little far fetched in my opinion.
Comment: He was busy fighting Hela, maybe that's why?
Comment: After the Miek fake-out, maybe he was too gunshy to ask about anyone else?
Answer: He didn't have time?
Sequence of events:

He arrives on Asgard after being absent for years (since the end of Thor 2: The Lost World) and identifies Loki as impersonating Odin
Then immediately leaves with Loki to Midgard (Earth).

 3. Then finds Odin (with help).
 4. Then encounters Hela.
 5. Then gets dumped on Sakaar.
 6. Then goes through the giant worm hole back to Asgard.
 7. Then immediately confronts Hela.
 8. Then evacuates the few survivors.
 9. Then Asgard is destroyed.

Probably when the dust settled and things calmed down on the ship (right before Thanos arrives) he started asking about other Asgardians, and learned of the deaths of his three companions, but he really didn't have time up until then.
Comment: You forgot "He gets a haircut by Stan Lee" :P