How do I explain to ClangFormat that `:=` is an assignment operator in my programming language, rather than label+assignment?

Question: ClangFormat does a relatively good job formatting code written in my programming language. However, one quirky problem is that it inserts whitespace (sometimes even new-line characters) between : and = in my assignment operator :=, like here. That does not prevent programs from being compiled, as the tokenizer for my programming language ignores whitespace between : and =, but it looks ugly. Is there a way to tell ClangFormat not to do that? Or do I have to write a formatter for my programming language myself? And, if so, how?
Comment: It seems on-topic to me, but I suspect the answer is that ClangFormat is not designed for this and it is not the right tool for the job. According to [the docs](https://clang.llvm.org/docs/ClangFormat.html), ClangFormat is *"A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code."* It does not appear to be a tool that is designed to be configurable for arbitrary other languages.
Comment: @user I'm pretty sure we've decided at least once that questions about using language design-specific software tools is perfectly on-topic...lemme find the post(s)
Comment: Note to close vote reviewers: ^ is not a reason to VTC this as off-topic, just an answer of "it's not possible"/a frame challenge
Comment: I disagree with the meta discussion and am voting to close this question in spite of it. I think this question is too specific a question about too specific a tool to be of general use to programming language designers and implementers other than the OP, so it shouldn't be on-topic here.
Comment: If you're asking about how to configure or add support for your language to ClangFormat, I'm afraid this question may be more on-topic on Stack Overflow. A question about designing your own formatter from scratch might be better on PLDI.
Comment: Since this seems to be in the VTC queue again, reminder that we've discussed this on Meta and have decided it is on-topic
Comment: @pxeger Where can I find that Meta discussion?
Comment: @FlatAssembler https://langdev.meta.stackexchange.com/q/417
Comment: @pxeger I agree in principle, but I also think the question can in principle be understood more broadly: it's generally about making the tool treat two symbols as a single operator when it doesn't already have a hard-coded rule to do so. Assuming the one answer so far is correct, the warning of unsuitability will be useful information for others who sought to use the same tool to do related things.
Answer: According to the docs, ClangFormat is

A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.

It does not appear to be a tool that is designed to be configurable for arbitrary other languages, so as far as I can tell, the answer is that there isn't an intended way to tell it the syntax for your own language.
Otherwise, the answer seems to be to write your own formatter, or to fork ClangFormat in order to support your language.


Generate random number in Plutus on-chain code

Question: Is it possible to generate a random number in Plutus on-chain code? For example, if I would like to implement a smart contract that works like gambling game, where a person deposits ADA and bets on a random outcome and then the contract generates that random outcome to determine if the player won?
Answer:
Is it possible to generate a random number in Plutus on-chain code?

No. On-chain code is deterministic, so there is no way to generate a number on-chian that someone off-chain couldn't predict.
The way around this would be to use an RNG oracle. Essentially outsourcing the generation of the random number to some third party, off-chain. You can then use that oracle's (or multiple oracles') data as an input for any games that needs random values.
Comment: Thats what I thought. Rather than using an oracle, would it be possible to simulate a RNG by somehow combining data available in UTXOs? If we would require the input transactions to have random datums and then combine them for all UTXOs would that be sufficiently random?
Comment: That would create a sort of lottery, where people would be looking for UTxOs that meet a certain requirement, so not exactly an RNG.


How to apply a master page to every Nth page?

Question: Is there a expression/code in "apply master page" dialogue to apply selected master to every n pages, for example every 6th page?
Any scripts suggestions will be appreciated!
Comment: Thanks for the script, Wolff! It works as described and is exactly what I needed!
Answer: I have made a script that should accomplish what you want.
The main functionality of the script (the first part) is commented and pretty straight-forward (if you know javascript). I have added a small input dialog to make the script easy to use, but I haven't commented that part of the code.
Copy the code below to a text editor and save it as a .jsx file (for example ApplyMasterToEveryNthPage.jsx) in the folder for user scripts.
In InDesign, run the script and a dialog box will appear. Here you choose which master to use, the first page to apply it to and the interval (n).
Let me know if it works for you.

<code>// APPLY MASTER TO EVERY NTH PAGE
// Copyright (c) 2017 Mads Wolff
// This script is distributed under the MIT License.

// MAIN FUNCTIONALITY

// Make a reference to the "pages" of the active document.
var pages = app.activeDocument.pages;

// Make a reference to the "masterSpreads" of the active document.
var masterSpreads = app.activeDocument.masterSpreads;

// Applies a master to every nth page starting at a certain page.
// Takes 3 arguments:
//   masterName   the name of the master spread
//   firstPage    the first page to apply the master to
//   interval     the interval (n) to apply the master at
function applyMasterToEveryNthPage(masterName, firstPage, interval) {

  // Make a reference to the "masterSpread" to apply.
  var masterSpread = masterSpreads.item(masterName);

  // Iterate through the "pages" at the chosen "interval", starting at the chosen "firstPage".
  for (var i = firstPage - 1; i < pages.length; i += interval) {

    // Make a reference to the "page".
    var page = pages.item(i);

    // Apply the "masterSpread" to the "page" by setting its "appliedMaster" attribute.
    page.appliedMaster = masterSpread;

  }

}

// DIALOG

// Stores all the names of the document's master spreads in an array.
function getMasterSpreadNames() {
    var masterSpreadNames = new Array;
    for(i = 0; i < masterSpreads.length; i++){
        masterSpreadNames.push(masterSpreads.item(i).name);
    }
    return masterSpreadNames;
}

// Displays the input dialog.
function displayDialog(){
    var dialog = app.dialogs.add({name:"Add Master To Every Nth Page"});
  var masterSpreadNames = getMasterSpreadNames();
    with (dialog) {
        with (dialogColumns.add()) {
      with (borderPanels.add()) {
        with (dialogColumns.add()) {
          staticTexts.add({staticLabel:"Master:"});
          staticTexts.add({staticLabel:"First page:"});
          staticTexts.add({staticLabel:"Interval:"});
        }
        with (dialogColumns.add()) {
          var masterNameDropdown = dropdowns.add({stringList: masterSpreadNames, selectedIndex: 0, minWidth: 200});
          var firstPageField = integerEditboxes.add({editValue: 1, minimumValue: 1, maximumValue: pages.length});
          var intervalField = integerEditboxes.add({editValue: 2, minimumValue: 1, maximumValue: pages.length});
        }
      }
    }
    }
    var dialogReturn = dialog.show();
    if (dialogReturn == true) {
        var masterName = masterSpreadNames[masterNameDropdown.selectedIndex];
        var firstPage = firstPageField.editValue;
        var interval = intervalField.editValue;
        dialog.destroy();
    applyMasterToEveryNthPage(masterName, firstPage, interval);
    } else {
        dialog.destroy();
    }
}

displayDialog();
</code>
Comment: ahhh... really appreciate it , it will save us all a lot of time... I test it and soon feedback too.
Comment: works great! thanks a lot for that simple user interface, that helps much more. just what I needed.
Answer: The best thing I can come up with is to generate the required page number sequence in 3-rd party software (like Excel) and then paste it in "apply..." field. Seems to work with documents several hundred pages long.
For example, in Excel put in A1 cell the initial page you want to apply master to.
Then, in B1 cell type A1+N.
Then apply and drag B1 by bottom right corner to the right for as many numbers as you wish. You'll have to copy the whole line of cells and replace tab symbols with commas.

Or you can use online tools like https://rechneronline.de/number-list/
Comment: thanks senge! looks a useful solution, while it is not what exactly i was looking about in InDesign... which I don't think it have that thou!


Ubuntu 17.10 gnome crashing on login

Question: I keep losing my gnome session every time I log in. I'd love to figure out what's going on and causing the crash but I'm very new to Gnome what with it only now being the default desktop for Ubuntu. This crash seems to happen every time I log back into my computer after locking it.
Answer: There appears to be hell lot of bugs in 17.10 specially with gnome, so for now I suggest to use X or unity.
X:
click on wheel and select X at login.
Unity:
sudo apt install unity
select good old lightdm instead of gdm when prompted, reboot and choose unity at login.
Answer: Having been trying to customize gnome to what I liked, I had created a folder under ~/.local/share/gnome-shell called /extensions and had filled it with an extension. Removing said folder fixed my problem.

Ubuntu 17.10 gnome crashing on login


Adding block below Header Logo

Question: I am placing a couple of static elements into the header, the issue is that the elements are being placed below the menu instead of below the header logo. Is this possible to put the block below the header logo image? I had to hack the css with a negative left margin and absolute top for now but it does not behave properly when elements are declared above it. (e.g. if admin logs in, or is not logged in, will affect the position vertically, etc)
Answer: If you are trying to place some block below the site logo, there should be a region below it. CSS come later.
If your block is going below menu, that means the region where you are placing are rendered below menu in the page.tpl.php
You have two choice here - either render the same region just after site logo or create another region in there.
Open your page.tpl.php & try to find -
<?php if ($logo): ?>
  /*more text*/
<?php endif; ?>

Render your region just after it (assuming your region name is header) --
<?php print render($page['header']); ?>

You can add DIV class or ID according to your need around it or do it in if-else, like -
<?php if ($page['header']): ?>

    <?php print render($page['header']); ?>

<?php endif; ?>

You can add your own region in theme.info file if you don't want to use the same where you were trying to place your static content.
Comment: Ah ok, that makes a bit more sense programatically. Wasn't sure if I could use the cms to render the block below the site logo or if I had to code it into the theme. When I put the block in header for all pages it renders below the menu so I had to hack the css to move it left. Thanks for your helpful answer!

Adding block below Header Logo


How to tailor a prince 2 project as a software supplier and the PM

Question: I am interested if anyone has tailored prince 2 to this purpose as many aspects of the project process do not seem applicable.  Such as assigning project board as this is done at the point of sale before I am involved and initiation doc etc.  any examples of tailored down method or advised would be appreciated
Answer: Remember that PRINCE2 is a method/framework for you to work within. The only thing that is absolutely required is to work within the principles of PRINCE2 (focus on products, continual business justification, manage by stages, manage by exception, defined roles/responsibilities, learn from experience, tailor the method to your needs).
The specifics of tailoring would have to be geared to your project, but the PRINCE2 manual has a good section on tailoring of the method that could give you guidance. If you don't need so much control or the project is of lower risk/criticality you could, for example:

Merge roles within the project board (e.g. executive and senior user could be same person)
Merge roles within the project team (e.g. PM and project support could be same person)
Tailor the detail and/or formality required in managment products (e.g. checkpoint and highlight reports)

Regarding the Project Board, also remember that membership does not have to be static. If it makes sense to change one or more members you should. The important thing like Iain said is that all interests (user, supplier and executive) are represented.
Answer: Hopefully I've understood the question correctly. I've been dealing with the same question from a Digital Agency perspective - working on major web development projects.
PRINCE2's conception of "customer" is not ideal in a software supplier / customer relationship.
We decided NOT to put the client on the Project Board because we don't want to bother the client with project minutiae, our internal resource anxieties. Most importantly though, this maintains a contractual fence between client and us (the supplier). A healthy project has everyone's interests aligned, but placing the client on the project board potentially places too much power with the client, which could lead to mission creep.
We call the "Project Executive" the "Product Owner" - this is usually the senior Account Director who knows the client the best. They represent the client in the process, but also act as the conduit if there are major budget/scope issues to resolve.
I don't know if this is the "right" way of doing things - but it seems to work OK.
Answer: I wonder whether you are trying to look at this as a single project, where perhaps it should be considered as two?

Developing the product that will be sold;
Implementing the product in the client's environment.

If I am right in my assumption, then you certainly can tailor each of these separately: just be sure that you keep a clear focus on the deliverables for the two different clients (internal and external) that correspond to the project that you are running.
At the point of sale, the client should be creating the project board, and you, as PM, will be invited to be involved, but remember that in a Prince 2 environment, the Project Board is responsible for the project, and the PM is the conduit through which delivery is achieved... This is not how it works using different project models, where the PM is solely responsible.


PHP constructor executes before arguments for nested variables can be supplied

Question: First things first, here is a little snippet code to help explain my problem:
<?php
class foo {

    public $title;

    __construct{

        echo "\n";
        echo "\n";
        echo "<title>".$this->title."</title>\n";
        echo "\n";
        echo "\n";

    }

    /**
    *
    * I get $title from index.php
    *
    */
    public function setTitle( $title )
    {

        $this->title = $title;

    }

    __destruct{

        echo "\n";
        echo "\n";

    }

}
?>

You've probably noticed already that this code will produce a title of well,  . Yah, there's an empty space there. :- )
To me this actually makes perfect sense (even if I wasn't expecting it) because the class constructor is being executed on the creation of the foo object meaning that it doesn't wait around for index.php to supply the argument for setTitle() which in turn returns the string that fills $this->title.
So if I truly understand whats going on here, what can I do to get around this issue? Should I be buffering the output using the built in buffer functions, and then modifying the stored output with the supplied title string? Any ideas?
I would really, really, really, like to keep this structure where the constructor and destructor contain this repetitive code. Its nice that these functions don't have to be called anywhere. I understand that some developers may consider this bad practice, but I am going to do it this way anyway because I want to because I think its cool. So i'm not really looking for advice in that aspect, unless you feel extremely motivated to inform me on my stupidity.
So, if you have any advice/ideas/knowlege to share with me that would be great.
Thanks, and feel free to take your time because I guess i'm going to be forced to stay inside hiding from the evil swine flu that has come to my city, so no rush!
Answer: teh_noob.  Listen to me.  These words that I'm typing right here.  Pretend I'm saying them, and hear the words that are coming out of my mouth. No. NO NO NO NO NO!  And no, I don't give a rat's butt how "cool" you think it is.
This is one of those unfortunate scenarios where it would be shorter to list the "right" things about this approach that the "wrong" things.  That is to say, your problems are numerous.  That being said, I'm going to go over only some of the things that are bad about this idea.
First, let's just discuss OOP in general. What you are doing here is my least favorite thing to see ever: what I call "programming with classes".  That is to say, structured programming in the guise of OOP because a class keyword was used.  If you're gonna do this, don't bother.  Just use functions.  This is class abuse plain and simple.
Classes are object blueprints.Objects lend themselves to encapsulation and instantiation. Unless you're really a fan of the Singleton pattern, why create a class that is clearly designed to be instantiated only once?  And before you say "But Peter, the Singleton Pattern helps us!!!1one" try to understand that it's actually not all that great. Besides, what you're doing here isn't even a reason people turn to the Singleton pattern in the first place.
Second is the topic of subclasses.  Maybe at some point in the future you'll want some popup pages for your site. Or you'll want print-only versions that are more than just CSS-driven.  Maybe you'll even want something that's not HTML at all like an RSS feed. What now?  How much other work that goes on in this constructor are you going to have to duplicate for these new page types to work?  But what if you've already started relying on subclasses to create individual pages?  Now you're fucked.  Sure, you can go back and hook up the decorator pattern, but why go through all that work when this problem can be avoided by non-stupid class design in the first place?
Thirdly, is the idea of echoing HTML in the first place. I'm fine with echo for a word or two here, a tag or three there.  But for large HTML chunks, it's just idiocy. Have the decency to escape to output mode and use HTML that's not locked down in a string.  Not only is it easier to edit and read, you can actually work with it in a WYSIWYG should you so desire.
Fourth, this badly, badly breaks the SRP.
Fifth - this kind of ridiculous design leads to the very type of problems you're trying to solve here.  Only you don't want to know that the solution is to remove the echo statements from your constructor.  Is there a way around it? Sure.  In fact, there's even more than one.  Do I recommend any of them?  No, not really.
Lastly, let's discuss headers. Maybe you haven't learned about them yet. Maybe you have and don't care.  But what's going to happen when, 6 months from now, you're working on a problem and you're working inside a method that's 10 calls deep in the stack and you realize a simple header() function will solve your problem. Maybe you need to adjust the cache-control or you need to manually set the response code - whatever.  But guess what, you can't. Why?  Because your silly constructor outputs to the browser the millisecond it's created.
So, to recap: NO!  Unless your actual, ultimate goal is to see some of your very on handiwork on The Daily WTF.
What can I offer besides admonishment?  Maybe part of a new direction?  Well, debugging output is hard enough in well-built systems, so don't start by shooting yourself in the foot that does it implicitly.  All output from your system should be explicit.  If you want to make a "page" type of class, that's fine.  Just don't do it like that.
class foo
{
    protected $title;
    protected $headers;

    public function setTitle( $title )
    {
        $this->title = $title;
    }

    public function addHeader( $header )
    {
        $this->headers[] = $header;
    }

    public function sendHeaders()
    {
        foreach ( $this->headers as $header )
        {
            header( $header );
        }
    }

    public function printPageHeader()
    {
        $this->sendHeaders();
        ?>

                    <title><?php echo $this->title; ?></title>

        <?php
    }

    public function printPageFooter()
    {
        ?>

        <?php
    }

    public function printPage()
    {
        $this->printPageHeader();
        $this->printPageFooter();
    }
}

$p = new foo;
$p->setTitle( 'Just Testing' );
$p->addHeader( 'Cache-control: no-cache' );
$p->printPage();

Comment: I wouldn't be being honest if I told you I agreed with everything you said there. But you do fall into the category of "extremely motivated", so I will award you the "answer" for this question. I think next time I ask a question such as this I will add more details as to the scope of my project so people will better understand what i'm getting at. Your rant made me tired i'm going to bed now. One last note my example above was only meant to help explain my question and was not actually in or a part of my framework.
Comment: Well, I'd love to see more about what it is you're working on, and ACTUALLY trying to do.
Comment: Don't drink mountain dew and then try to sleep. Maybe when i'm done ill send you a link to prove my stubbornness or everything will work fine without a problem because the code just works anyway. I could re ask my question as: "Help me find good ways to do something wrong because I know its "wrong" but I want to do it anyway because I like it that way and it works and it has an un-logical logic to it that only applies to this specific situation and its only a tiny part of the framework so it will not doom everything"
Comment: I do disagree about the string thing though. That `printPageHeader()` function is as far as I'm concerned totally unreadable because of the random spawning html. It might be a taste thing, but I really don't see why you would want _that_ in structured code. Maybe you want something like heredoc/nowdoc, or rather make a template with html and some code where you put your html (using a different template engine or php itself, that's another discussion we probably don't need here :) ).
Comment: @Nanne - yeah. I agree... now.  Not sure why I decided to write it like that.  To be fair, that *was* over three years ago ;)
Comment: wut?! I have no clue how I missed that, or how this question turned up in my browser.. That's... weird.. didn't mean to drag up old questions, for some reason my brain decided it was recent. Hmm. Carry on, nothing to see here I guess :D
Answer: You could do all the printing in the destructor. There all variables are known. However (like you said yourself) I think this is really really bad practice. I would suggest using kind of view / template files (you anyway have time enough :) ).
Answer: You could pass the title as an argument in the constructor?
Comment: please, stop! don't build a framework that outputs html in the constructor. so wrong!
Comment: I could, but the whole idea is that the title is supplied by index.php (this is all part of a little framework i'm building).
Comment: I have to, some times you have to take one for the team to make a difference.
Comment: Gotta side with Schnalle and Peter here. The point of a constructor is to initialize an object, not output content to the browser.
Answer:
schnalle: this is bad practice. this is madness.
the_noob: madness ...?
the_noob: (shouts) THIS ... IS ... LITTLEFRAMEWORKIMBUILDING!
the_noob: (kicks separation of code and presentation down the well)

i don't really get what you want to do, but just pass the title as a parameter to the constructor ...
<?php

class Title {
    public function __construct($title) {

        echo '<title>' . htmlspecialchars($title) . '</title>';
    }

    public function __destruct() {
        echo '';
    }
}

?>

if you really want your objects to print something, i'd suggest the magic __tostring() method, so you can simply echo your object. but for html tags ... still not useful.
i wish you luck with your framework, but you're either a genius (not likely) or a guy making the same mistakes (almost) every beginner did (before MVC arrived).

edit: i can't help you. you want direct output when the object is created, but need to get data into the object before it is created. so you try to workaround something ugly in making it even uglier. it just doesn't work that way!
  you're trying to build a new, better kind of car by attaching wheels to a living donkey, then complain because it somehow didn't work out as you expected (donkey on wheels! wheooo!), and now you ask the community how to attach taillights in a way that makes the donkey/car go faster.
Comment: LOL, yes I know i'm breaking all the rules here. But i'm done letting all these rules and standards boss me around! Its time to deviate from the dull pattern of web frameworks! So who's with me?!?!
Comment: hmmmmm...interesting, however I don't like the idea of passing variables directly into a constructor like that (for no logical reason). However that gives me the idea that maybe I could pass parameters from other functions.
Comment: In all seriousness, i'm no where close to a genius but i'm not dumb either. And what may come as a surprise to you, my framework is MVC based. I'm deviating from the rules a little bit though because I think it's better the way i'm doing it. You can and have already helped me. We must be seeing things from different angles because I see beauty in this. Don't hate me for asking for ideas.
Comment: i don't hate you for that, i did a lot of crazy (and nonsensical) stuff myself. learned a lot from those attempts to do it the "my" way. and i agree, you can do stuff quite elegant by wrapping html around objects. but the constructors and destructors are NOT meant for this and it absolutley makes NO sense to try to force them into this role.
Comment: Fair enough, but i'm still sticking with my way.


Where did the term "How's tricks" come from?

Question: Where does it come from and what it really use to mean?
Comment: The full OED has it first recorded 1915 under definition P4 **how's** (less frequently **how are**) **tricks?** - *how are things? how are you getting on? colloquial (originally U.S.).* Compare *You **never miss a trick*** (you exploit every opportunity) and ***How's your luck**?* (are you *getting* good opportunities?).
Comment: @StuartF: Obviously as a native Anglophone I'm quite familiar with the usage / semantics of the idiomatic expression itself, but the little bit of "research" I did before commenting above didn't get me anywhere near the level of understanding that user66974's answer provides in terms of origin / etymology. And who knows? Perhaps someone else could give us even *more* insights if the question were to be reopened (which I've just voted for).
Comment: How is this question "off-topic." while there are so many exactly like this on this site? Just see the "Related" panel on right side.
Comment: Regarding why it's off-topic, read the whole message: "Please include the research you've done, or consider if your question suits our English Language Learners site better. Questions that can be answered using commonly-available references are off-topic."
Answer: Tricks, meaning circumstances, one's life.
(backformation from colloquial  greeting how's tricks?)

1930  [US]    E.H. Lavine Third Degree (1931) 162: About an hour later, the sergeant came along and asked him how tricks were.

2000  [UK]    J.J. Connolly Layer Cake 104: Tricks are good but I ain't got time to enjoy things.

(Greens Dictionary of Slang)
Its origin is unclear, as noted in the following extract:

According to the Dictionary of Slang and Unconventional English, the phrase derives from either the nautical meaning of 'trick' ('turn of duty') or the card game 'trick'.
But from its early days, the phrase was considered crude, as evidenced by this 1924 reference: "'Well, Mrs. H., how's tricks?' His wife flushed slightly at the vulgarity of the phrase." Usage became prevalent in the 1930s, especially among pimps who'd ask the prostitutes in their employ how business was going ('turning tricks'), but the phrase was soon adopted by all the cool kids with greased-back hair and leather jackets...

…………..

The noun form of the Latin verb tricari is tricae, meaning 'trifles, toys.' From at least the mid-16th century we have trick referring to 'a trinket, bauble, knick-knack.' Farmer's A Dictionary of Slang, published in 1890, lists as current "Western American" slang a sense of trick meaning 'belongings, things, baggage.' For a phrase that is equivalent to "How's things?," it's not too far-fetched to think that it may have been influenced by this sense."
But the sexual connotation has outlived all others, making 'How's tricks?' a fun way to both show an interest in how someone is doing and mildly insult them at the same time!
Comment: Interesting.  I'm familiar with the term "turning tricks", but "how's tricks?" is so utterly unfamiliar to me that (as an American) I assumed it was of British origin.
Comment: @JohnBollinger - I've mostly seen it in old black & white Hollywood movies, where the speaker was trying to sound streetwise. So I don't think we can blame the Brits for this one.
Comment: I'd never even thought about the origin of the phrase and certainly never connected it with prostitution but, if it started as a pimp's phrase, that would certainly explain why a respectable married lady would blush at being asked how tricks were. I would like to have an attribution for the quote though, it's a pity that the blog gives no more details.
Answer: Google Books and Elephind newspaper database searches turn up matches for the question "How's tricks?" from at least as early as 1873. From "How's Tricks?" in the Nashville [Tennessee] Union and American (April 10, 1873), reprinted from the San Francisco [California] Chronicle:

"HOW'S TRICKS?"
There is a doctor in this city who has a speaking-tube leading from the main entrance of his building to his office, which is up just a few flights. For several days past a smart young wag named Swartz has amused himself by calling the doctor through the pipe, and then profanely ordering him to set out on an excursion to Tartarus. For some time this fun was taken in good part until the fine humor of the joke no longer became apparent. Accordingly, one afternoon, the disciple of Esculapius provided himself with a tea-kettle of water, heated to about 210 degrees Fahrenheit, and waited along side the pipe. Pretty soon the old familiar sound came up through the pipe, "Say, Doc, how's Tricks?" "Tricks is better now—I guess he'll get well," responded the doctor, reaching out after the tea-kettle.

Elephind reports that this anecdote—sometimes featuring a doctor with a tea kettle and sometimes a lawyer——was printed in at least 20 newspapers across the United States (California, Hawaii, Illinois, Indiana, Kansas, Louisiana, Minnesota, South Carolina, Tennessee, Vermont, and Wisconsin) and Australia (New South Wales, Queensland, South Australia, and Victoria) in 1873 and 1874.
from "A Big Yield of Cotton," in the Austin [Texas] Weekly Statesman (October 18, 1883):

He was sitting in a Pecan street saloon, with a broad-brimmed hat all decorated with beads. He also wore a regulation cow-boy belt and pistols, and on the heels of his boots wore a murderous set of spurs that seemed to be better adapted for stern wheels to a Mississippi river steamboat than to prick horse flesh. He was mer by a young man who seemed to know the fantastic gentleman, and he said to him :
"Hallo! Jim, whar'd ye kum from?"
"Oh, out west a right smart."
"How's tricks?"
"Well, stock' a lookin' well and the cotton crop are mighty good."

From an untitled item in [Toronto, Ontario] Grip (April 12, 1884):

Walking down York-street yesterday afternoon, I met Mr. Alderman Henry Piper. He was smoking a cigar (a most unusual occurrence), and a smile of satisfaction lit up his serene countenance. "How's tricks, Harry my boy?" I asked of that gentleman. "How's the Institute, and how's the fiery Gazelles?" "Bloomin" bet yer life" replied the great lecturer of animal life.

From "Trial of the Wilkinsons: Lawyers Descend to Personalities," in the New-York Tribune (January 31, 1886):

Conrad Loos, one of the depositors in the broken bank, said that he had a conversation with Alfred Wilkinson in regard to his property in 1884, after May 5 and prior to December 9. "Alfred came into my store," said Mr. Loos, "and I said to him, 'how's tricks? He said, 'It's an off year for stocks an I've got through and we've got our things in shape. We own water and gas stock and real estate and I am going to take a year off.'"

And from "Cheap Boarding-Houses: And the Torture Unfortunate Victims Undergo," in the St. Paul [Minnesota] Daily Globe (August 14 1886):

Cincinnati Enquirer.
"Hello. Jim!"
"Hello!"
"How's tricks?"
"Slow."
"Where are you boarding now?"
"On Seventh."
"Live high?"
"High h-ll!"

Multiple additional examples appear in U.S. newspapers throughout the 1890s and after.
A glossary of "Words from Northwest Arkansas" in Dialect Notes, volume 3, part 2 (1906) includes this entry:

how's tricks?, inter. cl. How are you getting on?

And an article title "Selling Conversations," in the [Minneapolis, Minnesota] Northwestern Miller (1910) gives a strong impression that "How's tricks?" was common in the breezy talk of traveling salesman in that era:

Conversation between Silas Weston, of Weston & Weston, Staple and Fancy Groceries, and F. Archibald Perceival, salesman for the New Fangled Roller Mills, on the occasion of his second visit.
"Hello , Mr. Weston, how's tricks?"
"Huh?
"I say, how's tricks, how's every little thing? Guess you don't remember me, F. Archibald Perceival, the 'New Fangle' man, eh?"

As mentioned in passing in user 66974's answer, J.S. Farmer & W.E. Henley, Slang and Its Analogues Past and Present (1904) has the following relevant entry for trick[s]:

Trick, subs. ... 4. (Western American).—Belongings, things, baggage.

So the prankster in the 1873 anecdote from San Francisco may simply have been using tricks in the general (in Western American English) sense of "things" when he asked the doctor "How's tricks?"
As for the mismatch between "is" and "tricks," that may signal (in early occurrences of the expression) a speaker's poor grasp of respectable English speech of the era, or it may represent a jocular intentional error—as it does today among many people who still use the phrase. The specific form "how's tricks?" seems quite central to the idiomatic usage: an Elephind search for "how's tricks" produces 844 matches (including duplicates), a search for "how is tricks" generates just 3 matches, and a search for "how are tricks" yields just 19.
Whatever the precise circumstances surrounding its origin, the expression has been in use in multiple parts of the United States for about 150 years now—and the sense of the expression seems to have changed remarkably little during that time.


Giving user a visual cue that form controls are disabled after clicking submit, while the form is being processed?

Question:
Never tested or researched this, tbh.
After clicking submit, the submit button's label is replaced by a "processing" animation indicator. Functionally - the form is disabled, so user can't mess up.
Is there a value in giving the user a visual cue that form is disabled, changing the state of inputs and form controls into disabled state?
Hm, not really sure. Maybe first time, as a reassurance they can't mess up incidentally. But does user need that kind of reassurance? Would they say, ok this is now disabled so I am at ease clicking around and messing about? I am not assuming so. Also, I assume after first time, on every subsequent time using the form dialog, visually changing the dialog after click becomes...eye-straining. It is useless clue, a known information, but your eye still registers the change on controls and dialog, and therefore it robs you of a little bit of attention, even though you might not think of it.
These are my assumptions - let me know your thought and experience, thanks.
Answer: See Should I disable form input while processing the form?.
I would hide the entire form, and redirect the user to the next screen.


New cat only licks sauce / gravy from wet food and ignores the chunks, but eats dry food without issues

Question: My girlfriend and I adopted a shelter cat, unknown age, but we were told she was rather old (10 to 17 years?) Was very shy in the beginning and hid under the bed or in my wardrobe. But purred when petted. Now she has fully accepted us as their servants, always coming and sitting on our laps when we return from work and getting comfortable on the couch. She's not hiding anymore and roams the flat freely. Hopefully we can let her out into the garden soon.
Her eating habits are rather un-cat-ish, though:
she eats very little. Most of the food goes to the trash can when her bowls (yes, several, we don't really know what food she was used to) are renewed.
She eats dry food, we see her eating from it, and sometimes we can hear her munching when we are in bed. She drinks water sufficiently.
From the wet food she only licks sauce / gravy and ignores the chunks (maybe she eats a few chunks, but merely as a by-product of gravy-licking.)
(Maybe I should write a letter to Whiskas asking for a bucket of their gravy.)
Is my cat behaving normally? Should I be worried she might be eating too little? (She doesn't seem enfeebled: jumps on the bed and on the couch and put her claws to the carpet.)
Comment: Not un-cat-ish. Also *some* cats (cats have widely varying personalities), such as my late cat (16 yrs), learned that if he didn't eat I'd change his food flavors (whoops) and got into a habit of holding out if he didn't like it. They can be *very* picky eaters. It took me a long time to break this habit. Try another flavor, or another form (e.g. loaf in sauce forms), or just switch her to dry only. Btw if you've got her on wet food you might want to run some numbers and count her calories just to double check she's meeting her daily requirements. Some wet foods are *very* low cal per mass.
Comment: Mine did that – until I started giving them _only_ canned food.
Comment: My cat does the same thing and she is older. Sorry I don't have an answer for you but I just want to say that I appreciate that you adopted a cat from the shelter that you knew was an older one. Its nice that you gave her a home :)
Answer: Some cats don't like chunks and gravy. In fact, some cats don't like wet food at all! If chunks and gravy isn't working try the paté version. Only give out small portions at a time, as wet food tends to dry up quickly, and then she definitely won't want it. You may also warm it up in the microwave to enhance the smell, but mash it sufficiently so that it's not too hot when she eats it.
Cats rely on smell and texture first when deeming it edible or not, which is why when they are kittens, it's a good idea to introduce them to different textured foods (preferably of the same brand to not cause any GI upset).
If you're worried she isn't eating enough, weigh her once to twice a week until you feel comfortable. I always recommend weighing once to twice a month for healthy pets to prevent weight gains or losses.
I will also add this little extra tidbit - since your cat is probably a senior, I highly recommend doing a wellness visit for blood work at your regular vet. Our senior kitties are at high risk for a number of illnesses, though the one I worry most about is kidney disease. The thing about kidney disease is that you only start to see physical signs once the kidneys have been damaged by ~70%. Catching it early will allow her to live longer, as you can start treating to slow the progression sooner. We like to do a senior wellness screen yearly to every second year as a preventative.
Comment: @YvetteColomb Ok got it, so it's from my royal canin learning modules - I had to take screenshots since it's not available to non-vet staff (though maybe if you ask you can get access to it?). http://imgur.com/a/iFgBs and http://imgur.com/a/wfATb
Comment: mashing it up and mixing it with the gravy is giving it the gravy taste. The issue is the chunk is not very tasty for the animal and that is usually because it is not made of meat, although it looks like meat. They do not just rely on smell and texture, this is a fallacy. They rely  on smell and taste - texture would come after this. Please make statements that can be supported, as we do not want to post misinformation here and you're a high rep user. I do like your suggestions on how to encourage the cat to eat it. Thanks.
Comment: All of my answers are factual, I work in the veterinary industry - I don't randomly make guesses and assumptions. Cats have very few taste buds, relying on taste is the very last thing pet food companies work on. Smell and texture are key.
Comment: No offence taken, I know it's hard to tell on chats lol. I'll find one for you once I get home.
Comment: I'm sorry I've offended you, I have no doubt you have great experience and knowledge, that is evident by your contributions. I'd like to see a citation for this, so I'll post a separate question (later today), it's an interesting topic and you can post an answer to it if you like.
Comment: No worries. I'm popping in here between visits to my horse - she's been seriously injured and this is a break for me. My activity on here comes and goes depending on life loads :)
I'm always interested to learn new things. And I'll reiterate, great to have you here :)
Answer: Basically your cat has got more sense than eat vegetables passing themselves off as meat. Recently I went through all the packets of so called cat food at a supermarket and they were 4% meat derivatives. Cats know this. Some of the larger tins are about 40% and some of the very premium small packets are a little better. Cats are pure carnivores and apart from a little grass don't eat veg in the wild.
Manufactures are conning us all making the vegetalbes look like meat.
Answer: I have three cats.

One of them is like your cat. Loves gravy, licks it off first, often skips the meat, does eat dry food. I experimented once by giving her dry food with gravy over it, and she finished the whole bowl (something she otherwise never does). So I think she simply dislikes soft meat.
Her sister loves gravy but does not pass up the meat afterwards
The younger one actively leaves gravy/jelly in the bowl. He eats everything else (including human food and even paper), but does not like jelly and gravy.

I don't see an issue with your cat's behavior. As long as she's eating something, it seems like it's a matter of preferring dry food and gravy over the chewy bits of wet food.
Answer: My cat is like that. I put a little extra water to give her more juice but, she still only drinks it. I have tried to give her every other one in store but, the result is the same. I recently discovered lickables. Its a wet cat food similar to our stew. She loves it. She will eat the whole package it just a few minutes. I would recommend trying that if nothing has worked.
Answer: This would be quite normal, as many of the chunks you see are not meat, but textured vegetable protein (TVP). The cat is preferring the food that has a meaty taste, as opposed to the vegetarian option.


Ethernet cable react with anti-theft RFID gate

Question: Yesterday I was leaving a shop, I had an ethernet cable in my backpack, and it reacted with the anti-theft gate, causing a false alarm.
I was just wondering why.. I had also other cables (hdmi, power cord) but after some trials we found out that was the ethernet one. Thank you
Answer: The cable happened to have correct length, inductance and capacitance so it acted as an antenna identical to the anti theft tag. The gate cannot know the difference between them.


What is the correct way to form a demonym from an acronym?

Question: For instance, what is the equivalent of New Yorker when using the acronym (NY or N.Y. instead of New York)?
Comment: I don't think this is common or codified enough in the English language that there is really a _correct_ way. I would most likely say an _NY'er_ (or a _US'er_, _PRC'er_, _LA'er_, etc.) … but others might think differently.
Comment: @JanusBahsJacquet I don't disagree, but I think most US folks would skip the apostrophes.
Comment: I suspect you're right. I suppose I'm wondering about the *most correct* or *least silly* way to do it.
Answer: I doubt it's formalized, but this is akin to how one forms the plural of acronyms. For example, compact discs: CDs or CD's?
Since the apostrophe denotes possession, it's more often correct to omit it when merely pluralizing, though there are some corner cases:

The Chicago Manual of Style has an interesting way to address this:
  They omit the apostrophe, unless there are periods in the
  abbreviation. So this would give you ATMs, or alternately A.T.M.'s.
  (A.T.M.s looks weird.) chicagomanualofstyle.org,
  "Plurals"
The 2009 AP Stylebook's "plurals" entry has no section on acronyms,
  but mentions "VIPs", I can't find anything addressing how to
  specifically pluralize acronyms. (The "abbreviations and acronyms"
  section is also of no help.)
  [source]

The same holds for demonyms, in my opinion: NYer looks more natural (or less unnatural, anyway) than NY'er.
That said, it still seems very unusual to use demonyms in this way (LA-lino? LAXer? PDXer.. hmm... for some reason it seems more natural with airport codes), so proceed with caution.
Comment: I disagree that this is akin to forming plurals of acronyms (and the possessive is a clitic, rather than a suffix, so it is not really relevant here). It 'feels' more akin to conjugating verbs made from acronyms to me, where an inconsistent hodgepodge of hyphens and apostrophes are employed—but never zero. For example, you'll find in both dictionaries and style guides forms such as _OD'(e)d_ and _OD-ing/OD'ing_, but not (that I have found, at least) _*ODd_ or _*ODing_. To me, _NY'er_ looks more natural than _NYer_.
Comment: Why in the world would anyone want to say NYer? It involves three syllables, the same number as New Yorker. So why not say the whole thing?
Comment: @WS2 this for written (not spoken) word, mostly
Comment: Also, this was just an example and there are other times where the acronym, for whatever reason, is more identifiable than the original name.


How to cite an edited book

Question: I want to cite some articles directly in Semantics, Volume 2 by de Gruyter (2011). I wonder if each article in it is a journal or conference paper that can be cited directly. Otherwise, I should cite the entire book of Semantics, Volume 2, right?
Comment: I'm voting to close this question as off-topic because it is not specific to linguistics and is within the scope of [academia.se].
Comment: Although the general rule is to cite a specific chapter/article etc. in an edited volume (we're talking about an in-text citation I assume), no further detail can be offered in principle because **you didn't tell us what style you have to use** (Chicago-17, APA-7, MLA-8 etc.).
Comment: @Nardog, this post is not off-topic because it is related to linguistic bibliography. So it should be left open.
Answer: It's an edited volume, so each book chapter must be cited separately. Edited volumes are very common in linguistics and your style guide, supervisor, or librarian will be able to help you find the correct citation style.
Answer: Semantics, vol. 2 is authored by John Lyons, and published by Cambridge University press. That single-authored work would be cited as such. The item you are presumably referring to is Semantics: An International Handbook of Natural Language Meaning, edited by von Heusinger, Maienborn & Portner and published as Handbooks of Linguistics and Communication Science 33.2 published by de Gruyter, contains 36 articles each of which has a separate author and title. If you want to refer to the entire collection, you cite Semantics: An International Handbook of Natural Language Meaning, edited by von Heusinger, Maienborn & Portner etc. Otherwise you cite the specific article that you are referring to.
Comment: @user1006 In linguistics conference presentations are often republished in journals or edited books. The conference presentation should only be used if you can't get access elsewhere. Edited books are reviewed by the editors and possibly more. But whatever you use you must cite, other formats don't matter if you don't read them.
Comment: Those questions are pretty basic and you should probably read https://en.wikipedia.org/wiki/Edited_volume
Comment: If I cite the specific article in it, should I also give the book name as Semantics, vol. 2?
Comment: No, because *Semantics, vol 2* is a different book. Actually, the citation would be *Semantics: An International Handbook of Natural Language Meaning*, vol 2 (for articles in vol 2). The first volume (same editors) is that title, vol 1.
Comment: Are articles in edited books generally published in other journals? Or are articles in edited books more like conference papers (i.e. with less review than journals)?

How to cite an edited book


jQuery awkward behaviour

Question: I am trying to load a page throughout ajax, the whole page, and formating mine as it finds in the loaded one. Something of a practical exercise.
The result of the ajax call is a string containing the page's html.
To make it simple, I made an example, with a string containing something of a page itself.

        <title>some test</title>

I got this awkward behavior when trying to pull one's css property, like height:

Firefox: #dvMain.height: 810px
Chrome: #dvMain.height:
IE8: #dvMain.height: 830px
IE8 (with IEtester): #dvMain.height: 830px
IE7 (with IEtester): #dvMain.height: 830px
IE6 (with IEtester): #dvMain.height: 830px

As it seems:

IE understands the css in the string, hell knows how (although that is a strange behaviour, I kinda like it, although I think I would not use it much),
Firefox behaves as I think it would be accurate, gets the class from style in the rendered page,
Chrome for my surprise, does not understand or don't relate it, uhn,.. well, just show nothing

Does anyone knows why?
Comment: I think you have to close the second div: ``.
Answer: Judging by your varied results i think its a matter of dom processing time i wonder if the results are different by amending the code like so:
var $sPage = $(sPage);
alert('#dvMain: ' + $('#dvMain', $sPage).css('height'));

OR
$(sPage).ready(function(){
  alert('#dvMain: ' + $('#dvMain', $(sPage)).css('height'));
});

jQuery awkward behaviour


Wear App and with custom build type with applicationIdSuffix

Question: I have an app where I'd like to add an Android Wear app extension. The main app has three build types (debug, beta and release). Beta builds have an applicationIdSuffix which allows me to install the play-store version and the current development version in parallel on the same device. This all worked fine until I added the wear app.
The main app`s build.gradle looks like this:
apply plugin: 'com.android.application'

android {
    ...
    defaultConfig {
        ...
        applicationId "com.example.mainApp"
        ...
    }
    buildTypes {
        debug {
            applicationIdSuffix '.debug'
        }
        beta {
            applicationIdSuffix '.beta'
        }
        release {
        }
    }
}

dependencies {
    ...
    wearApp project(':wear')
}

The Wear-App has the same build types with the same applicationIdSuffix values. However, when I build the beta app (by calling gradle assembleBeta) the build process builds :wear:assembleRelease instead of :wear:assembleBeta which is why I get the following error message during build:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:handleBetaMicroApk'.
> The main and the micro apps do not have the same package name.

How can I tell the build process to build the correct build type when packaging the main app with build type beta?
Answer: Following the link posted by Scott Barta (http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication) I came up with this :
In the build.gradle of the wear app, add publishNonDefault true (to publish all variants):
android {
    publishNonDefault true
}

In the build.gradle of the main app,
Replace
wearApp project(':wear')

By
debugWearApp project(path:':wear', configuration: 'debug')
releaseWearApp project(path:':wear', configuration: 'release')

Comment: How to combine this with flavors?
Comment: This doesn't seem to work with Android Gradle Plugin 3.0.0. The dependency mechanism has changed and also flavours don't play well with this either
Answer: You can't do what you want; the build variant of a module isn't propagated to the builds of dependent modules on build. This is tracked in https://code.google.com/p/android/issues/detail?id=52962
There's a facility to make one module depend on a specific variant of another one, as documented in http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication, but I don't think this mechanism can be extended to do differential packaging of Wear apps.
Comment: I tried the mechanism described in your second link but it doesn't work for ware apps.
Comment: Thanks for sharing the link tracking this issue.
Answer: UPDATE
Now there is official support for build variants (see answer of Cyril Leroux). Hence this answer is deprecated.

I found a very (very) ugly solution which has some drawbacks but works for now until there is support for build variants for wear apps.
I set a global variable in the rootProject which contains the applicationIdSuffix of the currently built main app.
Within build.gradle of the main app I added the following:
// Set a global variable, depending on the currently built build-type.
// This allows us to set the applicationIdSuffix of the wear app depending on
// the build-type of the main app.
android.applicationVariants.all { variant ->
    def task = variant.checkManifest
    def suffix = variant.buildType.applicationIdSuffix
    task.doLast {
        rootProject.ext.currentApplicationIdSuffix = suffix
    }
}

In the build.gradleof the wear app I added the following snipped:
android.applicationVariants.all { variant ->
    def task = variant.generateBuildConfig
    task.dependsOn(propagateApplicationIdSuffix)
}

task propagateApplicationIdSuffix << {
    project.android.buildTypes.all { type ->
        if (rootProject.hasProperty('currentApplicationIdSuffix')) {
            type.applicationIdSuffix = rootProject.ext.currentApplicationIdSuffix
        }
    }
}

This has several drawbacks:

You can't build multiple variants (i.e. gradle assembleBeta assembleRelease) because the wear app is only built once and hence the second build type fails
gradle check fails because of reason 1
The wear app is still built with build type release but the package name is just changed according to to application id suffix of the main app
Answer: Don't worry, you CAN do what you want to do.  I just did it for the enterprise app I work on.
The key is NOT to use wearApp project(':wear'), since that only works when you have the same applicationId in your wear app as your main app.  And let's face it, how often in real life does that situation happen?  If it happens, you probably aren't using Gradle to the best of it's ability.
You want to follow the instructions for Package Manually in the google wear docs
https://developer.android.com/training/wearables/apps/packaging.html#PackageManually
Unfortunately, this will require you to build your wear app with the same applicationId as the particular build variant you are making at the time, but it does allow you to successfully package the wear app inside an app with multiple applicationId.
Also, one trick I do that helps is to not put the wear apk inside /res/raw, but in /assets, that way you don't have to deal with Andriod Studio compressing the apk.
Hope this helps!  Drove me crazy for a couple days finding a solution.  And the only tutorial out there is in French, and I had to translate the website to read it!
https://translate.google.com/translate?hl=en&sl=auto&tl=en&u=http%3A%2F%2Fblog.octo.com%2Fpackager-une-application-android-wear-dans-la-vraie-vie%2F


Probability distribution of data and likelihood in Bayesian and Frequentive Statistics

Question: I have recently been studying Bayesian as well as Frequentive Statistics (mostly null hypothesis significance testing) and am confused as to the meaning of the distribution of the likelihood and observed data in both. According to my understanding, Bayesian school of though treats the distribution of the sampled data to be same as that of the likelihood of th data conditioned over the hypothesis (For example if data follows a normal distribution then the likelihood function is also normal with same mean and variance) whereas in the frequentive school, the likelihood or null distribution is basically the distribution followed by the test statistic which is different from the distribution followed by the data. Could someone explain whether my understanding is correct?
Answer: Your terminology is not exactly on the right track. Here is an
example to show the likelihood function and how it is used
in frequentist and Bayesian estimation.
Bayesian and Frequentist Inference for Bernoulli Data
Suppose we have a random sample $X_1, \dots, X_n$ from a certain population. In both frequentist and Bayesian approaches, the likelihood has the same form as the JOINT density function of $X_1, \dots, X_n$.
Not the density function of the population (or of a single observation).
$Likelihood.$ In its role as a likelihood function, the joint
density is viewed as a function of (one or more) unknown parameters,
with observed data values $x_1, \dots, x_n$ (often now written
in lower case) regarded as fixed known values. Another
convention for the likelihood function is to say that it is
defined only up to a constant multiple.
For example, suppose the $X_i$ are Bernoulli with parameter
$\theta$ (success probability). Then the joint 'density'
function is
$$f(\text{x}|\theta) = \prod_{i=1}^n \theta^{X_i}(1 - \theta)^{1 - X_i} = \theta^S(1-\theta)^{n-S},$$
where $S = \sum_{i=1}^n X_i.$
We often write $f(\text{x}|\theta) \propto \theta^S(1-\theta)^{n-S},$ where the proportionality symbol $\propto$ indicates
that we may leave out factors that do not involve the parameter of
interest.
Then $S \sim Binom(n, \theta).$ Specifically, if $n = 1000,$ and we observe $x_i$ with total $s = 620,$ then
$f(s|\theta) = {1000 \choose 620}\theta^{620}(1-\theta)^{380} \propto \theta^{620}(1-\theta)^{380}.$
$Frequentist.$ From a frequentist point of view, we find the maximum likelihood estimator $\hat \theta = s/n = 620/1000 = 0.62.$ (The point at which $f(s|\theta$ reaches its maximum is $s/n$.)
Various confidence
intervals have been proposed. A common 95% CI (based on normal
and other approximations and not so good for
small $n$) is $\hat \theta \pm 1.96\sqrt{\hat \theta(1-\hat \theta)/n}.$ For the data of our example, this is $(0.590, 0.650).$
The usual frequentist interpretations are that
$\hat\theta$ has good properties as an estimator of $\theta$:
it is unbiased because $E(\hat \theta) = \theta$ and it has minimum
variance among unbiased estimators. The CI is said to have been
produced by a procedure by which in 95% of such experiments
over the long run, the CI will cover the fixed, but unknown,
constant $\theta.$
$Bayesian.$ A Bayesian analysis view $\theta$ as a random variable with a
prior distribution. Because $\theta$ must lie in the unit interval,
a member of the Beta family of distributions is a common choice
for the prior distribution of $\theta:$ perhaps $Beta(1/2, 1/2)$ or
$Beta(1,1)$ if we have no previous experience or strong personal
opinion about $\theta;$ perhaps something like $Beta(330, 270)$ if
we think $\theta$ is likely to lie between 0.51 and 0.59, based
on previous experiments, polls or hunches about the
population.
Then Bayes Theorem comes into play. It states that the posterior
distribution of $\theta$ based on the prior distribution and the
likelihood function is
$$f(\theta|s) \propto  f(\theta) \times f(s|\theta),$$
where the (last suggested) prior distribution has 'kernel'
$f(\theta) \propto \theta^{330-1}(1 - \theta^{270-1})$ and the likelihood (from above) is $f(s|\theta) \propto \theta^{620}(1-\theta)^{380}.$
By the 'kernel' of a distribution we mean the factors that
involve the parameter of concern. Thus the kernel of the
posterior distribution is
$f(\theta|x) \propto \theta^{950-1}(1-\theta)^{650-1}$ and the
posterior distribution is obviously $Beta(950, 650).$ One possible
95% Bayesian probability interval for $\theta$ cuts 2.5%
from each tail of this distribution to give $(0.570, 0.618),$
which can be obtained from R code qbeta(c(.025,.975), 950, 650).
A Bayesian point estimate might be the mean of the posterior
distribution $950/(950+650) = 0.594$ (or its mode, which is
essentially the same in this case).
The Bayesian interpretation of these results is that--for the
particular survey or experiment at hand--the most likely value
of $\theta$ is 59.4% and that there is 95% probability
the true value of $\theta$ is between 57.0% and 61.8%. (Of
course these statements are subject to believing the prior distribution.)
If our prior distribution had been $Beta(1,1) = Unif(0,1),$
(a 'non-informative' prior) the 95% probability interval would have been
$(0.589, 0.650)$, numerically similar to the frequentist interval above.
Notes: (1) For simplicity, I have used 'density' for both discrete and continuous distributions; for former, I might have used 'point mass function'.
(2) Bayesian statisticians often use $p$ instead of $f$ for
density and likelihood functions.
functions. (3) Finding the posterior distribution was very simple in the example given, because of the algebraic compatibility of the prior and likelihood. In such cases we say the prior and likelihood
are 'conjugate'. Finding probability intervals for some posterior
distributions requires intensive computation.
Comment: I am confused a bit as to what has been considered as the likelihood function, is it the joint distribution of the samples i.e $f(x|\theta)$ or $f(s|\theta)$ because the latter is no longer a joint probability I think. Also, can you explain using data following normal distribution?
Comment: Good question, should have clarified that: Formally, the likelihood function is the joint dist'n of individual observations viewed as a function of the parameter(s)--observed data viewed as constants. But when there is a 'sufficient statistic' S. then for purposes of inferences on parameter(s), it is equivalent to use a simpler version of the likelihood function where data are reduced to S. (Here S is the binomially distributed sum of Bernoulli 0-1 data. The idea is that S contains all info necessary for inference.)


The importance of the different method of proofs?

Question: I am very familiar with the direct method of proof. Is this proof sufficient enough to be able to understand higher level proofs?  Do you need to be fluent in every type of proof? And does knowing how to apply the methods help ease the understanding process of higher maths? I have been self studying maths for a while and I still reach a standstill for long periods of time. I'm wondering if it's due to not being fluent in proof writing.
Answer: The art of the proof, in my opinion, is at the heart of pure mathematics. Eventually, as you do more problems, you will begin to see patterns in your approaches to proof. For instance you might see a problem and immediately think, 'Oh, I should tackle this using induction' or 'this looks like a familiar proof by contradiction'. In essence, by doing more and more math you will build up an intuition for proof that will steer you in the right direction.
Another great (and fun) feature of mathematics is the oft-variety of proofs that can solve a given problem. e.g. One might solve the same integral by integration-by-parts, a u-substitution, a geometric intuition (even/odd), etc..
Do not allow proofs to overwhelm you. With time, you will understand and begin to 'see' more approaches.
Comment: Excellent advice. Thanks a lot for that.
Answer: I'm just going to try to answer this part, based on my own experience of self-learning:

I have been self studying maths for a while and I still reach a standstill for long periods of time. I'm wondering if it's due to not being fluent in proof writing.

It could be due to quite a few things, some of which would be psychological rather than mathematical. And it depends a bit whether the standstill consists of slogging away without making progress—in which case you're slogging away at the wrong things or in the wrong way—or just long breaks from studying any maths.
With self-study it's really tempting to try to go too fast: "Right, I've just about got the idea of that, so let's go on to the next thing". I'd be surprised if you've not done this at all.
But real learning isn't being able to hang on to something long enough to just about get the idea of the next thing, and the next—it's about increasing your understanding.
The difficulty is that it's not always obvious where the gaps in understanding and knowledge are. So here's a suggestion for how to identify them.
First, ask yourself whether what you've just learnt or used feels crystal clear in your mind. If it doesn't, read through it and try to spot the places where you're unsure. Do you actually understand the theorem that was referred to in line $3$? Can you explain why the step from line $4$ to line $5$ is valid? And so on.
You'll probably find a number of little gaps: things you use all the time but aren't quite sure of why they're OK. Things that seem obvious but you can't explain why they're obvious. And those gaps are the things that you need to go back and work on. Don't be surprised if some of them go right the way back to something that was badly explained at school when you were 7 or 8.
Here's an example. Having habitually taken it for granted, I still felt uneasy about using this without justifying it:

if $\sum a_n$ converges on $A$ and $\sum b_n$ converges on $B$, then $\sum (a_n+b_n)$ converges on $A+B$.

So I went ahead and proved that, and found that my proof used the obvious-looking inequality
$$|x+y|\leq|x|+|y|$$
This sort of thing seems so obvious that one just uses it—but with a nagging feeling that "it's obvious" might not be adequate.
So I had to prove the inequality too, which I did like this:

First note that $x\leq |x|$ and that $|-x|=|x|$.
If $a+b\geq 0$, then
$$|a+b|=a+b\leq |a|+b\leq |a|+|b|.$$
If $a+b<0$, then . . . [slightly longer argument because of the minus signs]
. . . So in either case, $|a+b|\leq |a|+|b|.$

Finally, I noted that I'd used

$x\leq |x|$
$|-x|=|x|$
transitivity of $\leq$.

Theoretically I could have gone one step further and spelt out why $x\leq |x|$ and $|-x|=|x|$ follow from the definition of $|\cdot|$. (In the event, I explained it to myself mentally but didn't bother writing it down.)
See what's happened? I've gone right back from proving a theorem about convergent series, to proving basics about simple manipulations—but I've also given myself some practice in constructing proofs, for things which are simple enough to be easily checked.
I feel that this kind of thing is important in self-learning. The point is that without a teacher, you are the teacher, so you have to be able to identify the gaps in your understanding and to check thoroughly whether the logic of a proof is correct. Ultimately this means breaking down the steps until you know that each one is valid.
And I strongly recommend writing an actual list of the theorems and assumptions you've used. Use this list as a guide to what needs consolidating. Don't be satisfied until you can explain the reasoning behind all the list items. When you can, you'll be much more confident in using them. And it's absolutely fine if some of the things you need to explain to yourself are basics. Once they're more solid, the whole structure is more solid.


Is there a way to remove dead tags from the Main Chat room tags?

Question: the tables and pen-and-paper tags appear in the list of room tags for the main chat, but they are dead links because those tags don't currently exist.  Can they be changed, or are we stuck with them?
Answer: Some of those tags never existed on the main site. I put them there as a clue to new users what our chat is really about.
We've got one of the most active chats on the Stack. This means that people from any Stack Exchange site, when they look for chat rooms, will see ours near the top. We semi-regularly get people looking for video game chat, video game development chat, coding chat, mathematics chat, and just about anything else.
A few months ago, after our last batch of more joke-y tags got a little stale, I figured it couldn't hurt to put in some more "what we're about" cues.
(There really aren't many good tags for general chats: tags are supposed to be a lot more specific than a chat room for an entire Stack site. This leads to their tags being jokes, un-useful, or imaginary.)
Comment: Fair enough.  In truth I couldn't come up with any good suggestions as I composed this question.
Answer: They can be changed by room owners/moderators, but they're mostly non-functional descriptors anyway. There are only rare instances where chat tags are useful, so most chatrooms just either use them as jokes or general descriptors.
For instance, the Tavern on the Meta has the tags:
[bug] [crickets] [discussion] [excuses] [support] [waffles]

while in reality, [crickets], [waffles], and [excuses] don't link out to any useful tags on Meta Stack Exchange. Just a flavor thing.
Well, except waffles. Waffles are delicious. Though they're also pretty much just a flavor thing. But in a different way.


Field dependencies/Dependent picklist

Question: Hii wondering if this is possible. Can I have a value default in a dependent pick list based on the controlling field selection (I only have 1 value in the dependent field). So can this be defaulted somehow? Thanks in advance!
Comment: Welcome to SFSE. If it makes sense functionally, you can make the dependent picklist as required, then its value will be defaulted.
Comment: Thank you! How do I make it required?
Comment: Under "Fields & Relationships" for that object, open the dependent picklist field, click on Edit and check the option "Required"
Answer: Go to the respective object page layout and make the dependent picklist field as mandatory and save page layout.
Lightning Navigation: Setup --> Object manager --> Object --> Page layouts.

While creating a record, select controlling field value  then dependent field value will be auto updated. Refer the below screenshot.

Note: Lightning, it works for new records.

Field dependencies/Dependent picklist


How to catch command line arguments in Berkley Logo (UCBLogo)?

Question: Berkeley Logo User Manual tells that all command line arguments after a hypen will be collected in the variable:
<code>If a command line argument is just a hyphen, then all command line arguments
after the hyphen are not taken as filenames, but are instead collected in a
list, one word per argument; the buried variable COMMAND.LINE contains that
list of arguments, or the empty list if there are none.  On my Linux system,
if the first line of an executable shell script is
#!/usr/local/bin/logo -
(note the hyphen) then the script can be given command line arguments and
they all end up in :COMMAND.LINE along with the script's path.  Experiment.
</code>
I try it, and it doesn't work:
<code>$ cat test.lg
#!/usr/bin/logo -
print :COMMAND.LINE

$ ./test.lg
I can't open file -
?
</code>
Is there any ideas what's wrong?
I use ucblogo 5.5-2.1 from Ubuntu packages.
Answer: Berkeley Logo 5.5 does not support parsing of command line arguments from a script.
The User Manual you quoted is for Berkeley Logo version 6.  You should be able to use command line arguments just like that using ucblogo-6.0.
You can download Berkeley Logo 6.0 from http://www.eecs.berkeley.edu/~bh/


Writing serial data on a pin on Arduino

Question: I want to write some data (GPS) to a digital port on Arduino.  As far as I understand sending data via a pin as if it were USB is possible. But I don't know what function to use. digital.Write doesn't expect any data or strings. How do I write serial data on to a digital pin
Comment: Digital.Write takes exactly two arguments, the pin number and 'high' or 'low' - so you look at your bit stream and write the port accordingly, or speed things up by using a built in protocol like I2C, SPI etc...
https://www.arduino.cc/en/Reference/DigitalWrite
Comment: USB is a complex protocol which is not supported by most of the simpler processors used in most of the simpler Arduino boards.  So you need to specify your exact hardware or answers to your questions will have to be generic and vague.  The USB port on an Arduino Uno is actually a separate chip from that which you run your Arduino sketches on.  What your Arduino Uno program can do is send out serial data to this separate chip.  Not USB protocol.  Also, as far as I know, the only USB protocol supported on an Arduino Uno is Serial Data over USB.  Hopefully that is what the GPS uses.
Comment: It would help if you edited your title so that people know that you are asking about connecting a Arduno to a USB Device.
Comment: You need to edit this to be clear what exact "serial" signalling scheme you need to use, and if you are able to choose the pin on which the chip can do that best, or if it has to be a particular pre-chosen **and specified in the question** pin even if that requirement makes the task far more difficult or impossible.
Comment: I am talking about an arduino uno the data from which I am connecting to some other device to read. Right now just to an oscilloscope. I am not sure about the pin. I'm talking about a digital pin on an arduino.
The GPS data can be transmitted using the serial protocol as far as I understand, I'm just not sure how exactly to do that in terms of software.
Comment: Also, no I'm not connecting the arduino to a USB device, I just used that as an analogy. The GPS module is connected to an arduino via pins, the data is processed by an arduino and I want to extract this data and send it to other device using a digital pin.
Answer: Using the arduino library "software Serial" (https://www.arduino.cc/en/Reference/SoftwareSerial) you can use any pin to write/read serial data.
Answer: The Aruduino Uno uses an ATmega328P which only has 1 hardware UART to help the software communicate serially with the outside world.  If you are already using this hardware resource (for example through the normal Arduino serial library), it is unavailable to talk to a 2nd external device.  In such a case you can emulate a UART in software using this Software Serial Library in exchange for some processor time (that is, using a software emulated serial port will slow down your program's execution).
Comment: Yeah, I'm not trying to output it to a GPS. I am collecting some set of data, and trying to send it to some other device using a digital pin on my arduino. Most likely using serial connection.
Comment: This is likely not what the asker is trying to do - by appearances the data is GPS-like (probably NMEA or something) but they probably don't want to output it *to a GPS*.  Unless they mean some kind of moving map display for a GPS, but that probably won't want USB input, rather some suitable marine grade serial interface.
Comment: Again, it pays to tell which Arduino / processor you are using.  If the processor only has 1 UART you will need to use a software implemented library to talk to a 2nd device over a serial port.  If the processor has 2 UARTs, then the serial communications will be more robust.  But you will have to figure out if the Arduino serial port library you are using will support the 2nd UART of the processor you are using.
Comment: Oh I see, thanks. The arduino I'm using is uno with ATMEGA32BP-PU. However, if I'm using a digital pin to communicate do I just configure it as a serial port and then use the serial library?
Comment: Please re-word (edit) your Title & Question.  Make it clear you are already using the serial port built into the Arduino Uno.  And you wish to create a 2nd serial port.  I will in turn make my answer fit the re-worded (edited) question.

Writing serial data on a pin on Arduino


"Reinstall" FreeBSD using ZFS snapshots

Question: I am using a dedicated server, and unlike on VPS providers or VM machines, getting back to a clean state (untouched, after install) is quite a laborious thing to do (lots of clicking around in a web control panel and launching Java KVM viewers + doing the installation manually).
My question is that given ZFS support for snapshots, would it be possible to get back to a clean state just by issuing a single command?
My ZFS partition table would be the "Auto (ZFS)" offer by the installer, which looks like this on my server (using FreeBSD 10.2):
NAME                 USED  AVAIL  REFER  MOUNTPOINT
zroot               34.8G   176G    96K  /zroot
zroot/ROOT          1.46G   176G    96K  none
zroot/ROOT/default  1.46G   176G  1.46G  /
zroot/tmp           76.8M   176G  76.8M  /tmp
zroot/usr           33.2G   176G    96K  /usr
zroot/usr/home      32.6G   176G  32.6G  /usr/home
zroot/usr/ports      631M   176G   631M  /usr/ports
zroot/usr/src         96K   176G    96K  /usr/src
zroot/var            692K   176G    96K  /var
zroot/var/audit       96K   176G    96K  /var/audit
zroot/var/crash       96K   176G    96K  /var/crash
zroot/var/log        204K   176G   204K  /var/log
zroot/var/mail        96K   176G    96K  /var/mail
zroot/var/tmp        104K   176G   104K  /var/tmp

My questions are the following:

Is it possible to get back to this clean state using ZFS snapshots? What if I changed the kernel, deleted half the file-system, etc. Can a snapshot revert back everything like if it was just after installation?
If yes, how can I do that? What command do I need to create the snapshot and what do I need to revert to one?
Answer: take a recursive snapshot of zroot
zfs snapshot -r zroot@cleaninstall

called cleaninstall and then revert it with
zfs rollback zroot@cleaninstall

"Reinstall" FreeBSD using ZFS snapshots


Does Hubble constant $H$ change with time in $N$-body simulations?

Question: In $N$-body simulations, there is a Hubble constant $H$ in equation of motion.
when we integrate the equation of motion, does this constant H also change with the simulation time?
or it is just a constant of present Hubble constant in simulation.
Most simulations seems use $H = 100$ h KM/s/Mpc, where normalized h is usually $0.5$;
does this mean that the H in the equation (1) is a constant in simulation?
but we know $H$ is dependent on the physical time. A little bit confused here if someone can help!
any explanation and references are appreciated.
thanks a lot!

Equations of motion
Cosmological N-body simulations aim to represent the dynamics of galaxies in a large volume (from ~$10$ to $10^3$ Mpc across, where $1\text{ Mpc}=3.26\times10^6$ light years), whose overall motions are dominated by the mean cosmological expansion, described by a scale factor $a(t)$. In the absence of perturbations, two particles separated initially by $\vec r_1$ at time $t_1$, will, at time $t_2$, be separated by $\vec r_2=\vec r_1a(t_2)/a(t_1)$. The relative velocity between any pair of particles then obeys Hubble's law $\vec v = H \vec r$, where $H(t)=\dot a/a$ is the Hubble parameter. It is convenient to remove this zeroth-order motrion by using a uniformly expanding system of "comoing" coordinates $\vec x = \vec r/a(t)$. Written in comoving coordinates, Newton's second law for a particle with comoving trajectory $\vec x(t)$ is:
$$\frac{d^2\vec x}{dt^2}+2H\frac{d\vec x}{dt}=-\vec\nabla\phi,\tag{1}$$
where $\phi$ is the perturbed gravitational potential. This Newtonian equation is correct even in general relativity as long as the gravitational fields are weka and the motion in the omoving sytstem are nonrelativistic. The gravitational potential $\phi$ follows from the usual Poisson equation, but with only the spatiall y varying part of the mass density field, $\delta \rho/\rho\equiv[\rho(\vec x, t)-\bar\rho(t)]/\bar\rho(t),$ providing the source:...
Comment: Simulations of what? The answer is dependent on what is being simulated. Growth of structure in the universe, then yes of course.
Answer: The Hubble parameter evaluated at this current time (redshift $z = 0$) is the Hubble constant ($ H_0 $), but the Hubble parameter is a function of time (as you have it in the scanned text).


Download Virus/Malware Purposefully

Question: Where can I download a virus, work, trojan, etc. for analysis? Yes, I'm actually hunting for malware, rather than keeping it at bay and hiding behind antivirus software and firewalls. I plan to analyze it in a lab for a project, but don't know where to even begin finding one.
Comment: Like the biologists who work in BSL4 facilities, do exercise appropriate caution; your friends and colleagues will appreciate it.
Comment: @msw I most certainly will. I'm just planning on doing some "dead" analysis on it. The VM is getting toasted immediately after.
Answer: I ended up finding my way over to VX Heavens, where they have a massive collection of virus broken down in to various categories (Backdoors, DoS, Worms, Hoaxes, Trojans, the works). Great if you need to analyze actual malicious code in a "dead" state (as much fun as surfing to a bunch of sketchy sites is and sorting through the mess later).
Answer: If you really want...
You can probably find some sort of virus "history" through standard google searches. I'm sure there are archived copies of such "I love you" worms.
If you are trying to purposefully infect a computer, download Windows XP (no service patches) and using IE 6/7 browse various sites of questionable content.
Then install LimeWire. Search for songs or music. Download as many as you can. Sort them out as real music files and <code>.exe</code> files pretending to be music files (often hidden in archives). Now run them all.
Install just about every browser toolbar you can find for IE, along with any available programs along the lines of "I sit in your taskbar and randomly popup telling you something".
However I feel I must warn you...
Doing the above will most certainly trash the machine. Also you probably will have limited insight as to what actually caused the most damage. You will most surely have various viruses and malware present, but finding and identifying them will be a challenge in and of itself, not to mention dissecting the programs.
Comment: Don't use IE 7. IE 6 is much more vulnerable.
Answer: Here are a couple options:
A) Hit up a bunch of adult websites and click on every banner ad you see.
B) Go to a torrent search engine (http://thepiratebay.org/ or http://www.torrentz.com/, for example) and do a search for "keygen". Download a bunch and start firing up the executables within.
You will definitely end up with some nasties sooner than later using these techniques.
Answer: Very funny how people can get viruses without even trying and then when you want one... its pretty much impossible to find one. I have a bunch saved to a thumb drive to mess around with later and a bunch in the "virus vault" in my antivirus software. A good place to start would be to check the virus vaults in the antivirus software for all the computers you have access to. You can then restore the virus to wherever you want.
Answer: Honestly? Start googling for free antivirus software. You are guaranteed to find something on that list, especially if its something you've never heard of. Web pages that scream you are infected! in red capital letters ten feet high (okay, maybe not that urgent) are dead give-aways that you've found badware for the taking.

Download Virus/Malware Purposefully


Gravitational potential energy in terms of half-mass radius

Question: In Barbara Ryden's Intro to Cosmology, she states that the gravitational potential energy of a cluster of galaxies, that is given by
$$
W = -\frac{G}{2}\sum\limits_{i,j,\ i\neq j}\frac{m_im_j}{|\vec{x}_j-\vec{x}_i|}
$$
can be written in terms of the total mass of the cluster, and the half-mass radius, that is the radius of a sphere, located at the center of mass of the cluster, that contains a mass $\frac{M}{2}$,
$$
W = -\alpha\frac{GM^2}{r_h}
$$
where $\alpha$ is some numerical factor. I have tried to derive this expression with no success, and was wondering if any reference to it exists.
Answer: First consider two identically shaped galaxies, but one of them having the mass of each part scaled by some factor. If the masses are $M_1$ and $M_2$, then the scale factor is $M_2/M_1$.
Gravitational potential energy of the second galaxy is then:
\begin{equation}
W_2=-\frac{G}{2}\sum_{i,j,i\ne j} \frac{\frac{M_2}{M_1}m_i\frac{M_2}{M_1}m_j}{|\vec x_i - \vec x_j|}
=\left(\frac{M_2}{M_1}\right)^2 W_1 =M_2^2\frac{W_1}{M_1^2}
\end{equation}
If, in addition to the different mass, one galaxy is also uniformly stretched, one having radius $r_{h,1}$ and the other having radius $r_{h,2}$, it can be similarly shown (using $|\vec x_i - \vec x_j| \rightarrow |\frac{h_{r,2}}{h_{r,1}}\vec x_i - \frac{h_{r,2}}{h_{r,1}}\vec x_j|$) that the gravitational potential energy of the second galaxy is now:
\begin{equation}
W_2=\frac{M_2^2}{r_{h,2}}\frac{W_1 r_{h,1}}{M_1^2}
\end{equation}
One can therefore define:
\begin{equation}
\frac{W_1 r_{h,1}}{M_1^2}=\frac{W_2 r_{h,2}}{M_2^2}\equiv-G\alpha
\end{equation}
When defined like that, $\alpha$ is a positive dimensionless number that depends only on the shape. This immediately leads to the desired equation:
\begin{equation}
W=-\alpha\frac{GM^2}{r_h}
\end{equation}


Update a preprint on ResearchGate to conference publication after acceptance

Question: Is there a way to update a preprint on ResearchGate to the published conference version including accepted conference information etc.? I have not found a straightforward way to do this, I don't think deleting the preprint and replacing it with the conference version is a good solution especially if the preprint already has followers, comments etc.
Answer: I contacted Researchgate requesting to them merge two papers once (a preprint and a postprint). All they did was to delete one of the papers (unfortunately the 'better' of the two). Not recommended. Instead, I would suggest you either update the previous upload or upload a second version, preferably both. Update the old for your followers. I can't say for sure, but I think new uploads get some priority in the feed of other users. By performing both these actions you maximize the exposure your paper gets.
Comment: Wow, that is sad, losing a better version. For now I have adopted your suggestion, i.e. uploaded the current one separately, thou this results to duplicates, however both versions slightly differ in content.
Comment: Yeah. Having duplicates is not ideal, but I think it is the best solution for now. Especially in the short term, you benefit from the extra attention to your paper(s). Hopefully Researchgate will add more functionality in the future, including the option to merge two papers manually.


Question about Weinberg QFT Vol. 1 Eq. 6.1.14

Question: In Weinberg QFT Vol. 1 Eq. 6.1.14, he defines the propagator for a fermion to be
$$ \theta(x-y)\{\psi^+(x),\psi^+{}^\dagger(y)\} - \theta(x-y)\{\psi^-{}^\dagger(x),\psi^-(y)\}$$
where $\psi^+$ annihilates particles, and $\psi^-$ creates antiparticles. He claims (cf. 6.1.1) that this comes from a term
$$\langle 0 | T\{\psi(x),\psi^\dagger(y)\}|0\rangle$$
in the S-matrix. My question is, I don't see how the relative minus sign between the two terms in 6.1.14 (my first equation) follows from the time ordering in the second equation. Peskin and Schroeder say that it's just a definition of time ordering for fermions, but that can't be true because the time ordering is already defined in the definition of the S-matrix in terms of time-ordered products of the Hamiltonian.
Answer: In addition to the other answer, the reason we need the extra minus sign is so that the time-order is Lorentz invariant.
Consider the case $(x-y)$ is space-like, first notice that the fermionic fields anticommute:
\begin{equation}
\psi(x)\psi(y) = - \psi(y)\psi(x)
\end{equation}
There is a frame with $x^0 > y^0$, in this frame:
\begin{equation}
T\{\psi(x)\psi(y)\} = \psi(x)\psi(y) \label{eq1}
\end{equation}
Since $(x-y)$ is space-like, there will be another frame in which $x^0 < y^0$. In this frame, if we were to use the definition without the minus sign, then:
\begin{equation}
T\{\psi(x)\psi(y)\} = \psi(y)\psi(x) = -\psi(x)\psi(y) \label{eq2}
\end{equation}
As you can see, the result would be different between the two frames. In order to resolve that, we need the extra minus sign.
Answer: The Hamiltonion is always involves products of an even number of  fermions, so the definition of time ordering for products of  Hamiltonian $H(t)$'s  does not dictate the time time ordering rule for individual Fermi fields. It turns out that if we define
$$
\langle0| T \{\psi(x)\psi(y)\}|0\rangle= \theta(x_0-y_0)\langle0|  \psi(x)\psi(y)|0\rangle -  \theta(y_0-x_0)\langle0|  \psi(y)\psi(x)|0\rangle,
$$
it makes subsequent equations nicer.
Comment: @Eric David Kramer.  No!  I just meant that the definition with the minus sign is useful, and that the one without is not.
Comment: You're saying that if we define the fermion propagator with a + sign, we get the same answer at the end?
Comment: Then I'm still confused. The thing I want to calculate is the time-ordered product of Hamiltonians, which is well-defined. By Wick's theorem, this should be equal to a product of propagators. I just wanted a proof (or a hand-wavy argument) that this only works with the minus sign.
Comment: The Hamiltonians are even in fermion number, so no minus sign is needed in the T product of $H$'s. You need minus signs when using Wick's theorem to evaluate the contractions of out-of-order fermions  in the T product of $H$'s   to get propagators.
Comment: Right, that's the claim. (It's also what we use and seems to work.) I just want a proof of that point exactly. I.e. a proof that you need the minus sign when using Wick's theorem. But OK I agree it somehow has to be true.


Fourier Transform Form: two sin components & a phase shift & a magnitude for only one term

Question: This is an example from my text book of a continuous signal:
$$x_{in}(t)=\sin \left( 2\pi \cdot 1000 \cdot t\right) + 0.5\sin \left( 2\pi \cdot 2000 \cdot t + \dfrac{3\pi}{4} \right) $$
So to perform a fourier transform on this signal, how to do that, isn't it a bit funny, since it has two sine components. Shouldn't complex numbers have a sine term and a cosine term? And it's got a scalar term applied to only one component, don't those usually apply across both terms of a complex component? And it's phase shifted, what to do about that?
Comment: Have you tried writing out the Fourier transform and evaluating the integral?
Comment: Another hint: $\cos(w t + \phi) = \cos(\phi) \cos(wt)-\sin(\phi) \sin(wt)$
Comment: actually that equation is inconsequential isn't it? since we don't perform an FT on that, we'll just have a bunch of numbers, supposedly generated from those, and it's on those # that we perform the foueier transform operation isn't it?
Comment: yeah I just need to actually plug in for N and calculate everything out isn't it?
Comment: yea sometimes working through the maths can give you a real feel for what is going on
Comment: oh and the other good identity is $\cos t = (e^{i t} + e^{-i t})/2$
Answer: Fourier Transform is a linear one, so you can make use of superposition principle:
$$ \mathscr{F} [\alpha x(t) + \beta y(t)] = \alpha \mathscr{F}[x(t)] + \beta \mathscr{F}[y(t)] $$
So for the first component $$x(t) = \sin \left( 2\pi \cdot 1000 \cdot t\right)$$
by definition:
$$\mathscr{F}\left[\sin(2\pi f_0 t + \phi) \right] = \dfrac{i}{2} \left[ e^{-i \phi}\delta(f+f_0) - e^{i \phi}\delta(f-f_0) \right] $$
you get:
$$ \mathscr{F}[x(t)]=\dfrac{i}{2} \left[ \delta(f+1000) - \delta(f-1000) \right]  $$
Second component is a sinusoid with shifted phase, so the complex exponent represents that:
$$y(t) = \dfrac{1}{2} \sin \left( 2\pi \cdot 2000 \cdot t + \dfrac{3\pi}{4} \right)$$
has following Fourier Transform:
$$\mathscr{F}[y(t)] = \dfrac{1}{2}\dfrac{i}{2} \left[ e^{\dfrac{-3\pi i}{4}}\delta(f+2000) - e^{\dfrac{3\pi i}{4}}\delta(f-2000) \right] $$
By summing both results you get the Fourier Transform of your signal.


How to install Garena in Ubuntu 18.04

Question: Im from Philippines South East Asia, Im using Ubuntu 18.04, how can I install Garena here? I would like to play League of Legends
Comment: If this answer is right for you, please mark answer as "accepted".
Answer: You can't. Garena you can install with wine and notes found on wineHQ, There is a gold rating so it is possible to install.
But

Currently supported games:
Warcraft 3: The Frozen Throne, Warcraft 3: Reign of Chaos, Counter-Strike (1.5 , 1.6 , Source ), StarCraft: Brood War, Dawn of War, and Quake 4.

-> No League of Legends.
If you want League of Legends and feel the need to play from Linux have a look at this very very long post on Reddit. It guides you through every setting you need. For a better gaming experience I would advice to install Windows with a dual boot and play from there or by installing Virtualbox, Windows in it, Garena in that and League of Legends in that.
There is another reason for that: as of a month ago they changed their client and this restricts 3rd party applications. 99 out of 100 times this means Wine is not useable since that is one of those and maintained by the community.

How to install Garena in Ubuntu 18.04


Phrase for Someone Not Understanding the Value of Something

Question: Is there some phrase I can use for lamenting about someone possessing something very valuable yet not understanding or appreciating the value of this item? I feel like I've heard such a phrase before, but I can't think of it for the life of me.
Comment: What exactly is wrong with this request that it was put on hold? You say to include information about how it will be used, but I don't know if that applies--I just wanted to know if a phrase that describes that situation exists because I felt like I had heard it before.
Answer: "To cast pearls before swine" is a common (and Biblical, Matthew 7:6) aphorism for giving someone a valuable item of which they don't appreciate the significance or cost.


Samsung wifi printer printing garbage after upgrading to 18.04

Question: After upgrading to Ubuntu my Samsung wifi Multifunction printer prints random characters regardless of the version of the suldr driver.
Answer: That was happening to me when I was printing to my Samsung M2820-DW because linux was sending the print job driverless, but in raw mode.  I'm not an expert, but the following worked for me, both in Ubuntu 18.04 and 20.04:

Open Ubuntu Settings.
Choose Printers from the left panel
Up near the top right of the main window, click the Add button
Your printer should show up in a list with and address of {bunch of hex digits}.local .  Select that, and click the Add button in that window.
The system may offer to download a driver.  If so, accept it.

That's it.  To check your work, point your browser at localhost:631 , and choose the Printers tab.  The printer you added should show up as having a model something of the form, "Samsung M262x series, driverless, cups-filters 1.20.2"  Print to that one.  Do NOT print to the printer that has a model, "Local Raw Printer," even though it appears to be your Samsung.  The latter is the one that prints reams of random characters.
Answer: First install the suldr driver either by downloading it from the HP/samsung site, or via the https://www.bchemnet.com/suldr repository (see https://github.com/dorfsmay/laptop-setup-ubuntu-18.04/blob/master/idempotent/031-suldr-samsung-drivers). This is required to be able to use the scanner.
Then:

open a browser
navigate to localhost:631
click on "Printers" in top bar
click on name of the printer (Samsung...)
Click on the "Administration" drop down menu, and select "Modify Printer"
You'll be prompted for your user id and password, enter your Linux login credentials
select the first printer in "Discovered Network Printers", "Continue"
"Continue" again
select "Samsung XXXXX driverless cups-filters", "Modify Printer"

Now when you click again on "Printers" in the top bar, it should show "driverless" under "Make and Model"