Prove that a sentence is a tautology using resolution

Question: I have the following sentence.
$(A ∨ (B ∧ C) ∨ (¬A ∧ ¬B) ∨ (¬A ∧ B ∧ ¬C))$
I am having difficulty understanding how to apply the resolution method.

What (I think) I know so far:
In terms of resolution as it applies to my problem, it seems I am considering the resolution technique (of propositional logic).
Given the resolution technique in the following form:
$$\underline{\{Q ∧ O\} \  \{¬O\}}$$
$$Q$$
To put it in my own words, the resolution technique reduces a sentence to a set of clauses of literals and considers which what the value of each literal would have to be such that the conjunction of each clause would be true. So in my cause I need to:

Rearrange my sentence to a set of clauses.
Determine the value for each literal, using the technique above.
Use the information from step 2 to determine weather the sentence is a tautology (I don't know how to do this).

Am I on the right track? Any tips?
Answer: See Resolution (logic) :

the resolution technique uses proof by contradiction and is based on the fact that any sentence in propositional logic can be transformed into an equivalent sentence in Conjunctive Normal Form.

1st step :

the negation of the sentence to be proved (the conjecture) is to be considered.

In your case, we have :

$$\lnot [A ∨ (B∧C) ∨ (¬A∧¬B) ∨ (¬A∧B∧¬C)] \equiv [¬A ∧ (¬B ∨ ¬C) ∧ (A ∨ B) ∧ (A ∨ ¬B ∨ C)].$$

As said above, the proof procedure works by contradicition : assume the formula $\lnot \varphi$ (where $\varphi$ is the conjecture) and apply iteratively the rule.
If the procedure gives us as result that the formula $\lnot \varphi$ is unsatisfiable, we can conclude that the original conjecture ($\varphi$) is a tautology.
2nd step :

the sentence is transformed into a Conjunctive Normal Form with the conjuncts viewed as elements in a set, $S$, of clauses, where a clause is a disjunction of literals.

Thus, the formula above will correspond to the set of clauses :

$S = \{ ¬A, (¬B ∨ ¬C), (A ∨ B), (A ∨ ¬B ∨ C) \}$.

3rd step :

The resolution rule is applied to all possible pairs of clauses that contain complementary literals. After each application of the resolution rule, the resulting sentence is simplified by removing repeated literals. If the sentence contains complementary literals, it is discarded (as a tautology). If not, and if it is not yet present in the clause set $S$, it is added to $S$, and is considered for further resolution inferences.
If after applying a resolution rule the empty clause, $\square$ (or : $\bot$), is derived, the original formula is unsatisfiable (or contradictory), and hence it can be concluded that the initial conjecture is a tautology.

We have to apply the rule to the set $S$ above :
1) $¬A$
2) $¬B ∨ ¬C$
3) $A ∨ B$
4) $A ∨ ¬B ∨ C$
5) $B$ --- from 1) and 3)
6) $¬B ∨ C$ --- from 1) and 4)
7) $¬C$ --- from 5) and 2)
8) $C$ --- from 5) and 6)

$\square$ --- the empty clause : from 7) and 8).

The rule has the property that preserves satisfiability, i.e. the new set of clauses is satisfiable iff the original one is.
Thus, if after iterated applications of the rule the empty clause  is produced, being it unsatisfiable (the empty clause in another way of representing a contradiction) this is enough to conclude that also the original set of clauses is unsatisfiable.
Comment: >the negation of the sentence to be proved (the conjecture) is to be considered.
@Mauro would you mind adding a little bit of clarification to this point?
Comment: my reference text is "Language, Proof and Logic" (J. Barwise, J. Etchemendy). I know see that "To show that a sentence is logically true, we need only show that its negation is not satisfiable" p 492, task 17.35, so I missed this piece of information.
Comment: @Oscar - perfect: that property is the key-point of resolution proof procedure :-)
Comment: yes, that property was certainly not a good piece of information to have missed. But thanks to your help I am now aware of it :) Thanks for the very thorough answer, I will review it shortly


Check Enum values by label

Question: Having something like this (example):
enum {
  label1,
  label2,
  //label3,
  label4,
  total}

Is it possible to check if any of the labels are present?
I need the total value in order to create matrices of the correct size, but need to know which of the labels are present in the list in order to perform operations specific to each item.
Comment: Not really possible in a sense you cant do Enum::label3 == undefined. Use list of strings or a smarted Enum class
Comment: It sounds like an enum might not be the best thing to use in your situation.
Answer: Try this:
enum My_Labels
{
    label1,
    label2,
    // label3,
    label4,
    total
};

static My_Labels check1 = label1;
static My_Labels check2 = label2;
static My_Labels check3 = label3;
static My_Labels check4 = label4;

You should get a compilation error for any missing elements.
Also, if you comment out label3, the value of label4 changes.

Check Enum values by label


Terraria Invalid Housing?

Question: Alright, so I made this really nice house in Terraria, I'll provide pictures to help. So the left side of the house says the housing is valid and the left side is symmetrical to the right side exactly. But the right side says the housing is invalid! I'm super confused of what might be happening...

I'm currently standing in the right side where it says invalid housing, but directly on the left side it's valid housing and someone is living in it too.
Comment: Is there a chair in that room?
Comment: Also how is there two people living in the same room? (2nd from the top on the left)
Comment: @Aequitas - it looks like the game is trying to center the icon for the room that curves around the left of the building.  Just a quirk of a non-square room I think.
Answer: From your picture, it looks like the only stipulation you might be violating is the Corruption limit. That side of your house might be too close to the Corruption. As a test, try making a small house down on the ground to the right of your current house and then check if it is valid housing.

Terraria Invalid Housing?


Python/Flask - Reference Textfile IN a Javascript File

Question: This is simple if I was doing it in static html files, but as i'm working with Flask it is surprisingly difficult.
I have a html page which correctly includes a Javascript file. This java script files has an AJAX function that will read a textfile.
Does anyone know if I can reference a textfile in Javascript within a Python flask webapp?
HTML:

JS:
function alertFunc() {
  $.ajax({
      url : "/Users/me/myfile.txt", //I believe this is the issue!
      dataType: "text",
      success : function (data) {
          $("#div1").html(data);
      }
  });

I have put a test function in this JS file and it works so there is no issue with linking the HTML page with the JS page.
Answer: add your .txt file to your static folder
then point to /static/my.txt
or add an endpoint (@app.route('my_text.txt')) and return it ...
its really easy... im not sure why you had the dig on flask ... I think its just as easy in flask as html and your powers in flask are much greater than simple html ...
main.py
from flask import Flask,render_template

app = Flask(__name__)

@app.route('/')
def hello_world():
    return render_template('index.html')

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

static/main.js
function alertFunc() {
    $.ajax({
        url: "/static/my_text.txt",
        dataType: "text",
        success: function (data) {
            console.log(data)
            $("#div1").text(data);
        }
    });
}

static/my_text.txt
just a simple message

templates/index.html

Comment: I have already tried adding it to the static folder!, but referencing a txt file within JS file is not working in this manner: {{ url_for('static',filename='my.txt') }}
Comment: Ok so I understand how to put it in the static folder, but can you give me a clear example of how to reference the text file in JS?---------- URL: /static/my.txt ??
Comment: Thank you! I cant believe it was that simple!!


how to insert a matrix within another matrix in matlab

Question: We have a data set X n*m matrix and I want to create a matrix like this W=[0 X;X' 0]
how should I do that in Matlab?
   A=[1 2;3 4];
   B=[0 A;A' 0];

what's wrong with that code?
Comment: A is 2x2 and the 0 only 1x1 so the dimensions dont add up. `B=[[0;0] A;A' [0;0]];` would create a 4x3 if that was your goal. `B=[zeros(2) A; A' zeros(2)]` if you wanted a 4x4 but in every case you have to add enough 0s to match the dimensions.
Answer: A possible solution using kron:
A = [1 2; 3 4]

result = kron([0 1;0 0], A) + kron([0 0;1 0], A');

result =

   0   0   1   2
   0   0   3   4
   1   3   0   0
   2   4   0   0

Answer: You just need to use zeros to make sure the dimensions agree
A = [1 2; 3 4];
z = zeros( size( A ) );
B = [ z, A; A', z ];

Answer: Because the size of 0 is not the as A and A' in row and column.
You can create a matrix with the size of what you want:
B = zeros(2*size(A));

and replace the value where you want:
B(1:2, 3:4) = A;
B(3:4, 1:2) = A.';


Can I use a motion sensor to control fluorescent lights that are plugged into an outlet?

Question: In my garage, the light switch by the door is wired to an outlet on the ceiling. I've got two, inexpensive 4' fluorescent lighting fixtures plugged into that outlet. I know that wiring a fluorescent light to a motion sensor directly can be tricky. I don't know if that applies to an outlet.
Is it safe to switch out the switch that controls the outlet with a motion sensor like the Leviton "Occupancy Sensor"?
Comment: Links broken to Leviton sensor.
Comment: Fixed the link. Apparently, my copy/paste skills could use some work.
Comment: The specifications on this particular motion detector say "The PR150 installs in place of a single pole switch, and it can be used with incandescent and fluorescent lighting (Rapid Start Magnetic ballast ONLY)."  Newer ballast are gonna be electronic.  Watch for that.
Answer: It shouldn't be a problem, if you purchase the proper motion sensor. When shopping, make sure the sensor specifically mentions compatibility with florescent lights.
The Heath Zenith Occupancy Motion Sensor Wall Switch

Controls up to 500 Watts incandescent and 400 Watts fluorescent
  lighting

According to it's documentation.
You can pick one up at Home Depot for ~$15.00 or Amazon for $32 USD (2018).
If you shop around, you can also find sensors that work with compact fluorescent lamps (CFL). Like this one from Hubbell Building Automation, Inc..
Comment: @Steven That just means you have to keep moving while you're in the garage. No standing still, you're supposed to be working.
Comment: Compatibility is for the balasts, but ultimately, if you flip a fluoro on/off over and over without some time inbetween cycles, the bulb and other components will have short lifespans.
Comment: For the motion sensor part, I'm just looking to have the lights automatically turn on when I'm carrying stuff to and from the car. If I'm actually working out there, I'd flip it over to manual. Of course, I'd like tho think that I'm active enough when I'm working that they'd stay on anyway....
Answer: Like everybody is saying, look at the box.  Some older technology will say for fluorescent with magnetic ballast only, but now all ballast sold in US and probably most countries are electronic now, so know what you have for a ballast when you buy.
There are 2 different types of technologies most used for commercial use.  PIR or Passive InfraRed which looks for body heat, and Ultrasonic which actively sends out ultrasonic waves and then measure movement by calculating the difference in previous waves.
I would look for dual-technology sensors that takes both technologies and combines them into one sensor.
Fluorescent and motion sensors are really nothing new.  A lot of commercial building use them in restrooms, and some power companies offer rebates for using motion sensors for controlling aisle lighting in big warehouses.  Some detectors 'learn' from it's history to help eliminate nuisance trips.
Answer: I'm not sure why a fluoro would be "tricky" - a motion sensor is just like a switch toggling the circuit on/off.  The one thing to note with fluoro's is that turning them on and off frequently drastically reduces their lifespan, so while this is technically possible, it is not recommended with this type of fixture/bulb.
Comment: I figure it would just act as a switch, but there was something on the package warning about working with fluorescents. My assumption was that the light fixture wouldn't be able to tell the difference since it was just plugged into an outlet, but figured it would be better to verify that than get an unpleasant surprise.
Answer: If you would rather place something between the light and the wall, a motion sensor flood light rigged to control a power outlet in a separate box might work well... If you are comfortable and good with electrical work, this may be a cheap fix for you. Motion sensor lights can be purchased at Habitat Re-Stores or other re-use stores for a very low cost. I made one at one point with unused items laying around my house and a flood light from Habitat Re-Store. It works wonderfully to turn on the lights in a small shed.
Parts:

Used Flood Light
Outlet Box
Outlet
Wire (if needed)
Plug


Inches vs Inches^3

Question: Peace to all.  After gathering and calculating the measurements by volume (of a box), will the results be in regular inches or will they be in inches^3?
For example, if the dimensions of the item are as follows:  L = 4.13in, W = 5.50in, H = 7.50in, will the result of the volume be 170.36in or 170.36in^3
When is inches^3 appropriate compared to inches?....Does the same rule apply to all measurements in this scenario (such as CM, MM, etc)?
Comment: Cubic inches are a unit of volume, square inches are a unit of area and inches are a unit of length.  Same goes for all units of length.
Comment: A cuboid with volume $8\textrm{ in}^3$  might have dimensions $(1\textrm{ in}\times1\textrm{ in}\times8\textrm{ in})$ or  $(1\textrm{ in}\times2\textrm{ in}\times4\textrm{ in})$ or $(2\textrm{ in}\times2\textrm{ in}\times2\textrm{ in})$ or etc.

Notice that both the numerical value and the unit of each side multiplicatively contribute to (get multiplied to obtain) the volume quantity $8\textrm{ in}^3.$
Comment: It should be $\mathrm{in}^3$. When we say that the volume of an objectis $170 \, \mathrm{in}^3$, you can think of this as meaning that we can fit 170 *cubes* with a side length of $1$ inch into the box. (Technically, this might only possible if the cubes can be stretched and squished, though.)
Answer: You can sort of treat the units as quantities. The volume is $4.13\text{ in}\times 5.50\text{ in}\times 7.50\text{ in}=(4.13\times 5.50\times 7.50)(\text{in})^3$. Hence, the unit of volume is $\text{inches}^3$. In general, you can apply this strategy of treating units as a variable/quantity in order to find the units for another property/measurement calculated from a formula. It can also be helpful when figuring out unit conversions.
Comment: Are you suggesting $3$ inches $\times 5$ feet equals 15 inchesfeet?  This only works when all units are identical, else one needs to convert units to a common unit.
Comment: @amWhy Sure, it doesn't sound conventional or meaningful, but it still works out mathematically. You can convert inchesfeet into inches^2 or any other more meaningful area unit using standard unit conversions.
Answer: A volume is always measured in length3. In your case, length is inches.
Outside of physics, people may not be quite so careful, or knowledgable. If you buy a chainsaw, you might be told it has a 1.6" engine. In context, it obviously means cubic inches. You're smart enough to figure that out. The chainsaw salesman may neither appreciate nor understand a correction.
Comment: Sometimes the diagonal length is used instead, so be careful!
Comment: @Trebor When has the diagonal length of a chainsaw ever been used to specify it? And which diagonal?
Comment: I don't mean chainsaws specifically. For instance, the limit of luggage size in my city's public transport uses the diagonal length. It serves as an inaccurate but practical measure of volume in some sense.
Comment: @Trebor Outside of physics, people may not be quite so careful, or knowledgable, or be worrying about volume per se. If you want to transport luggage, you might be limited by the diagonal length. In context, it is obviously vaguely related to volume, and to length, and to width, and to height, and to mass, and to difficulty of stowing. You're smart enough to figure that out. The luggage inspector may neither appreciate nor understand a lecture.
Answer: Indeed the measurement of the volume of the box will be in inches cubed, i.e. $\text{in}^3$.
The same goes for other units: If the side length of the box is in centimeters ($\text{cm}$), then the volume of the box will have units $\text{cm}^3$.
Answer: If $X$ is the number of cubic units $\space (u)\space$ it is always appropriate to write
$ X\space  u^3\space$ as opposed to $X^3 u.\quad$
The distinction is important where, for example, $X>1\implies  X^2 mi >Xmi^2.\quad$  Oddly enough, casual language portrays it the other way: "$X\space$ square miles is less than $X\space$ miles squared," where the  latter refers to a square that is $X$ miles on a side.
In your example each $1D$  measurement is expressed as a unit to the first power but the final expression shows the unit cubed.
$$4,13\space in\space \times\space 5.5\space in\space \times\space  7.5\space in
= 170.3625\space in^3$$
Comment: You cannot compare $X^2\text{mi}$ to $X\text{ mi}^2$. Perhaps you were thinking $(X\text{ mi})^2\gt X\text{ mi}^2$.

Inches vs Inches^3


How to design an algorithm to determine how many numbers are in a string?

Question: Design an algorithm to determine how many numbers are in a string. Example, given the string "Hello people from the 4 worlds, this is my only 1 program", the output must be 2.
Comment: It is, in my opinion. That's why we have `algorithm` tag on StackOverflow.
Comment: I agree that @PetrusOnesmus should provide some more details - where he stuck or which part he can't solve however I don't agree algorithms must always go with language - algorithms don't have language, algorithm is a recipe how to do something, doesn't matter if you implement it in Java, C, C++ or whatever
Comment: @DevCl9 `Design an algorithm` - language is not specified but I guess @Petrus Onesmum is loooking for algorithm/idea, not for code in specific language.
Comment: what language? Stackoverflow is only for technical questions. Add more debugging details (you attempt code)
Comment: It's not on-topic with stackoverflow then. It must not be answered here.
Comment: If It had some code and Op is stuck on some specific thing, yes. If all theoretical and no code, I don't think so. That's why you'll always find `algorithm` tag along with other language tags and not alone
Comment: @Michu93 I could be wrong, but that's my understanding
Answer: Basically you need to write a simple parser to parse out the numbers in your string.  To do that you need to be able to recognise a number correctly, which is a little more complicated than just recognising digits.  Something like "-12,348.971" is a number, but contains the characters -,. which are not digits.  However, the string "-,." is not itself a number.
Read through the string, character by character.  When the parser finds the start of a number, count one more number found, and read through all the characters that form that number.  Read '123' as a single number, not three numbers.  When you reach the end of the number skip over non-number characters until either you find the next number or you reach the end of the file.
You might want to read up on writing a simple parser in the language of your choice.
Comment: I'm afraid I do mind.  Better ask it here.
Comment: do you mind sharing your email, i want to ask you something


How to join / concatenate / merge all rows of an RDD in PySpark / AWS Glue into one single long line?

Question: I have a protocol that needs to take in many (read millions) of records. The protocol requires all of the data is a single line feed (InfluxDB / QuestDB). Using the InfluxDB client isn't currently an option so I need to do this via a socket.
I am at the end of my ETL process and I now just have to take the final RDD I have created and take all of those rows and transpose them into a single line but can't figure out how to do this (and how to do it properly!)
In PySpark / AWS Glue I currently have:
def write_to_quest(df, measurement, table, timestamp_field, args):
    HOST = args['questdb_host']
    PORT = int(args['questdb_port'])
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    try:
        sock.connect((HOST, PORT))
        rows = df.rdd.map(lambda row: row.asDict(True))
        new_rdd = rows.map(lambda row:
                                 _row_to_line_protocol(row, measurement, table, timestamp_field)).glom()

        #transform new_rdd to single_line_rdd here

        sock.sendall((single_line_rdd).encode())

    except socket.error as e:
        print("Got error: %s" % (e))

Called by:
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args['JOB_NAME'], args)

allDaily = glueContext.create_dynamic_frame.from_catalog(database=args['db_name'],
                                                         table_name="daily",
                                                         transformation_ctx="allDaily",
                                                         push_down_predicate="(date_str='20040302' and meter_id='NEM1206106')"
                                                         # for faster testing
                                                         )

# TODO: Handle entire DF as a single payload
df = allDaily.toDF()
tdf = df.withColumn('reading_date_time', F.to_timestamp(df['reading_date_time'], '%Y-%m-%dT%H:%M:%S.%f'))
tdf = tdf.drop(*["ingestion_date", "period_start", "period_end", "quality_method",
                 "event", "import_reactive_total", "export_reactive_total"])

write_to_quest(df=tdf, measurement="meter_id", table="daily", timestamp_field="reading_date_time", args=args)

The shape of new_rdd is a set of lists of strings:
RDD[
['string here,to,join','another string,to,join'...x70]
['string here,to,join','another string,to,join'...x70]
['string here,to,join','another string,to,join'...x70]
x200
]

How do I get this so I have a single line that has everything joined by '\n' (newline)?
e.g:
'string here,to,join\nanother string,to,join\n....'

I have so far tried several combinations of foreach like:
foreach(lambda x: ("\n".join(x)))

But to absolutely no avail, I am also concerned about scalability for this - for example I am pretty sure using .collect() on millions of rows is going to kill things
So what is the best way to solve this final step?
Edit after accepted answer
The specific solution from Werners answer I implemented was this (I removed Glob to get one list item per row and then removed the whitespace (as Influx / Quest is whitespace sensitive)
def write_to_quest(df, measurement, table, timestamp_field, args):
    """
    Open a socket and write the row directly into Quest
    :param df_row:
    :param measurement:
    :param table:
    :param timestamp_field:
    :param args:
    :return:
    """
    HOST = args['questdb_host']
    PORT = int(args['questdb_port'])
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    try:
        sock.connect((HOST, PORT))
        rows = df.rdd.map(lambda row: row.asDict(True))
        new_rdd = rows.map(lambda row:
                            _row_to_line_protocol(row, measurement, table, timestamp_field))
        result = new_rdd.map(lambda r: "".join(r) + "\n") \
            .aggregate("", lambda a, b: a + b, lambda a, b: a + b)

        sock.sendall((result.encode()))

    except socket.error as e:
        print("Got error: %s" % (e))

    sock.close()

Answer: Each row of the rdd can be mapped into one string per row using map and then the result of the map call can be aggregated into one large string:
result = rdd.map(lambda r: " ".join(r) + "\n")\
    .aggregate("", lambda a,b: a+b, lambda a,b: a+b)

If the goal is to have one large string, all the data has to be moved to a single place at least for the final step. Using aggregate here is slightly better than collecting all rows and concatinating the strings on the driver as aggregate can do things distributed and in parallel for most of the time. However enough memory for the whole final string is still required on a single node.
Comment: This worked like an absolute dream - I have updated my question based on this with the solution that worked for my specific use case above - thank you :)


Pyodbc Store html unicode string in Sql Server

Question: I want to store html string in sql server database using pyodbc driver. I have used nvarchar(max)as the data type for storing in the database but it is throwing the following error
Error:

('HY000', '[HY000] [Microsoft][ODBC SQL Server Driver]Warning: Partial insert/update. The insert/update of a text or image column(s) did not succeed. (0) (SQLPutData); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]The text, ntext, or image pointer value conflicts with the column name specified. (7125)')
Comment: Can it be an ODBC driver issue? The driver you are using may not support writing large text? See here https://code.google.com/p/pyodbc/issues/detail?id=277
Answer: The link that Anthony Kong supplied includes something that may resolve the issue; it did for me in a very similar situation.

switch to DRIVER={SQL Server Native Client 10.0} instead of DRIVER={SQL Server} in the connection string

This would be for Sql Server 2008 (you didn't specify the Edition); for Sql Server 2012 it would be Native Client 11.0.
Comment: Or you can use 'ODBC Driver 17 for SQL Server'  driver


Append to an XML file

Question: I am writing some data to an XML file.
Here is the code:
    try {

    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

    // root elements
    Document doc = docBuilder.newDocument();
    Element rootElement = doc.createElement("company");
    doc.appendChild(rootElement);

    // staff elements
    Element staff = doc.createElement("Staff");
    rootElement.appendChild(staff);

    // set attribute to staff element
    Attr attr = doc.createAttribute("id");
    attr.setValue("1");
    staff.setAttributeNode(attr);

    // shorten way
    // staff.setAttribute("id", "1");

    // firstname elements
    Element firstname = doc.createElement("firstname");
    firstname.appendChild(doc.createTextNode("yong"));
    staff.appendChild(firstname);

    // lastname elements
    Element lastname = doc.createElement("lastname");
    lastname.appendChild(doc.createTextNode("mook kim"));
    staff.appendChild(lastname);

    // nickname elements
    Element nickname = doc.createElement("nickname");
    nickname.appendChild(doc.createTextNode("mkyong"));
    staff.appendChild(nickname);

    // salary elements
    Element salary = doc.createElement("salary");
    salary.appendChild(doc.createTextNode("100000"));
    staff.appendChild(salary);

    // write the content into xml file
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(new File("file.xml"));

    // Output to console for testing
    // StreamResult result = new StreamResult(System.out);

    transformer.transform(source, result);

    System.out.println("File saved!");

  } catch (ParserConfigurationException pce) {
    pce.printStackTrace();
  } catch (TransformerException tfe) {
    tfe.printStackTrace();
  }
}

This code writes the XML data to the "file.xml". If I already have a "file.xml" file, what is the best way to append the XML data to the file? Will I need to rewrite the whole above code, or is it easy to adapt the code?
Comment: Take a look here: http://stackoverflow.com/questions/883987/java-appending-xml-docs-to-existing-docs
Answer: Yes - you're dealing with DOM, so you have to have the whole file in memory. Alternative is StAX.
Answer: StreamResult result = new StreamResult(new File("file.xml"));

Check this line.
Replace the above line with this.
StreamResult result = new StreamResult(new FileOutputStream("file.xml", true));

By default the second parameter is false.
True means it will append to file, false means it will overwrite it.

Append to an XML file


Understanding associators as natural transformations

Question: Reading Baez and Stay's "Rosetta Stone," and trying to understand the definition of monoidal category on page 12, I read that a monoidal category requires a natural isomorphism called the associator, assigning to each triple of objects $X, Y, Z \in C$ an isomorphism
$$a_{X,Y,Z}:(X\otimes Y)\otimes Z\overset{\sim}{\rightarrow}X\otimes (Y\otimes Z)$$
and then trying to understand this associator as a natural isomorphism, which is a special case of a natural transformation.
A natural transformation relates a pair of functors $F$ and $F'$ that both map from a category $C$ to a category $D$. To narrow in on the definition of $a$, the associator, I must find two functors and a source category $C$ given an original functor, which, in the case of the associator, is the tensor product $\otimes$, which maps from the cartesian product category $E\times E$ to an original category $E$.
I am imagining that to define $a$ as a natural transformation, I must think of its source category $C$ as $E\times E\times E,$ which should be ok since the cartesian product of categories is evidently associative, and its destination category $D$ as just $E$, getting there via the two different parenthesizations of $X\otimes Y\otimes Z$.
Then the first functor of the natural transformation, $F$ would be something that computes $((X\in E)\otimes(Y\in E))\otimes (Z\in E)$ straight out of the category $E\times E\times E$ into $E$, and the second functor of the natural transformation $F'$ would be something that computes $(X\in E)\otimes((Y\in E)\otimes (Z\in E))$ to go from $E\times E\times E$ to $E$.
This leaves me feeling vaguely queasy, leaning on the associativity of the cartesian product and not really precisely defining the functors $F$ and $F'$, and I'd like to know if I've missed the mark.
EDIT: thinking more about why I feel queasy, it's because I've assumed some kind of projection operator that can "pick" elements from the cartesian product of categories $E\times E\times E$, but such an operator is not immediately obvious from the given definition of the cartesian product of categories on page 11, namely that $C\times C'$ is a category wherein objects are pairs $(X\in C, X'\in C')$, morphisms are applied and composed componentwise, and identity morphisms are defined componentwise. This doesn't, prima facie, give me a way to pick $X$ or $X'$ from $(X, X')$.
Answer: The first functor here is actually a composition $$(\mathcal C\times\mathcal C)\times\mathcal C\xrightarrow{(-\otimes-)\times\text{Id}}\mathcal C\times\mathcal C\xrightarrow{\otimes}\mathcal C\\ ((a,b),c)\mapsto (a\otimes b,\ c)\mapsto(a\otimes b)\otimes c$$ and the second functor is the composition $$\mathcal C\times(\mathcal C\times\mathcal C)\xrightarrow{\text{Id}\times(-\otimes-)}\mathcal C\times\mathcal C\xrightarrow{\otimes}\mathcal C\\ (a,(b,c))\mapsto (a,\ b\otimes c)\mapsto a\otimes( b\otimes c)$$ However, if we want $\alpha$ to be a natural isomorphism between them, we have to consider both parenthesizations of $\mathcal C\times\mathcal C\times\mathcal C$ as equal. But this would be wrong since, formally, they are different. We can resolve this issue by extending the first functor above with the map $\mathcal C\times\mathcal C\times\mathcal C\to(\mathcal C\times\mathcal C)\times\mathcal C$ sending the triple $(a,b,c)$ to the pair $((a,b),c)$ (and similarly for the second functor). It is straightforward to check that this really is a functor. Similarly $(-\otimes-)\times\text{Id}$ is a functor. (Both cases can be seen as applications of the general fact that given functors $F_i$ from a category $\mathcal C$ to the categories $\mathcal D_i$, indexed by some set $I$, there is a unique functor $F:\mathcal C\to\prod_I\mathcal D_i$ such that $p_i\circ F=F_i$ where $p_i:\prod_I\mathcal D_i\to\mathcal D_i$ is the projection.) Finally, $\otimes$ is a functor by hypothesis. So it makes sense to talk about a natural transformation between $(-\otimes-)\otimes-$ and $-\otimes(-\otimes-)$.
Answer: The objects of $E\times E\times E$ are the triples $\langle X,Y,Z\rangle$ of objects of $E$. One functor assigns $\langle X,Y,Z\rangle \mapsto (X\otimes Y)\otimes Z$ and the other assigns $\langle X,Y,Z\rangle \mapsto X\otimes (Y\otimes Z)$, and so it is required that these are naturally isomorphic (and that, altogether satisfy the pentagon diagram for quadruples of objects and the unit diagrams).
By the way, this all is much related to the thing about which you wrote

"which should be ok since the cartesian product of categories is evidently associative"

Cartesian product is not associative in the strict sense! Neither that of sets. Because $(A\times B)\times C$ contains pairs of different sets than $A\times (B\times C)$ (and $A\times B\times C$ is a third set). But they are naturally isomorphic. That's a main example.


SQS Single Request Processing with Multiple Messages

Question: I am trying to find a document of how requests will be processed if there is some network error between request from Client -> AWS SQS?
Because if one request can contain up to 10 messages, how would it work if there is an http error on the request while the 10 messages are being processed to SQS? Does SQS fail the whole request, and all 10 messages are being re-published? OR some messages get processed, and we will reprocess the whole thing again (which will have some duplication)?
I am trying to determine if I can cut cost with aggregating messages into 1 single request, but wonder if this will hurt idempotency.
Answer: So when you're sending messages as batch you'll be processing it one by one so each message will have its unique receipthandle so you've delete each message programmatically after processing it to avoid duplication
Comment: Sorry could you explain this? `when you're sending messages as batch you'll be processing it one by one ` - are you basically saying to send single message/request to do receipthandle? Or are you saying when sending 10 message/request, SQS has a receipthandle to not accept the same message? Also processing as in an SQS Client Publisher processing, or we have to build a publisher that does this?


What is a suitable post hole depth for a 4' fence?

Question: Would 21 inches of post below ground be enough to support 4 feet picket fence (wooden)? I have dug holes 25-26 inches and planning to fill 4-5 inches of gravel. I am planning 8 feet panels (only 3 or 4 panels are 10 feet). 1st time DIYer and recently learned about frost heaving. I am in Missouri (zone 6) and the frost line here is 30". Half of my property has very clay soil and half is very rocky (took appox and hour for 1 hole). I have already bought 4x4x6 post and now wondering if I should replace those by 4x4x8 and dig deeper below 30".
Comment: Be sure to have a **digging bar** to go with your post hole digger or auger.  A digging bar is great at breaking up clay and prying out rocks.  You can find them at any large home improvement retailer.
Comment: @JeffWheeler yes, a digging bar is what I have been using to dig rocky part of my fence area.
Comment: Correct, 21 inches is shallower than 30 inches.
Comment: @MonkeyZeus Thanks. So 30" with 6" gravel or 36" with 6" gravel, what do you think? Not sure how to prevent this frost-heave. I did dig bell-shaped holes.
Comment: @JeffWheeler, yes! A pickaxe or shovel will not help you past 1 foot down.
Answer: Assuming that you plan to set the posts in concrete then you should follow these rules:
For wind strength:
The post should be buried 33%-50% of the exposed height
You'll be exposing 4 feet above ground so the buried portion should be 1.3-2 feet; your 6 foot post will suffice for wind strength especially since a picket fence has large gaps between the vertical boards.
For frost protection:
You're in zone 6 so the bottom of your post should be at least 30 inches below the ground.
You plan to use 5 inches of gravel? You need to dig down 35 inches.
Do not skimp on protecting against frost!

When water freezes, it expands about 9 percent—think of how ice cubes are domed above the original water level in the ice cube tray. Ice exerts a pressure of about 50,000 lbs. per square inch—enough force to lift even a large building. A puny little deck on inadequate footings doesn't stand a chance.
The reason buildings and decks don't always return to their original height is that surrounding dirt sometimes fills in under the footing while it's lifted.
Heavy clay soils don't drain well, so they tend to have more frost heave problems than sandy, well-drained ones. But even if footings are deep enough, ice lenses can latch onto the rough surfaces of wood and concrete and lift footings and posts from the side. That's why concrete piers poured in waxed cardboard tubes and smooth wooden installing deck posts work well for below-grade support.

https://www.familyhandyman.com/project/how-to-build-a-solid-frostproof-deck-footing/

In conclusion:

Dig down 35 inches

The hole width should be at least 3x the width of your post; 4x3 = 12" wide hole

Place your 5 inches of gravel
Pour 6 inches of concrete

Place 6 inches of solid material such as a brick into the center of the concrete to make step #4 possible

Place your post on top; 2 feet below the ground should leave you with 4 feet above ground

You may find that it's easier to just set taller posts and cut them down short later since land is almost never perfectly straight. Some posts might be 4 feet above ground and others might be 5 feet.

Pour 2 feet of concrete around your post

Use a post level to make sure everything is perfectly vertical
See https://diy.stackexchange.com/a/226599/42053 for how to use braces if you want perfection

Pour extra concrete so that it rests an inch or two above the dirt so that you can slope it outwards to prevent water pooling near the wood
Comment: @vabii Please put down your shovel and read my post thoroughly. If it takes you an hour to dig one post hole then do you really want your hard work ruined by a single winter? Set your posts properly and then you can just enjoy your fence instead of worry about your fence.
Comment: @vabii Sadly, a bell shaped hole doesn't help against frost upheaval; it's just going to provide a greater surface area for ice to push upwards. When water freezes under your post it is considerably easier for the ice to push upwards instead of down. The bell shape might aide in wind resistance if you actually needed wind resistance but overall it will do more harm than good considering the frost. If you can rent some heavy equipment like a skid steer with a jack hammer and post hole digger attachment then I would definitely consider doing that.
Comment: @vabii What issue are you trying to protect against? The french drain suggestion is practically a joke since it would also have to be below the frost line. Skip the gravel idea because it's useless, dig 30 inches and do the math from my answer. What is so confusing?
Comment: Thorough answer that does not beat around the drainage/gravel bush. May I suggest a second bullet under #5: "Support the post upright plumb with braces while the concrete cures". Since the rest was detailed, I thought this would fit. Also, as an alternative you can float the post with horizontal bracing on the soil surface to offset it from the the bottom rather than using a brick and cutting the tops.
Comment: @P2000 Very nice! I figured it was a bit too much info to fit in a bullet point beneath my #5 =D
Comment: If I understand you correctly, the post doesn't need to go below 30", only the hole in which post is set?
Comment: @vabii You are planning to use 5 inches of gravel so the hole should be 35 inches deep.
Comment: Thanks, 5 inches of gravel because of heavy clay soil I have.
Comment: @vabii I'm not against the gravel but it's just loose fill so it provides nothing structural for wind nor frost purposes. However, consider that water drains to where there is least resistance. You'll actually be draining water from the clay directly beneath your post so it could accelerate concrete deterioration and post rot. In the winter it will literally be a pool of water which will do some serious upheaving if an unexpected cold snap penetrates below 30 inches. If you're interested in gravel then make a French drain leading away from your posts.
Comment: I see. I guess the best technique against frost heaving is setting the post it self below 30". I was avoiding that partly because I am digging these hole without an auger and partly because I didn't want to dig 36" for a 48" fence. Even if I get an auger, 1/3 part of my property is so rocky that auger won't work too.
Comment: @vabii If you skip the gravel idea then you only need to dig down 30 inches instead of 35.
Comment: Okay. and 8"/9" inches of concrete then? Are suggesting this if I have French drain or would it work without it too?
Comment: :-) , I googled French drain and though you are seriously suggesting that..
Comment: @vabii Sorry for the sarcasm; sadly it doesn't transmit very well via text. My main point is that every decision has to have a purpose. Gravel does more harm than good and you **cannot** escape the 30 inch frostline requirement. I'm sorry that you have terrible soil conditions but that doesn't give you a free pass to cut corners. If you want your fence to look like crap after a single winter then go ahead and skimp; it's just a fence, not a building foundation.
Comment: @P2000 I've never done the support brace technique. I looked up some pictures and it seems like it would be a hassle for the common DIYer but I guess if OP rents a skid steer with attachments then is it really DIY any more? =)
Comment: @P2000 Seems like it would cause a recursive issue because attaching the brace could shift your post out of alignment and once it's attached you can't adjust it except to remove it and try again.
Comment: @MonkeyZeus I posted an answer to better illustrate what I meant. Discussion welcome of course. I had success with this technique.
Answer: To position the posts plumb (upright), you can support them with braces that are attached near the top of the post, and rest on the ground, with a securing peg.
And to offset the bottom of the post from the bottom of the pit, you can lift them using supports placed flat on the soil (illustrated in red, below).
This allows you to pour the gravel and concrete/cement after adjusting the height of the post and aligning its top with other posts. Or if you are pouring only concrete/cement (no gravel) you can now pour it in one go and ensure that the concrete envelopes the bottom of the post.
You can use this same technique to fine-tune the alignment of the tops of all your posts without having to cut the tops after placement.
You can also pre-cut the posts based on the slope of the ground, and use the offset bracing to do the fine alignment.

Crossing the brace is probably not necessary, since its purpose is to lift the post and not vertically stabilize it. So one 2x4 will do. Also, you can run a long 2x4 from one post to another, resting it on the soil and supporting both posts, if it's hard to brace across a hole due to obstructions like rocks etc..
Original image: https://www.construction53.com/2011/09/setting-and-aligning-the-poles/ with edits in red.
Answer: The rule of thumb is 1:3, so 16" for a 48" fence. Adjust according to soil conditions and frost depth. Whether you go to frost depth or apply other mitigation techniques is up to you. A good strategy is to ask your neighbors what they've done and evaluate the outcome in those cases.
Comment: Thanks. Could you please give some pointers on other mitigation techniques you are referring to? I did read about bottom-wide (bell-shaped) curved, which is how I have dug these holes.
Comment: That's a different question and one I'm not prepared to answer.


I start upgrade and download only part of the packages

Question: I  start upgrade  and download only 1366 packages out of 19..  How to  Restart  remaining packages for downloading ?
Comment: OMG U DOWNLOADED 1345 MORE PACKAGES THAN YOU SHOULD HAVE!
Comment: @Alvar meant `sudo apt-get update && sudo apt-get upgrade`. If after that you still see some packages not updated (it would say they are "retained"), then do `sudo apt-get dist-upgrade`.
Comment: Welcome to Ask Ubuntu! As it stands, your question may need a little more information  in order for it to be answered. Please edit the question and add more details. For example, are you trying to upgrade from 12.10 to 13.04? What messages you get (error or otherwise)?
Comment: If you are upgrading through the GUI update manager then It will resume automatically from where its terminated. all you need to do is just run normally,:)
Answer: If you want to upgrade from the terminal then you can simply run it with
sudo do-release-upgrade

thats it. It will upgrade your system to latest release . I mean to 13.04.
If the upgrade were aborted, clean the download folder first
sudo rm -rf /var/lib/apt/lists/lock
hope that helps.
Comment: i try sudo do-release-upgrade they give me error msg
Comment: so you have terminated it in middle . ok do like ` sudo rm -rf /var/lib/apt/lists/lock `


How can I level quickly in Skryim to the point that I can get a daedric sword?

Question: I just really want to know if there's a fast way to level as I really want a daedric sword.
Note that I don't have Dawngaurd but I do have Hearthfire and Dragonborn.
Comment: If your goal is simply to use a daedric quality sword, The *Mystic Binding* perk available at Conjuration L20 gives you exactly what you're looking for.  And before you get your Conjuration to 20, to buy that perk, *Bound Sword* will at least give you an Orcish quality sword.
Answer: Since you don't have access to the console on Xbox, the fastest way to level is simply to use skills.  But you don't have to reach a minimum level to get a daedric sword, only to find a daedric sword as loot.
If you get your smithing skill high enough you can craft one using leather strips, a daedra heart and 2 ebony ingots.
One sure location for a daedra heart is Enthir at the College of Winterhold but is also common around alchemy stations in dungeons.  You can also find several in the final part of the quest The Black Star, assuming you loot the dremora.
Ebony can be found in Gloombound Mine, but if you don't have access to orc strongholds you can also find enough for a daedric sword in Redbelly Mine near Riften.


What type of drywall tape should I use for a drywall to plaster patch?

Question: What would be the best drywall tape for drywall to plaster patch?
The patch is on a non-insulated garage ceiling, so there will be temperature swings from 0 to 100 probably through the year.
I had to patch because of some water damage, the old material is plaster over rocklathe (3/4" total), and new is just a dual layer of 3/8" drywall.
I have setting type compound, but I'm not sure of which tape would hold up better for these circumstances.
Comment: Is there living space on the other side of that?
Comment: Nope, just an attic.
Answer: I like the mesh tape for this sort of thing - because you can get material through it, and it seems less prone to peel.
The self-adhesive aspect is not all that significant - it's merely holding it (barely) in place until it's embedded in compound. The compound is what actually sticks things together.
Comment: +1.  I recently had a bunch of this kind of work and used a special (blue) mesh tape that, i believe, was marketed for this specific purpose (or thereabouts).  i bought it at Home Depot
Comment: I'll see if I can find some of that wide tape, might have to go to a drywall store to get it though.  I have time though, it's not going to be above 50 degrees in the garage until spring :)
Comment: +1 Look for the thick blue tape - usually marketed as plaster tape (not drywall). Fibers are thicker, glue is super sticky, even on dusty surfaces, and it is a tad wider.
Comment: https://www.menards.com/main/building-materials/drywall/drywall-tape/300-veneer-plaster-tape/p-1444450692654-c-13061.htm?tid=-2790206722416456607
Answer: Fiberglass Mesh Tape
Fiberglass mesh tapes are usually self adhesive and easy to use, so tend to be the tape of choice for many DIYers.

Mesh tapes tend to be a bit thicker, and require more compound to cover.
Mesh tapes are self adhesive, so once they're stuck they don't tend to bubble or peal later.
Paper Tape
Paper tapes can be a bit more difficult to work with, which can lead to highly visible seams when used by inexperienced users.

Paper tapes are a bit thinner, so typically requiring less compound to cover. Though it must be set in compound, so may require more coats.
If paper tape is not set properly in compound, it can bubble and/or wrinkle as the compound dries.
Comment: I've always found paper to be the way to go.  I get a better finish with it.
Answer: Tape will not fix this mess. You need to first pull the sheetrock down and shim it so that it's flush and fits the hole. You should try to get 1/4" or lower gap. Then tape it and spackle.
Comment: This doesn't answer the question about which type of tape to use. FWIW it looks relatively flush in the picture.
Comment: Ceiling is RockLathe with Plaster coat, so it's near impossible to get a perfectly clean cut on.  Patch panel does have extra framing behind it so it's not being supported by the existing plasterwork though.


Arquillian Drone Test with @RunAsClientSide-annotated test method and in-container test method runs with NoClassDefFoundError

Question: The Arquillian-Guide Functional Testing using Drone and Graphene says that it is possible to "mix in-container and client modes in the same test".
I am trying to run this little example:
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.spring.integration.test.annotation.SpringWebConfiguration;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

import java.io.File;

@RunWith(Arquillian.class)
@SpringWebConfiguration
public class ClientAndContainerTest {

@Deployment
@TargetsContainer("process")
public static WebArchive createDeployment() {
    File warFile = new File("src/test/resources/webApp.war");
//        File[] testLibs = Maven.resolver().loadPomFromFile("pom.xml")
//                .resolve("org.seleniumhq.selenium:selenium-chrome-driver")
//                .withTransitivity().asFile();
    return ShrinkWrap
            .createFromZipFile(WebArchive.class, warFile)
//          .addAsLibraries(testLibs)
            ;
}

@Test
@InSequence(1)
public void testContainerSide() {
    // test some in-container stuff
}

@Drone
private WebDriver browser;

@Test
@InSequence(2)
@RunAsClient
public void testClientSide() {
    // Run some UI-tests
}

}

The testclientSide() passes without problems. But the testContainerSide() runs with a
java.lang.NoClassDefFoundError: Lorg/openqa/selenium/WebDriver;
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver

A soon as i add selenium-chrome-driver dependencies with Transitivity to the Deployment (uncomment the lines in the createDeployment()-Method) it works. But i don't see the point in adding Selenium to the container-deployment because it should only be needed on client side.
Can anybody tell me why testContainerSide() method is looking for org.openqa.selenium.WebDriver ?
Comment: Check this discussion https://stackoverflow.com/questions/47823506/exception-in-thread-main-java-lang-noclassdeffounderror-org-openqa-selenium-w/47845104#47845104
Comment: Thanks for the hint but i always run mvn clean first and i deleted my repository and let it run again. But it still does not work. And the real question is why it is even looking for Selenium.
Comment: Now I think, it's not an issue with Selenium-dependencies. I created a LoginPage-class that i injected into the test class with  `@Page
    private LoginPage loginPage;` and now i also have to add the LoginPage.class to the Shrinkwrap, even though i do not need it in the container.
Comment: You are right !!!
Answer: I think, the only solution is to seperate ui-/client-side-tests from in-container-tests by using one test-class for each.
If you want to use both techniques in one test-case, you can use arquillian-suite extension to run both tests-classes concurrently within a single deployment.


How to increase the limit of unity launcher's sensibility

Question: When I change the sensibility of the launcher in the "Change Desktop Background/Behaviour", for the auto-hide mode, it doesn't really change.  I can't appreciate the change. As a consequence it is hard to bring it up and annoying.
Is it like that in all PCs or is it in the Apple Computers?
Comment: Possible duplicate? - http://askubuntu.com/questions/127704/the-auto-hide-function-of-launcher-does-not-work-well
Comment: possible duplicate of [How can I change the Unity launcher delay?](http://askubuntu.com/questions/37083/how-can-i-change-the-unity-launcher-delay)
Answer: Install CompizConfig Settings Manager. Open it and edit Ubuntu Unity Plugin: Set Launcher Reveal Pressure to 1 (instead of 20 - default).
Be careful with changing settings in CCSM, though!
Comment: What do you mean by be careful with changing?
Comment: It sometimes happend to me that some things didn't work as they should after I changed some settings in CCSM. You can reset all these settings by [doing what is described here](http://askubuntu.com/a/71931/46531).


Installing WIne

Question: I'm struggling with installing Wine on fresh   Description: Ubuntu 18.04.1 LTS
<code>404  Not Found [IP: 91.189.*.* 80]
:3 https://dl.winehq.org/wine-builds/ubuntu bionic InRelease

E: The repository 'http://ppa.launchpad.net/wine/wine-builds/ubuntu bionic
Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is
therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user
configuration details.

sudo dpkg --add-architecture i386
wget -nc https://dl.winehq.org/wine-builds/Release.key
sudo apt-key add Release.key
sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
sudo apt-get update
sudo apt-get install --install-recommends winehq-stable
</code>
I've been trying from official site https://wiki.winehq.org/Ubuntu and also youtube videos, but both ends with the same error (above)
Any idea?
Comment: Possible duplicate of [How to install the latest version of WINE as the system version?](https://askubuntu.com/questions/892230/how-to-install-the-latest-version-of-wine-as-the-system-version)
Comment: Possible duplicate of [Xenial repository does not have a Release file](https://askubuntu.com/questions/866901/xenial-repository-does-not-have-a-release-file)
Answer: Install Wine 3.0.3 in Ubuntu:
1. Open terminal via Ctrl+Alt+T or by searching it from app launcher. When it opens, run command to add the repository key:wget -nc https://dl.winehq.org/wine-builds/winehq.key && sudo apt-key add winehq.key
2. Add wine repository via command:sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
3. Finally check updates and install wine stable packages:sudo apt-get update
                                                          sudo apt-get install --install-recommends winehq-stable
Uninstall:
sudo apt-get remove --autoremove wine-stable wine-stable-amd64

Installing WIne


What does the "Armor" stat do in Geneforge 2?

Question: One of the many stats on your character sheet is "Armor". Just about any piece of clothing or armour will increase this. But what does it actually do? Presumably, it makes you harder to kill in some way, but I can't find any section of the in-game manual that explains how.
Ideally, I'd like to know the exact math behind Armor. Failing that, I would like to at least know whether it reduces enemy chance to hit, damage inflicted, or both, and what types of attacks it works against.
Answer: If I remember correctly, in Geneforge 1 & 2, armor reduces damage by a fixed amount. Whether it reduces it by exactly the armor value or if the armor value is used in a calculation to determine the amount it reduces, I do not recall. I believe it only works against physical attacks. It does not reduce the enemy's chance to hit.
In Geneforge 3-5, armor reduces by a percentage instead. This means armor doesn't scale with difficulty in Geneforge 2 like it does in the later games, which is why you'll feel like you're wearing tissue paper on Torment difficulty.
Comment: Awesome. Do you have a source, or is this just from your own experimentation with the game?
Comment: I played Geneforge 1-4 about 3 years ago so its mostly memory. But i did find [this thread](http://spiderwebforums.ipbhost.com/index.php?/topic/17718-mechanism-change-and-balance-of-geneforge-series/) which seemed to confirm it.


A student draws 5 cards from a standard deck of 52 cards

Question: A student draws 5 cards from a standard deck of 52 cards

How many ways could the selection result in a hand with no clubs?
How many ways could the selection result in a hand at least 1 club?

I'm not sure I'm using pigeon-hole principle for both.
Even using the pigeon-hole, I have no idea how to apply on that.
Comment: Why do you want to use the pigeonhole principle?  Just count.  (Hint for b): use a).)
Comment: 1 and 2 are the same?
Answer: The are $52\cdot\frac{3}{4}=39$ cards which are not clubs. Part a) is effectively asking, given these 39 cards how many ways are there of choosing 5 in other words what is 39 choose 5:
$$\binom{39}{5}=575757$$
For part b) we can do something similar, lets start with choosing 1 club. There are 13 to choose from, then there are still 39 remaining non clubs for the remaining 4 cards so for hands with one club we have
$$13\cdot\binom{39}{4}$$
For hands with two clubs we have at first 13 to choose from, then 12 so we have $13\times12$ possibilities for the clubs. But this is just how many ways can we choose 2 cards from 13, i.e. $\binom{13}{2}$. Then for the non-clubs there are $\binom{39}{3}$ ways to choose the remaining 3 cards. Therefore for a hand involving $i$ clubs there are
$$\binom{13}{i}\cdot\binom{39}{5-i},$$
which we can sum from $i=1$ to $5$
$$\sum_{i=1}^5 \binom{13}{i}\cdot\binom{39}{5-i}.$$
According to Wolfram|Alpha is equal to 2,023,203 possible hands involving at least one club.
Also rather than calculating this directly as above we can see that since there are $\binom{39}{5}$ ways of choosing a hand not involving a club then there must be $\binom{52}{5}-\binom{39}{5}$ ways of choosing a hand that has at least one club. The two answers agree (as one would hope!).
Answer: By direct counting: there are 13 clubs cards in a deck of 52 cards, the student has to draw 5 non-clubs cards:
he can pick the first non-clubs card out of 52-13=39 non-clubs cards;
he can pick the second non-clubs card out of 38 cards and so on.
Thus he can pick 5 non-clubs cards in
$$
39 \cdot 38 \cdot 37 \cdot 36 \cdot 35 = \frac{39!}{(39-5)!}
$$
Since in the request of drawing 5 cards it doesn't matter the order the student picks these 5 cards, this number has to be divided by the number of ways you could arrange 5 cards: 5!
Thus he can pick 5 non-clubs cards in:
$$
 \frac{39!}{(39-5)!5!}={39 \choose 5}
$$
To me your question number 2 looks exactly like the number 1.
Edit: now I see the question has been edited.
For point 2 you can reason in the same way, but considering that the hand has to contain at least a club; i.e one card has to be choosen between 13 and the others between 52-1=51 cards.


Generics and Wildcards: Java likes "new Foo>"

Question: Alright, so Java doesn't allow the following:
Foo<?> hello = new Foo<?>();

This makes sense-- after all, what's the point of generics if you're just gonna box/unbox everything anyways?
What's weird, is Java does allow this:
Foo<Bar<?>> howdy = new Foo<Bar<?>>();

Granted, this actually accomplishes more, though at some point, there would be a cast to get whatever Bar is working with.  But if Java is okay with some specificity, why doesn't it allow this?:
Foo<? extends Mal> bonjour = new Foo<? extends Mal>();

The only reason I ask is I'm fixing to rely on the "wildcard inside a class parameter of a constructor", and would seriously like to know the implications/intent behind it.
EDIT: To clarify my question, on what grounds are these statements allowed/disallowed?  I'm aware that "Java doesn't permit wildcards in constructors", but the question is, why all this weirdness?  Why aren't bounded wildcards allowed if nested wildcards are okay?
Answer: As for the rationale: new Foo<?> should probably better be written as new Foo<Object>, so the compiler restriction here forces to write the code as readable as you can. The last example could likewise be new Foo<Mak>(), as there is nothing you can do on a Foo<? extends Mal> that you cannot do on a Foo<Mal>. Note that the converse isn't true: a Foo<Mal> might accept Mal arguments where a Foo<? extends Mal> doesn't.
On the other hand, you really might want a Foo object which can handle Bar objects of any kind, so Foo<Bar<?>> makes perfect sense. This would be the case if you only access methods of Bar which don't rely on the type argument. There is nothing for the compiler to complain here.
Comment: I think I understand what you're saying: if a constructor accepts a class param `Mal`, the instance inherently accepts anything that's a subclass of `Mal` (though a _reference_ to the instance wouldn't be able to point at a generic with a subclass unless a wildcard were specified.)
Comment: Looking at my comment over a year later... I'm pretty sure that's one of the most incomprehensible things I've ever said.
Answer: The reason your first and third declarations don't work is because of JLS §15.9:

It is a compile-time error if any of the type arguments used in a
  class instance creation expression are wildcard type arguments
  (§4.5.1).

In your first declaration, ? is a wildcard type. In your third declaration, ? extends Mal is a wildcard type.
The reason your second declaration does work is because Bar<?> is not a wildcard type. Bar<?>'s type is Bar.
What do you mean by the "wildcard inside a class parameter of a constructor"?
Comment: Well yes, they're wildcards and wildcards aren't allowed in those cases-- but my question is, _why_?  Why was this design decision made?  Why is the third code block any less legitimate than the second?
Comment: By that I mean something in the form of `new Foo>`
Comment: @Phillip The first and third code blocks are pretty much the same. For the first, the `?` could be replaced with `Object`, `Mal`, `SubclassOfMal`, `SubSubclassOfMal` so on and so forth. For the third, the `?` could be replaced with any of the above except for `Object`. There are still an infinite number of actual types that could match the `?`, and the compiler can't handle that.
Answer: When you instanciate an instance of a parameterized type, you must specify a type. ? and ? extends Mal are not types. Bar<?> is a type. You can find more information on this page.
Here is an example for your second case:
Bar<Object> bar1 = ...;
Bar<String> bar2 = ...;
List<Bar<?>> list = new ArrayList<Bar<?>>();
list.add(bar1);
list.add(bar2);

You can imagine to store Bar instances in a list, but you do not need to know their type parameters.
Answer: new Foo<?> can be equivalently replaced with new Foo<SomeRandomTypeIMadeUp> where SomeRandomTypeIMadeUp is any type that satisfies the bound of that type parameter. The simplest choice is to simply to pick the upper bound of that type parameter, e.g. if it is class Foo<T extends X>, then new Foo<X> would suffice.
You may ask, why is it that I can just choose any arbitrary type parameter, even one that may have absolutely no connection to the rest of my program? Isn't that unsafe? The answer is no, because that's precisely what Foo<?> means -- the type parameter can be anything, and you cannot depend on what it is. This demonstrates the sheer absurdity of what you're asking to do. Something created with new Foo<?> would be pretty much completely useless, because you cannot do anything with it that depends on the type of the type parameter.
Types with wildcards are generally useful. For example, you can have an argument of type List<?> and you can pass any type of List to it, and it simply gets stuff out of the list. But in that case, you are not creating the list. The function that created the list and passed it to you probably had some non-wildcard type parameter. In the scope of that function, you can still put things into the list and do useful things with it. If a function were to create a List<?>; this would be pretty useless -- you cannot put any element except null into it.
This is why you are not allowed to do new Foo<?>: It is utterly useless; you are probably using Generics wrong if you want to use it. And in the extremely rare case you actually want it, there is a ready substitute, new Foo<AnyTypeThatSatisfiesTheBounds>.
Foo<Bar<?>> is very different. Bar<?> is a specific type. Foo<Bar<?>> does not mean you can assign Foo<Bar<Something>> to it; rather, that is illegal; the type parameters of Foo must match if they are not wildcards. Also unlike with a wildcard, with a List<Bar<?>>, you can put objects into it and take objects out of it.


Dimension of the space of irreducible rank $1$ representations

Question: This paper says that given a finitely generated group $\Gamma$, let $d_N(\Gamma)$ be the dimension of the space of irreducible rank $N$ representations. The number $d_1(\Gamma)$ coincides with the first Betti number, so one may think of $d_N(\Gamma)$ as a nonabelian generalisation.
Now given a compact manifold $X$, take $\Gamma$ to be $\pi_1(X)$, then the the space of irreducible rank $1$ representations is just the $Hom(\pi_1(X),\mathbb{C}^*)\cong Hom(H_1(X),\mathbb{C}^*)\cong H^1(X,\mathbb{C}^*)$. Now I wonder why $H^1(X,\mathbb{C}^*)$ is a vector space?
And $\mathbb{C}^*$ is not a ring, I wonder how to get the first Betti number?
Also what does it mean by "so one may think of $d_N(\Gamma)$ as a nonabelian generalisation"?
Answer: Why should this be a vector space? It is not. As for the statement in the paper: It is correct. The space $Hom_{irr}(\pi_1, GL(n, {\mathbb C}))$ (or a suitable quotient of this space by the action of $GL(n, {\mathbb C})$) is a complex-algebraic variety, so it has dimension. This dimension can be regarded as a generalization of the dimension of a vector space, just as the dimension of a general topological space is a far-reaching generalization of the notion of dimension from linear algebra.
Edit 1. In order to see that $Hom(\pi_1, GL(n, {\mathbb C}))$ is an algebraic variety, consider a presentation of $\pi_1$:
$$
<s_1,...,s_k| R_1(s_1,..,s_k), R_2(s_1,...,s_k),....>.
$$
Then $Hom(\pi_1, GL(n, {\mathbb C}))$ is identified with the subset of $GL(n, {\mathbb C})^k$ given by the equations
$$
R_i(x_1,...,x_k)=1, i=1,2,...
$$
and inequalities $det(x_1)\ne 0,..., det(x_k)\ne 0$,
where $(x_1,...,x_k)\in Mat(n\times n, {\mathbb C})^k$.
The latter is a complex-algebraic variety (not necessarily irreducible).
One can verify that the subset of irreducible representations is Zariski-open, making $Hom_{irr}(\pi_1, GL(n, {\mathbb C}))$ an algebraic variety as well. Regarding quotients by conjugation, see the reference I gave here.
Edit 2. The subset of irreducible representations is Zariski-open is proven for instance in Proposition 1.10 (page 11) in the book
Alexander Lubotzky, Andy R. Magid, Varieties of Representations of Finitely Generated Groups, Memoirs of AMS, vol. 336, 1985.
Make sure you read the discussion on the preceding page 10 as well.
Edit 3. In fact, $Hom(\pi, GL(n))$ is not just a variety but a scheme, this is again explained nicely in the reference above. The associated functor of points is
$$
A\mapsto Hom(\pi, GL(n))[A]= Hom(\pi, GL(n,A))
$$
for commutative rings $A$. This scheme has a quotient, traditionally called the character scheme (topologists tend to call the quotient the  character variety), which can be understood either as the GIT/Mumford quotient
$$
X=X(\pi, n)=Hom(\pi, GL(n))//GL(n)
$$
where $GL(n)$ acting on representations via conjugation (see the same reference) or, better as a stack. For the latter interpretation I do not have a good reference. This distinction becomes important for instance when you consider the Zariski tangent space of the character scheme at $[\rho]\in X=X(\pi,n)$: In general it is not isomorphic to $H^1(\pi, Ad\circ \rho)$. However, if one interprets  $X$ as a stack, then
$$
T_{[\rho]} X\cong H^1(\pi, Ad\circ \rho).
$$
Comment: This answer is not complete
Comment: @Danny: It is complete, what else would you want to know?
Comment: For example, my last question. For example, why is that a complex algebraic variety? For example, why is the dimension the first Betti number? For example...
Comment: @Danny: Your last question I answered; the dimension of $Hom_{irr}(\pi_1, GL(n, {\mathbb C}))$ has very little to do with any Betti numbers once $n\ge 2$. As for why it is an algebraic variety, I will add an explanation.
Comment: why is the dimension $Hom(\pi_1(X), GL(1,\mathbb{C})$ equal to the first Betti number of $X$?
Comment: @Danny: Are you familiar with the universal coefficient theorem for cohomology?
Comment: I know but $C^*$ is not s ring, how do you define the rank of $GL(1,C^*)$?
Comment: It is a complex manifold (actually, an abelian complex algebraic group), so you use its dimension as a complex manifold, it will equal the 1st Betti number.


Checkbox Selected Event not Available for UWP Xamarin

Question: i am using Messier16.Forms.Checkbox library for Checkbox Control in Xamarin Windows App. it does not have Selected event.
Kindly suggest any library in xamarin UWP project for Checkbox control which contains Selected Event.
Thanks in Advance
Reddy Krishna
Answer: From the sample source of Messier16.Forms.Controls.Checkbox:
checkbox.PropertyChanged += (sender, e) =>
{
    if (e.PropertyName.Equals("Checked"))
    {
        cb2.IsEnabled = checkbox.Checked;
        cb3.Checked = !checkbox.Checked;
    }
};

Re: https://github.com/messier16/Forms.Controls/blob/master/Sample/SampleLocalApp/SampleLocalApp/Pages/CheckboxPages/CheckboxCodePage.cs#L31


moodle 2.7 filemanager issue

Question: I'm working with a file manager on a form in moodle 2.7.
The save and upload files features are fine.
I need to determine if the file manager object currently holds a file.
This is what I've tried:
if($draftitemid = file_get_submitted_draft_itemid('attachments')){
   $A=1;
}else{
   $A=2;
}

But it always return 1;
Answer: [SOLVED]
Just after saveing the form files and before update record I use:
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, $component,$path, $itemid,'',false);
if(!empty($files){
 $A=1;//have files
}else{
 $A=2;//No files
}

this work for me.
Answer: This line:
$draftitemid = file_get_submitted_draft_itemid('attachments')

Sets $draftitemid to the value returned by file_get_submitted_draft_itemid('attachments'). Setting a variable always evaluates to true when in an if statement. Thus, this is a typo and what you want is:
if($draftitemid == file_get_submitted_draft_itemid('attachments')){

moodle 2.7 filemanager issue


ADF Pipeline Stopped Working: Job failed due to reason: The result has 0 output columns. Please ensure at least one column is mapped

Question: I've successfully manually triggered a pipeline in development many times.  We're loading csv files into an Azure Blob Storage container from Sql server and sinking with an Azure SQL database. Now when I run the same pipeline I get the error: 'StatusCode':'DF-Executor-InvalidOutputColumns','Message':'Job failed due to reason: The result has 0 output columns. Please ensure at least one column is mapped. The schema is late binding.  I can preview in Source (sometimes), but not in Sink. I've not changed anything since last successful run.  Anyone else ever experience this?
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: Make sure your 'Allow schema drift' option is enabled in 'Sink' tab.
Answer: I had the same issue, so I will try to explain my problme in more details. I SUPPOSE it is the same thing.
I have a Data Flow within a pipeline. The data flow has only one source - a csv file within a blob storage container. The data flow has also the following compnents: Filter, devrive column, aggregate and two niks (one for the full flow, other for the aggregator). The flow runned multiple times with success in the past, even one hour ago!
After i changed the container from where the source loaded, the problem started to happen. I tried to go back to the previous container without success either.
Now, I can see the dataset and preview the data. No issues here, regardless where the file is.
When I debug the data flow, though, the error occurs in the source component. When I select "Data Preview", the messsage "The result has 0 output columns. Please ensure at least one column is mapped" occurs.
My source settings are set through two parameters:

FileName: testes with diles with extension txt and csv (that previously worked fine)
ColumnDelimiter: Tested with files having tab and | delimiters (that previously worked fine)

My projection display correctly my 24 outputs with the correct data type. Everything works up to the point I try to debug. I tryed to log out and restart the debug mode, both without success.
Below my JSON for the full flow and for the source component.
Data Flow
{
"name": "DCV_Parent_Load",
"properties": {
"folder": {
"name": "Data Ingestion"
},
"type": "MappingDataFlow",
"typeProperties": {
"sources": [
{
"dataset": {
"referenceName": "FileDCVParent",
"type": "DatasetReference"
},
"name": "DCVParentConnector"
}
],
"sinks": [
{
"dataset": {
"referenceName": "LegacyDCVParent",
"type": "DatasetReference"
},
"name": "SinkDCVParent"
},
{
"name": "SaveMetada"
}
],
"transformations": [
{
"name": "NullTreatment"
},
{
"name": "AddColumns"
},
{
"name": "RemoveHeader"
},
{
"name": "GetMetadata"
}
],
"script": "..." /I removed this line for data security/
}
}
Source Info
source(
output(
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/  as string,
/input name/  as string,
/input name/ as string,
/input name/ as string,
/input name/ as string,
/input name/ as string
),
allowSchemaDrift: true,         /I also tried to disable schemaDrift, having no success/
validateSchema: false,
ignoreNoFilesFound: false,
wildcardPaths:[($FileName)]
) ~> DCVParentConnector
Answer: Possible scenario 1:
You have no files to process further

Maybe you deleted first one with "Delete source files", or "moved" with "After Completion" setting
Maybe you used filter with start-end time for new files and there are no new files to process

There is a "Allow now files found" checkbox that "supposed" to throw no error when there are no files, yet as of 11.2021 I found that it does work on debug mode yet it does not work well on Triggered mode and gives out "Result has 0 output columns" error.

Possible scenario 2:

You are trying to do an Alter Transformation for Insert/Update/Delete on some condition and Sink does not allow one of these required.
For a scenario where Sink already contains data and you are going to Update and Sink does not have Update right you may get this error.

In below case Upsert (Insert / Update on condition or maybe you use upsert==true() too) Insert and Update are used

On the sink side if you do not have Update method -> Allow update and provided your Items already exist and it will do an update (or update overwrite) it will fail.
Answer: Check the schema, table and column names in your destination dataset. Having some characters like blank space in schema, table or column name can cause this issue.
Comment: This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30341826)
Answer: This issue may happen if you are not defining schema to your sink table on your database.. Example: Azure PostgreSQL
Answer: In my case the problem was in case sensitive column name.
For example, I had "SomeID" column name in SQL DB table schema and in ADF parameter value it was "SomeId", which is OK from SQL perspective but looks like not OK from ADF.
After specifying column names exactly as they are in DB schema, the problem was solved.
Hope this will help somebody!


What roles can realistically be performed by Cho'Gath?

Question: Cho'Gath is free this week in League, and I'm very excited as I'm strongly interested in this Champion.  However, I know very, very, little about him. I know some of the things he can do, but I'm sure that regular Cho players can teach me more than a thing or two.
Most League players know that many hero's can play roles they are not meant to, and while such behavior may be successfull at times, most hero's have roles they were specifically designed for. Cho is obviously a tank of sorts, but other than pure tank, what other roles if any, can Cho realistically perform?
Comment: Fwiw, Chogath Bot is usually at top; and will roam to bot to help out. I rarely see him at mid except in a team fight.
Answer: Well, let's examine every role.  I will be assuming that the current widely-used metagame is the one under which you are asking the question (which is an important assumption to make explicit!).
Top: A top champion should be fairly "tanky" and able to withstand damage, and he should also ideally have an escape move in order to avoid ganks from the enemy jungler (e.g., Shen's taunt, Jax's jump, etc.).  Cho'gath can certainly be built as a tank, and a very effective one at that.  He also has a good bit of CC between his Rupture and the Feral Scream.  While he doesn't have a true escape move which gives him a burst in speed or quick way to change locations, a well-placed Rupture can easily get him out of harm's way.
Jungle: A jungler should ideally have some form of self-healing ability, enough CC to be effective at ganking without taking Exhaust as a Summoner Spell), and enough damage to clear the jungle in at least somewhat efficient time.  Cho'gath has all of these things: Carnivore heals him with each minion he kills, Rupture lets him pop his enemies into the air, and his Rupture, Vorpal Spikes and Feast all do enough damage to get him through the jungle just fine.  In fact, it's actually very nice to use Cho'gath as a jungler because it is considerably easier to gain Feast buff stacks while clearing the jungle than in lane while dealing with enemy harassment.
Mid: In the current metagame, mid lane almost always has an AP carry in mid lane (you will sometimes see a Talon, or maybe even a Sivir, but this is extremely rare).  It is very viable to build Cho'gath straight AP, and his abilities do a ton of damage if you do.  You can even take advantage of his tankiness if you do so by grabbing Rod of Ages or Rylai's Crystal Scepter.  The issue here is predominantly one of range.  Cho'gath's ranged spells have a considerably shorter range than most other standard AP carries.  Furthermore, his auto-attack is melee.  This makes your job very hard in mid lane; not only will it be difficult to harass your lane opponent (who likely outranges you), but it will be difficult to keep up in the creep score due to the fact that you need to close to melee range in order to last hit (which opens you up for significant 'poke' from the enemy champion).  This quickly results in your falling behind your opponent in gold as you have to either give up some minion kills or be constantly recalling to heal.
Bot - Support: A support character primarily have at least one of three things: an ally heal, an ally buff, or an enemy CC.  Cho'gath has only one of these.  Rupture is very useful for letting your AD carry pick up a kill.  Furthermore, it's generally a benefit to have a somewhat tanky support, and Cho'gath meets this criterion.  However as a support character you will not be able to capitalize on your Feast or gain its buff without taking minion or champion kills from your AD carry (something that a support shouldn't do).  While it might not be many minion kills (unless you're dying a lot), it still adds up over time, and the last thing you want is for your AD carry to fall behind the enemy's.
Bot - AD Carry: Because Cho'gath is an AP character and does not have a single skill that scales off of AD or buffs a related stat (such as an Attack Speed buff), it is not viable to build Cho'gath as an AD carry.
The rest is certainly up for argument, however I would say that while it is possible to go mid as Cho'gath and attempt to be AP carry, it will be so extremely hard to keep up with your enemy (never mind getting ahead of him) that there are much more viable options.  I can't see Cho'gath mid being more than passable in this role, and he will more often than not be a detriment.  The same goes with his support capability (though to a lesser extent).  While he could do the job, and maybe even do it well, the fact is that there are many other champions out there who can do the same job and do it much better.
As such, I would conclude that his two best and most viable roles are in top lane and in the jungle.  Which is better is certainly open for debate.
In answer to the less restrictive question "What is viable?" I would include support in this list (because it can certainly be extremely effective if played correctly) but still exclude mid AP carry due to the inherent limitations and difficulties.
Comment: Well, I've never seen Gragas used at a high level of play (meaning, pro or tournament level).  But he has a little bit more of a sustain and ability to initiate than Cho'gath.  His passive lets him regenerate life each time he uses an ability and the `Drunken Rage` reduces the damage he takes.  He can also close very quickly with his opponent (no matter how much range he might have) using `Body Slam`.  Combine that with the poke provided by `Barrel Roll` and a well-placed `Explosive Cask` knocking the opponent closer to him or his jungler, he seems a little more viable.
Comment: @Alok what is meant when a champion is called 'Melee' or 'Ranged' is their Auto attacks; and as such Gragas is a Melee mage like Kassadin.
Comment: Well done, I have only one question\argument. You mentioned that Cho would be a less than ideal mid due to his range issues, but Gragas is an AMAZING mid, and also is melee. Yes, his barrel has a nice range on it, but I feel rupture's range is arguably similar. Whats your take on this?
Comment: I would also point out that Barrel Roll can be used to zone an enemy, or at least limit the available movement, in mid lane.
Comment: @Ender I didn't consider Gragas as melee when he was free; AP Gragas can farm with barrels and generally stays at range (except if using body slam)
Comment: There is a Platinum 1 player that plays AP Cho'Gath in Mid, and does so very well. Harasses with Feral Scream and range hits creeps with Vorpal Spikes. Cho'Gath is definitely one of the most versatile champions.
Comment: @RyanKempt Yeah, a lot has changed in the meta since this post.  It was over a year ago!  Haha
Comment: @JeffGohlke Woops, didn't notice that! I had a friend link me this URL and all my brain picked up was Aug 14, not the 2012 part. Lol
Comment: @RyanKempt Cho is a lot more viable now that they standardized the time of Rupture.  It used to be variable (between 0.5 and 0.75 seconds), so it was really hard to be certain of hitting an opponent.  I've heard he's a lot more popular since that change.
Answer: Since he scales off of AP, he cannot be an AD carry.
While his ultimate hits hard and is true damage, it lacks range.  His silence and pop up also do decent damage but have the same range issue.  To make use of his spells, he has to get in close, without a closer.  Between kiting and enemy burst, he will quickly die if he doesn't build tanky. If he builds tanky, there isn't room to build him as an AP DPS.
He can function as a jungler.  He has a decent clear time, innate sustain, and two CC spells for tanks.  The only down side is that he will get less income than he would in lane, making it expensive for him to be a tank.
His best role is top lane tank.  He is a solid counter to sustain type heroes like Vlad and Yorick that can be troublesome.
Comment: Good answer, I would like to see other answers first before I accept it however, as different perspectives tend to bring new ideas and information.
Answer: As a long time Cho player (he was my first main character when I was learning to play) I would say that he is best suited to top and second best to mid.  However be aware that in both cases what matters most is your lane opponent.  There are characters than Cho'gath has an easy time fighting (katarina, kennen, fizz, ziggs, and other squishy AP characters) and some that he has a really hard time fighting (olaf, riven, darius, and other in-your-face brawlers).
Also, I'm sure there are good links to guides you can find, but I almost always take flash ignite for summoners (the flash-feast combo is too good to pass up), and go 9/21/0 masteries for some damage but mostly tankiness.  I tend to build Rod of Ages first, then Rylai's, and finish up with a mix of tank and AP items depending on what I need to survive in fights and still do damage.
I personally love Cho'gath as a character and I hope you enjoy playing him! Best of luck
Answer: He is probably best as a jungler or a top laner. but you can do support if mana is not a problem to you cause his Q uses quite a lot so cho'gath relies mainly on his passive which restores mana and health when you kill something, but being a support you won't be able to do that cause your ADc will be doing that.
In my opinion he's better jungle.


Christoffel symbols in Differential geometry iff proof

Question: I need help in proving that $H = 0$ for a surface iff $g_{11}L_{22} - 2g_{12}L_{12} + g_{22}L_{11} = 0.$
I think that these are the Christoffel symbols exploited in some manner and normally, I'm not sure what matrix representation this was derived from.
Thanks in advance!
Comment: Can you maybe state all the definitions of the various symbols? Not only for the reader, but this might already help you see where you could begin a proof!
Comment: What do you mean by $L_{11}, L_{12}, L_{22}$?  I assume they're the coefficients of the second fundamental form, but I want to make sure.
Comment: Yes, that is correct. Sorry about my wrong thought, still learning the material
Comment: Hi! I'd like to know what does $H$ mean? where are the Christoffel symbols here?
Comment: not very sure, still trying to learn that
Comment: But Christoffel symbols are objects (non-tensors) with three indices (unless you contract two of them). I.e. $$\Gamma^\alpha_{\beta\gamma}=\frac{1}{2}g^{\alpha\mu}(g_{\mu \beta,\gamma}+g_{\mu \gamma,\beta}-g_{\beta\gamma,\mu}).$$
Answer: Usually when talking about surfaces $H$ refers to the mean curvature. Mean curvature is defined to be $$H = \frac{L_{11}}{g_{11}} + \frac{L_{22}}{g_{22}}$$ If you know some linear algebra, then you will recognize that this is the trace of the bilinear form $L$. Let me give you a hint on how to do your problem. Divide your equation by $g_{11}g_{22}$ (why can't $g_{11}g_{22}$ be zero?) to obtain $$\frac{L_{11}}{g_{11}} + \frac{L_{22}}{g_{22}} = \frac{2g_{12}L_{12}}{g_{11}g_{22}}$$ Since $H$ does not depend on the parametrization, it follows that $$\frac{2g_{12}L_{12}}{g_{11}g_{22}}$$ doesn't depend on the parametrization either. Thus, we may as well choose a parametrization in which $g_{12} = 0$ (it is always possible to do this- such parametrizations are called ``orthogonal parametrizations''). Thus $H = 0$.
Now let's consider the converse statement. Suppose that $H = 0$. Thus
$$\frac{L_{11}}{g_{11}} + \frac{L_{22}}{g_{22}} = 0$$
To finish the problem, you want to show that $-2g_{12}L_{12} =0$. But this does not have to be true! (For a counterexample, consider the catenoid and choose any system of coordinates whose coordinate vectors are not orthogonal. Then it will turn out that $g_{12}$ and $L_{12}$ are nonzero). On the other hand, the converse is true if we assume that we are working in an orthogonal parametrization (that is, we choose coordinates that are orthogonal to each other). For if $g_{12} = 0$, then it is clear that $-2g_{12}L_{12} =0$


How do I deliver all burgers in under one minute?

Question: In the mission Dynasty Dash: Eden-6 you have to deliver burgers to five locations spread all across the map on a ten minute timer. One of the bonus objectives is to deliver all burgers with 9:00 minutes remaining.
How can this be achieved? Also if it's possible: what is the bonus reward for doing so.
Comment: For missions like this in BL2, me and my friends would clear enemies from the area around the drop points first  then camp on as many as possible before someone triggers the timer. Instant delivery of three drops. For solo - just clear enemies so you get a clean run
Comment: Please take into account that burder missions also offer possibility to increase remaining time by destroying nearby posters.
Comment: The only reward seems to be more cash. There isn't any hidden reward for doing it in under 1 minute. The mission can be repeated an unlimited number of times.
Answer: This mission in particular has a secondary objective that is mentioned but not labelled on the quest tracker. Shooting competitors signs will add some seconds to your remaining time. They are highlighted red and are seen as you drive between the different delivery points.
Comment: nice find. And also, Burgerlands 3 *scnr*
Comment: It's actually not delivering it under 1 minute, but finish the delivery with more than 9 minutes to spare.  The difference is you can add time by shooting signs, so strictly speaking, this is not answering the question but is actually the correct answer.


GWT CELLTABLE : How to set columns descending icon on celltable header?

Question: How to set columns descending icon i.e. DESC icon on celltable header  ?
On celltable loading.. I want to set sorting order to column i.e. previously sorted column/sorting order by user (In last login , before logout)
I tried following way
table.getColumnSortList().push(testColumn); i.e setting column ascending to true with ASC Icon on top of header.It works fine
Now I want to set column in descending i.e DESC icon on top header ? How to do it ?
Any help or guidance in this matter would be appreciated
Answer: When you call table.getColumnSortList().push(testColumn) if no sort info is set on the column it sets the sort to ascending. If you call it another time it reverses the sort order.
// Show the descending sort icon on a column.
ColumnSortInfo sortInfo = table.getColumnSortList().push(testColumn);
if (sortInfo.isAscending()) {
    table.getColumnSortList().push(testColumn);
}

To set the sort icon according to state saved in variable sortOrder:
// Assuming sortedOrder = true means ascending
// and sortedOrder = false means descending
ColumnSortInfo sortInfo = table.getColumnSortList().push(testColumn);
if (sortedOrder && !sortInfo.isAscending()) {
    table.getColumnSortList().push(testColumn);
}
else if (!sortedOrder && sortInfo.isAscending()) {
    table.getColumnSortList().push(testColumn);
}

Comment: Thanks for reply. jonic above code is used for flipped the order. My problem is that I want to show sorted order of column after celltable loading. eg. I have xml. I am getting only one column information i.e column(columnname, sortedOrder[false/true],dataTypeOf) as per column information I want to set ASC/DESC icon close to Column as per value.


Use LinkedIn JSAPI credentials cookie to authenticate a user

Question: We would like to implement "Sign-in with LinkedIn" in our app. Since the app has JS fronted and RESt-based backend, we decided to exchange JSAPI tokens for REST API OAuth tokens as described here.
If a user successfully signs in, the frontend sends credentials cookie with client-side bearer token and member ID to the backend. On the backend we check if a user with such a member ID already exists and if not, we exchange JSAPI token for REST API OAuth token, retrieve user details from LinkedIn a store it in our database.
Now the question is if we can use that cookie to authenticate each user's request to our REST backend. After a user successfully signed in via JSAPI, the cookie should be automatically passed to our backend on all subsequent requests so we can check member ID. Are there any drawbacks that we missed? Or is this idea as a whole wrong?
Should we rather authenticate a user only once by means of the cookie and then issue our own authentication token and send it back to the client?
Comment: why you want exchange token.if you want to save user profile.you can use javascript callback function and send ajax request with user details and do what you want.
Comment: So what you suggest is to do OAuth dance on the client side, get user profile and then send the details to the server?
Comment: I would not recommend doing the oAuth dance on the client side. It's not particularly secure and people could intercept and alter the data before it's transmitted to your server. Use the secure cookie, convert the token server side and go from there.
Answer: The way cookies work in general is they are passed on every request to the domain they belong to. LinkedIn is setting a credentials cookie to your domain.
As long as you are validating those credentials on every request it's perfectly acceptable to use their tokens as authentication.
Personally I don't find that to be a great idea and would prefer to validate their credentials once and create my own auth token to use from there on out. You can always set that token to expire at some-point and re-validate the LinkedIn credentials (which will still be getting sent on every request anyway). This limits the amount of times you're checking with LinkedIn and should increase the responsiveness of your app.
Comment: Your points are definitely valid. Especially that one with using our own auth token. Now we are thinking about a flow like this. We do OAuth dance with LinkedIn completely on our server side (OAuth authorization token flow) and when done, we redirect to our client URL (our frontend is JS app) along with our own auth token in URL fragment or query parameter. The second part is similar to OAuth implicit flow. Can you see any pitfalls?
Comment: @Nathan This is pretty much what we're doing. I would hesitate to put your auth token in the url or as a query param. The less exposure you can give that token the better. We're storing our own auth tokens as a signed cookie. The cookie gets sent along even with our ajax requests.
Answer: Either way could work.
If you are using the LinkedIn cookie to validate a user by member id, you should validate the cookie's signature on each request per section 2 of the doc you linked and question 2 of the FAQ.
Using your own token could make it easier to implement an account which belongs to your app and is not necessarily connected to LinkedIn, assuming there's the potential to either connect solely with some other service(s) or no 3rd part(y/ies). Still should validate any time you trust the member id in the cookie though.
The doc provides a validation example in PHP, and if you're interested in improving a ruby version, I have a shameless plug.
The flow that you've outlined in your latest comment of going straight for the OAuth tokens is the best way to go if you were only signing in to convert the JSAPI tokens to OAuth tokens and then not using the JSAPI further. If you were planning to actually use both the JSAPI tokens within your front-end app and the OAuth tokens on your back-end, then it's better to take the conversion route.


Server responses fail corresponding to load test using JMeter

Question: Using JMeter, I am load testing a web application that is hosted locally(Apache 2). When I am generating load like 5000+ virtual user, I saw more than 30% CPU is idle but still getting failed responses. Mostly it gives java.socketException. Will anybody please clear me If anything is going wrong from my end?
Thanks in advance.
Answer: I believe you experience a problem described in Connection Reset since JMeter 2.10 ? wiki page. If you absolutely sure that everything is fine with your server (CPU usage is far not only one metric which needs to be considered) you can work it around as follows:

Switch "Implementation" of all your HTTP Request samplers to HTTPClient4. The fastest and the easiest way of doing this is using HTTP Request Defaults configuration element
Add the next lines to user.properties file (lives under /bin folder of your JMeter installation)
httpclient4.retrycount=1
hc.parameters.file=hc.parameters

In hc.parameters file (same location: JMeter's /bin folder) add the following line:
http.connection.stalecheck$Boolean=true

You need to restart JMeter in order to pick the new properties up
Comment: Thank you for your response. I will definitely try this.