How to solve a transitive closure question?

Question: If $r=\{ (1,3),(2,1),(3,4),(4,2)\}$ then which one of the following matrices is the adjacency matrix of $r^{+}$, the transitive closure of $r$?
Select one:
a. \begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 0 \\ \end{pmatrix}
b. \begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 \\ \end{pmatrix}
c. \begin{pmatrix} 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 0 & 1 \\ \end{pmatrix}
d. \begin{pmatrix} 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \\ \end{pmatrix}
e. \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix}
Could you please explain the how today create adjacency matrix for this question? I am aware that the answer is b. Thanks for any explanation.
Comment: Do you know how to compute the transitive closure of $r$?
Comment: I am not sure I did the adjacency matrix calculation and got  e for my answer which I know is incorrect, any further details on how to approach this would be helpful?
Answer: Transitive closure of a relation $r$ is the smallest transitive relation that contains $r$. One forms a transitive relation of $r$ by adding a pair $(a, c)$ in $r$ whenever the pairs $(a, b)$ and $(b, c)$ belong to $r$. We keep on doing this until it is not possible to add further any other pairs. In this problem, I can add the pair $(1, 4)$ to $r$ because $(1, 3), (3, 4)$ belongs to $r$. So $r$ is updated as $$r=\{ (1,3),(2,1),(3,4),(4,2), (1, 4)\}.$$ By same reasoning I can add $(4, 1)$ and repeating this process, $r^+$ turns out to be $A\times A$ where $A=\{1, 2, 3, 4\}$. Now the adjacency matrix of $A\times A$ is b.
Comment: Thanks so does that mean {1, 1} and {2, 2} can exist as well?
Comment: Yes they will as you continue the process.
Answer: Observe that the pairs of $r$ describe a cyclic permutation of the vertices of the graph. This means that every vertex can eventually be reached from any other, so the transitive closure is the complete graph with four vertices. The corresponding adjacency matrix should be obvious at this point.


Plants vs. Zombies 2 Piñata Party mini-game location?

Question: An update released today includes a piñata party mini-game. Where is it in the game? I can't find it.
Comment: And what's that thing about "Penny's dashboard"? Never seen that anywhere, too...
Comment: It says that the piñata party is a 24 hour event, so maybe one will start at midnight.
Answer: It said that the pinata party appears on Monday and Thursday on the app store on the iPad.
Answer: I believe it acts the same as the Yeti game (which appears once a day).
Answer: Piñata Parties are every Monday and Thursday at 4:00 PM PST:


Serial port over USB in Linux changes unexpectedly

Question: I have a problem with a custom electronic device communicating with a workstation via RS232 on USB interface.
As soon the device is connected, it receive, says, the address /dev/ttyUSB0, after some (random ) time of sending receive commands, the device appear to hang.
By looking at the device events ( dmesg ), we found the following error:
ftdi_sio ttyUSB0: failed to get modem status: -32
...
USB disconnect, device number 29
[66208.321174] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[66208.497613] usb 1-1.5: new full-speed USB device number 30 using ehci-pci
[66208.589052] usb 1-1.5: New USB device found, idVendor=0403, idProduct=6001
[66208.589055] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3

So apparently the system notices a device disconnection/reconnection, thus, the device is mounted to another port, ie /dev/ttyUSB1, causing further communication failure.
Creating a test bed changes the behavior: error seems to appear less frequently, while using a complete application the error appears recurrently.
Application uses jSSC-2.8.0 to communicate with the serial port. The whole application is written in java 8, and uses the Restle library to issue some REST requests to some web services.
What can cause these strange behavior?
ADDED
as per @DarkFalcon comment below, test bed polls the device usually faster than the real app: this could possibly explain why test perfors better than the other.
Comment: Have you fiddled with any USB power saving settings, such as the `autosuspend_delay_ms` file in `sysfs`, which controls how long the kernel waits before turning off a USB device to conserve power?
Comment: Maybe that device is not compatible with ftdi_sio or you need a specific driver, search for vid and pid to identify the needed device driver and install the kernel module.
Comment: I know you say centos, but here is a post about controlling it on Ubuntu which you may find useful: http://askubuntu.com/a/581404
Answer: The problem was due to power management: the box decided the device is idle and after a certain time it removes the power. The device then apparently comes alive again in almost 0 time. So the strange behavior
Answer: This error is printed by driver due to broken pipe. See ftdi_get_modem_status() in driver file drivers/usb/serial/ftdi_sio.c.
You may try other libraries like 'serial communication manager', purejavacom etc. And see if problem persist. I feel, first identify who is actually creating problem; your app, serial library or driver. Then accordingly move forward. Driver has been tested and probably either library or app might have something we need to rectify.
Comment: If an app running in user space can break a driver, it would be an issue.


Final Fantasy XIII cutscene lag

Question: I just installed FFXIII on my new laptop.  I've never played the PC version until now.
I turned the graphics all the way up using the pre-game window - rendering real-time game-play is no problem.  I'm getting well over 30fps.  However, the cutscenes seem to be lagging and glitching for some reason.
What could be the cause of the cutscene lag - could it be my laptop, if not, is there anything I can do about this?
Specs:

Intel i7 (2.4 to 3.6GHz)
32GB Ram
2x GTX 860 (SLI)
3x SSD Raid 0
Comment: Can you choose to run the game in dx9 mode? I recall Batman: Arkham City having the same issue, I'd get 60 fps in game, but pre-rendered cutscenes would stutter. Running the game in dx9 mode fixed it.
Comment: The FF13 port is also fairly lousy - check the steam forums for details. They may improve it in days / weeks / months to come, but possibly not.
Answer: Either plug in a usb controller or disable all HID-Compliant devices in the device manager.
The issue is that every couple of seconds, the game is testing all HID-compliant devices for a controller.  These tests interrupt smooth video playback.
If you disable the HID-compliant devices keyboard and mouse should still function, but extra features on them (media buttons) may not.

Final Fantasy XIII cutscene lag


PHP store random word in string to use multiple times

Question: public function generateRandomString($length = 16) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
         $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

I'm looking for a way to store this in a variable. For an example: $random = $this->generateRandomString(); and use this variable over and over again, without it changing the value. How can I do this?
Comment: Set a property in your class , `public $this->random`
Comment: you can use file, db, memcache, redis or my open source project https://github.com/Halayem/ANYEM
Comment: What exactly is the problem? Calling the function? Assigning its return value to a variable? Keeping that variable around? Persisting that variable across multiple requests?
Comment: store value in global variable
Comment: create a local static variable and perform generation only on the first invokation. On the consecutive invokations just return that variable
Comment: Is your question how to make the variable persistent?
Answer: Create a property in your class:
Class MyClass {

   private $myRandomString;

   public function generateRandomString($length = 16) {
       $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
       $charactersLength = strlen($characters);
       $randomString = '';
       for ($i = 0; $i < $length; $i++) {
         $randomString .= $characters[rand(0, $charactersLength - 1)];
       }
       return $randomString;
    }

    public function generate() {
         $this->myRandomString = $this->generateRandomString();
    }

    public function fetchRandomString(){
         return $this->myRandomString;
    }

}

$myClass = new MyClass();
$myClass->generate(); //Puts the random value in `private $myRandomString`

$myValue = $myClass->fetchRandomString(); //Returns the random string created
$myAnotherValue = $myClass->fetchRandomString(); //Returns the random string created (still same value)

Answer: The following is the revised version with less function calls.
class NumberGenerator {
   private $length = 16;
   private $myRandomString = null;

   function __construct($length){
     $this->length = $length;
   }

   public function generateRandomString() {
       $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
       $charactersLength = strlen($characters);
       $randomString = '';
       for ($i = 0; $i < $this->length; $i++) {
         $randomString .= $characters[rand(0, $charactersLength - 1)];
       }
       return $randomString;
   }

    public function fetchRandomString(){
        if($this->myRandomString === null){
           $this->myRandomString = $this->generateRandomString();
        }
         return $this->myRandomString;
    }
}

//usage
$myClass = new NumberGenerator (16);
$randomStr = $myClass->fetchRandomString();
echo $randomStr;      //example output: CqaLEYILzxLbWPDw


Older Magic Chef Dishwasher Won't Drain - How to Test Motor/Pump Assembly?

Question: I have a Magic Chef CDB4000TQ0 dishwasher that is not draining. Based on my research, a common cause of this is a faulty pump/motor assembly (part # WPW10247394 for entire assembly; motor part # 8283457). However, I have yet to find consistent guidance on how test this part, specifically what is the expected resistance when tested with a multi-meter?
I would appreciate any guidance on how to test this part, as well any items I may test to resolve this problem.
Thanks.
Answer: First test would be to use multimeter and see if the pump gets power when it supposed to do so, in the program mode.
From here we have
1- has power but not running, so it is the motor it self
2- has no power, it is the control relay from the programer
3- Motor is turning but pump is not pumping, it is the motor to pump connection shaft, or the pump it self.
Resistance meter will not give any usable results.


Does posting a review on Steam give me better recommendations?

Question: I know that Steam harvests all kinds of interesting data points to determine what games to recommend; for example, it recommended a 2D shooter roguelike to me "because you spent 0.1 hours playing Enter the Gungeon."
If I leave recommendations (good or bad) for games I own, does that give Steam more data and result in better recommendations?
Comment: There's [a meta post here](https://gaming.meta.stackexchange.com/questions/12616/would-a-question-asking-about-how-steams-recommendations-feature-works-on-top) about whether these types of questions are on-topic or not.
Answer: I have no actual source for that other than Steam not mentioning it, but I'm certain that your reviews/recs have no impact on your own recommendations.
Steam itself says (when you're not logged in) your recommendations are influenced by

what your friends are playing and what they have reviewed.
games similar to what you've been playing. (your case)
new content available for games you own.

I believe it would be impractical and falsify the results, if Steam would actually take your own reviews into account for your recs. The reviews you post are for one single game and granted that you own that one game already a new recommendation would make no sense. Also a review is for a single game, not for the genre of it. Only because you like or dislike that one game it would have little to no impact on the rest of the genre and you would probably still (not) play it.
Posting reviews still has a positive result, since they have an impact on the recs to your friends and games you hate are less likely recommended to them.
PS: While it may be possible to get less recommendations for additional content for games you've given a bad rating it's still possible, because this happened to me. So it's safe to assume that even there your own recs are not (or very little) influenced by your reviews. It's more helpful to not play those games than giving a bad review.
Comment: @ashes999 it sounds stranger than it is. There are people who like shooters and dislike a specific game like CS Source (or the old CS 1.6 vs CSS rage wars, FIFA vs PES, etc). They could give CSS a bad rating and would still love to hear about and try other shooters or even CS GO.
Comment: Thanks for this. It seems really strange to me that what your friends reviewed influences your queues, but your own bad reviews don't influence queues (and instead, Steam says "oh you played that game, here's a similar one.")
Comment: that makes sense. Thanks for taking the time out to research this and explain it so clearly.


How to convert ebook in Calibre?

Question: How do you convert an ebook to a different format in Calibre?
If I select a book, click the big "Convert Books" button, select output to "MOBI", and click "OK", it appears to run a job successfully, but no new ebook format is generated.
If I click on the jobs, and show details for the last job run, the final line in the log is:
<code> MOBI output written to /tmp/calibre_5.9.0_tmp_q1zebnlm/v8c6whw0.mobi
</code>
But that file does not exist.
Where is it putting the file?
Comment: Look in home for **Calibre Library**. They should all be there.
Answer: Convert an E-book to a Different Format in Calibre
The first time you open an E-book in Calibre you are asked to specify a location for the library and are offered a default location of home/username/Calibre Library.
This is probably the first place to start looking.
You can also open a text file in Calibre and convert it to .epub, then see were that ends up.

How to convert ebook in Calibre?


change Php date in days ago

Question: I am using a component on Joumla that returns dates in this format: 2 months and 6 days ago.
But I need the date to be displayed like this:
xx seconds ago
or xx minutes ago
or xx hours ago
or xx days ago.
The developer told me I have to modify this code, but I am completely new to Php. I tried all day today for over 12 hours in a row, and all I was successfully accomplish was to breakdown my site.
So Could anyone give me help with this. I am willing to grant FTP access if is need. this is the code:
<code>function dateFormatFromTo($from, $to = null)
 {
    $par = JComponentHelper::getParams( 'com_djclassifieds' );
    $to = (($to === null) ? (time()) : ($to));
    $to = ((is_int($to)) ? ($to) : (strtotime($to)));
    $from = ((is_int($from)) ? ($from) : (strtotime($from)));
    $output = '';
    $limit = $par->get('date_format_ago_limit','2');
    $units = array
    (
       "COM_DJCLASSIFIEDS_DATE_YEAR"   => 29030400,
       "COM_DJCLASSIFIEDS_DATE_MONTH"  => 2419200,
       "COM_DJCLASSIFIEDS_DATE_WEEK"   => 604800,
       "COM_DJCLASSIFIEDS_DATE_DAY"    => 86400,
       "COM_DJCLASSIFIEDS_DATE_HOUR"   => 3600,
       "COM_DJCLASSIFIEDS_DATE_MINUTE" => 60,
       "COM_DJCLASSIFIEDS_DATE_SECOND" => 1
    );

    $diff = abs($from - $to);
    $suffix = (($from > $to) ? (JTEXT::_('COM_DJCLASSIFIEDS_DATE_FROM_NOW')) : (JTEXT::_('COM_DJCLASSIFIEDS_DATE_AGO')));

    $i=0;
        foreach($units as $unit => $mult){
            if($diff >= $mult){
                if($i==$limit-1 && $i>0){
                    $output .= " ".JTEXT::_('COM_DJCLASSIFIEDS_DATE_AND').' '.intval($diff / $mult)." ";
                }else{
                    $output .= ", ".intval($diff / $mult)." ";
                }
                //$and = (($mult != 1) ? ("") : (JTEXT::_('COM_DJCLASSIFIEDS_DATE_AND')));
                //$output .= ", ".$and.intval($diff / $mult)." ";
                if(intval($diff / $mult) == 1){
                    $output .= JTEXT::_($unit);
                }else{
                    $output .= JTEXT::_($unit."S");
                }

                $diff -= intval($diff / $mult) * $mult;
                $i++;
                if($i==$limit){ break; }
            }
        }
        $output .= " ".$suffix;
        $output = substr($output, strlen(", "));
  return $output;
 }
</code>
So, I would greatly appreciate if someone can help me out. I can give FTP access if needed.
I have Php 5.3
Thank
Answer: This is an adaptation of Date_HumanDiff class
<code>    date_default_timezone_set('GMT');

    function getDifference($timestamp, $reference = null) {
        static $MINUTE = 60;
        static $HOUR   = 3600;    //static::$MINUTE * 60
        static $DAY    = 86400;   //static::$HOUR * 24
        static $WEEK   = 604800;  //static::$DAY * 7
        static $MONTH  = 2628000; //static::$YEAR / 12
        static $YEAR   = 31536000;//static::$DAY * 365

        $formats = array(
            array(0.7 * $MINUTE, '%d seconds ago', 1),
            array(1.5 * $MINUTE, 'a minute ago',   1),
            array( 60 * $MINUTE, '%d minutes ago', $MINUTE),
            array(1.5 * $HOUR,   'an hour ago',    1),
            array(      $DAY,    '%d hours ago',   $HOUR),
            array(  2 * $DAY,    'yesterday',      1),
            array(  7 * $DAY,    '%d days ago',    $DAY),
            array(1.5 * $WEEK,   'a week ago',     1),
            array(      $MONTH,  '%d weeks ago',   $WEEK),
            array(1.5 * $MONTH,  'a month ago',    1),
            array(      $YEAR,   '%d months ago',  $MONTH),
            array(1.5 * $YEAR,   'a year ago',     1),
            array(PHP_INT_MAX,   '%d years ago',   $YEAR)
        );

        $futureformats = array(
            array(0.7 * $MINUTE, 'in a moment',   -1),
            array(1.5 * $MINUTE, 'in a minute',   -1),
            array( 60 * $MINUTE, 'in %d minutes', -$MINUTE),
            array(1.5 * $HOUR,   'in an hour',    -1),
            array(      $DAY,    'in %d hours',   -$HOUR),
            array(  2 * $DAY,    'tomorrow',      -1),
            array(  7 * $DAY,    'in %d days',    -$DAY),
            array(1.5 * $WEEK,   'in a week',     -1),
            array(      $MONTH,  'in %d weeks',   -$WEEK),
            array(1.5 * $MONTH,  'in a month',    -1),
            array(      $YEAR,   'in %d months',  -$MONTH),
            array(1.5 * $YEAR,   'in a year',     -1),
            array(PHP_INT_MAX,   'in %d years',   -$YEAR)
        );

        if ($reference === null) {
            $reference = time();
        }

        $timestamp = ($timestamp instanceof DateTime) ? $timestamp->getTimestamp() : (is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp));
        $reference = ($reference instanceof DateTime) ? $reference->getTimestamp() : (is_numeric($reference) ? (int)$reference : strtotime($reference));

        $delta = $reference - $timestamp;

        if ($delta >= 0) {
            foreach ($formats as $format) {
                if ($delta < $format[0]) {
                    return sprintf($format[1], round($delta / $format[2]));
                }
            };
        } else {
            foreach ($futureformats as $format) {
                if (-$delta < $format[0]) {
                    return sprintf($format[1], round($delta / $format[2]));
                }
            };

        }
    }

    // will output 52 minutes ago
    echo getDifference('2014-01-15 15:24:00', '2014-01-15 16:16:12') . PHP_EOL;

    // without second param will output difference with the current time
    echo getDifference('2014-01-15 15:24:00') . PHP_EOL;
</code>

change Php date in days ago


Regular expressions not matching first instance of last character in pattern

Question: Sorry for the confusing title but I'm not sure how better to explain it.
I am building a simple web server for a school project that has to parse a custom scripting language. I have a line that looks like this:

Here's the date: <% pr date() %>

Here's the date again: <% pr date() %>

I'm using the following regular expression to try and pull out the <% ... %> stuff...
<% *(.*) *%>

The problem is it is matching from the first open tag to the last closing tag, rather than from the first open tag to the first closing tag. So the resulting match is this:
<% pr date() %>

Here's the date again: <% pr date() %>

...instead of:
<% pr date() %>

I thought I could solve it by using something like this, but it doesn't seem to work:
<% *([^(<%)]*) *%>

...but it doesn't seem to work. Any help is appreciated, thanks.
Answer:
The problem is it is matching from the first open tag to the last closing tag

You need a non-greedy match which stops upon the first time a match is recognized:
.*  --> greedy ("maximum munch")
.*? --> non-greedy ("minimal munch")

The non-greedy quantifier can of course be applied to most other patterns.
However, I would advice against using regexes. The meta-pattern OPEN-TOKEN CONTENT CLOSE-TOKEN is simple enough for a hand written parser/scanner. It will then also be easier for you to recognize when your tags are within comments (and possibly other cases were you don't want a match):

Code like above might not be encouraged by you, but you have to consider that.

Footnote: Each time you (write a parser|fire a regular expression), you are in prison with one leg already.
Comment: Thank you, can you point me in the direction of a resource that might explain the alternative to regexes with more detail? I'm not sure where I would start if I were to write a hand written parser/scanner.
Comment: It might make sense to insert a value dynamically in a comment as well. T4 templates for instance do not take account the grammar of the enclosing text.
Comment: It's a very simple scripting language that really just mimics an "echo" in PHP along with a couple of functions like date() for the current date. I just don't really know what you mean by a handwritten parser, the only solution that came to my mind was to use regular expressions to find what I'm looking for in the string so I'm just wondering how else I could find them at all. Do you mean to just manually iterate through the content one character at a time myself?
Comment: @AdamWathan: `Do you mean to just manually iterate through the content one character at a time myself?` -> Indeed. You could then add state to the parser as needed, for special cases (if needed at all). Don't forget to check that the lookahead character is not beyond the limits.
Answer: You are using .* which is greedy quantifier
Use .*? instead of .* which is a lazy quantifier
i.e Use the regex <%(.*?)%>

So,<%(.*)%> would match till the last %> it finds
<%(.*?)%> would match till the first %> it finds


Alternating series error estimatation theorem for $\sum_1^{\infty} (-1)^{n+3}\frac{n}{n^2+8}$

Question: $$\sum_1^{\infty} (-1)^{n+3}\frac{n}{n^2+8}$$
Here is my question: Using the alternating series error estimation theorem, what is the smallest number of terms needed to estimate the entire sum with an error of magnitude less than $10^{-6}$?
So from what I know about the alternating series error estimation theorem, it's when you have to list out the terms and adding up a certain number of terms makes the error of the estimation the next term that was left out of the group of terms.
So I wrote out the first few terms, is that how you approach this problem? Am I supposed to find the term with the 0.000001 place?
Here are the first few terms:
0.11 - 0.166 + 0.176 - 0.16 + 0.151
So far I do not see any term to that place. Is there some other way to do this problem?
Comment: I suppose that you did not finish your last sentence.
Comment: oh wait let me fix that thanks
Comment: So your problem is that none of the **five** first terms is less than 10^{-6}? Sorry but (1) does this really come as a surprise? and (2) sure you have no idea how to overcome this obstacle?
Comment: @Did well um ya I just started learning about this theorem, so (1)ya it comes as a surprise and (2)my only idea is to keep listing out terms. Is that how it goes?
Comment: Imagine that the first suitable term is at n = 10^6... Still think this is how it goes? And if you were asked for some rest less than 10^{-12}...
Comment: Try to make the statement more general, may be. What is $n$ such that $???$ ? From there, you could conclude.
Comment: @Did well how else do I do this problem? Isn't the goal to find the first term to be in the form of 0.000000?
Comment: Hint: How to solve the *exact same question* for the series $$\sum_{n\geqslant1}\frac{(-1)^n}{n}\quad ?$$
Comment: @Did let me try that
Comment: The question should be interpreted as:
Find the first $N$ such that
$$\varepsilon_N \stackrel{def}{=}\left| \sum_{n=1}^\infty (-1)^{n+3}\frac{n}{n^2+8} - \sum_{n=1}^N (-1)^{n+3}\frac{n}{n^2+8}\right| < 10^{-6}$$

The *alternating series error estimation theorem* tells you if
the underlying series is decreasing, the error $\varepsilon_N$ is bounded from above by the first term you skip. i.e

$$\varepsilon_N = \left| \sum_{n=N+1}^\infty (-1)^{n+3}\frac{n}{n^2+8} \right|
\le \frac{(N+1)}{(N+1)^2+8}\tag{*1}$$
Your question becomes: "What is the first $N$ such that RHS$(*1) < 10^{-6}$"?
Answer: You could use the Calabrese criteria (see the references) to approximate the sum of alternating series:
References:
http://ecademy.agnesscott.edu/~lriddle/apcalculus/approxSeries.pdf
Answer: This is horribly wrong proposition but that was the case in 1955 at least in some textbooks.

Using the alternating series error estimation theorem, what is the smallest number of terms

It cannot provide smallest number in all cases! Only some number where error is at least as specified but in reality error can be smaller.
$$0.0000005\le\frac{(N+1)}{(N+1)^2+8}$$
gives $$N \le -0.9999954999657348$$ and $$ 2000000.9999954998\le N$$
So the answer is 2 million terms, now we need to verify there is no smaller value, like 1 million (which is 2 times less, that is how Calabrese criteria error bond works).
Well, you can check this with Wolfram Mathematica first.
The sum of the series can be found in symbolic form: $$\frac{1}{4} \left(\psi ^{(0)}\left(i \sqrt{2}+1\right)-\psi ^{(0)}\left(i \sqrt{2}+\frac{1}{2}\right)+\psi ^{(0)}\left(1-i \sqrt{2}\right)-\psi ^{(0)}\left(\frac{1}{2}-i \sqrt{2}\right)\right)$$
where $$\psi ^{(0)}$$ is polygamma function.
We can see that it is actually 1 million terms, not 2 million.
+1 to the guy above who gave the citation.


How do I request permission to dock my ship?

Question: The latest update has added the ability to dock with a starport in Zelada, however, I can't seem to work out how exactly I'm supposed to dock. Approaching the station results in a warning that I do not have permission to land and I'm seeing no option in the controls that will allow me to communicate with the station to request permission to dock.

How do I request permission to dock my ship aboard the Corolis Starport in Zelada?
Answer: To dock you will need to request permission by selecting the station in the contacts pane in navigation and then select "Request Docking":

This will give you a designated dock to land in and a time limit for docking permission.
Comment: on the keyboard, Q and E cycle between tabs in the left screen so you can get to dock permission request. This took me a long time to find also.
Comment: Once the comms panel is open, what button do you press to bring up this lock target/request docking dialog?


WinApi control doesn't show on the main window

Question: hello I have the following win32 program, and I have an EDITTEXT control that doesn't show up on the screen. There is meant to be two EDITTEXT controls drawn on the main window, but only one shows, why is this?
full code
#include <windows.h>
#include <iostream>
#include "resource.h"
using namespace std;
const int BUFFERMAX = 512;
char server_ip[BUFFERMAX];
int port;

const char windclassname[] = "windowClass";

LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK AboutDialog(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
INT_PTR CALLBACK ConnectWin(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
    WNDCLASSEX parent_window;
    HWND hwnd;
    MSG msg;

    parent_window.cbSize = sizeof(WNDCLASSEX);
    parent_window.style = 0;
    parent_window.lpfnWndProc = WndProc;
    parent_window.cbClsExtra = 0;
    parent_window.cbWndExtra = 0;
    parent_window.hInstance = hInstance;
    parent_window.hIcon = LoadIcon(NULL,IDI_APPLICATION);
    parent_window.hCursor = LoadCursor(NULL,IDC_ARROW);
    parent_window.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    parent_window.lpszMenuName = MAKEINTRESOURCE(ID_MENU);
    parent_window.lpszClassName = windclassname;
    parent_window.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

    //Registering the Class for use.
    if ( !RegisterClassEx(&parent_window)){
        MessageBox(NULL,"Could not Register WindowClass","Error",MB_OK);
        return 0;
    }

    //Creating the window
    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,windclassname,"UI test",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,250,350,NULL,NULL,hInstance,NULL);
    if ( hwnd == NULL ){
        MessageBox(NULL,"Could not create window","Error",MB_OK);
        return 0;
    }

    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);

    while ( GetMessage(&msg,NULL,0,0) > 0 ) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;

}

LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){
    switch (msg){
        case WM_CREATE:

            HWND chatbox_cntrl;
            HWND message_text;

            chatbox_cntrl = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
                WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
                0,0,240,260,hwnd,(HMENU)CHATBOX,GetModuleHandle(NULL),NULL);

            message_text = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
                WS_CHILD,0,270,240,10,hwnd,(HMENU)MESSAGETEXT,GetModuleHandle(NULL),NULL);

        break;
        case WM_COMMAND:
            switch(LOWORD(wParam)){
                case ID_MABOUT_INFO:
                    DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_MABOUT_INFO), hwnd,AboutDialog);
                break;

                case ID_MCONTROLS_CONNECT:
                    int ret = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_MCONTROLS_CONNECT), hwnd,ConnectWin);
                break;
                case ID_MCONTROLS_EXIT:
                    DestroyWindow(hwnd);
                break;
            }
        break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
    }
    return DefWindowProc(hwnd,msg,wParam,lParam);

}

INT_PTR CALLBACK AboutDialog(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){
    switch (msg){
        case WM_CLOSE:
            EndDialog(hwnd,WM_CLOSE);
        break;
        default:
            return false;
    }
    return true;

}

INT_PTR CALLBACK ConnectWin(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){
    switch(msg){
        case WM_COMMAND:
            switch(wParam){
                case CONNECT_BUTTON:
                    int len = GetWindowTextLength(GetDlgItem(hwnd,EDITTEXT_CONNECT));
                    int recv = GetDlgItemText(hwnd,EDITTEXT_CONNECT,server_ip,len+1);
                    port = GetDlgItemInt(hwnd,EDITTEXT_PORT,NULL,false);
                    EndDialog(hwnd,CONNECT_BUTTON);
                break;
            }
        break;
        case WM_CLOSE:
            EndDialog(hwnd,WM_CLOSE);
        break;
        default:
            return false;
    }
    return true;
}

these are the two controls.
case WM_CREATE:

            HWND chatbox_cntrl;
            HWND message_text;

            chatbox_cntrl = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
                WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
                0,0,240,260,hwnd,(HMENU)CHATBOX,GetModuleHandle(NULL),NULL);

            message_text = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
                WS_CHILD,0,270,240,10,hwnd,(HMENU)MESSAGETEXT,GetModuleHandle(NULL),NULL);

        break;

Answer: The message text window doesn't have the same style flags as the first.  Specifically, it is missing WS_VISIBLE.  This could well be your problem.
Comment: @sil3nt:  No need to apologize.  Was that a typo in your OP, or did this fix the problem?
Comment: It was a mistake unfortunately, wasn't paying much attention when I was writing it. have only recently started learning the API :).
Answer: Did you call InitCommonControlsEx() before creating your edit windows? Does CreateWindow() return a valid HWND?
INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof(icc);
// Load one of the intrinsic User32 control classes.
// The user controls include button, edit, static,
// listbox, combobox, and scrollbar.
dwICC = ICC_STANDARD_CLASSES;
::InitCommonControlsEx(&icc);

Comment: -1. InitCommonControlsEx() has nothing with edit control. Edit control is implemented in user32 not comctl32.
Comment: @Xearinox: [The edit control is implemented in both user32 and comctl32](http://msdn.microsoft.com/en-us/library/windows/desktop/hh298434.aspx). Even if that were not the case, calling `InitCommonControlsEx()` with [the `ICC_STANDARD_CLASSES` flag set](http://msdn.microsoft.com/en-us/library/windows/desktop/bb775507.aspx) states that it will "load one of the intrinsic User32 control classes. **The user controls include button, edit, static, listbox, combobox, and scroll bar**" It is appropriate to use this function to load the edit control, especially if you want visual styles.
Comment: @Xearinox: Did you take a look at the MSDN documentation I linked? Comctl32 is included in Windows XP, and the docs make a note specifically for Windows XP that the edit control exists in both user32 and comctl32 and have slightly different behavior (namely the appearance of the password character).
Comment: Oh, I know about this feature. My mistake.
Answer: Have you initialize the controls before load it with InitCommonControlsEx? Try this code one.
int InitControls() {
    INITCOMMONCONTROLSEX iccx;

    iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    iccx.dwICC = ICC_WIN95_CLASSES;

    InitCommonControlsEx(&iccx);
}

Remember to include header commctrl.h and library comctl32.dll
Good luck!


SQLite3 Python - Checking if an entry exists

Question: I'm trying to check for duplicate usernames in a database but I'm getting the error:

sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied.

What are the bindings referred to here and how might I go about fixing this?
conn = sqlite3.connect('data.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS users (username, f_name, l_name, age, email, uid)''')
for u in range(0,1):
   a1 = input("Enter desired username:\t")
   a2 = input("Enter first name:\t")
   a3 = input("Enter last name:\t")
   a4 = input("Enter age:\t")
   a5 = input("Enter email:\t")
   a6 = str(uuid4())
   add = [a1,a2,a3,a4,a5,a6]
   c.execute('''SELECT username FROM users WHERE username=?''', a1)
   exists = c.fetchall()
   if not exists:
       c.execute('INSERT INTO users VALUES(?,?,?,?,?,?)',add)
       conn.commit()
   else:
       print("Error: Username already in use.\n")

Answer: There's a subtle problem in this line:
c.execute('''SELECT username FROM users WHERE username=?''', a1)

The second argument to .execute() must be a container!
So you can do something like this instead and it will work:
c.execute('''SELECT username FROM users WHERE username=?''', (a1,))
                                                           # ^  ^^ this is now a tuple!

Comment: That did it. Thank you.


How do I handle Neighborhood defense when gang members spawn as fast as I can kill them?

Question: I recently picked Saints Row 2 up again after a year or so away from it. I have a situation where the Ronin are attacking the neighborhood where Aisha's house is. I've tried going in and killing the lieutenants, but even with a full gang and all of the weapons, the Ronin literally spawn faster than I can kill them. In the space of shooting a gangster in the head, another two cars will pull up out of nowhere. I am playing with the Gentlemen of the Row mod with a few of the settings turned on, but I don't see anything in the settings that should be boosting the spawn rate of the gangs or enhancing their weapons.
Should I just ignore the neighborhood and move on to the main plot? Do more side-missions to pick up some sort of benefits to better battle them? Hack some game files to nerf the Ronin?
Answer: You mention going after the lieutenants, but it's worth re-iterating: the moment the last marked enemy dies, the event is over and everyone else loses aggro.
Beyond that, a couple suggestions come to mind (just started another playthrough of SR2 w/ GotR):

Bring all the homies you can. If nothing else, they'll draw some fire so you can concentrate on the targets.
Choose your battle - you'll get mobbed as soon as you enter the district, but not until you enter. So find out where the bosses are and plan your approach accordingly. Bring a heavier vehicle, punch directly in, drop them ASAP.
If you're feeling evil, grab yourself a Tornado attack helicopter and just kill 'em all from the air. (It's possible to get one of them fairly early, or likely via GotR cheat if you're just feeling the need to vent.)


How to start Chrome always in "Incognito Mode"?

Question: So... I found a solution to be able to open Chrome on 12.04 in Incognito Mode by default (How do I make Google Chrome open Incognito by default?).
I can't seem to get it to open consistently in Incognito Mode with all the pages I have set to load on startup e.g. In OS X, I open Chrome, which defaults to Incognito Mode and loads all the websites I have set in the "Open a specific page or set of pages" preference. In Ubuntu I can't replicate that.
Comment: Possible duplicate of: http://askubuntu.com/q/159630/10698
Comment: I'm not even sure why this is closed as bug report...
Answer: In Ubuntu/Linux unless you edit the .desktop file it won't work. Run the following:
sed 's/\/google-chrome/\/google-chrome --incognito/g' /usr/share/applications/google*.desktop

Is not efficient but will do the work.


do linear block code codewords need to contain the original k bits?

Question: In standard form, the Generator matrix of a linear block code will contain the Identity matrix. However, the generator matrix need not be in standard form. However, is it the case that k of the n codeword bits will be the original k message bits? That is to say, will it always be the case that there will be k different columns in the Generator matrix with a single 1 in them?
In particular I'm interested in Golay codes, but a more general statement would also be helpful.
My guess is "no", because you could in theory just take a Golay code in standard form, flip every bit in every codeword and have an equivalent code, but I'm not sure if my reasoning is faulty here
Possibly related: Can all linear code be adapted so that the first bits of the encoded message are the bits from the original message?
Answer: Well, actually you kind-of answered the question yourself. However, your two questions are not equivalent. Your first question: "Is it the case that $k$ of the $n$ codeword bits will be the original $k$ message bits?" is not equivalent to your second question "Will it always be the case that there will be k different columns in the Generator matrix with a single 1 in them?" The answer to both questions is no.
For the first one, pick my stupid code with generator matrix $\left[\begin{array}{cc} 1 & 1 \\ 0 & 1 \end{array}\right]$ and data $\left[\begin{array}{cc} 1 \\ 1 \end{array}\right]^T$ to get the codeword $\left[\begin{array}{cc} 1 \\ 1 \end{array}\right]^T\left[\begin{array}{cc} 1 & 1 \\ 0 & 1 \end{array}\right] = \left[\begin{array}{cc} 1 \\ 0 \end{array}\right]^T$. This vector does not contain all the entries of your data you wish to transmit.
I guess you know the answer to your second question. A code does not have to be in its standard form "to work."
So why does all of the codes that we are interested in can be put into the standard form? As otherwise, $G$ would contain a $0$-row, which means you are not encoding one of your data bits (obviously this does not make sense, you may then improve your coding rate by throwing out that bit without sacrificing performance).
Another relevant question is why would want to use the non-standard form of a generator matrix. The reason is that sometimes encoding using the non-standard form of the generator matrix may result in a better performance if your decoding algorithm is non-maximum-likelihood.
Comment: thank you for managing to give a good answer to a question I was having a hard time asking :)
Comment: @Mala, You are welcome.


Test outlets to see if knob and tube? (grounded?)

Question: Considering a rewire in the future and want to figure out which outlets (and ideally fixtures) are knob and tube. I know many are, some are not. Probably all 2 prong outlets are k&t, possible some 3 prongs are as well.
Is this best done with a multimeter, an outlet tester or something else? What are the steps then? Thanks!
Answer: There is no electrical or technical way to tell if a box is wired with K & T. You'd get the same results with old non-grounding NM cable.
The only way is visual. You'd have to open each box and check with your eyes.
Answer: The copper wire used in knob and tube has identical electrical behavior to copper wire in any modern cable assembly. Determining the wire type (sheathing around the copper) and cable assembly or use of conduit is something that can only be done visually.
Opening up the electrical device boxes (make sure you understand how to work safely on electrical equipment if you proceed with these steps) and inspecting the wire coming into the box will allow you to determine the type of wire feeding into the box. Also, tracing visible portions of wiring in an open attic or basement also provides good clues. That said, if any work was done on your home without a permit prior to your ownership, it is certainly possible that the work was done by a homeowner or handy man unfamiliar with proper electrical code and safety. In these cases, it is not uncommon to see modern wiring in a device box with an illegal and unsafe splice/junction concealed inside of the wall.
Regarding your guess that 2 prong outlets are knob and tube while 3 promo outlets may be modern wiring is a good guess. That said, the three prong outlets may still be knob and tube even if an outlet tester reports proper grounding because it is permissible to run separate ground wires to ground old wire in some situations, so that still brings you back to visual inspection as the only way to confirm the wire type.
Answer: I don't know of a tester that'll tell you about wiring type.  Your best hope may actually be looking at how wires enter the junction boxes, as well as a borescope in any openings therein.  Borescopes are quite inexpensive of late and attach to a phone as their power and display.    I would use a plastic-bodied one and turn off the power.
What people worry about with K&T is wiring failure.  This is easily detected by an arc-fault breaker (AFCI).   The AFCI will have trouble if several K&T circuits share a neutral, but that was never a common practice for the same reason it's not today: 2 hots sharing a neutral overloads the neutral unless it's set up just right (MWBC).
There was another worry which was debunked.  Consider Romex, run through walls packed with insulation.   Despite both conductors packed tight together in an insulating sheath, they don't have any trouble cooling.  For some reason, somebody thought Knob-n-Tube would have a problem with that, particularly blown-in insulation done as a retrofit.  Further research proved that to be false: insulation-packed K&T didn't have any worse trouble than otherwise.  So states have started allowing blown-insulation over K&T.
The third issue with Knob-n-Tube is no ground.   NEC 2014 liberalized the rules for retrofitting grounds, so you can add grounds wherever needed.
If it was me and I suspected K&T, I would install AFCI breakers, and retrofit grounds as needed.  The cost of a big wiring tear-out is better spent on other safety concerns.
Comment: A shared neutral (not hard to check for) is a very good reason to tear out (or repair in kind) the K&T.  It's bad now, and it was bad in 1920, and they knew that.   **They also knew about MWBCs.** so it's possible that shared neutral situation was competently installed as an MWBC and then incompetently and haphazardly moved from a fuse panel to a breaker panel with no respect or attention paid to polarity.
Comment: I agree with AFCI breakers provided there are no shared neutrals between circuits since that would cause phase imbalances and unnecessary tripping. To my knowledge, this is one of the common pitfalls with retrofitting AFCI breakers for a lot of knob-and-tube installations.


BLAS sdot_ function returns unexpected result

Question: I'm trying to generate dot product of two matrices using the below compiling command in Linux-GCC:

gcc -L/usr/lib64/atlas -lblas code.c

and here is the code which seems to have compiled without an error:
#include < stdio.h>

int main()
{
  int n,incx,incy;
  int x[] = {1,2,3};
  int y[] = {2,3,4};
  int z;
  incx =1;
  incy =1;
  n = 3;
  z = sdot_(&n, x, &incx, y, &incy);
  printf("%d", z);
  printf("\n");
  return 0;
}

So I expect to see 1*2 + 2*3 + 3*4 = 20, however when I run the binary the result "3" is printed.
Any ideas?
Comment: Can you please share the definition of this api sdot_(&n, x, &incx, y, &incy);?
Comment: http://www.mankier.com/3/sdot.f or just `man sdot`
Answer: You use wrong types and implicit declaration of sdot_. You should add the function prototype (or include a header) and use the right types.
#include <stdio.h>

float sdot_(int* n, float* x, int* incx, float* y, int* incy);

int main()
{
  int n,incx,incy;
  float x[] = {1.f,2.f,3.f};
  float y[] = {2.f,3.f,4.f};
  float z;
  incx =1;
  incy =1;
  n = 3;
  z = sdot_(&n, x, &incx, y, &incy);
  printf("%f", z);
  printf("\n");
  return 0;
}

If you enable warnings, you will get them from your compiler for your version of the code:
cc sdot.c -lblas -Wall
sdot.c: In function 'main':
sdot.c:14:3: warning: implicit declaration of function 'sdot_' [-Wimplicit-function-declaration]


i would like to install debian

Question: i already made a unallocated space on windows disk management with the size about 10 gbs and is it possible to install Debian into that exact hard drive without partitioning anything?
Comment: Debian != Ubuntu. Try [unix.se]
Comment: It sounds like you've already partitioned your disk by allocating a 10GB partition using Windows Disk Management.  Following instructions for installation, you should be able to use that partition to install Ubuntu.  I'm not quite clear on exactly what you're asking here, but 10GB should be enough for a Debian/Ubuntu installation, but most people would suggest you have more space available than that.
Answer: Ubuntu need at least a primary partition to work. Besides that swap is advisable if you use memory consuming programs. And needed if you want to put the computer in hibernation. If you install Ubuntu it will automatically set up the needed partitions for you when you choose "Install Ubuntu alongside windows".
Comment: thanks for answering somehow debian is not booting when i insert the cd into the tray when i boot up

i would like to install debian


Is it possible to join two tables into one single table , both tables have the same column names ...?

Question: Is it possible to join two tables in mysql  into one single table , both tables have the same column names ...?
table a has
id name state
1  jose  up
2  sam   mp
3  jack  tn

table b is
id name state
4  ken  ker
5  sk   wb

is it possible to join both like:
id name state
1  jose  up
2  sam   mp
3  jack  tn
4  ken   ker
5  sk    wb

Comment: The resulting output of your query is **UNION** and not **JOIN**
Comment: Yes. It's possible. Use UNION
Answer: Use UNION ALL
SELECT
  id,name,state
from
  tbla
UNION ALL
SELECT
  id,name,state
from
  tblb

If you want the exact duplicates to be excluded from the output. Use UNION
SELECT
   id,name,state
from
   tbla
UNION
SELECT
   id,name,state
from
   tblb

Reference:

18.104.22.168 UNION Syntax
Comment: WHAT IF I HAVE 5,6 TABLES?
Comment: @user3304713 : You can still use a `UNION` or `UNION ALL` if you have 5 or 6 tables. You just continue adding `UNION` clauses
Answer: The requirement you are describing is a union all query, not a join:
SELECT id, name, state
FROM   table_a
UNION ALL
SELECT id, name, state
FROM   table_b

Comment: WHAT IF I HAVE 5,6 TABLES?
Comment: Then you add 5,6 `union all`s: `select id, name, state from tablea union all select id, name, state from tableb union all select id, name, state from tablec...`


Strategy for Iskatu Nightmare/Hell - Witch Doctor

Question: I have a been trying to solo farm Iskatu for experience to get my levels up to a point where playing Hell is less "squishy". For some reason I am not finding the right build for the Witch Doctor to make killing him alone on Nightmare with the templar effective.
I have been using this build which is nice in doing passive damage but is not effective on the higher levels.
http://us.battle.net/d3/en/calculator/witch-doctor#aZUdjT!ZVW!aYZaYZ
What is the most effective build for killing this boss that places an emphasis on speed to complete specifically for the Witch Doctor? How does this build change when you fight him on Hell vs Nightmare.
Comment: fwiw I've found the beginning area in act 3 (light the beacons quest) is still the fastest experience, even faster than iskatu runs over and over
Comment: For the record, gargantuan is not really a good spell. Once the monsters start getting "vampiric", they will heal pretty fast killing the gargantuan, to the point of making them impossible to kill as long as you keep respawn the creature.
Answer: In my experience as a witch doctor it is best to aoe away all the small shadow demons and "slowly" chip away at Iskatus health in the process. I made you a new skilltree:
http://us.battle.net/d3/en/calculator/witch-doctor#hSUdiP!ZVW!aaaZaa
Here is the reasoning behind the spells:

Firebomb (Flash Fire): You deal damage to Iskatu and remove extra shadow creatures that stand around him.
Locust Swarm (Pestilence): Spreading the locust across all enemies will get rid of them rather easily. Plus you do not really benefit from "Grasp of the Dead" since you don't want to kite enemies in this build.
Spirit Walk (Jaunt): That's a no-brainer. If Iskatu is close to you you pop Spirit Walk to make yourself immune. The rune adds more time to that which is always a plus.
Soul Harvest (Siphon): To increase your damage obviously. But the healing rune is more preverable since you will mostly stay at one spot and take a few hits, which you can now heal.
Acid Cloud (Acid Rain): When the room is full of small enemies with little health: AOE all the way.
Fetish Army (Fetish Ambush): When the Situation gets slightly out of hand a Fetish Army will do you more good than a giant. Plus they do good amounts of damage on Iskatu should they get to him (rather unlikely due to the adds). If you high level enough I would take the (Legion of Dagger) rune instead. More staby.

If you are level 60 and you fight him in hell I would change the Locust Swarm with Zombie Charger (Zombie Bears). As well as the Acid Cloud to Mass Confusion (Mass Halluzination). Also the Jungle Fortitude passive becomes a Vision Quest. This setup allows you to keep 4 spells on cooldown at all times, thus giving you huge amounts of mana to summon these high burst damage AOE bears every few seconds. This allows you to clear out the area around you at all times and when Iskatu gets close to you he is toast.
If your equipment isn't that great yet or has mainly offensive stats I would keep Jungle Fortitude and give away Pierce the Veil instead, especially since this gives you even more mana for bears.
Comment: Also: the OP should look into enabling the game option "elective mode" which allows one to place any skill into any slot, at least for the really difficult times where (s)he is struggling and can't find the right mix of skills to make it through.
Comment: I won't add an answer because, frankly, this is a sort of non-constructive question (no correct answer), but I use(d) locust swarm, the gargantuan pet and zombie wall (in addition to the soul and spirit you suggest) for most of the way up to lvl60. I also used the passive skill which boosts int with orbs. If you drop a zombie wall to stall the swarms, pop soul harvest, and grab any orbs that drop, you will probably have 5 stacks of +int, plus the soul harvest. Your dps goes through the roof, and with aoe and pets, this translates to huge damage.
Comment: @Warba I think it also helps greatly to fight while positioning yourself at one of the corners since you'll at least have one of your sides covered. This is easy when you're playing single, harder to coordinate with more people :)
Answer: This method works great for the budget witch doctor:
Run around (make sure the WD has boots that grant at least 10% speed increase) till Iskatu appears. Then attack viciously and run off. Repeat this hit-and-run and Iskatu will eventually succumb.
Nightmare:

Hell:

Have fun :)
Answer: I have read almost all the weird and intricate ways players are playing the Witch Doctor with the spectre run and whatever else. Thought I would share my simple works.
Gargantuan is a must, which one you prefer is up to you. Personally the stun is too useful as it saves your team dps. The rage version also very good.
Next I prefer firebomb but with the last rune to blast a larger area. This means everything in a 9 yard or so radius is taking dmg from centre out every shot.
Now I have come to use the grasp a lot with the extra slowing feature. Really allows for great crowd control slowing everything down especially in frantic modes plus more AoE.
Next we throw in either a Manituo Phantasm or acid whatever you prefer.
To finish I always have my little healing voodoo. He has a super quick summon, almost 3k dart every second to health. Plus regularly minimises an enemy including elites.
Again I took to the strategy in mind that the doctor curses and plays the field. I leave single shots to the Hunters and the bangs and whooshs to the Wizards. I am literally controlling the field, slowly halting and smashing out the AoE.
Get good enough loot, 100k buyouts will get you sufficient. Int, Res all crucial.


Pipe R markdown through Knitr?

Question: I found out from this question that you can call Knitr from a script like this:
Rscript -e "library(knitr); knit('myfile.Rmd')

But is there a way to get it to use stdin and stdout instead of files?
I tried several variations on
Rscript -e 'library(knitr); knit2html(text=readLines(), output=stdout())'

but none have worked so far.
EDIT: I suppose worst case, I could write a wrapper script that writes stdin to a temp file, calls knitr on it, echoes the output file, and deletes them. But that's kind of ugly :(
Comment: See http://stackoverflow.com/questions/9370609/piping-stdin-to-r perhaps.
Comment: and be sure to use the argument `quiet=TRUE` in `knit()` or `knit2html()` to suppress other possible messages that may pollute `stdout()`
Answer: OK I tried it again today, and here's a working script:
#!/bin/bash

# Hacky version of what I thought should be doable like so:
# Rscript -e 'library(knitr); knit2html(text=readLines(), output=stdout())'
# Turns out you need tempfiles for some reason?

input="/tmp/input.Rmd"
output="/tmp/output.html"
rcode="library(knitr); knit2html(input=\"$input\", output=\"$output\")"

cat /dev/stdin > "$input"
Rscript -e "$rcode" &> /dev/null
cat "$output"

You pipe R markdown in and HTML comes out. Ignores any errors.
Answer: Here is one version:
#!/bin/Rscript
library(knitr)
input <- readLines('stdin')
invisible(knit(text=input, output=stdout(), quiet=TRUE))

Then (assuming script is knit.R, rmd file is test.R and md to html converted is multimarkdown:
knit.R < test.Rmd | multimarkdown > test.html

Pipe R markdown through Knitr?


How to make my iphone app icon update like the weather app icon?

Question: I have an application that I'm currently building that requires me to display a visual update on the application it self. example:
The weather app displays 14 degrees celcius and some clouds as its application icon. When the weather changes there is an update to the way the icon looks without having to open the weather app. The applications icon changes to reflect the update in weather. You can then open the weather app to get more information if need be.
In my application I need to have an update system like that which shows the user information without opening the application. If they would like more information they can open the application then.
I have no idea how to accomplish this task at the moment. I hope someone will be able to help or point me in the right direction. Thank you for your time.
Comment: which version of iOS are you running? The weather.app on my iPhone 4 with 4.1 doesn't do that.
Comment: seconding that the weather app doesn't update.  ever.  the calendar app, does, though, and I'd be interested to know how it does it.
Comment: The Weather app icon only changes depending on the region where an iPhone was purchased. It shows 73 degrees Fahrenheit and 23 degrees Celsius depending on which scale a region commonly uses. Other than that it isn't dynamic. I've never seen 14 anywhere — sure your device isn't jailbroken?
Comment: I'm running iOS 3.1.3 I just checked it now. My weather app says 23 degrees, and when I open the app the current weather is 23 degrees. I even checked the weather app on my blackberry and its consistent with that too. Even on the blackberry it auto-updates the image too with the current temperature and if its cloudy or not.
Comment: No my device isn't jailbroken. I mean it could be a coincidence...since everyone is saying it doesn't I guess it doesn't..
Answer: You can't do what you are proposing. As far as I know the weather app always displays 23 degrees C. I know the iCal app displays the date but this is done using private API's only allowed for use by Apple since there is no way to do this with the public SDK.
You can however display badge numbers like the AppStore app does to display the number of available updates.
Comment: Blackberry OS is a COMPLETELY different platform that iOS. It is VERY wrong to assume that the two apps would function in the EXACT same way.
Comment: +1 Yes, Apple does this with their Calendar app using private APIs.
Comment: :( gah...I guess it doesn't. Not sure why the weather app on the iphone is different than the weather app on the blackberry..the blackberry one does it..i know that for a fact. I guess it can't be done on the iphone.
Answer: You can specify a "badge" (like unread messages on the mail app icon), but you can't change the icon of your app programmatically using the public SDK.
Comment: @ArpitRaniwala `[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];`
Comment: can anyone please guide on how to add badges to the app icons programatically.
Comment: Thanks Jack. I figured this out long back, but anyways thanks for your concern.


I run my hot water in the bathroom sink and the toilet next to it starts bubbling

Question: I run my hot water in the bathroom sink and the toilet next to it starts bubbling.
What could be causing this?
Answer: Sounds like the sink and toilet share the same sewer pipe, and that pipe is starting to get clogged.
Looks like the water coming from the sink is filling the pipe and the only place for the air in it to escape is the toilet.
Answer: Bubbling of the toilet, along with gurgling sounds from drains, are usually signs of a blocked vent pipe. If your sink drains slowly at first, this is most likely the case. Unfortunately, clearing the vent often involves getting on the roof, removing anything visible on the vent pipe, and then clearing the vent with a garden hose or long snake.
It's possible that the sink is vented with an AAV, a special one way valve, that's installed as close to the top of the sink as possible, and if this fails, you'd have the same problem as a clogged vent. The solution in that case is to replace the AAV.
If there's a clog downstream of the toilet, as Netduke suggest, that would be evident if running the sink eventually backups up into the toilet or bathtub/shower. If that's the case, you can simply snake the line with a special snake designed for toilets or a long snake run from the sink.


Why is my "npm install" downloading a lot of excess libraries that I did not specify?

Question: This is my package.json dependencies array:
{
  "cookie-parser": "~1.0.1",
  "body-parser": "~1.0.0",
  "express": "~3.5.0",
  "socket.io":"1.0",
  "mongodb":"2.2.21",
  "request":"2.79.0",
  "q":"1.4.1",
  "bcryptjs":"2.4.0",
  "jsonwebtoken":"7.2.1",
  "lodash":"4.17.4",
  "express-jwt": "5.1.0"
}

and then when i perform an NPM install this is the output:
https://i.stack.imgur.com/tVUVz.jpg
Why am I getting all of this? On one PC I'm only getting the dependencies I requested but on my laptop I get all of this. I am very confused. I have the output as well but it looks ugly when pasted here.
Comment: Many packages require other packages in order to work so those get downloaded as a part of the package you specified in your `package.json` file.
Comment: You sure the extra folders aren't dependencies of your dependencies?
Comment: look at the `package.json` for the dependencies you have listed in your `package.json`
Answer: The packages you're installing have dependencies - this means that when you install them, you're also installing their dependencies.
Answer: I went ahead and created a mock package.json with your dependencies and did an npm install.
Indeed, the packages actually displayed were the ones listed, but an npm ls will show all of the dependencies each of those dependencies installed, as noted by Pineda in a comment on your question.
You can use npm ls to view the dependency structure. Full documentation can be found here: https://docs.npmjs.com/cli/ls
Comment: I feel my answer is more complete than the one submitted above, which is effectively a one-liner. - Is there any feedback to guide me in future answers?
Answer: To dispel any weirdness regarding packages (which happens to me too), it's best to delete node_modules folder and npm i again. After that, combination of dependencies in your package.json (both dev-dependencies and normal-ones), should match the output of the command: npm ls --depth="0".
Now, on both your PC and your laptop the npm ls --depth="0" will match the combined list of all dependencies in package.json. Both cannot mismatch, otherwise that would mean npm became self-conscious and went rogue .
Now, the readers of SO down-voted your question assuming you don't understand that dependencies can have dependencies and that's where the folders are coming from.
I hope that's not the case and that you will not get discouraged by any negativity happening in SO.
There is another possible scenario which might explain your case.
If you forgot to add --save when installing dependencies, dependencies were just saved into node_modules folder, but not added to your package.json. Thus, you might have inadvertently installed more things that you use.
When you delete the node_modules folder and install again, all dependencies are wiped and only what was in package.json is installed. That's why I suggest to delete node_modules folder first. As a note, npm-publishing automation libraries like my preferred np tend to wipe and reinstall dependencies before publishing the npm packages because of this exact reason. There can be "rubbish" in node_modules and wipe/reinstall helps.
I suggest to refer to this brilliant answer on --save.
With regards of previous answers, Jonathan mentioned npm ls but I find it unwieldy on anything else than trivial libraries — too much scrolling. It's best to use npm ls --depth="0" to check just the topmost level of your dependencies.


How can I pass a JavaScript function to Silverlight?

Question: I'm evaluating the JavaScript/Silverlight interop capabilities and have been able to create a Silverlight instance using JavaScript and call methods on it. However, I now need a way of passing a JavaScript callback function to Silverlight.
Simply passing a JavaScript function to a Silverlight method expecting an Action doesn't work although the error suggest that it's intended to. What am I missing? The exception details:
Microsoft JScript runtime error: System.ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.
   at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure)
   at System.Windows.Hosting.ScriptingInterface.GetDelegateForScriptObject(Type eventHandlerType, ScriptObject obj)
   at System.Windows.Browser.ScriptObject.ConvertTo(Type targetType, Boolean allowSerialization)
   at System.Windows.Hosting.ScriptingInterface.GetScriptParamValueForType(ScriptParam scriptParam, Type desiredType)
   at System.Windows.Hosting.ScriptingInterface.ConvertFromScriptParams(ParameterInfo[] parameters, ScriptParam[] args)
   at System.Windows.Browser.ManagedObjectInfo.ScriptMethod.Invoke(ManagedObject obj, InvokeType invokeType, ScriptParam[] args)
   at System.Windows.Browser.ManagedObjectInfo.Invoke(ManagedObject obj, InvokeType invokeType, String memberName, ScriptParam[] args)
   at System.Windows.Hosting.ManagedHost.InvokeScriptableMember(IntPtr pHandle, Int32 nMemberID, Int32 nInvokeType, Int32 nArgCount, ScriptParam[] pArgs, ScriptParam& pResult, ExceptionInfo& pExcepInfo)

Answer: Without seeing your code I cannot say what you are doing wrong but I can describe what has worked for me in the past.
On the Silverlight side you need to register a class as a scriptable object. Then create a method that is marked as a ScriptableMember and takes a string that will be your passed in JavaScript method. I also added a method called InvokeCallback which will invoke the passed in javascript callback.
[ScriptableType]
public partial class Page : UserControl
{
    private string jsCallback;
    public Page()
    {
        InitializeComponent();
        HtmlPage.RegisterScriptableObject("silverlightInterop", this);
    }

    [ScriptableMember]
    public void RegisterCallback(string callback)
    {
      jsCallback = callback;
    }

    public boid InvokeCallback(string arg)
    {
      if(!string.IsNullOrEmpty(jsCallback))
      {
          System.Windows.Browser.HtmlPage.Window.Invoke(jsCallback, arg);
      }
    }
}

On the JavaScript side you can call the RegisterCallback method that you defined in Silverlight by grabbing the silverlight object on the page and calling the method off of the name "silverlightInterop" which we registered as the name of our scriptable object.
function jsCallback(someArg) {
   alert(someArg);
}

var silverLightControl = document.getElementById("silverlightControl");
silverLightControl.content.silverlightInterop.RegisterCallback("jsCallback");

I hope this helps. I also have some sample code the demonstrates this which I wrote a while ago here
Comment: As far as I know you cannot avoid that. When Silverlight invoke objects they are in the context of the webpage, silverlight itself doesn't store representations of JS objects. You could create some sort of registry of names to anonymous function on the JS side and when Silverlight calls your JS with a name you look up the anonymous function in that registry but that is similar to just using named functions.
Comment: @Freed:  Its a common misconception that a type need be marked with `ScriptableType` __and__ exposed members be marked `ScriptableMember`.   In fact only one or the other is needed.  When a type has `ScriptableType` __all__ its public members are available for scripting.   Usually you don't want this, you only want to put `ScriptableMember` on the specific members to be exposed to Javascript.
Comment: The ScriptableMember and ScriptableType annotations are all there, as well as the RegisterScriptableObject and normal method calls do work. I was really hoping to avoid having to pass strings around for function calls as I want to use anonuymous functions...
Comment: ... it turns out this _does_ work if the delegate type is an EventHandler.
Comment: Yes, all good now. Still weird this isn't mentioned anywhere on http://msdn.microsoft.com/en-us/library/cc645079(v=vs.95).aspx.
Answer: There is a simpler way to pass Javascript function to Silverlight.  All values from javascript can be represented by the ScriptObject type, this includes a function.  Its for this reason that the ScriptObject has a InvokeSelf method.
You can create a property as simple as:-
 [ScriptableMember]
 public ScriptObject Callback { get; set; }

Now lets say in Javascript we have this function:-
function sayHello(name)
{
    alert("Hello " + name);
}

We can assign this to the property (assume the RegisterScriptableObject("Page", this) has been done) with this JS:-
document.getElementById("mySL").Content.Page.Callback = sayHello;

Now in Silverlight code we can invoke this Callback with:-
Callback.InvokeSelf("Freed");

Answer: Apparently, this does work if the using a delegate type of EventHandler (or EventHandler<>), but not for other delegate types.
Answer: My Code:

function sendText() {
    return "Hi from Javascript!";
}

string obj = HtmlPage.Window.Invoke("sendText", null) as string;
txtReturnData.Text = obj;

Dim obj As String = TryCast(HtmlPage.Window.Invoke("sendText", Nothing), String)
txtReturnData.Text = obj


ImageJ: Export list of histogram for multiple Images

Question: after hours of trying and searching related topics, I don't get further. I am trying to create a small ImageJ script that splits channels of a picture, saves on .tif version with enhanced contrast (this part works) AND creates a histogram and saves it values as .csv (this part does not work, it doesn't save anything).
I have no idea why it doesn't work so here is my whole code.
input = getDirectory("Input directory");
output = getDirectory("Output directory");

Dialog.create("File type");
Dialog.addString("File suffix: ", ".tif", 5);
Dialog.show();
suffix = Dialog.getString();

processFolder(input);

function processFolder(input) {
    list = getFileList(input);
    for (i = 0; i < list.length; i++) {
        if(File.isDirectory(list[i]))
            processFolder("" + input + list[i]);
        if(endsWith(list[i], suffix))
            processFile(input, output, list[i]);
    }
}

function processFile(input, output, filename) {
    print("Processing: " + input + filename);
    open(input + filename);
    run("Split Channels");
    selectWindow(filename+" (blue)");
    close();
    selectWindow(filename+" (green)");
    close();
    selectWindow(filename+" (red)");
    run("Histogram");
    getHistogram(values, counts, 256);
    saveAs("Results", output + "Histogram of " + filename + ".csv");
    close();
    saveAs("TIFF", output+ "processed_" + filename);
    selectWindow("processed_" + filename);
    close();

}

I appreciate every input. Cheers!
Answer: not sure you can save it as a csv file using the IJ macro language. However here is some code to do the same thing but save it as a txt file (this example only takes the value from 255)
getStatistics(mean, min, max, std, histogram);
white=histogram[255];
// list2 is the list of images in a for loop - adds image name to results
print(white,",", list2[j]+" smi31");

selectWindow("Log");
saveAs("txt", file1+"Result");

Hope this is helpful :-)


change of OS from windowsxp to ubuntu

Question: I am using samsung cpu with Intel Pentium P4 processor and 512MB RAM. Can I run ubuntu with these specifications smoothly?
Answer: Yes, AND No.  I have run late-ish variants of Ubuntu, 12.04 and higher on computers with less than 1g of RAM, but if I recall correctly, I had difficulty performing the installation due to the low memory.  In the end, I installed the OS on a separate computer with more RAM and then moved the drive to the computer with the lesser quantity of RAM and it worked.  I would not go so far as to say it worked terribly well, but it worked.
In my experience Pentium 4's actually run pretty well with Ubuntu, provided they have enough RAM.  My definition of enough might not be someone else's.  In my experience, the cutoff is about 1.25gb, below which the system is annoyingly slow and prefers to have only one application loaded at a time.  My advice to you would be to see if you can add 1gb of RAM to your machine.
I would guess that your 512 is made up of two 256 modules.  I would advise you to take one of them out and replace it with a 1gb, thus upgrading to the minimum I outlined and spending a minimum of money.  If you can afford to purchase two such modules and expand your memory to 2gb, I would advise doing so.
Had you listed the brand and model of your machine, I probably would have looked up a favorable price for you on Amazon.com
Comment: You might also wish to take a look at [lubuntu](http://lubuntu.net/) which uses a much lighter weight desktop than mainstream Ubuntu.  Even then I suspect that 512M is going to be on the low side of usable.
Comment: Well, if we are going to go THERE, we might as well suggest this user install the Debian based DSL (Damn Small Linux) which, though graphical, I believe I've heard can run with as little as 16mb of ram on a 486.  It would certainly run great on this 486 without any hardware upgrades.  The only question is, would the user enjoy it?  http://www.damnsmalllinux.org/
Comment: The point of suggesting lubuntu as an alternative is that it's still (basically) Ubuntu, whilst needing less hardware.  You get this "out of the box" which makes it suitable for a new user.  If it were me I'd just remove Unity and use something lighter by hand, but it's nice to have an installer do it for you.  A 'problem' like this basically has two paths towards a 'solution'.  Either get more hardware, or minimise the hardware requirements.  The 'best' solution is probably a balance between the two
Answer: I won't use the word smoothly at all, but it's surely doable. I would head towards less resources-hungry versions anyway, like xubuntu or lubuntu as said. If you could get your hands on an old ram bank (say another 512 for example) you would get a better experience with Ubuntu

change of OS from windowsxp to ubuntu


trying to get the selected option to user object using angular js

Question: I am new to angularjs. I am trying to get the designation variable to the user object. I tried below code , but it is not working. And I am getting same problem with adding date too.
app.js
angular.module('myApp', [])
    .controller('MyCtrl1', ['$scope', function($scope) {
      $scope.master = {};

      $scope.Submit = function(user) {
        $scope.master = angular.copy(user);
      };

      $scope.Reset = function() {
        $scope.user = angular.copy($scope.master);
      };

      $scope.Reset();
    }]);

My html code

    Designation

      <select name="designation" id="designation" ng-model="user.designation">
      <option value="Assistant General Manager">Assistant General Manager</option>
      <option value="General Manager">General Manager</option>
      <option value="Manager">Manager</option>
      <option value="Assistant Manager">Assistant Manager</option>
      //I tried to print the user object, but it is getting nothing.Here I was trying to read the value of that option.
      </select>

Here is the code for date

      Date Of Birth(mm-dd-yy)

          <input type="text" ng-model="user.dob"  data-date-format="mm-dd-yyyy" class="span11" >

thanks in advance
Comment: What exactly isn't working?
Comment: where are you tring to print the user object?
Comment: can u create demo in fiddle or plnkr
Comment: can you put the code pertinent, I mean the printing part.
Comment: It is preferably best to use angular's "ng-options" service when you are dealing with Select element
Answer: You have to call module name and controller name in the template. Also you have to display the 'user' object in the template to show the selected designation and entered date.
see this link
http://plnkr.co/edit/fs4qQJfosCBwDD4861sM?p=preview
HTML:
<!DOCTYPE html>

    <link rel="stylesheet" href="style.css" />

      Designation

          <select name="designation" id="designation" ng-model="user.designation">
            <option value="Assistant General Manager">Assistant General Manager</option>
            <option value="General Manager">General Manager</option>
            <option value="Manager">Manager</option>
            <option value="Assistant Manager">Assistant Manager</option>
          </select>

      Date Of Birth(mm-dd-yy)

          <input type="text" ng-model="user.dob"  data-date-format="mm-dd-yyyy" class="span11" >

{{user | json}}


Bluetooth (Atheros AR3012) not working on Ubuntu 15.04

Question: I have a Zenbook UX21 and I'm not able to get bluetooth up and running.
I've just installed blueman and bluez, but I'm still not able to connect devices because they are not found.
uname -a
Linux daniel-UX21E 3.19.0-18-generic #18-Ubuntu SMP Tue May 19 18:31:35 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

lsusb | grep -i "bluetooth"
Bus 003 Device 006: ID 13d3:3375 IMC Networks Atheros AR3012 Bluetooth 4.0 Adapter

hcitool dev
Devices:

(empty list)
rfkill list
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
1: asus-wlan: Wireless LAN
Soft blocked: no
Hard blocked: no
2: asus-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
3: hci0: Bluetooth
Soft blocked: no
Hard blocked: no

Edit: Jeremy helped me to fix my problem temporary (sudo hciconfig hci0 up).
Unfortunately, Bluetooth is not working after I restarted my notebook.
hciconfig -a does not list a device, all other commands return the same as before (see comments below). I had to start the bluez daemon manually.
sudo /etc/init.d/bluetooth status -l

says
bluetooth.service - Bluetooth service
  Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
  Active: active (running) since Mit 2015-06-10 09:10:33 CEST; 30min ago
Main PID: 3096 (bluetoothd)
  CGroup: /system.slice/bluetooth.service
       └─3096 /usr/sbin/bluetoothd -n

Comment: Do you see a list of files using this command `ls /lib/firmware/ar3k`  Also do `modprobe -c | grep 3375 | grep ath3k` does terminal return ath3k?
Comment: Yes I do. Everything seems to be fine.
Comment: Any errors reported in `dmesg | grep -i firmware; dmesg | grep -i bluetooth`
Comment: everything, except the first line seems quite good:
[    0.143444] [Firmware Bug]: ACPI: BIOS _OSI(Linux) query ignored
Comment: And that firmware bug is normal.  Was there anything else?
Comment: Not really. Just messages like "HCI device initialized" and "HCI socket initialized" or "usb 3-1.1: product: bluetooth usb host controller"
Comment: what does `hciconfig -a` show, if anything
Comment: hci0: Type BR/EDR, Bus: USB and additional information but nothing like an error
Comment: Did it say UP or DOWN under BD Address?
Comment: DOWN. thx for your help btw.
Answer: From your comments, getting bluetooth working should just involve
sudo hciconfig hci0 up

Since it seems to forget this setting after a reboot
gksudo gedit /etc/udev/rules.d/90-bluetooth.rules

and paste the following into the file
ACTION=="add", KERNEL=="hci0", TEST=="/usr/sbin/hciconfig", RUN+="/usr/sbin/hciconfig hci0 up"

Save, exit program and reboot to test
Comment: It works like a charm now. Thank you so much for your help, Jeremy!
Comment: But I'm not sure if it's really solved since it's not working properly. After rebooting my notebook it is not working anymore...
Comment: Are you using Kubuntu?
Comment: Nope. It's Ubuntu.
Comment: @Daniel Is it blocked by rfkill?
Comment: No it's neither hard nor soft blocked.
Comment: I wrote an answer with a suggestion. There is updated firmware.
Comment: Tried your updated answer without success. Executed in terminal hciconfig hci0 up says "Can't get device info: No such device"
Comment: `sudo rm /etc/udev/rules.d/90-bluetooth.rules` reboot and see if it finds device.  If it doesn't find a device check `dmesg | grep firmware` for errors
Answer: Try to install new firmware for this device.
You can download it from HERE
It can also be installed by adding ppa
 sudo add-apt-repository ppa:hanipouspilot/rtlwifi
 sudo apt-get update
 sudo apt-get install linux-firmware

Comment: Blueman still says that no adapters were found.
Comment: @Daniel You need to turn off the computer (not reboot) and turn it on again after you added the firmware.


Carrier infinity 25vna heat pump utility curtailment

Question: I have a newly installed infinity greenspeed hp system and the utility is trying to figure out how to control the outdoor unit in heating mode.
It's my understanding that the utility sends a signal to the UTIL input on the outdoor unit which then gets relayed to the infinity stat for instructions on how to respond to the curtailment demand from the utility.
Under advanced service menu, set up, and utility curtailment, there is a option to set up a response in cooling situations... "Disable, turn off, or low stage". There's no option for what to do in heating mode.
My infinity touch stat shows it as possible to curtail in heating mode in the install manual (page 61). But... It isn't there when I go to implement that option.
I've seen elsewhere on boards that the infinity can not curtail in heat mode, but that would mean the install manual is incorrect. Plus, when I first enter the curtailment menu the option is there for a split second and then disappears. It is almost as if some other selection or setting is preventing it from being displayed.
Any ideas? I would really appreciate help as it is preventing me from receiving a large rebate from the utility
Comment: Where are you on this planet? That would be a useful addition to this question
Comment: Sure. I'm in Minnesota
Comment: Who do you have for an electric utility, for that matter?  I wonder if they only really need curtailment in the summer....also, is your heat-pump backed up by strip heat, a gas furnace, or something else?
Comment: Thanks. The utility is telling me that they want to be able to control both heating and cooling to provide me with the lower rate. My backup is strips plus separate electric baseboard, neither of which are utility controlled. Really seems like this is a simple software issue on the infinity control.
Comment: Here's the rub -- since you have strips/baseboard, if they aren't tied into the curtailment system -- when your heatpump heat gets curtailed, the strips/baseboard will kick in to maintain the setpoint, causing your power usage to go *up*, not down.  Whoops!
Comment: Right, but the utility will be getting 12¢ kw instead of 5.
Comment: What I'm saying is that the *utility* won't get the results they expect if they curtail your heatpump heat.  It would be rather counterproductive for them if they hit the curtail button on your house, only to have the load go *up* instead of down, no?
Comment: Also, what's the exact model number on your heat pump's outdoor unit, how many kW of strip heat do you have in your system, and how many kW of baseboards does your house have?
Comment: Last but not least, did you have an ACCA Manual J (heating/cooling load calculation) run when this system was installed?
Answer: Only your utility knows what their requirements are specifically.  You may be best getting a different person there to look at your situation.  We have had rebates offered here in Connecticut for ductless heat pumps and as I recall homes that had baseboard heat were disqualified.  But that was without utility regulation.  I suspect you have a case if you can control the built-in strip heaters as long as the Infinity heats a major portion of the house.  For example all but a three season room or mud room.  Be patient and ask questions.
Comment: Hello, and welcome to Home Improvement. Good answer: keep 'em coming!


change border color on hover for Material UI TextField

Question: I have been trying to change the hover color of Material UI's outlined TextFeild. It seems like it has many state like active, focus, focused:hover etc.
I have found this post on which address my problem but I don't want to add MuiThemeProvider every time.
I am able to achieve it some extend but still I can't change color on hover when it was not focused.
https://codesandbox.io/s/kx0zx9q7jo
Answer: It seems like your root styles became overridden at some point. Maybe its not ideal solution, but I got it working with !important keyword:
"&:hover:not($disabled):not($focused):not($error) $notchedOutline": {
  borderColor: "red !important"
}


Wire and Conduit for Indoor Sub Panel with Outdoor Main Panel Through Attic

Question: My main panel is outdoors on one end of my house.  Planning to add a sub panel for very occasional welder use, electric car charging, and future expansion in the garage on the other side of the house.
By far the easiest path would be outdoors from the main panel along the wall (that side of the house is obscured from view, luckily) up to the attic.  Into the house at the attic, across the attic and down the garage wall.
Is it sane to run individual conductors through liquid tight non metallic conduit for this?  Would the conduit need to be continuous through the attic?  Total run will be about 75 feet.  Is there a better solution?  I assume 3-3-3-5 SER is not viable since it can't be installed in conduit and I assume this will have to be in the outdoor exposed section.
As a side note, not sure if I can use the 75 degree chart or 60.  The wire plus the breaker on the main panel and the connections sub panel determine this?  If 75 degree, I could run 4 awg for an 85 degree breaker?  That seems adequate.  What size ground and conduit?  If I have to use 60 degree, I'll go with 3 awg, and I believe 1" conduit and 5 awg ground?
Comment: I can definitely plan to not run the welder when charging the car and vice versa, the welder is typically in my workshop, this is only for the off chance I need to fix something that needs to drive in instead of be carried into the shop.
Comment: Car charging can be up to 48 amp, but is completely viable at 32 amp as well.
Comment: It seems like UF-B might be an option for running in conduit on the exposed portions and bare in the attic?  But I don't see 3-3-3-5 UF-B available.  Not sure about 4-4-4-x (where X is the unknown to me ground wire size if I got with 4 awg).
Comment: I assume you have "appearance issues" with just running it along the exterior (at sill or eve level it's not that obnoxious if painted to match, but everybody has an aesthetic they can and can't live with.) Likewise some issue with running through the nice cool basement rather than the hot, hot attic (perhaps you have no basement?)
Comment: The main panel is in the center of the side of the house, and the sub panel will be the same.  It would be a much longer run, and seems like more work to go around the attic rather than through it.  Basement is finished, no way to easily get wire through it.
Comment: Do you plan to run the wire out the top of the panel via a hub fitting, or out the side and up via an LL or LR body?  How much clearance is there to each side of the panel, and what make and model is the existing panel?
Answer: You must use the 60 degree column if your feeder is < 100A.  The 75C column is allowable if the feeder >= 100A, and all the other conditions for 75C are met, which they usually are.
Using 310.15B7 (#4Cu) is out of the question.  That table is for service not feeders.  Yours does not supply the entire facility, so no go. If you want to use #4Cu you must breaker 70A, since you don't get the 100A bump.
Keep in mind attic temperatures require a temperature compensation if they're high.  It's also good to think about voltage drop if your distance >=120 feet, but don't think too much about it - base it on actual daily load, not breaker trip, and never put 3% into a voltage drop calc.

It's legal to run cable in conduit, it's just really masochistic.  The stuff is so stiff that you will have a bear of a time manhandling it, and realistically will probably have to call an electrician to do it.
Also masochistic is spending on copper for anything this large. Copper is a semi-precious metal. Aluminum AA-8000 is a fantastic choice but you will need #1Al.  Aluminum requires slightly larger conduit but the savings in wire easily pays for it.   I only use copper on very short runs.  If you heard something about aluminum being bad, what is true does not apply here.

There are several ways to do it.

conduit all the way, and individual THWN or XHHW wires in conduit.
conduit up the wall only, wet-location cable continuously the whole way including through the conduit.
conduit up the wall only to a junction box, individual wires in the conduit, then a splice to dry-location cable.  The splice will be fairly expensive due to the very large junction box required and Polaris connectors, may cost more than just running conduit the whole way.

I see no reason for liquidtight conduit.  You will still need to use outdoor rated wire or cable.  The one place it might help is keeping water out of the breaker panel if you top exit.  I strongly prefer to bottom exit for obvious reasons, but that will be quite a large radius turn.
Comment: @Evan absolutely correct.  And yes, it is.  Also, take what I said about aluminum seriously. Copper isn't deluxe. In fact the lugs will be aluminum, not least because they expect you to use aluminum...
Comment: You can use the 75°C column for <100A *as long as the equipment is rated/labeled for 75°C terminations* (breaker and loadcenter lugs are, receptacles...aren't.)
Comment: I'm dubious that liquid-tight would actually help much with water entry. PVC, properly glued, is just as water-tight, but either will be (as defined by code, and that's based on reality) wet inside anyway - from condensation, if nothing else.
Comment: Thanks for the detailed answer.  So as a side note, is it true that 3-3-3-5 would be acceptable for 100 amp because you can use the 75 degree column, but dropping down to 4-4-4 would move to the 60 degree column and therefore only allow 70 amp?  That's a big difference in allowable ampacity between that one step in wire size.
Comment: This will be a left exit from the main panel, top is taken by the integrated meter, bottom is full due to feeder for the shed, an air conditioner, and one other existing conduit that I'm unfamiliar with.  The appeal of liquidtight flexible is making it from the attic to the main panel left side, but I suppose one turn in a schedule 40 wouldn't be too hard for a novice to pull off?
Answer: Personally (yup, this is an opinion), I think using liquid-tight is nuts. It's expensive and also a relative pain to pull in (as compared to EMT or rigid PVC.) Should be a pretty straightforward run as described, with little need for fancy bends.
Typically you'll need, or at least want, some pull boxes (a junction box for access, but no actual junction in it) or LBs (possibly LRs or LLs) for access when pulling, rather than trying to make the whole shot in one go. Up the wall, LB, across the attic, LB, down the wall to subpanel, at the simplest level.
Edit to add:
Left exit from the box, either an LR (vertically) an LL (horizontally) or an LB (sideways) will get you done easily, so long as the conduit size is adequate for the wire.

I believe that strictly speaking PVC conduit less than 8 feet from the ground should be schedule 80 for "damage resistance." You may need a real electrical supply rather than a box store to get that. You may find the real electrical supply to actually be cheaper, too. And I throughly agree about using aluminum wire.
Comment: Yes. I've seen too many rodent-gnawed cables in attics to not want conduit in an attic; I also prefer to avoid avoidable junctions, and will choose wires over cable to pull in conduit all day long (pulling cable in a conduit is miserable.) Don't veer too close to the maximum fill percentage - more room makes for an easier pull, and does not cost a lot more, typically.
Comment: And I even recommend metal conduit where rodents are concerned. They could nibble through PVC, but they Do Not Like zinc...
Comment: Thanks for the quick answer.  So you are suggesting individual THHN/THWN conductors in some form of conduit the entire length of the run?  And continuing that rigid conduit through the attic?
Comment: Upvoting as I really appreciate the response.


Banshee won't open

Question: Hello, world.
My computer turned off while banshee was updating my music library. Now I can't open it. The error says: "found a fatal error. Exception has been thrown by the target of an invocation."
Any clues?
Answer: Try removing ~/.config/banshee-1/banshee.db (~ means your home folder).
If you don't see the .config folder inside your home folder, press CTRL+H to make hidden files visible, and press CTRL+H again to make them invisible again when you're done.
~/.config/banshee-1/banshee.db is the SQLite database where Banshee stores your music library. When you remove it it will be created again when you start Banshee.

Source: http://banshee.fm/support/faq/
Answer: I'm not sure if this will help, but you could try deleting the local configuration files for Banshee and trying again.
Open Nautilus and press CTRL+H to show hidden files and folders.  Browse to the folder .local and inside you will find a folder called share.  Open this folder and find the folder called banshee and delete it.  Then try reopening Banshee.
If that doesn't work you can try reinstalling the application by using the following terminal commands.
sudo apt-get remove banshee
sudo apt-get update
sudo apt-get install banshee

Again, I'm not sure if this will help or not, but I'll add that if you try opening Banshee from the Terminal it should spit out an error report. If you post that here in your question, perhaps someone who knows more than me can help you.
Comment: Don't forget to make a backup of ~/.local/share/banshee before you try the steps @shawn mentioned.
You can also try to run these commands without deleting ~/.local/share/banshee
`sudo apt-get remove banshee
sudo apt-get update
sudo apt-get install banshee`
If that doesn't work out, you can try Shawns solution.
Comment: Thanks, Shawn. The answer provided by RobinJ worked fine.

Banshee won't open


Find the System Name, IP Address and other information in SQL Server who dropped or altered stored procedure

Question: I am facing an issue that someone or some how some of my stored procedures were deleted or dropped. Now, I need to know how to find the user, system name (PC Name, Application Name or other) IP Address of that person who have dropped/deleted those stored procedures from my database.
I have generated the schema change report from SQL Server from which, I can see the user Name who dropped the stored procedure with drop time.
Now, I need to find the system name, IP and other information if it is possible.
Report from SQL Server (this is a demo from SQL Server where I have found change schema report. I can share the original report)

I appreciate you help and response. Please, let me know if any information is required to this question. Thanks in advance.
Note: the stored procedures were deleted 3 days ago, when I have found that issue.
Comment: `sys.traces` will give you the file name of the default trace; `fn_trace_gettable` can then be used to get the data yourself. IP address is not included, but the user name, host name and application name are. Do note that host and application name are supplied by clients and thus subject to spoofing, making it unsuitable for security auditing, but good enough if you just need a stick to beat a careless user with.
Comment: Dear, @marc_s Sir, I am expecting help from you. Thank you for editing my post.
Comment: @JeroenMostert thanks for you information. The problem is that, I can not get the file from the server due to permission. So, I can not do that. Is there any other way to do that.
Comment: There is no permissions issue since the server can always read its own trace files. You do need permission to execute `fn_trace_gettable`, but if you can run that report you should already have that. There is no need to copy the trace files locally or somesuch (although that is a good idea if you want the information later, because eventually this trace data will roll over and you'll lose it).
Comment: @JeroenMostert Thank you for your time. Can you post an answer with example and steps.
Answer: Just to elaborate in detail what @Jeroen Mostert has mentioned...
You can get lot of information from Administrative log/trace file.
SELECT * FROM fn_trace_getinfo(NULL)
WHERE property = 2 AND traceid = 1

Above query will return trace file location. Once you get that you can run another query to extract information from trace file. E.g. (Replace "...trc" with actual file name with full path)
SELECT * FROM fn_trace_gettable('...trc', -1)
WHERE EventClass = 47 AND ObjectType = 8272

You can refer following links to apply more filter criteria as per your need.
Link for Deleted Event Class
Link for Object Type


How to make custom prompt take effect at iex start?

Question: I have a custom prompt but when I launch iex, a builtin prompt shows. After I hit enter my prompt takes effect.  How can I make my prompt take effect when iex starts?
Here's what I'm seeing:

And this is my .iex.exs file:
IEx.configure(
  colors: [ enabled: true],
  default_prompt: [
      "\e[G",   # move to column 1
      "\e[35m", # magenta
      "MY %prefix(%counter)",
      ">",
      "\e[0m"   # reset
    ] |> IO.chardata_to_string
)

Comment: I guess it's a bug. What version of `iex` do you have?
Comment: 1.3.0 (as shown in the screenshot) this behavior existed in previous versions too.
Answer: It's a bug in iex. I've tracked down and fixed it: https://github.com/elixir-lang/elixir/pull/4895
Comment: Thanks so much for finding and fixing the bug.  And thanks to @JoséValim for reviewing and accepting your PR so quickly!