How is the Cache of Uldir item level reward determined in World Of Warcraft?

Question: For certain weekly events, a quest appears that rewards upon completion a "Cache of Uldir". Two weeks ago, the item level reward was from Heroic.
Under the item it shows different levels, such as raid finder, normal, heroic, and mythic.
How is the item level reward determined for the Caches of Uldir?
Answer: It's simple: Timewalking events (for dungeons in past expansions) are ALWAYS Normal for the latest raid, which is now Uldir and with patch 8.1 will change to the recently announced Siege of Zuldazar. the Mythic Dungeon event (for dungeons in the current expansion) is ALWAYS heroic for the latest raid. Items can still warforge (+5 or +10 itemlevels), titanforge (+15 or more itemlevels), gain a socket or a tertiary stat (speed, leech, indestructible or avoidance) in accordance with the rules for the item the cache gives you. Currently, there is no way to get a raid finder or mythic cache.


How to send values through methods

Question: I am stumped trying to send a value through some methods as part of a question which reads
Write the following method: computeDiameter: This method accepts the radius (r) of a circle, and returns it's diameter (2*r)
It's under the "Passing values through different methods", so instead of asking me for a simple variable/formula like
double r;
double diameter = r*2; //along with Scanner and some System out prints

It's asking me to send the value of r through another method, then return the method and print out the new value for r. This is what I have so far
import java.util.*;
public class UserSquares
{
 public static void main(String[] args)
  {
    int r = 2;
    int result=0; //I set result=0 hoping to initialize it properly.
    computeDiameter(r);
    System.out.println(result);
 }
public static int computeDiameter(int r)
  {
    int result = r * 2;
    return result;
  }
}

This question seemed very simple which is why i tried to tackle it. I know the basics of sending values through a method, but i don't know how to return them. I don't really have money for actual text books (so i settle for quizlet questions and stuff like that), and youtube videos don't help at all so I like coming to the forums to get help when I am really stumped but want to move on with other topics.
(this question is part of a java self test, just thought I should share that as I've asked a number of questions on this site and each time someone responds with something negatively as if I am trying to get you guys to complete my homework for me. I am not taking any Java classes, these questions are just self testing my skills so that when I do major in java programming after i finish highschool, I can have a pretty nice understanding of it. Again, this is not for a test, I am welcome to all types of explanations, as long as it is in the realm of comprehension for a beginner Java student. Please and thank you in advance)
EDIT: Thanks Guys. Immediately after I submitted this I worked on it some more and found a solution so i'll share it
new code
import java.util.*;
 public class UserSquares
 {
  public static void main(String[] args)
   {
     int total, r = 2;
     total = computeDiameter(r);
     System.out.println(total);
  }
 public static int computeDiameter(int value1)
   {
     int result;
     result = value1 * 2;
     return result;
   }
 }

EDIT #2: Holy crap I didn't expect to receive so many solutions so quick. Was about to answer it myself so that it would appear to be done. Sorry for the waste of your time guys, I will read every one of them to see the different solutions you guys offered and learn them so that your time isn't totally wasted. Thanks so much.
EDIT #3: Had a redundant line remaining from my first code that I forgot to take out that went through the compilation and didn't affect the outcome in anyway, but still decided to take it out. Thanks CodeMatrix!
Comment: Just edit the line `computeDiameter(r)` to `result = computeDiameter(r)` that will fix it. Because if you just name the return value inside the method result the result you declared above in the main method will never know what result comes out from the method.
Comment: The `result` in your `computeDiameter()` method is a local variable. So it is not visible outside of the method. The `result` in your `main` method is another local variable, only visible in the `main` method.
Comment: As said above; you assign 0 to `result`. Which is fine to initialise it. But you want then to change the value of `result` to the return value of your method. So therefore, `result = ...` will assign a new value to your variable, which in your case is the return value of `computeDiameter`. Just having `computeDiameter(r);` on its own does the calculation, but then does nothing with it. That's why you assign it to `result`.
Comment: CodeMatrix - Yeah I understood that after inputting different values and such. It hit me like a pile of bricks when I found out what I was doing wrong.
Comment: Pieter - I figured returning the result would replace the variable value in the main method which would print it out. Boy was I wrong, and the realization came to me like knock out punch.
Comment: And btw you have no need to execute the `computeDiameter` method a second time after the initialization from the `result` variable in your main method :).
Comment: notyou - perfect explanation, and I realized it after i submitted it onto the forums. I had no idea what i was doing wrong, until i realized that they were local variables. Thank you for taking your time out to answer, I appreciate it from you all.
Comment: CodeMatrix (second comment) - AHH, I forgot to take that out from my first code. I had a feeling I had to take something out, but it compiled and worked so I just rolled with it.
Comment: @Jeff as you're new, take a quick read of this: https://stackoverflow.com/help/someone-answers
Comment: notyou -I would say thank you so much for redirecting me to the forum rules, but I see that's against the rules. I won't comment on my own question to thank someone anymore, so ill just nod to you with best wishes. (for real though, I'll stop from this day forward)
Answer: As I said in the comment section.
Go ahead and change this
int result = 0;
computeDiameter(r);
System.out.println(result);

to this
int result = 0; //or you use int result = computeDiameter(r);
result = computeDiameter(r);
System.out.println(result);

Answer: its very simple:
int result = computeDiameter(r);

or just
System.out.println(coputeDiameter(r));

Answer: You have to assign the value which is being returned from computeDiameter(r) method to the result variable in order to print that.
result = computeDiameter(r);
System.out.println(result);

How to send values through methods


Origin of the flag variety

Question: When and where were flag varieties (more generally $G/P$'s) first introduced? What was the original motivation to study it?
To my knowledge, I'd say an early motivation to study the Grassmannian was to formalize Schubert calculus, and their use in the theory of characteristic classes later. I also know flag varieties are essential for the splitting principle but surely they did appear before.
Comment: I suppose the obvious parallel would be the study of intersection theory on non-linear homogeneous spaces.
Answer: Question: "When and where were flag varieties (more generally G/P's) first introduced? What was the original motivation to study it?"
Answer: Maybe a Historian should give a precise answer to this, but words such as "Grassmannian" and "Plucker" are the names of mathematicians involved in the study of these varieties in the 1900s.
It is a fact that for any semi simple algebraic group $G$ over a field $k$ of characteristic zero and any parabolic subgroup $P \subseteq G$ the quotient $\pi:G \rightarrow G/P$ is a smooth projective variety - the flag variety of $P$.
Given any invertible sheaf $L \in Pic^G(G/P)$ it follows its global sections $H^0(G/P, L)$ (if non-empty) is a finite dimensional irreducible $G$-module and all finite dimensional irreducible $G$-modules can be constructed in this way (the Borel-Weil-Bott theorem). There is also the study of regular holonomic $D_{G/P}$-modules $E$ on $G/P$ (the Bernstein-Beilinson notion $D$-affinity) and relation to generalized Verma modules. This is a much studied topic: The relation between the representation theory of $G$ and the geometry of $G/P$. The Bezout theorem is a theorem about the intersection of curves in $\mathbb{P}^2_k$, and this goes back to the 1700s and 1800s and Newton and Bezout. This theorem does not hold for plane affine curves.
Comment: "Thank you. I think D-modules on G/P comes much after the introduction of the flag varieties. I was interested in the original motivations to study flag varieties, so I don't think this is an answer to my question. – student"
Answer: Yes, D-modules were introduced in the 1960s/70s. One of the first occurrences of the projective  plane was with the "Bezout theorem", and as mentioned this theorem is not true for the affine plane. The theorem is non-trivial since it speaks of multiplicities: If $C_1,C_2 \subseteq \mathbb{P}^2_k$ are two plane projective curves of degrees $d_1,d_2$ where
$$C_1 \cap C_2=\{P_1,..,P_l\}$$
are their common points (with intersection multiplicity $m_i$) it follows
$$ \sum_i m_i =d_1d_2.$$
Hence the theorem speaks of multiplicity. You may describe $\mathbb{P}^2_k$ as $SL(3,k)/P$ for a parabolic subgroup $P$, hence the projective plane is an example of a "flag variety $G/P$": It is a parameter space parametrizing lines $l$ in $k^3$.
This is what the flag variety does in general: If $1 \leq d_1<d_2<\cdots d_k< d$ is a set $\underline{D}$ of integers, there is the flag variety $\mathbb{F}:=\mathbb{F}(\underline{D},k^d)$. This is a smooth projective variety parametrizing flags $E_i$ in $k^d$ of type $\underline{D}$. There is a parabolic subgroup $P \subseteq SL(d,k)$ and an isomorphism $\mathbb{F}(\underline{D},k^d)\cong SL(d,k)/P$. There is a 1-1 correspondence between
the set of $k$-rational points $\mathbb{F}(k)$ of $\mathbb{F}$ and the set of flags in $k^d$.
Comment: Thank you. I think $D$-modules on $G/P$ comes much after the introduction of the flag varieties. I was interested in the original motivations to study flag varieties, so I don't think this is an answer to my question.
Comment: @student - I believe the Bezout theorem is one of the first occurrences of the notion "flag variety" - the projective plane is such a variety.

Origin of the flag variety


New receptacle tripped/sparked

Question: Today I switched out an receptacle and when I turned the power back on and checked the outlet with my receptacle tester, everything was good. I switched out another receptacle with no issues that is on the same circuit and then checked both of the receptacles again. This time when I tested the first receptacle, a spark flew and the circuit was tripped. I am not positive, but I think I tested the second outlet on that receptacle this time.
You can see that the second hot terminal is the one that is burnt. Also, the I took a picture of the original receptacle along with the new one. The other odd thing is that the original receptacle had the hot wire attached with a wire nut and an extra inch of wire, even though there is plenty of wire in the box.
Any thoughts about what happened and what needs to be done?
Answer: You have a metal junction box.  It is properly grounded.
When you plugged in the tester into that receptacle, the receptacle moved a bit inside the box, and the screw came into contact with the side of the metal box.  Or possibly a ground wire was bent up somewhere it sbould not be.
Solve it by wrapping the outlet in a couple turns of electrical tape, after screwing down any unused screws as Tester101 mentions.
Comment: The original receptacle didn't have screw terminals, is this why it wouldn't have had screws?  However, I did wrap the new one with tape and you can even see the singe mark from the terminal that sparked. Would there be any other reasons for this happening or maybe I didn't tape it well enough?
Comment: @junta Proper electrical tape should have stopped it for sure unless it was being forcibly pinched by being screwed down. I generally go 3 layers.

New receptacle tripped/sparked


Bathroom vent through existing roof vent

Question: I have a roof with two gable vents as well as slanted vents that look a lot like these one:
I do not want to install an extra vent specifically for bathroom so I was wondering if I could use one of the existing top ones. It looks like from underneath there is a circular hole that I can push a duct in. The roof vents don't leak so they are solid even with really crazy rain, hail snow etc.
Can I install on existing vent? If yes, do I have seal it after pushing the vent in so that no humidity will return back down to the attic? What's the best way to go about doing this?
Comment: What if I were to install a louvered vent on the gable side of the house? Cutting a hole on the gable should be easier than soffit (less crawling)
Comment: Why not use a soffit vent? They are nearly zero impact, and don't affect your roof line. I see some potential issues with trying to use one of these vents, namely if you block it off to ONLY vent the bathroom, you've restricted venting to the room, if you don't restrict it to just the bathroom, you could actually siphon the humid air back into your attic, and needless to say that would be bad.
Comment: The roof of the upper house is about 600 sq ft with two large gable vents and two roof vents. I figured blocking one of the vents won't make much of a difference. Probably it would increase flow on the gables and the other remaining roof vent. Aren't soffits a bad idea since they are considered to be intakes?
Comment: Typically, vents are there for a reason, and unless you have someone especially familiar with roof construction, I wouldn't block an existing vent. Re. Soffits, typically, you block off a few feet of the soffit vent on either side so it cannot draft/siphon the moist air in. It seems odd to me that you'd have gable vents, central roof vents AND soffit vents. That combination would seem to work against one another. I would check and see which are truly open.
Comment: Seems reasonable
Answer: We've got several things going on here:

This is a ridge-mounted, Slant-Back Roof Vent -- it's used to ventilate attic air to the outside. It should not be used for double-duty for a bath fan exhaust. Warm moist bathroom air will condense on its underside and can cause moisture damage & mold on the roof sheathing.
As a Slant-Back Vent, the original photo shows it installed backwards. The slanted side is installed to the top to shed rain water; unseen in this photo is the screened bottom side (see attached photo).
As previously mentioned, most building codes require the bath exhaust to be vented directly to the outdoors. Attic locations should use insulated duct to reduce condensation problems. The exhaust ducts can discharge through the roof, soffit or gable siding -- but a damped vent hood should be installed as well.
If this installation is to be done by an average homeowner or handyman, I typically recommend a siding-mounted vent. Retrofit roof vent installations require proper interlacing with roof shingles (not just gobs of tar); a poorly done job will result in a roof leak.
Comment: "Ridge-mounted"? No.
Comment: They _can_ be. They can also _not_ be. Depends on the roof layout. :) Regardless, that isn't "ridge-mounted".
Answer: I agree that effectively blocking off an existing roof vent is not a good idea for the long term health of the roof. In my experience ventilation is often lacking in that regards already.
Also the pipe should be as short as possible; the longer it is the colder it is at the end and the more water vapour will condense on the inside of the pipe rather than being piped outside.
Shortest route out is always best.
Answer: I ran a main bath vent to a roof vent for many years after finding the duct terminated in a previously unvented attic. I simply hung the end of the flex duct up under the vent, and did not seal it in any way. It worked fine, and was certainly an improvement over the earlier configuration, with the following caveats:

You will see moisture accumulation on the roof deck, which could accelerate decay. Ideally, point the duct directly into the plastic or metal roof vent and avoid wood framing components.
You will probably see premature curling or other degradation of the shingles around the vent due to moisture and freeze-thaw cycles.
This solution doesn't include a secondary backdraft preventer such as a purpose-built roof or wall vent would typically provide. You're relying solely on the one included with the fan housing.
This is certainly not best practice or code-compliant. Do it with that in mind, you home improvement renegade.
Answer: 1) the vent in your picture is installed upside down. The vent will clearly mark which way end is the top of vent for installation purposes.
2) if you want to vent bathroom fans through the roof; use a gooseneck. The gooseneck has a flap that opens and shuts when the fan is on and then turned off. PRIMEX makes the best goosenecks in my opinion.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to contribute here.
Answer: It depends on the hole size under the vent cover. Most of those holes aren't even half the size of the cover. So, enlarging the hole for the bath pipe & larger would have no detriment. Additionally, the roof's or attic's natural flow will ensure that no humidity will blow back or remain inside at all & it'll actually assist the bath fan.


List Multiplication: repeat paired elements and de-reference

Question: I've found numerous solutions on how to repeat a List of Lists while flattening the repeated elements, like so:
[[1,2] for x in range(3)]
: [[1, 2], [1, 2], [1, 2]]

However, I actually have a list of objects that need to be repeated in-line in the List, like so:
mylist = [var1, var2, var1, var2, va1, var2]

without the extra inner list, and importantly, var1 should be copied, not referenced, such that changes to mylist[0] will not also change mylist[2] & mylist[4] etc.
Other solutions regarding lists only still leave the list elements as "pointers", meaning editing one element actually alters all the repeats of that element in the list.
Is there a readable one-liner for using multiplication/comprehension to do this while removing the "pointers" in the list?
This is an operation users may have to do often with my class and a for() loop will make construction of their list much less readable.  I'm already sad that we can't just use [var1, var2] * 30 without overloading __mult__, which I'm trying to avoid. That would have made their code so readable.

For example, the following use of deepcopy() is not good enough, as the objects are referenced and thus unexpectedly altered
>>> obj1=[1]; obj2=[200]
>>> a=deepcopy( 3*[obj1, obj2] )
>>> a
[[1], [200], [1], [200], [1], [200]]
>>> a[0][0]=50
>>> a
[[50], [200], [50], [200], [50], [200]]

the 50 propagated throughout the list, rather than changing only the first element.
Comment: Why do the objects referenced by `varX` have to be copied? Are they mutable objects? Do you need a deep copy or is a shallow copy enough?
Comment: `map(list, repeat([1, 2], 30))` using [**`repeat`**](https://docs.python.org/2/library/itertools.html#itertools.repeat) from [**`itertools`**](https://docs.python.org/2/library/itertools.html).
Comment: Or just `list(repeat([1, 2], 30))`
Comment: @DrNightmare No, that'll give the same list of `[1, 2]` each time.
Answer: You need
import copy
[copy.copy(y) for x in range(3) for y in [var1, var2]]

Or shallow copy is not enough
[copy.deepcopy(y) for x in range(3) for y in [var1, var2]]

Answer: I'm not quite sure what behavior you're looking for.  Depending on what you want, one of these two options might be right:
In [0]: from itertools import chain

In [1]: from copy import deepcopy

In [2]: [deepcopy(x) for x in 3*[var1, var2]]
Out[2]: [[1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4]]

In [3]: list( chain( *(3*[var1, var2]) ) )
Out[3]: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]

Comment: Whoa, crap, you're totally right.  Thanks for pointing that out -- I hadn't thought hard enough about how deepcopy works.  It will duplicate a set of objects, including internal references they make to eachother, such that no copied objects in the new set refer to the old set.  But for every "internal" reference in the old set, an identical "internal" reference exists in the copied set.  (Updated the answer with a correction.)
Comment: Thanks, I would have thought `deepcopy( 3*[var1, var2] )` would work, but it seems they're still referenced to each other - changes to `mylist[0]` are also changing `mylist[2]` & `mylist[4]`.
(sorry can't paste example code here - won't accept newlines)
Comment: Added code to question, showing why this didnt work as I need it. Will try your second method later today. Thanks!


Need Help For Completely Transfer in Ubuntu

Question: I use ubuntu 13.04 in dual boot with windows. I want to completely move into ubuntu. But I need some help.
I am a freelance web designer. Sometimes my clients send me PSD files to make theme html or anything else. But I can't use photoshop in ubuntu. I know by using wine I can install photoshop. But I have dought that can I slice my psd layers in ubuntu as I do in windows. Sometimes I have to create banner/button in photoshop. So I need a best solution for handling this type of problem.
I hate windows so much. At the first when I used ubuntu 10.04 I am in love in ubuntu. So please help me to move in ubuntu.
Regards,
Mahbub Alam
Comment: You will have to look at alternates to Photoshop, GIMP or inkscape or similar. alternately consider running photoshop in a virtual machine such as KVM or virtualbox.
Answer: Try Gimp.

GIMP is an advanced picture editor. You can use it to edit, enhance,
and retouch photos and scans, create drawings, and make your own
images. It has a large collection of professional-level editing tools
and filters, similar to the ones you might find in Photoshop. Numerous
fine-control settings and features like layers, paths, masks, and
scripting give you total control over your images.
Many image file formats are supported, including JPEG, Photoshop
(.psd), and Paint Shop Pro (.psp) files. It can also be used to scan
and print photos.

To install click Gimp
Source:Ubuntu Apps


Keep Adding to NSMutable Array

Question: I am pretty new to Objective-C, and trying to create a to-do list app with a table view. I am trying to keep adding strings to my mutable array as the button is pressed. But each time I press the button only the last string gets added to the array.
- (IBAction)notebutton:(UIButton *)sender {

   NSMutableArray *mystr = [[NSMutableArray alloc] init];
   NSString *name = _noteField.text;
   [mystr addObject:name];
   [self.tableView reloadData];
}

Comment: you should create array outside the method and initialize, then add strings to array in method noteButton:
Comment: Yea that makes sense but where would be a good place to create the array?
Comment: you can make it in viewDidLoad. just declare it in your .h file and make initilization in viewDidLoad
Comment: it is explained in answer below very well
Answer: Do not declare the NSMutableArray each time. Declare it only once.
Make NSMutableArray *mystr; as a property and allocate it in viewDidLoad() once.
in .h or .m file
@property(nonatomic,strong) NSMutableArray *mystr;

viewDidLoad()
self.mystr = [[NSMutableArray alloc] init];

- (IBAction)notebutton:(UIButton *)sender {

   NSString *name = _noteField.text;
   [self.mystr addObject:name];
   [self.tableView reloadData];
}

Comment: then I get this error "Initializer element is not a compile-time constant"
Answer: You Are creating mutable array on method. so each time its Allocating and making new array.
Just allocate the nsmutable array in viewdidload/viewdidappear and add object in your method.

Keep Adding to NSMutable Array


PHP: Function to group object array by objects element

Question: I am working with a multi-dimensional array.i want to group this array by brand_id and cat_id. In the following array  [0],[1] and [2],[3]  have similar brand_ids and cat_ids.i want to remove product_ids and want get sum of qtys in that object.
 Array (
        [0] => stdClass Object
        (
        [brand_id] => 1
        [cat_id] => 1
        [qty] => 150
        [product_id] => 1
         )
        [1] => stdClass Object
        (
        [brand_id] => 1
        [cat_id] => 1
        [qty] => 250
        [product_id] => 5
        )
        [2] => stdClass Object
        (
        [brand_id] => 4
        [cat_id] => 35
        [qty] => 100
        [product_id] => 322
         )
        [3] => stdClass Object
        (
        [brand_id] => 4
        [cat_id] => 35
        [qty] => 200
        [product_id] => 321
        )
        )

i want to rearrange array like this
  Array (
            [0] => stdClass Object
            (
            [brand_id] => 1
            [cat_id] => 1
            [qty] => 400
             )

            [1] => stdClass Object
            (
            [brand_id] => 4
            [cat_id] => 35
            [qty] => 300
            [product_id] => 322
             )
             )

Comment: I suggest you look at the query that created this array rather than fiddling with its results
Comment: What about http://php.net/manual/en/function.usort.php
Comment: @ceadreak `usort` is for reordering an array, it doesn't merge elements.
Answer: Create a 2-dimensional associative array whose keys are the brand_id and cat_id, and values are the objects with the qty property containing the total quantity.
$result = array();
foreach ($products as $p) {
    if (isset($result[$p->brand_id][$p->cat_id])) {
        $result[$p->brand_id][$p->cat_id]->qty += $p->qty;
    } else {
        $clone = clone $p;
        unset ($clone->product_id);
        $result[$p->brand_id][$p->cat_id] = $clone;
    }
}

You can then flatten the array with array_walk_recursive.
$return = array();
array_walk_recursive($result, function($a) use (&$return) { $return[] = $a; });

I got that code from How to Flatten a Multidimensional Array?


Craftsman 3/4 hp garage door won't go down.

Question: I have a craftsman 3/4 hp garage door that will not go down, sometimes it goes down about 2 inches then back up and flashes 10 times. It will go all the way down if I hold the wall button until it reaches the end of its travel.
I've checked all the tracks for any obstructions, I've unplugged the thing for 24 hours, cleaned the sensor lenses with alcohol, and that's when I noticed that the receiver (green LED light) doesn't appear to be working anymore, no matter how I position the two sensors the green light never turns on and there is absolutely nothing blocking the sensors.
So, can I just replace the sensor or is there an issue somewhere else in the system?
Comment: my garage door opener does that when the `lock` button on the wall control (wired control) is activated
Comment: No, unfortunately that doesn't seem to make any difference. The light on the wall control blinks when locked and stays solid when unlocked, but didn't seem to affect the sensor lights at all. Thank you.
Answer: Check your garage door opener manual for a trouble-shooting procedure which may help figure out where the problem really is. It certainly could be just the sensor. Having had a bizarrely behaving garage door which turned out to be the main "computer" board in the opener, I'd want to try and check that the sensor was getting whatever it needed to operate correctly before I'd assume that the sensor was the cause of the sensor not working and bought a new one. If, for instance, the main unit is not supplying power to the sensor, replacing the sensor won't fix it. Your manual may provide some procedures to test/isolate the problem.
More generally, my advice (despite the fact that I did replace that main board for a successful repair) is always to consider the age of the unit and the price of a replacement. Parts are often not returnable and don't have any warranty, while a whole new unit comes with a whole new warranty. In my case I bet that the board, at about half the cost of the relatively new opener would do it, as I knew there had been a nearby lightning strike. With an older unit, I'd lean heavily to replacement to avoid replacing so many parts trying to solve the problem that I'd have spent less for a complete new opener.
To be clear, I have no idea where your actual problem is, but it could be:

The sending unit
The receiving sensor unit
Or the main unit powering both units and reading the sensor output
Or the wires connecting them may be broken.

If your garage has mice as most do, that last one might be the first one to check.
Comment: +1 for the wires connecting them.  This was the problem in my garage, the road salt from the car had corroded the wires near the garage floor.  No power, no sensor.
Comment: I don't know if the wires broke when I was pulling them out or if it was broken before hand but one of the staples was really snug and while trying to get it out I broke one of the wires. So I stripped the wires spliced them together and wah lah everything is working again. I'm still not sure why after 5 years the wires suddenly broke but that doesn't matter anymore. Thanks for the ideas and help everyone.
Comment: The fact that it did not work, then worked after you spliced them together indicates that it was broken beforehand.

Craftsman 3/4 hp garage door won’t go down.


LXC unprivileged container: apt-get fails to download anything inside

Question: I'm running Ubuntu Xenial and set up simple unprivileged user container from template (also Xenial).
When I attach inside and try to just do upgrade or install anything 'apt-get' fails with following messages:
root@c1:/# apt-get update
E: setgroups 65534 failed - setgroups (22: Invalid argument)
E: setegid 65534 failed - setegid (22: Invalid argument)
Reading package lists... Done
E: setgroups 65534 failed - setgroups (22: Invalid argument)
E: setegid 65534 failed - setegid (22: Invalid argument)
E: Method gave invalid 400 URI Failure message: Failed to setgroups - setgroups (22: Invalid argument)
E: Method gave invalid 400 URI Failure message: Failed to setgroups - setgroups (22: Invalid argument)
E: Method http has died unexpectedly!
E: Sub-process http returned an error code (112)
E: Method http has died unexpectedly!
E: Sub-process http returned an error code (112)

So the question is - what's going on here?
Answer: By default user '_apt' has uid=65534, but lxc (and host) is configured to allow only 10000 subuids and subgids for user (and therefore unprivileged containers).
One solution might be to set user '_apt' uid inside container below 10000.
The other way is to up subuids/subgids limit on the host. Use command sudo usermod --add-subuids 260000-325536 --add-subgids 260000-325536 $USER for user that owns container, and ensure lxc user containers are configured with:
lxc.id_map = u 0 260000 65536
lxc.id_map = g 0 260000 65536

Comment: I don't think ubuntu is configured with `10000` subuids. I think it's configured for `65536`, starting at `10000`. Changing `_apt` uid to something below 10000 (in my case I tried `106`) resulted in the same error: `E: setgroups 106 failed - setgroups (1: Operation not permitted)`
Comment: In case it helps anyone else, for me the failure was writing `deny` to `/proc//setgroups` from within the user namespace
Answer: I got a similar error when building my docker container. Turns out that I forgot to write sudo before my docker build command.
Answer: In my case, @Alwin's solution cannot be used as I'm running rootless. Regarding @dilettant solution, there isn't lxc in my environment, nevertheless replaced _apt's uid using sed -i 's/_apt:x:100:65534/_apt:x:100:100/g' /etc/passwd. Also followed @cheshirekow's comment and in my case /proc/<pid>/setgroups contained allow and not deny.
I solved it indirectly by installing brew as an alternative using:
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ENV PATH=$MVND_HOME/home/linuxbrew/.linuxbrew/bin:$PATH


Impossible to crop image from Photos

Question: I want to pick an image in the app "Photos" of Google+.
Then, I crop this image with the crop of Google plus too.
But when I valid my crop, a toast appears with the text "Impossible de to save modifications" and the blue circle does not stop.
Why ?
Code :
<code>    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setType("image/*");
    intent.setData(selectedimg);
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 170);
    intent.putExtra("aspectY", 170);
    intent.putExtra("outputX", 256);
    intent.putExtra("outputY", 256);
    intent.putExtra("return-data", true);
</code>
Comment: Exactly the same problem. I haven't found the answer.
Answer: There are lots of Android vendors whose devices do not support this action. Have a look at the the following links.
http://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html
Is com.android.camera.action.CROP not available for Android jelly bean 4.3?
http://androidthings.blogspot.gr/2012/08/using-android-crop-intent-and-action.html#.U0J27vl_uDo
Comment: The thing is, Google+ Photos App supports Crop. In fact, if you launch and ACTION_PICK intent with intent.putExtra("crop", "true"); and then select Gallery, and then when you pick the picture, choose Photos App to crop, that works. The problem is when you choose Photos to pick the picture, because then the crop is never trigered. So I my guess is that PhotosApp has a different crop parameter that the intent should provide
Comment: I have exactly the same problem. When you select the Google+ Photos app to select the image, the crop is never triggered. On the other hand if you choose the gallery to select the image then you can crop it with the Google+ Photos app.

Impossible to crop image from Photos


Accessing and modifying Wifi state in Android

Question: I was wondering if I could get a second (or many for that matter) set of eyes to help me with this. I cannot for the life of me figure what is causing this. Basically, this is just a wireless activity that allows you to change the wifi state. However, my code is kicking out a nullPointerException at the call of getWiFi();. Its also pointing to line 123 but I see nothing wrong. Can anyone see why this would crash? My permissions in the manifest are correct to my knowledge. Here is the code from the java file. Line 89 is where getWifi(); is called. Any help would be greatly appreciated.
Code for WirelessManager.java
<code>import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.view.View;
        import android.view.View.OnClickListener;
        import android.net.wifi.WifiInfo;
        import android.net.wifi.WifiManager;
        import android.widget.TextView;
        import android.widget.ImageView;
        import android.widget.Button;

        public class WirelessManager extends Activity {
    //index values to access the elements in the TextView array.
    private final int SSTRENGTH = 0;
    private final int WIFISTATE = 1;
    private final int IPADD     = 2;
    private final int MACADD    = 3;
    private final int SSID      = 4;
    private final int LINKSPD   = 5;

    private TextView[] data_labels;
    private TextView name_label;
    private TextView enable_label;
    private Button state_button;
    private Button back_button;
    private WifiManager wifi;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info_layout);

        wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
        TextView[] titles = new TextView[6];
        data_labels = new TextView[6];

        int[] left_views = {R.id.first_title, R.id.second_title, R.id.third_title,
                       R.id.fourth_title, R.id.fifth_title};

        /*R.layout.info_layout is the same layout used for directory info.
         *Re-using the layout for this activity, so id tag names may not make sense,
         *but are in the correct order.
         */
        int[] right_views = {R.id.dirs_label, R.id.files_label, R.id.time_stamp,
                             R.id.total_size, R.id.free_space};
        String[] labels = {"Signal strength", "WIFI State", "ip address",
                          "mac address", "SSID", "link speed"};

        for (int i = 0; i < 5; i++) {
            titles[i] = (TextView)findViewById(left_views[i]);
            titles[i].setText(labels[i]);

            data_labels[i] = (TextView)findViewById(right_views[i]);
            data_labels[i].setText("N/A");
        }

        name_label = (TextView)findViewById(R.id.name_label);
        enable_label = (TextView)findViewById(R.id.path_label);
        state_button = (Button)findViewById(R.id.back_button);
        back_button = (Button)findViewById(R.id.zip_button);
        back_button.setText(" Back ");

        state_button.setOnClickListener(new ButtonHandler());
        back_button.setOnClickListener(new ButtonHandler());

        ImageView icon = (ImageView)findViewById(R.id.info_icon);
        icon.setImageResource(R.drawable.wireless);

        get_wifi();
    }

    private void get_wifi() {
        WifiInfo info = wifi.getConnectionInfo();
        int state = wifi.getWifiState();
        int strength = WifiManager.calculateSignalLevel(info.getRssi(), 5);
        boolean enabled = wifi.isWifiEnabled();

        name_label.setText(info.getSSID());
        enable_label.setText(enabled ?"Your wifi is enabled" :"Your wifi is not enabled");
        state_button.setText(enabled ?"Disable wifi" : "Enable wifi");

        switch(state) {
            case WifiManager.WIFI_STATE_ENABLED:
                data_labels[WIFISTATE].setText(" Enabled");
                break;
            case WifiManager.WIFI_STATE_DISABLED:
                data_labels[WIFISTATE].setText(" Disabled");
                break;
            case WifiManager.WIFI_STATE_DISABLING:
                data_labels[WIFISTATE].setText(" Being Disabled");
                break;
            case WifiManager.WIFI_STATE_ENABLING:
                data_labels[WIFISTATE].setText(" Being Enabled");
                break;
            case WifiManager.WIFI_STATE_UNKNOWN:
                data_labels[WIFISTATE].setText(" Unknown");
                break;
        }
        if(enabled) {
            data_labels[IPADD].setText(FileManager.integerToIPAddress(info.getIpAddress()));
            data_labels[MACADD].setText(info.getMacAddress());
            data_labels[SSID].setText(info.getSSID());
            data_labels[LINKSPD].setText(info.getLinkSpeed() + " Mbps");
            data_labels[SSTRENGTH].setText("strength " + strength);
        }else {
            data_labels[IPADD].setText("N/A");
            data_labels[MACADD].setText(info.getMacAddress());
            data_labels[SSID].setText("N/A");
            data_labels[LINKSPD].setText("N/A");
            data_labels[SSTRENGTH].setText("N/A");
        }
    }

    private class ButtonHandler implements OnClickListener {

        public void onClick(View v) {

            if(v.getId() == R.id.back_button) {
                if(wifi.isWifiEnabled()){
                    wifi.setWifiEnabled(false);
                    state_button.setText("Enable wifi");
                }else {
                    wifi.setWifiEnabled(true);
                    state_button.setText("Disable wifi");
                    get_wifi();
                }
            }else if(v.getId() == R.id.zip_button)
                finish();
        }
    }

}

Code for AndroidManifest.xml

        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="coxxxxxxxxxx"
      android:versionCode="100"
      android:versionName="1.0.0"
      android:installLocation="auto">
    <application android:icon="@drawable/icon" android:label="@string/app_name" >

        <activity android:name=".Settings" android:label="@string/app_name" />

        <activity android:name=".ProcessManager" android:label="@string/manager_act" />
        <activity android:name=".WirelessManager" android:label="Wireless Information" />
        <activity android:name=".ApplicationBackup" android:label="Installed Applications" />

                <activity android:name=".Main"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <data android:mimeType="*/*" />
                <category android:name="android.intent.category.OPENABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>

        <activity android:name=".AudioPlayblack"
                  android:label="@string/media_dialog"
                  android:theme="@android:style/Theme.Dialog" />

        <activity android:name=".DirectoryInfo" android:enabled="true"
                  android:label="@string/dir_info">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <data android:mimeType="application/manager" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".HelpManager"
                  android:label="XXXXXXXXX"
                  android:theme="@android:style/Theme.Dialog" />

 </application>
            <supports-screens android:smallScreens="true"
                      android:normalScreens="true"
                      android:largeScreens="true" />
            <uses-sdk android:minSdkVersion="4"
              android:maxSdkVersion="10"/>

         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

         <uses-permission android:name="android.permission.INTERNET"></uses-permission>
         <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
         <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>

       </manifest>
</code>
Answer: Off by 1 error.  Your for loop getting the views goes i<5, but you're accessing i=5 with LINKSP.  Increase your for loop and all arrays by 1.
Comment: WOW!!! Thanks man....I dont know how I was missing that. You nailed it. Works fine now. I looked at that for at least 1 and a half hours today an could not see it! I cant thank you enough!


Angular2 - Fire event on Leaflet-Event

Question: I am trying to impement Leaflet with Angular 2 TS for my Ionic 2 app. I want to emit my pinClicked-event when a Leaflet-pin was clicked. How to do this? In Angular1 $scope.$apply was the solution...
private refreshMarkers() {
    L.marker([40.731253, -73.996139])
      .addTo(this.map)
      .on('click', function() { alert('JA'); } );
  }

  private pinWasClicked() {
    this.pinClicked.emit('');
  }

Comment: Have you tried `on('click', () => this.pinWasclicked())`?
Comment: can u share ur source code to have look?
Comment: Please check this plunkr https://plnkr.co/edit/tHoaxmtzsJ6W3e1qYHpq?p=preview What is wrong here?
Comment: I think you don't need further code.. There are two functions. With on() I subscribe to the 'click' event and want to execute the pinWasClicked() function.
Comment: Yes: TypeError: Cannot read property 'call' of undefined
    at e.fireEvent (leaflet.js:6)
    at e._onMouseClick (leaflet.js:7)
    at HTMLImageElement.s [as _leaflet_click18] (leaflet.js:8)
    at ZoneDelegate.invokeTask (zone.js:356)
    at Object.onInvokeTask (ng_zone_impl.js:37)
    at ZoneDelegate.invokeTask (zone.js:355)
    at Zone.runTask (zone.js:256)
    at HTMLImageElement.ZoneTask.invoke (zone.js:423)
Comment: Have you tryed .on('click', pinWasClicked );
Comment: Thank you @yurzui. Do you want to write the answer? Would be great if you can tell me, what this syntax means? () =>
Comment: @yurzui , your code does a great job of triggering a function in the parent component, but it doesn't seem to carry any data with it.  You pass a n empty string with the emit method, but I can't see how to access that data in the app component.  Any ideas?  I've tried gal007's suggestion, but that doesn't fire the function in parent at all.
Comment: @carpiediem Check this  https://plnkr.co/edit/tHoaxmtzsJ6W3e1qYHpq?p=preview
Answer: Try this
private refreshMarkers() {
let marker=L.marker([40.731253, -73.996139]);
  marker.addTo(this.map);
  marker.on('click',
             (e)=>
             {this.pinWasCliscked(e)} );
}
private pinWasClicked(e) {
console.log(e);
this.pinClicked.emit('');
}

Angular2 - Fire event on Leaflet-Event


How to repair this split ceiling joist?

Question: While installing some new recessed lighting in my attic today, I noticed this split in one of the ceiling joists. The split is about 4 ft 6 in long starting from the end of the joist. The joist is a 2x12 and is about 19 ft long. The joist is only supported at the ends; there are no other walls or supports underneath it.

How urgent is it to address this? What options do I have for a repair that would be acceptable? The only way I could get another 19 ft joist there to sister the entire joist would be to open up the ceiling.
EDIT: Additional context
The house was built in 1979. It is a single story house in a sort of U-shape:

The joist in question runs along the top of the living room, which has a raised 10 ft ceiling (rest of house has 8 ft ceilings). Here is a view of the living room. The split in the joist in question is above the sliding glass door and runs from the left side of the picture to the right side. The width of the living room along the joist is about 18 ft:

Here is a view of the ceiling looking the opposite direction. The joist still runs left to right across the picture:

This is a view in the attic looking towards where the joist is split. This picture shows how the ceiling is raised. The ceiling joists run from the front of the picture to the back and are perpendicular to the rafters for the roof. The split is on the far side of the attic:

This view shows a close up of how the joists are supported in the foreground of the previous picture:

This shows how the joists are attached to the frame on the far side (where the split is):

EDIT: Nearly final result
Here's what the nearly final result looks like (I still need to replace the block that was between the joists):

I was able to get a 10 ft board in place to sister with the joist with the split. I used pairs of 3/8in bolts spaced about 24 in apart to bolt it together. Near the split, I put the bolts below the split and put one extra one in. I used construction adhesive between the joist and the sistered joist.
In the area that was split, I also drove a few 8in lag screws vertically through the joist. It wasn't able to close the split, but hopefully it helps:
Comment: Sistering an 8 or ten foot piece should be more than enough.  Think it is more of a repair when you get to it, than have it done yesterday, but sooner the better.  A crack going top to bottom is the very bad type, the one you is common and usually not a concern, except for your size.
Comment: That is some very tidy wiring on the right-hand wall! Whatever you do, be sure you don't drive a nail into your wires or damage them when maneuvering the new/patch lumber into place.
Comment: Is there a perpendicular wall underneath any part of that span? If so, how far from the plate to that wall?
Comment: @AloysiusDefenestrate No, just at the ends of the joist.
Comment: Agree that a shorter sister would be adequate, though I'd lean toward 12-14' (in spite of how awful that might be). If that's not going in through the attic hatch, think about opening a hole under the roof.
Answer: I'll start off by saying that nothing you read on this site or anywhere else is a substitute for an on-site professional. There may be aspects to the situation that we can't see and you weren't aware are critical. You should have someone local take a look. That out of the way, here are my thoughts.
This isn't an urgent situation.

These joists appear to only support the ceiling. I see no evidence that they carry even the roof, let alone other portions of the structure.
The crack looks old. It doesn't have the bright, fresh signature of a new break.
It primarily follows the grain of the board. Since large timbers nearly always show "checking", or shrinkage cracks at some point, it's not at all uncommon to see similar cracks in even milled lumber.
It's just one joist. The load of the drywall and hardware it carries is spread across many joists.

Repairs needn't be complex.
One option would be to simply slather some construction adhesive in the cracks and run long timber screws or light-gauge lags down through the joist every foot or so to bind it back together. Pilot properly to prevent new splits, especially in the portion of the joist above the crack--it'll be quite brittle.
I can't tell with certainty how much clearance you have for more elaborate repairs, but I get the impression that you could slide in a new member alongside the cracked joist for sistering. Even if you can get something in there that spans from the end to a few feet past the primary cracks, that should be adequate. Here are some suggestions.

Use either solid, small-knot lumber of roughly the same size as the original joist, or use modern engineered lumber such as OSB of at least 1" total thickness. This could be stair stringer material (1" to 1¼") or two layers of 8' or 10' sheathing.
Plywood only offers roughly half the strength because every other ply is crossgrain. I wouldn't use it if you have other options. Absolutely do not use any form of pressed particle material, such as particle board or fiberboard.
Whatever lumber you use, fastening is critical. You don't take advantage of the repair unless the patch is rigidly bonded to the old joist.
While construction adhesive isn't rated as a structural component, it's worth using. It will add significant bond strength to the system.
Suitable fasteners will allow tight connection without requiring impacts that may damage your ceiling finish. Consider 2½" construction screws or lags, carriage or hex bolts, or ~3" pneumatic cement-coated or ring-shank nails. Hand-driven nails will likely result in damage to the drywall below.
If using screws or lags, consider piloting through the new member to allow the screw to slip, increasing clamping force. You could also use half-thread screws to accomplish the same.
The old joist will be very hard. You'll want to pilot properly into that as well if not using self-drilling fasteners.
If you're not able to achieve a tight connection with screws alone, use C-clamps or other devices to temporarily tighten the joint.
I would still try to screw the upper portion of the existing joist down into position, even if with just a few shorter screws. A large gap reduces its effectiveness, and it's just good workpersonship to get that tight before locking everything in place.
Comment: I updated the post with the (nearly) final result based on your advice.

How to repair this split ceiling joist?


In Java calling procedure or function in Oracle PL/SQL. Return Resultset false

Question: I have a function plsql, run function in plsql return cursor have data
But i call this function in java problem return cursor empty
Help me handling problem this
This is function oracle plsql
FUNCTION get_canh_bao
      ( p_toolname      in  varchar2,
        p_toolid        in  varchar2,
        p_toolurl       in  varchar2,
        p_parent        in  varchar2)
      RETURN  sys_refcursor IS

    s           varchar2(32000);
    ptype       varchar2(32000);
    pday        varchar2(32000);
    psql        varchar2(32000);
    pcreate     varchar2(32000);
    re          sys_refcursor;
    pwhere      varchar2(32000);
BEGIN
--
    pwhere := '';
    s := 'select b.TYPE_REPORT, b.DAY_NHAPLIEU, a.sql_cmd, a.name_createdate'
        ||' from cpcdata.tbl_config_nhaplieu a'
        ||' left join cpcdata.tbl_mainmenu b'
        ||' on a.tool_id = b.ID '
        ||' where b.show_all = 0 and b.flag = 1 and b.ID = '''||p_toolid||'''';
    execute immediate s INTO ptype, pday, psql, pcreate;
            -- Tinh ngay canh bao
            if (INSTR(psql,'where') > 0 ) then
                pwhere := ' and ';
            else
                pwhere := ' where ';
            end if;
            CASE
                WHEN ptype = 'day'    THEN
                    s := psql ||pwhere|| ' to_char('||pcreate||',''dd/mm/yyyy'') = to_char(sysdate - '||pday||',''dd/mm/yyyy'')';
                WHEN ptype = 'week'   THEN
                    s := psql ||pwhere||pcreate||' between to_date(TRUNC (sysdate, ''iw''),''dd/mm/yyyy'') and'
                              || ' to_date(TRUNC(sysdate, ''iw'') + 7 - 1/86400- '||pday||',''dd/mm/yyyy'')';
                WHEN ptype = 'month'  THEN
                    s := psql ||pwhere||pcreate||' between to_date(TRUNC (sysdate, ''mm''),''dd/mm/yyyy'') and'
                              || ' to_date(LAST_DAY(TRUNC (sysdate, ''mm'')) + 1 - 1/86400 - '||pday||',''dd/mm/yyyy'')';
                WHEN ptype = 'quy'    THEN
                    s := psql ||pwhere||pcreate||' between to_date(TRUNC(sysdate, ''Q''),''dd/mm/yyyy'') and'
                              || ' to_date(add_months(trunc(sysdate,''Q''),3)- 1 - '||pday||', ''dd/mm/yyyy'')';
                WHEN ptype = 'year'   THEN
                    s := psql ||pwhere||pcreate||' between to_date(TRUNC (SYSDATE , ''YEAR''),''dd/mm/yyyy'') and'
                              || ' to_date(ADD_MONTHS(TRUNC (SYSDATE,''YEAR''),12) - 1 - '||pday||', ''dd/mm/yyyy'')';
                ELSE return null;
            END CASE;
    dbms_output.put_line(''||s);
    open re for s;
    RETURN re ;
    exception when others then
        declare
            s_err       varchar2(2000);
            str         varchar(2000);
            c_err       sys_refcursor;
        begin
            s_err := 'loi khi lay du lieu '|| sqlerrm;
            str := 'select '||s_err||' from dual';
            open c_err for str;
            return c_err;
        end;
END;

This is code java call function
ArrayList arr = new ArrayList();
            sql = "begin ? := config_pkg.get_canh_bao(?,?,?,?); end;";
            cs = conn.prepareCall(sql);
            cs.registerOutParameter(1, OracleTypes.CURSOR);
            cs.setString(2, "");
            cs.setString(3, "502");
            cs.setString(4, "");
            cs.setString(5, "");
            cs.executeQuery();
            ResultSet rs = (ResultSet)cs.getObject(1);
            System.out.println("------------Exception---------------"+rs.next());
            while (rs.next()) {

              System.out.println("a");
              String[] str =
              {"1" };
              arr.add(str);
            }

Comment: What do you mean by the cursor being 'empty'? Do you mean it returns no rows, or it's invalid, or something fails? Also, `trunc(date)` returns a `date`. `to_date()` only works on strings, so `to_date(date)` implicitly converts the date to a string using session defaults before converting it back to a date again, which can give unexpected results.
Comment: i sure, it return cursor no data.
Comment: Why when calling procedure or function in Oracle PL/SQL. it return cursor contains data
Answer: You should use bind variables, would be similar to this:
pwhere := '';
s := 'select b.TYPE_REPORT, b.DAY_NHAPLIEU, a.sql_cmd, a.name_createdate'
    ||' from cpcdata.tbl_config_nhaplieu a'
    ||' left join cpcdata.tbl_mainmenu b'
    ||' on a.tool_id = b.ID '
    ||' where b.show_all = 0 and b.flag = 1 and b.ID = :toolId';
execute immediate s INTO ptype, pday, psql, pcreate USING toolId;
        -- Tinh ngay canh bao
        if (INSTR(psql,'where') > 0 ) then
            pwhere := ' and ';
        else
            pwhere := ' where ';
        end if;
        s := psql ||pwhere||pcreate||' between :aDate AND :bDate';

        CASE
            WHEN ptype = 'day'    THEN ...
            WHEN ptype = 'week'   THEN
                open re for s USING TRUNC (sysdate, 'iw'), TRUNC(sysdate, 'iw') + 7 - 1/86400- pday;
            WHEN ptype = 'month'  THEN ...
        END CASE;

Comment: thanks you, i try use bind  variables but function return no data record


Affordance of ContentEditable elements (without changing the background)

Question: Context
I want to use the ContentEditable attribut instead of classic inputs.
It sounds like a duplicate of Affordance of Edit In Place functionality, but actually I would like to avoid the changing of background-color as suggered by the answer. Also, the linked question is dated from 2011 and UX practices evolve constantly, so maybe there are new approaches and solutions for this subject.
This is my currently approach : a different color in addition of a bottom border.

(sorry for the french on this gif)
You can try it with this demo : http://jsfiddle.net/Lazgp/6
I chose the blue and the dotted border for no really good reason, just like that.
Question
Have you any feedbacks or advices to improve it?
Comment: It looks fine, I think in the context of having triggered the edit mode user will easily spot the difference and proceed to editing fields data. However, this is rather opinion-based question.
Answer: Looks great! Dotted and dashed lines actually work great to give affordance. But the best thing you can do, to make people really understand that it is in fact editable, is to make the first field focused automatically.
This will give the user an immediate visual feedback and no guessing is required anymore.
Answer: It's really very unusual and have controversial affordance.
Dotted and dashed lines usually used for showing popup with some additional info and it just tells a user - you can click on me but not you can edit me.
I would suggest showing inputs for all editable items after switching to edit mode. It has greater affordance and also inputs motivates users to enter information.
Answer: The interaction looks good, here some ideas that must be tested if possible :

Why not propose your Modifer button on every section as Wikipedia does in order to improve focus ?

This interaction does not exist yet on English wikipedia, as far as I know

Be careful with dashed underlines and blue combinations, they could be misinterpreted as links. Your approach seems fine but you should acknowledge that it is quite unconventional.
As an echo to the previous remark : when hover/clicking in one of the inputs, it should look more like an input with the little help of a background as Basecamp does. Focus an make an example on the first input to help understand the interaction.


Double integral of $f(x,y)= xy/\left((1+|x|)^2+(1+|y|)^2\right)$ from $(-1,-1)$ to $(1,1)$

Question: Given
$$f(x,y) = \frac{xy}{(1+|x|)^2+(1+|y|)^2},$$
show that
$$\int_{-1}^1\int_{-1}^1f(x,y)\,dx\,dy = 0.$$
I have $$\int_{-1}^1\left(\int_{-1}^0f(x,y)\,dx+\int_0^1f(x,y)\,dx\right)dy,$$
and I think those inner integrals sum to $0$, but I don't know how to show that.
I then need to show that $f$ is not (Lebesgue) integrable on $\mathbb{R}$ but I should get the first part before moving on to that.
Comment: $f$ is defined on a square, not on a subset of R. So what does it mean to show $f$ is not lebesgue integrable on R?
Comment: The value on $[0,1]\times[0,1]$ is the same as the value on $[-1,0]\times[0,-1]$ and is the negative of the value on each of the sets $[-1,0]\times[0,1]$ and $[0,1]\times[0,-1]$.
Comment: We're given a hint that f is not integrable on [.5,1]x[.5,1], if that helps at all.
Answer: For every $ab$ in $[0,1] \times[0,1]$ there is $cd$ in $[-1,0] \times [0,1]$ such that $ab=-cd$ and $ab$ and $cd$ are symmetric with respect to $y$-axis. For every $ef$ in $[-1,0] \times [-1,0]$ there is $gh$ in $[0,1] \times [-1,0]$ such that $ef=-gh$ and $ef$ and $gh$ are symmetric with respect to $y$-axis.
I think that this shows that the integral is indeed zero.


Use window.location.hash to change the background color of an element

Question: The following code is just for example, I want to use window.location.hash so that if someone opens a website like this,
http://fiddle.jshell.net/2uPEs/3#row=green|red

They get #green row click triggered and #box color should be red,
Now I must need to show the background-color in URL, in example it's static but in real case scenario, it will be dynamic.
HTML

green

blue

Box

CSS
.a-class{ width:300px; height:200px; background-color:gray; float:left;}
.b-class{ width:300px; height:200px; float:right;}
.row {  background-color: #ccc; float: left; margin: 10px 0; padding: 1em; width: 50%; }
.box{ width:50%; height:50%; border-style:solid;}

JS
$(document).ready(function () {

    $("#green").click(function() {
        $("#box").css("background-color","red");
    });

     $("#blue").click(function() {
        $("#box").css("background-color","yellow");
    });
});

Here is the Fiddle Demo.
Comment: Is there any reason that you are using # instead of ?row=
Comment: ?row= would invoke a new URL load at run time.  No reason for that if it is all handled by the client.
Comment: You could use the `:target` selector. It is also implemented in jQuery (https://api.jquery.com/target-selector/).
Answer: try something like this:
demo : http://jsfiddle.net/qsDn5/46/
get url from widow and manipulate it to get requred values.
$(document).ready(function () {
 var url = window.location.pathname;
 //var url = "http://fiddle.jshell.net/2uPEs/3#row=green|red";
 var sUrl = url.split("#")[1];
 var arr =  sUrl.split("|");
 var bdColor = arr[1];
 var rowColor = arr[0].split("row=");
 alert("box color: "+ bdColor+ " row color" + rowColor);

});

Comment: Awlad, thanks but this is not what I am looking for :(, what I want is, when I click on green, it should change url and then add stuff to it using location.hash, and when someone go to the url with hash tags, it implements them
Answer:
What I want is, when I click on green, it should change URL

You need to bind a click handler for the elements (defElm variable in the following) to change the window.location.hash.

and when someone go to the URL with hash tags, it implements them

So, You could bind a handler to window.onhashchange event, split the hash string to get the variables, and change the #box background color.
Here you go:
$(document).ready(function() {
  var defElm = [
    {
      'element': 'green',
      'color': 'red'
    },
    {
      'element': 'blue',
      'color': 'yellow'
    }
  ];

  $.each(defElm, function(i, v){
    $("#" + v.element).click(function() {
      window.location.hash = "#row="+ v.element + "|" + v.color;
    });
  });

  $(window).bind('hashchange', function() {
    var _hash = window.location.hash.trim().split('|'),
        elm = _hash[0].substr(5) || false;
        clr = _hash[1]           || '';

    if (elm) {
      $("#" + elm).click(function() {
        $("#box").css("background-color", clr);
      }).click(); // trigger the click handler
    }
  });

});

WORKING DEMO.
Note: You probably need to download the Bin demo into your computer to check the effect (open the downloaded file in your web browser).
Comment: +1, thanks not allowed to download anything, so can't test it
Comment: @CustomizedName Just click on the `Bins` item at the top menu bar, then click on the *Download*.


Does Guns of Icarus game have an ending?

Question: I was playing Guns of Icarus and followed a route all the way to the "Into The Breach" level. But that level seems to be a never-ending survival one.
Is there any way to actually finish the game? Is there any ending of some sort?
Answer: Perhaps unfortunately, there is not an ending to the story. I have played the game, and Into the Breach is meant to be the final apocalyptic mission. It's your suicide mission into the pirates, and does not end until you die; you just try to accumulate a high score.
If you're looking for references, this review calls Into the Breach "survival mode" which is just what I have described above. This survival mission is also the end goal of the game. Everything else is just a build up to upgrade your ship in preparation.


Making a menu with toggle which can be animated using the top property

Question: I'm trying to make a toggle button, so when you click once on #mbtn, it must be set to top:0px and when you click a second time, it must be set to top:-110px.
Here is the code I'm using but it seems like it's not working, where am I wrong?

Comment: Can you add the basics of the HTML/CSS you are using or a JSfiddle etc?
Comment: @lee_gladding well, my code is not working how can i add basic html to jsfidle when apperantly im trying to make my menu move from invisible (-110px top) to 0pxtop (to visible)
Answer: Per jQuery API, you have to use toggle with an action, such as click. For example:
$( "#mbtn" ).click(function() {
  $( ".menu" ).toggle( "slow", function() {
    // Animation complete.
  });
});

JSfiddle
I assume you were trying to hide the menu bar? if so, take a look at .slideToggle() instead. Here is the JSfiddle example.
Comment: @Tahi , so like this: http://jsfiddle.net/dqjsts0a/1/ Updated the JSfiddle of Melissa
Comment: no, im trying to do the oposite, the starting point of menu must be hidden, then when u click it must be open, then when u click for second time it must hide it again


How do you disable tooltips in ember-cli-chart?

Question: I am using ember-cli-chart which is a wrapper for chart js. I am trying to disable the tooltips.
I have tried the following code but it does nothing:
chartData: computed('model', function() {
    return {
      labels: ['1', '2'],
      datasets: [{
          label: 'Example Label',
          data: [this.model.example1, this.model.example2],
          options: {
            tooltips: {
              enabled: false,
            }
          }
      }]
    }
  }),

Why does this not disable the tooltips?
Answer: The documentation for ember-cli-chart shows this example usage:
{{ember-chart
  type=CHARTTYPE
  data=CHARTDATA
  options=CHARTOPTIONS
  width=CHARTWIDTH
  height=CHARTHEIGHT
  plugins=CHARTPLUGINS
  customLegendElement=CUSTOMLEGENDELEMENT
}}

You need to define options as a separate property that's passed in when invoking the chart component.


function ()() in javascript

Question: I am not sure how to call/frame this question title, but can anyone explain me what does the below code do?
var routes = require("./routes/routes.js")(app);

I am seeing a second () with app being passed, what does that do?
https://github.com/couchbaselabs/restful-angularjs-nodejs/blob/master/app.js
To my surprise, in the code above the variable routes is not at all used in app.js? what's the purpose. I am quite confused here does (app) argument do anything magic here?
Comment: (1) The routes.js file exports a function so it's immediately invoked and the result stored in `routes`. (2) In that call, the `app` is passed to the router, so app does actually make use of the router, just not of the variable `routes`.
Comment: That's what I was responding to. What makes me suspect that this will not work is the async way routes is setup. You give routes your app, it it adds stuff to it. Now, if `app.use` is setup such that it passes a copy of `app` to its second router argument, then I think that might work as well.
Comment: @HunanRostomyan : app.use("/", require("./routes")); is this code equivalent to above code?
Comment: That could work. I'm not sure. Give it a try.
Comment: @HunanRostomyan: That works, my question is this same as above code? in the above i don't specify any path but here i do with "/"?
Answer: The construct
foo()();

expects that foo() returns a function and calls it immediately. It's equivalent to the more readable:
var func = foo();
func();

A similar construct you'll often see is:
(function() {
    // function definition
})(args);

This defines a function and calls it immediately. The primary use is to emulate block scope for variables.
Comment: Can you just do a small fiddle with a basic example on foo()(arg) ?

function ()() in javascript


How can I use a variable in my inner class?

Question: I have this code using Kotlin:
class A{
    var myVariable:String?=null

    constructor(myVariable:String){
        this.myVariable = myVariable
    }

    init {
        println("Success !")
    }

    inner class B{
        init {
            println(myVariable)
        }
    }
}

fun main(args:Array<String>){
    var b = A("test").B // this does not work
}

And unfortunately it does not work I get:
Error:(20, 23) Kotlin: Nested class 'B' accessed via instance reference
Error:(20, 23) Kotlin: Classifier 'B' does not have a companion object, and thus must be initialized here

How can I solve my problem?
Answer: When you do:
A("test").B

You're saying "Fetch something from an instance of A" - in this case, it's a class. However, this isn't the syntax you're looking for in your case. You can get mostly anything, but getting a reference is a separate issue. If you want to get a function, the syntax is different from getting a field or calling a function. Although this isn't very important, bit might still be worth keeping that in mind.
Since B is an inner class, you're so far entirely correct that you need an instance of A first. But you also need an instance of B. When you initialize B, it's still "connected" to the parent class, which is why you can access outer variables without any problems. However, it's still an initializable class - and you need to initialize it.
So you need to initialize B as well. The Kotlin syntax for this is pretty nice (where as the syntax in Java is slightly horrible) - all you need to add is () at the end.
So you'll end up with this:
val b = A("test").B()
// ...

This is because it's an inner class. If you had a static inner class (in Kotlin, that's a class within a class without the inner keyword), the initialization would've been A.B() - A isn't initialized in those cases.
You can also split up the initialization:
val a = A("test")
val b = a.B();

Once you have the variable, it's exactly like every other variable - the only difference here is the initialization.
Answer: You should create an instance (call constructor) of class B before accessing its members:
fun main(args:Array<String>) {
    val b = A("test").B()
    b.someFunction()
}

class A {
    var myVariable:String? = null

    constructor(myVariable: String) {
        this.myVariable = myVariable
    }

    init {
        println("Success !")
    }

    inner class B {
        init {
            println(myVariable)
        }

        fun someFunction() {
            myVariable = "set new value to the variable"
        }
    }
}

Answer: Try this:
class A{
    var myVariable:String?=null

    constructor(myVariable:String){
        this.myVariable = myVariable
    }

    init {
        println("Success !")
    }

    inner class B{
        init {
            println(myVariable)
        }
    }
}

fun main(args:Array<String>){
    var b = A("test").B() // You have to call the constructor here
}


Auto-backup of SPSS

Question: Does SPSS automatically create a backup of data files?
I require that because the data that was entered for a long time in SPSS was not saved, even with using Ctrl+S for many times during data entry.
Answer: If you created your data by running DATA LIST with inline data, you could find this in the journal file, which is on by default.  However, if the data were entered in the Data Editor but not saved - I can't guess how that could happen - there would be no backup.
Comment: Where is the journal file located?
Answer: SPSS does not auto-save as far as I know - but on my machine the Ctrl + s shortcut works to save. When you do save SPSS sends a SAVE command to the output window so you can always check that a save did actually occur. And if you check the output it will say if there is another type of error when trying to save the file (e.g. don't have write permissions, file is locked, etc.)
It might be worth a look to open up your journal file. If you accidentally saved the file to an unknown location it would show the directory in the journal.
Answer: (Reference# 1479525) says the auto save enhancement request has been forwarded to SPSS Development. That was in 2011.
JKP suggested checking your journal files if the data was created by running DATA LIST with inline data (and not with the Data Editor).
To figure out the location of your journal files open SPSS, then go to 'Edit' > 'Options' > 'File Locations'.
I also had problems with Ctrl+s during my last data entry that occured in two different situations:

The data set wasn't activated. Window title bar showed [ ] instead of [DataSet1]. On Crtl+S the output window then displayed an error. 'Save as' worked without problems.
Ctrl+s after every completed case, no problems. Then sometimes instead of saving, it simply activated the cell or nothing happened at all. Only restarting SPSS made Ctrl+s work again. I never figured out the cause, it didn't seem to be linked to any specific action.
Perhaps SPSS 20 doesn't play well with Ubuntu 12.04. Again, 'Save as' was reliable.

Auto-backup of SPSS


BATV; What is it and how is it configured?

Question: I have tested my email server on allaboutspam.com to see why the emails are beeing considered spam by hotmail and gmail servers.
The results was amongst other faults, the BATV.
This is the complete result from allaboutspam.com on my BATV:
BATV is a mechanism wherein an outgoing Email server adds a tag to the Envelope From address of all outgoing Emails. For example, if an Email address goes out with From address as <email@example.com>, the Envelope From is changed to <firstname.lastname@example.com>, where 'SBDGAUJ' is the added tag. This tag is generated using an internal mechanism and is different for each email sent.
If any bounce is received by the Incoming email servers, they are checked to see if the Bounce address has the proper tag (in above case 'SBDGAUJ'). If not, the email is rejected.
Could somebody explain this in simpler words... How is it configured?
currently I have this setup when sending email with php:
$mail_message="text_text_text_text";

$headers="MIME-Version: 1.0"."\n";
$headers.="Content-type: text/plain; charset=UTF-8"."\n";
$headers.="From: Skuffen <firstname.lastname@example.com>"."\n";
$subject="SUBJECT HERE";

mail($email, '=?UTF-8?B?'.base64_encode($subject).'?=', $mail_message, $headers, '-firstname.lastname@example.com');

This is a swedish language so you know (utf-8)...
Thanks
Answer: I think that you need to set this up in your Mail Transfer Agent. The PHP mail() command sends mail through the local sendmail (or compatible, like Exim, Postfix or Qmail) installation. That's where BATV needs to be configured.
If you are on a simple shared hosting, contact your hosting provider.


$.ajax() call success handler datatype=text

Question: I have a simple ajax call that is returning a text string correctly from the server, and I want to compare the response in the success handler, in this case if data == "Yes", do something, however I can't seem to make the comparison operator work. Not sure what I am doing incorrectly.
Server side:
if(mysqli_affected_rows($dbc) == 1) {
    $message .= "Yes";
}
echo $message;

jQuery:
dataType: "text",
success: function(data, success) {
   console.log(data, success); //Yes
   console.log(typeof(data));  // string
   var response = data;

   if(response == "Yes") {
      $('.slideout').animate({width:'0%'}, function() {
         $('.slideout').css({'display':'none'});
   })
}

Answer: I was returning more data from the serve than I was expecting, that is why the comparison operator did not return as True.


Accordion on page needs to have one of the boxes stay open and not be collapsable

Question: I have 3 tabs at the top of the page, and then an accordion in each one.
I need my bottom option in the accordion to always stay open at a fixed height of 200 pixels.
I'm thinking I can take it out of the accordion and just set a default height, however I need it to switch within the tabbed system as well. Any ideas?
Here is the code
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title>test page</title>

    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/skins/dark.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/custom.css" type="text/css" media="screen">

Size >

A

B

C

A

Content

B

Content

C

Content that needs to stay open to 200 pixels

First

Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.

Second

Phasellus mattis tincidunt nibh.

Third

Nam dui erat, auctor a, dignissim quis.

Content that always needs to stay open to 200 pixels

Comment: please provide a fiddle.
Comment: So you are trying to make the last option in each `` always open at 200px?
Comment: So you are trying to make the last option in each  always open at 200px?

Yes I am
Comment: Did you check out my answer? Does it address your question?
Comment: It almost worked. See my comment below! I'm not sure what is missing because in a fiddle it works correctly. But the browser doesn't seem to be rendering it the same way at all.

http://jsfiddle.net/jYgnL/
Answer: I guess if you're sticking with jQuery UI, you could make it it's own non-collapsible accordion, click here to take a look (Note edited from my original answer to address your 200px height issue):

1

2

3

Heading1

The content of heading1

Heading2

The content of heading2

Always open Heading

This content must always be open

Heading1

The content of heading1

Heading2

The content of heading2

Always open Heading

This content must always be open

Heading1

The content of heading1

Heading2

The content of heading2

Always open Heading

This content must always be open

And the JS:
 $(function () {
     $("#tabs").tabs({
         heightStyle: "content"
     });
      $( ".height_control:not(:last-child) .sub_accordion").accordion({
         collapsible: true,
          heightStyle: "content"
      });
     $( ".height_control:last-child .sub_accordion" ).accordion({
         collapsible: false,
         heightStyle: "fill"
     });
 });

And finally the CSS:
.height_control:last-child {
    height: 200px;
}

Comment: This works perfectly, other then now it only loads my active tab instead of the 2nd and 3rd tab's content as well (as it the 2nd and 3rd tabs on top don't accordion open)
Comment: I'm not sure I understand the problem. Can you upload a screenshot as an update to your question or in [Photobucket](http://www.photobucket.com), or if you can't, then describe it in terms of the HTML tags in your code (e.g. "The content in `` is always collapsed").
Comment: Here it is
http://d.pr/i/YwQn

Basically the first tab works just fine, content slides up and down and opens, but when going to the second tab, the bottom stays open, but boxes A and B won't open to display the content at all.
Comment: Take a look at [this JSfiddle](http://jsfiddle.net/quhbM/1/), and let me know if that works in your browser, it worked on mine in chrome and firefox.
Comment: Thanks so much for all your help! It worked, I was missing a closing div tag as well, which may have been affecting it.


Network Manager doesn't respect DHCP settings?

Question: Had my Ubuntu 20.04 system running without any issues for months, but lately I had to start running sudo dhclient after every reboot, otherwise I am not able to connect to the internet.
I am fairly sure this issue has to do with my recent attempt at trying out Wireguard which I may have misconfigured resulting in a broken setting somewhere (Wireguard is now uninstalled).
Right after login, my network manager connection looks like this, which was identical when everything was running fine:

After running sudo dhclient, I have network but the network-manager settings haven't changed.
I could add the dhclient command to a startup script, but what I would really like is to understand what got messed up!
Here is my /etc/netplan/01-network-manager-all.yaml config
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

Thank you in advance for your help!
Edit: more details
I am connected to my router both through ethernet and wifi, and on startup only ethernet seems to have issues. My DHCP client is a pihole docker container running on a NAS on the LAN. My setup didn't change recently tho.
running ifconfig, these are the outputs for my enp4s0 and wlp5s0 interfaces:
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.108  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::e8fc:b999:680:6d7d  prefixlen 64  scopeid 0x20<link>
        ether 0c:9d:92:8a:c9:7a  txqueuelen 1000  (Ethernet)
        RX packets 631  bytes 563240 (563.2 KB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 578  bytes 65883 (65.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfc400000-fc41ffff

enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.108  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::e8fc:b999:680:6d7d  prefixlen 64  scopeid 0x20<link>
        ether 0c:9d:92:8a:c9:7a  txqueuelen 1000  (Ethernet)
        RX packets 631  bytes 563240 (563.2 KB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 578  bytes 65883 (65.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfc400000-fc41ffff

the output doesn't seem to change after running sudo dhclient, but I noticed one RX dropped error, and only on the ethernet interface.
Edit 2:
Looks like my /etc/resolv.conf file doesn't exist at startup (may be an obvious thing but better to add this info
before:
cat /etc/resolv.conf

after:
cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 192.168.1.112

Edit 3:
my /etc/systemd/network folder is empty
running sudo iptables -L before and after running dhclient shows the following differences (only differences shown since I use PIA VPN and it adds a ton of entries, but it has been installed on my system for months too):
before:
Chain piavpn.r.300.allowLAN (1 references)
ACCEPT     all  --  anywhere             22.214.171.124/4

[...]

This stuff below isn't present after running the command
Chain ufw-skip-to-policy-output (0 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
Chain ufw-track-forward (1 references)
target     prot opt source               destination
Chain ufw-track-input (1 references)
target     prot opt source               destination
Chain ufw-track-output (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             ctstate NEW
ACCEPT     udp  --  anywhere             anywhere             ctstate NEW
Chain ufw-user-forward (1 references)
target     prot opt source               destination
Chain ufw-user-input (1 references)
target     prot opt source               destination
Chain ufw-user-limit (0 references)
target     prot opt source               destination
LOG        all  --  anywhere             anywhere             limit: avg 3/min burst 5 LOG level warning prefix "[UFW LIMIT BLOCK] "
REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
Chain ufw-user-limit-accept (0 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
Chain ufw-user-logging-forward (0 references)
target     prot opt source               destination
Chain ufw-user-logging-input (0 references)
target     prot opt source               destination
Chain ufw-user-logging-output (0 references)
target     prot opt source               destination
Chain ufw-user-output (1 references)
target     prot opt source               destination

after:
ACCEPT     all  --  anywhere             base-address.mcast.net/4

[...]

entries missing

Let me know if you need other info
Answer: After troubleshooting all day long, I just gave up: instead of understanding what was causing this issue I just fixed the problem even though I am 100% sure the issue comes from somewhere else:
Based on this askubuntu answer I removed the symlink from /etc/resolv.conf and added my own DNS entry. After a restart I noticed the file got replaced with one created by Network Manager, so I just updated that one.
Everything is back to normal, even though I am still unsure what caused all this mess.
Comment: So basically, you were correctly connected to the Internet all the time, only your DNS resolution wasn't working? That's always the first thing to try if you suppose you don't have Internet connection, ping some server by its IP address. Then you can right away narrow down the problem to DNS.
Comment: Remove the big banner at the end of the answer it does not add anything.
Comment: @raj the thing is that my dns server was set correctly if you check  the images (192.168.1.112 has always been the proper dns ip), but for some reason I couldn't actually send dns requests to it. At the end by checking the contents of `resolv.conf` I noticed that contrarily to what the gui was showing me I had no dns server set up. Since I never had this kind of issues I didn't expect the entire networking interface to basically report false information, hence expected dns to be reacheable
Comment: @David done, thank you for the feedback


Terminology between essentially bounded function and bounded function.

Question: My question is that if $\sigma_{n}(x)\to f(x)$ almost everywhere, where $f(x)$ is essentially bounded function and $|\sigma_{n}(x)|\leq K$ then how can we prove that $|f(x)|\leq K$
Comment: Kns last inequality you mean almost surely ?
Comment: yes i want to show that $|f(x)|\leq K$ a.e..
Comment: Just take the limit in the inequality $|\sigma_{n}(x)|\leq K$
Comment: So we get $|f(x)|\leq K$ a.e., it implies $f(x)$ is essentially bounded. does it mean $f(x)$ is bounded?
Comment: No see the William's answer. It is not possible, in general, to show that $f$ is bounded. Another very simple example can be constructed by using a Dirac delta measure.
Answer: Suppose that $E = \{x : f(x) > K\}$ is not measure zero. Then for all $x \in E$, $\sigma_n(x)$ does not converge to $f(x)$ since $f(x) > K$ but $\sigma_n(x) \leq K$. Hence $\sigma_n$ does not converge to $f$ almost everywhere since it does not converge on $E$ which is not measure zero. Contradiction!
Comment: Upvoted, but with a reservation. The inequality $\sigma_n(x)\le K$ holds only a.e. When learning a.e. convergence, it is a good practice to give names to exceptional sets: for example, $E_n=\{x\colon |\sigma_n(x)|>K\}$, and $F=\{x\colon \sigma_n(x)\to f(x)\}^c$. Now let $E=F\cup\bigcup_n E_n$. Since $E$ is a countable union of null sets, it is a null set. For all $x\notin E$ we have $|f(x)|=\lim_{n\to\infty} |\sigma_n(x)|\le K$. QED.


Test for Apple Push Notification

Question: I am using node.js (server framework) and mongoose.js (mongo based schema modeling) as the backend for an iOS app and I am using Mocha (test framwork) to make sure everything works.
What I really want to know, and can find no documentation on, is how to test on the server if the push notifications are being appropriately sent. I am using apnagent and at the moment I can see that push notifications are being sent correctly by manually checking my device but I am having difficulty finding an automated way to test that they are working correctly.

That may be enough of a description to answer at a high level what needs to be done. But in case it is not here is the actual code:
Mongoose Model fires off a push notification upon creation:
#this code is called after this model is saved in mongodb
eventModel.post 'save', (doc) ->
  #push the message
  sendMessageToDevice = (event, token) ->
    message =
      event_body:
        eventId: event._id
        lat: event.lngLat[1]
        lng: event.lngLat[0]
    agent.createMessage()
      .device(token)
      .alert('New Event! ' + event.description)
      .set(message)
      .send()

  #cycle through the users to push to
  #get all the unique device tokens in the database for APN
  users.getAllUniqueDeviceTokens (error, devices) ->
    if error then return util.handleError error
    console.log "Sending push notices to all devices (%d):", devices.length
    console.log devices
    for token in devices
      sendMessageToDevice doc, token

    #send some verification here that the code ran correctly???

Then in my Mocha test file I have:
it 'should receive push notification from fort creation', (done) ->
    #some logic here to verify that push notifications were sent
    done()

Comment: I would use a request mocking framework like [nock](https://github.com/pgte/nock) to intercept the request to APN. The urls seem to be located in the code [here](https://github.com/argon/node-apn/blob/7692ce7514e51dbf38ef24ec1e3c3092da4efbc6/lib/connection.js#L87-L102).
Answer: In many situations, while writing tests, it is either impossible or simply too dangerous to verify that an action has really taken place (i.e. a push notification has been delivered). Imagine writing a unit test for the rm command where you would like to ensure that doing rm -rf / succeeds. Obviously, you cannot let this action take place and verify that your root partition is indeed empty!
What you can do, however (and should do, really), is verify that whatever commands, routines or other actions necessary to accomplish the task are being invoked correctly, without actually allowing them to take place.
In your particular situation, you do not need to verify that your push notification has been delivered because your application is not responsible for the notification's delivery. However, you can test that the push notification is being correctly delivered to the push server.
So, instead of testing for successful delivery, you test

Whether the outgoing request is properly formatted (i.e. JSON is valid)
Whether it contains the data you expect it to contain (i.e. a field in JSON is present and contains expected data)
Whether the authentication token required by the server is included
Whether the target server is correct (i.e. you are indeed sending the data to xxx.apple.com and not to localhost)

Ideally, these test requests will not even reach the target server - doing so would mean you are relying on two factors that are not always perfectly stable:

network connectivity
target server availability and proper functionality

In the past, I dealt with this so that I first manually issued a correct request, captured the response and then mocked the whole communication in the unit test (using i.e. nock. That way, I am completely in control of the whole communication.
Answer: As far as I know, there's no way to check if an APNS request has reached its destination or not. Apple tends to have this "everything's fine, and if it's not, then it should be your fault" policy with us developers. If things haven't changed since I started coding, you make an APNS request by sending raw data (JSON payload, you probably know the whole format) through the 2195 port, and you get absolutely no response for that.
Only thing I can think of, if you have a physical iOS device (an iPod, an iPhone or an iPad), you can "automate" a test by launching a PUSH request with a hardcoded token, corresponding to your device and a test app, and if you receive the notification then it works.
Oh, and if it doesn't work, please make sure you have all required ports open if you're operating behind a firewall. It's the first big stone I stepped into when I first dove into this ;) (related: https://support.apple.com/en-us/HT203609)

Test for Apple Push Notification


Cannot format argument from within spdlog

Question: I am trying to use spdlog. I incorporated it with my code, but now I am getting the following error:
....fmt\core.h(1016): error C2338: Cannot format argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#formatting-user-defined-types
  ....fmt/core.h(1013): note: while compiling class template member function 'int fmt::v6::internal::arg_mapper<Context>::map(...)'
          with
          [
              Context=context
          ]
  ....fmt/core.h(1213): note: see reference to function template instantiation 'int fmt::v6::internal::arg_mapper<Context>::map(...)' being compiled
          with
          [
              Context=context
          ]
  ....fmt/core.h(1027): note: see reference to class template instantiation 'fmt::v6::internal::arg_mapper<Context>' being compiled
          with
          [
              Context=context
          ]
  ....fmt/core.h(1198): note: see reference to alias template instantiation 'fmt::v6::internal::mapped_type_constant<int,context>' being compiled
  ....fmt/core.h(1342): note: see reference to function template instantiation 'unsigned __int64 fmt::v6::internal::encode_types<Context,int,>(void)' being compiled
          with
          [
              Context=context
          ]
  ....fmt/format.h(3375): note: see reference to class template instantiation 'fmt::v6::format_arg_store<context,int>' being compiled
  ....spdlog/details/fmt_helper.h(49): note: see reference to function template instantiation 'std::back_insert_iterator<fmt::v6::internal::buffer<char>> fmt::v6::format_to<char[6],int&,250,char>(fmt::v6::basic_memory_buffer<char,250,std::allocator<char>> &,const S (&),int &)' being compiled
          with
          [
              S=char [6]
          ]

... and this is the end of the error message. It never reaches my code, so I have no idea where to look at. Any ideas what could be the reason for this?
spdlog is version 1.6.1. The last error line is from here:
inline void pad2(int n, memory_buf_t &dest)
{
    if (n >= 0 && n < 100) // 0-99
    {
        dest.push_back(static_cast<char>('0' + n / 10));
        dest.push_back(static_cast<char>('0' + n % 10));
    }
    else // unlikely, but just in case, let fmt deal with it
    {
        fmt::format_to(dest, "{:02}", n);  // <--- HERE
    }
}

and it doesn't look particularly wrong to me.

Update: after some try-and-errors commenting out all spdlog invocations I narrowed it down to this:
spdlog::info("Foo{}", Point{1, 2});
Where Point is my own class in my own namespace. I do provide for it a way to print itself:
template<typename OStream>
OStream &operator<<(OStream &os, const Point &p) {
    return os << "[" << p.x << ", " << p.y << "]";
}

Comment: Add `#include `
Comment: Can you provide your `Point` class, please? Did you declare the `operator <<` in it?
Comment: Could you please provide some more code where you call the `spdlog::info`
Comment: You need the special include @PiotrSkotnicki mentioned if you want your user defined type to be formatted using `operator<<`. Otherwise you need to provide a [fmt::formatter class specialization](https://fmt.dev/latest/api.html#formatting-user-defined-types).
Comment: @JorgeBellon I have a code, that prints user-defined class, but I didn't manually include that file and it works
Comment: The documentation [is pretty clear about that](https://fmt.dev/latest/api.html#std-ostream-support).
Comment: Yes, the documentation is clear, and yes that was my omission. Fixed now and works as intended. My only wish is that the error message was a little bit more helpful. @PiotrSkotnicki If you could promote your comment to an answer I will gladly accept it.
Answer: spdlog uses the {fmt} library for formatting the output text, and that requires the <fmt/ostream.h> header file to be included in order to enable std::ostream-like support.
Regardless of using external implementation of the {fmt} library, or the one from spdlog sources itself, there's the special header <spdlog/fmt/ostr.h> that includes the file version that is in use.
Once included, spdlog should be able to use your operator<<.
Alternatively, you can create a custom formatter, that's also capable of parsing a formatting string:
template <>
struct fmt::formatter<Point> {
    constexpr auto parse(format_parse_context& ctx) {
        return ctx.end();
    }

    template <typename Context>
    auto format(const Point& p, Context& ctx) {
        return format_to(ctx.out(), "[{}, {}]", p.x, p.y);
    }
};

Answer: The other answer is overall correct: spdlog is based on {fmt} library, which has build-in std::ostream support including formatting of user-defined types that have an overloaded insertion operator (operator<<).
But starting from version 9 of {fmt} library, one needs to explicitly specialize fmt::formatter struct for user classes deriving it from ostream_formatter as follows:
#include <spdlog/fmt/ostr.h>

#if FMT_VERSION >= 90000
    template <> struct fmt::formatter<Point> : ostream_formatter{};
#endif

See: https://fmt.dev/dev/api.html#ostream-api