How to fade between different background colors of a `UICollectionView` as the user scrolls to a different page?

Question: I'm trying to replicate eBay's listing menu on their iOS app in which users can scroll through different images of a listing. I noticed that the background color is a solid color that replicates the surround colors of the background in each image.
As I scroll through a different image (different page) with a different surround background, the actual background of the UICollectionView changes to somehow reflect it.
Here's what I mean:

As you can see in the first picture, the background is a light color, somewhat resembling the image's background. As I scroll halfway to the 2nd picture, the background turns darker.
Finally:

My setup is similar:

Using DominantColor, I was able to set the UICollectionView's background color with each UIImage's dominant color. As the user scrolls half-way between the first and second page, the UICollectionView background color is set the 2nd page UIImage's dominant color.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as UICollectionViewCell

    let frame: CGRect = CGRect(x: 0, y: 0, width: imagesView.frame.size.width, height: imagesView.frame.size.height)

    let subView: UIImageView = UIImageView(frame: frame)

    subView.image = imagesArray[indexPath.row].image

    subView.contentMode = UIViewContentMode.scaleAspectFit

    if colorsArray.count > 0
    {
        // Set background dominant color of first image
        collectionView.backgroundColor = colorsArray[0]
    }

    cell.addSubview(subView)

    return cell
}

func scrollViewDidScroll(_ scrollView: UIScrollView)
{
    let scrollValue = (scrollView.contentOffset.x / UIScreen.main.bounds.width)

    let pageWidth: CGFloat = imagesCollectionView.bounds.size.width

    let currentPage: Int = Int( floor( (imagesCollectionView.contentOffset.x - pageWidth / 2) / pageWidth) + 1)

    if scrollValue != 1
    {
        UIView.animate(withDuration: 1, animations: {

            self.imagesCollectionView.backgroundColor = self.colorsArray[currentPage]

        })

    }
    else
    {
        UIView.animate(withDuration: 1, animations: {

            self.imagesCollectionView.backgroundColor = self.colorsArray[currentPage]

        })

    }
}

However, I'm having a difficult time on how to slowly transition from the current background color to the next background color as soon as the user starts scrolling, as seen in the 2nd picture above.
The way it is currently implemented as above in scrollViewDidScroll, it starts to fade into the next color when the page is half-way scrolled between the next page, and with a 1 second animation, it will become that color within 1 second, regardless of if the next page is half-way or fully shown.
How can I achieve this?
Comment: Answered here https://stackoverflow.com/a/56072529/4568747
Answer: Using Fogmeister's answer in obj-C and user3344977's nicely conversion of it to Swift, as well as Tonton's guidance, I came up with the solution:
func scrollViewDidScroll(_ scrollView: UIScrollView)
{
    let pageWidth: CGFloat = imagesCollectionView.bounds.size.width
    let currentPage: Int = Int( floor( (imagesCollectionView.contentOffset.x - pageWidth / 2) / pageWidth) + 1)

    let maximumHorizontalOffset: CGFloat = scrollView.contentSize.width - scrollView.frame.size.width
    let currentHorizontalOffset: CGFloat = scrollView.contentOffset.x

    let percentageHorizontalOffset: CGFloat = currentHorizontalOffset / maximumHorizontalOffset

    if percentageHorizontalOffset < 0.5
    {
        imagesCollectionView.backgroundColor = fadeFromColor(fromColor: colorsArray[currentPage], toColor: colorsArray[currentPage + 1], withPercentage: percentageHorizontalOffset)
    }
    else
    {
        imagesCollectionView.backgroundColor = fadeFromColor(fromColor: colorsArray[currentPage - 1], toColor: colorsArray[currentPage], withPercentage: percentageHorizontalOffset)
    }
}

func fadeFromColor(fromColor: UIColor, toColor: UIColor, withPercentage: CGFloat) -> UIColor
{
    var fromRed: CGFloat = 0.0
    var fromGreen: CGFloat = 0.0
    var fromBlue: CGFloat = 0.0
    var fromAlpha: CGFloat = 0.0

    // Get the RGBA values from the colours
    fromColor.getRed(&fromRed, green: &fromGreen, blue: &fromBlue, alpha: &fromAlpha)

    var toRed: CGFloat = 0.0
    var toGreen: CGFloat = 0.0
    var toBlue: CGFloat = 0.0
    var toAlpha: CGFloat = 0.0

    toColor.getRed(&toRed, green: &toGreen, blue: &toBlue, alpha: &toAlpha)

    // Calculate the actual RGBA values of the fade colour
    let red = (toRed - fromRed) * withPercentage + fromRed;
    let green = (toGreen - fromGreen) * withPercentage + fromGreen;
    let blue = (toBlue - fromBlue) * withPercentage + fromBlue;
    let alpha = (toAlpha - fromAlpha) * withPercentage + fromAlpha;

    // Return the fade colour
    return UIColor(red: red, green: green, blue: blue, alpha: alpha)
}

Now, when the user starts scrolling to the next/prev page, the background color will slowly change due to color alpha change in percentageHorizontalOffset.
Thanks to all mentioned!
Answer: If the change of colour needs to be in sync with the scroll, ie, gradually changing the colour, you would probably want to the changes in scrollViewDidScroll using the scrollview from your collectionView
By getting the 2 background image colour (perhaps using Mike JS Choi's answer), you can compare their differences. Using the scroll value from 0 to 1, you can change the colour gradually.
Use some local variable to let the method know what is your current image
func scrollViewDidScroll(_ scrollView: UIScrollView) {
    let scrollValue = (scrollView.contentOffset.x / UIScreen.main.bounds.width) - 1

    guard let nextColor: UIColor? = getBackgroundColor(from: nextImage) else { return }

    let currentImage = getBackgroundColor(from: currentImage)

    let currentIndex = pageControl.currentPage

    if scrollValue != 0 {
        backgroundColor = colorDifference(current: currentColor, next: nextColor, transitionValue: abs(scrollValue))
    } else {
        backgroundColor = nextColor
    }
}

func colorDifference(current: UIColor, next: UIColor, transitionValue: Int) -> UIColor {
    var currentRed: Float = 0
    var currentGreen: Float = 0
    var currentBlue: Float = 0
    var currentAlpha: Float = 0
    current.getRed(&currentRed, green: &currentGreen, blue: &currentBlue, alpha: &currentAlpha)

    var nextRed: Float = 0
    var nextGreen: Float = 0
    var nextBlue: Float = 0
    var nextAlpha: Float = 0
    next.getRed(&nextRed, green: &nextGreen, blue: &nextBlue, alpha: &nextAlpha)

    let finalRed = (nextRed - currentRed) * transitionValue
    let finalGreen = (nextGreen - currentGreen) * transitionValue
    let finalBlue = (nextBlue - currentBlue) * transitionValue
    let finalAlpha = (nextAlpha - currentAlpha) * transitionValue

    let finalColor = UIColor(colorLiteralRed: finalRed, green: finalGreen, blue: finalBlue, alpha: finalAlpha)
    return finalColor
}

So you will have to figure out how to store your current image is and getting the next image (which you could be scrolling forwards and back), then use those within the scrollViewDidScroll method.
glhf fam
Answer: The tricky part is to find a color corresponding to each picture. I once used TDImageColors which worked just fine : https://www.cocoacontrols.com/controls/tdimagecolors
Then all you have to do is transition from one color to another. As in @Tonton answer.


Formatting history command using \t instead of space as separator

Question: Is it possible to format history command output using tab separator instead of space between fields?
I know the variable $HISTTIMEFORMAT is there another variable to format the output?
For example:
command_number{\t}date_time{\t}command{\n}

It doesn't have to be a specific shell.
Comment: does not apply for fish: fish history just prints the command. fish does not have history expansion, so `!` does not apply
Comment: `$HISTTIMEFORMAT` is unique to Bash. It does not exist in other shells.
Comment: Check if `history | column -t` is the output you are looking for (you might have to install package `bsdmainutils`), and if yes, define a shell alias or function that does that.
Comment: @HuHa it's not, since this command replaces the space in each command with a tab also.
Comment: Why would you need that?  A split to separate id from command seems the more obvious method.
Answer: Without knowing your exact purpose, here is a way to remove leading whitespaces, and also replace the default "double space" (separating the columns with ID and Command) with a \t instead:
history | sed 's/^[ \t]*//;s/ \+ /\t/'

The sed expression is 2-part:

s/^[ \t]*//: This part removes any leading spaces or tabs (if you for some reason want to start each line with a \t, do this instead: s/^[ \t]*/\t/).
s/ \+ /\t/: This part replaces 2 or more spaces with a \t.

The order is important, since you want to first remove any leading whitespaces, and afterwards replace any 2 or more spaces with \t. If you just run the 2nd part, you also risk getting \t at the beginning of lines with smaller ID numbers.
With this, you hopefully have some building blocks to continue customizing your command. If you also want to add timestamp to the history, it gets a little more complicated, since there are additional single spaces separating the columns.
A little inspiration came from this post.


Visual Studio 2017 Pro - XAML Designer crashes by create a new Project

Question: since a few days i have the problem if i create a new wpf project in Visual Studio 2017 Pro the XAML Designer crashed with an exception like this:
System.Runtime.Remoting.RemotingException
[] Der Designerprozess wurde unerwartet beendet.
bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain.Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IIsolationDomain.CreateInstance(String assemblyName, String assemblyCodeBase, String typeName)
bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.Initialize()
bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)
bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedObjectFactory.Initialize()
bei Microsoft.VisualStudio.DesignTools.DesignerHost.Services.VSIsolationService.CreateObjectFactory(IIsolationDomainFactory isolationDomainFactory, IObjectCatalog catalog)
bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationDomainFactory domainFactory)
bei Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.CreateLease(IIsolationDomainFactory domainFactory, CancellationToken cancelToken, DesignerServiceEntry& entry, IServiceProvider serviceOverrides)
bei Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func2 func, CancellationToken cancelToken) bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.<>c__DisplayClass10_01.b__0()
bei System.Threading.Tasks.Task`1.InnerInvoke()
No Solution i have found on the Web works for me...
I have uninstalled Visual Studio, uninstalled all SDK's and installed Visual Studio after reboot but nothing works...
Has Anybody an idea for me
Comment: Is it fully updated?  you can start VS is safemode, if that works its likely an corrupt extension, if not you might need to do a repair or reinstall. Also if this is Core Wpf, i think its still a little buggy
Comment: How i can start in save mode?
Comment: `devenv.exe /SafeMode`
Answer: I found some methods here. If it can't solve your problem, you could report this problem in the Developer Community.
Answer: Here is the steps I would take:

Make sure your Visual Studio is fully up-to-date
Start Visual Studio in safe mode devenv.exe /SafeMode (this loads only the default environment and services.)

2.1 If that works it's likely a corrupted extension. try and uninstall some of your extensions, and third-party tools
2.1 You can also check the VS logs Devenv /log LogFile, this might give you more information about the error

Repair visual studio
Reinstall visual studio

If you are fully updated and still can't get it to work, I would consider making a bug report with Visual Studio.
How to report a problem with Visual Studio or Visual Studio Installer
Comment: Sorry, but all this steps wasn't helpfull... any other ideas?
Comment: All? Or select steps?
Comment: @RenéKolbe if nothing works (which I don't belive) you need to talk to the vender. This should happen, it doesn't happen for me, or lots of other people. It's thr software or your environment, or both
Comment: Hi @all,
now i give up... I've uninstall the VS2017 completly, ihave deleted all Files and Folders after uninstall, i have clean up the registry manualy and uninstall all SDK's... then i have installed the VS 2017 clean but always the same :-(
Thanks for help!
Answer: my solution for this Issue works. I've done the following steps:

i uninstalled VS 2017
i uninstalled all SDK's
i clean up and delete all Visual Studio Folders in c:\program and c:\program x86 and in user\appdata and so on
i have clean up the registry and delete all entries by "Visual Studio"
after this i installed Visual Studio 2017 on my "D" Drive

An now it works fine...
Comment: I am glad to hear that your problem has been solved, you can click '✔' to mark your reply as an answer.


Error with pip install [url]

Question: I'm attempting to install a plugin for Trac and would like to not use easy_install since there is no uninstall for packages installed that way.
So I issued:
# pip install https://trac-hacks.org/svn/accountmanagerplugin/tags/acct_mgr-0.4.4

And this happened:
Collecting https://trac-hacks.org/svn/accountmanagerplugin/tags/acct_mgr-0.4.4
  Using cached https://trac-hacks.org/svn/accountmanagerplugin/tags/acct_mgr-0.4.4
  Cannot unpack file /tmp/pip-fOSusX-unpack/acct_mgr-0.4.4 (downloaded from /tmp/pip-B6tUyR-build, content-type: text/html; charset=UTF-8); cannot detect archive format
Cannot determine archive format of /tmp/pip-B6tUyR-build

When I browse https://trac-hacks.org/svn/accountmanagerplugin/tags/acct_mgr-0.4.4/, I'm seeing some unpacked files on a server and not an archive.
Is there a way I can download all of those, archive them to a tar.gz or something, and would pip then be able to install?
Or is there a flag with pip that will let it work with non-archived packages?
Comment: Try `pip install svn+https://trac-hacks.org/svn/accountmanagerplugin`.
Answer: You'll need to specify the scheme svn+https:
# pip install svn+https://trac-hacks.org/svn/accountmanagerplugin/tags/acct_mgr-0.4.4

Error with pip install [url]


How to create magic geters and setters for doctrine ORM Entity in ZF2?

Question: Hello I am new to ZendFrame work... I have followed some basic tutorials to build modules using doctrine orm.. I have successfully completed all the tutorials.
What I am trying now is to create Entities with magic getters and setters like this rather than coding all the getters and setters for each properties of entity class:
/* Magic getter to expose protected properties.
     *
     * @param string $property
     * @return mixed
     */

public function __get($property) {
    return $this->$property;
}

/**
 * Magic setter to save protected properties.
 *
 * @param string $property
 * @param mixed $value
 */
public function __set($property, $value) {
    $this->$property = $value;
}

This is how I used to handle the form in the controller:
        $user = new User();
        $builder = new DoctrineAnnotationBuilder($entityManager);
        $form = $builder->createForm($user);
        $form->setHydrator(new DoctrineHydrator($entityManager,'Module/Entity/User'));
        $form->bind($user);

        if($this->getRequest()->isPost())
        {
              $form->setData($this->getRequest()->getPost());
              if($form->isValid()) {
                $u = $form->getData();
                var_dump($u);exit();
              }
        }

When i submit the form with correct data the form submits without any error but the properties of User object in the form are null:
object(Module\Entity\User)[272]
  private 'id' => null
  private 'firstname' => null
  private 'lastname' => null
  private 'email' => null
  private 'password' => null
  private 'rdate' => null
  private 'role' => null

This may be because Form object only relays on getters and setters of the object class binded to it.... but I am not sure... :(
Is there any solution for magic getters and setters to work with zend forms??
Answer: First of all, this has nothing to do with Zend Framework 2. The DoctrineObject hydrator is responsible for hydrating the object.
Secondly, you instantiate the hydrator incorrectly. If you look at its source, the second parameter is a boolean value indicating whether the public API of the entity should be used (getter/setter methods) or not.
Because you pass a string, it always evaluates to true which instructs the hydrator to actually use getter and setter methods, and because such methods does not exist, they are not getting called.
If you wish to bypass any class logic and just fetch/set values from the object with Reflection, you should instantiate the hydrator that way:
$form->setHydrator(new DoctrineHydrator($entityManager, false));
However, this is a terrible idea in the OOP world - bypassing logic, using magic methods. Beginners tend to create such shortcuts. Follow some good tutorials on how to create good, maintanable code as I'm not going to cover such topics here.
Comment: Thnx @mike I was following the tutorial in which they passstring in the second argument I thought it may be name space to the class...
Comment: Official tutorial is outdated :)


A false Variable Doesn't Validate as false

Question: I am having trouble understanding some weird behavior in my code and I am wondering if anyone can tell me what I am doing wrong?
I have a Boolean variable isWaiting and it is saved as false in localStorage and when it is retrieved, it is shown as false but when you do validation, it doesn't see it that way. Here is a small code to replicate my issue:
(function(){
    localStorage.setItem("isWaiting", false);
    var isWaiting = localStorage.getItem("isWaiting");
    console.log("isWaiting = " + isWaiting)
    console.log("Is isWaiting False? " + Boolean(isWaiting === false));
    // I have tried it as this as well
    console.log("Is isWaiting False? " + (isWaiting === false));
})()

Should get:

isWaiting = false
Is isWaiting False? true

Produces:

isWaiting = false
Is isWaiting False? false ⬅ This is clearly wrong, so why is this happening?

What am I doing wrong? Is the boolean value of false somehow getting mangled in the localStorage process and if so, how would I account for it, if not, then what is wrong?

Solution Update:10/09/18
Based on the kind replies helping me confirm that indeed my suspicion that the LS process is butchering the value type was correct and more specifically the solution provided by @bhojendra-rauniyar, I have changed the code to correct the type right at the moment of retrieval and then handling it as normal throughout the code avoiding having a ton of added code and it seems to have done the trick, thank you to all for your help.
...
    var isWaiting = Boolean(JSON.parse(localStorage.getItem("isWaiting")));
...

Comment: another useful thread https://stackoverflow.com/questions/7061702/store-booleans-in-javascripts-localstorage
Comment: @Narendra thank you for linking that, which was a duplicate, but following down the rabbit hole, I found (https://stackoverflow.com/questions/3263161/cannot-set-boolean-values-in-localstorage) which suggests a reason but it was posted back in 2010, does it still hold true I wonder?
Answer: Local storage stores the value in string. So, even if you use Boolean('false') will return true. Because it's not empty string. Anything that has value in string is to be true. To get around this, you may use:
Boolean(JSON.parse('false')) // false
Boolean(JSON.parse('true')) // true

So, you can do:
Boolean(JSON.parse(isWaiting))

Alternatively, you may also compare with string:
String(false) === 'false' // true

So, using:
console.log(String(isWaiting)) // will return false

Comment: Thank you, while the solution presented by others below would be less code, I think I like the stability and assurance of your method. I am going to try and test the code fix and if that resolves it then I will be back quick to mark it.
Answer: localstorage sets values as string.
In your example
Boolean(isWaiting === false) -> false
but if you check
Boolean(isWaiting === 'false') -> this will give you true
Comment: Ok, so you are suggesting just validate the string itself, thank you I didn't expect that LS would turn everything string only, live and learn.
Answer: LocalStorage will save values in the string and you cannot compare a string to boolean. So you need to compare it like this:
(function(){
    localStorage.setItem("isWaiting", false);
    var isWaiting = localStorage.getItem("isWaiting");
    console.log("isWaiting = " + isWaiting)
    console.log("Is isWaiting False? " + Boolean(isWaiting === 'false'));
    // I have tried it as this as well
    console.log("Is isWaiting False? " + (isWaiting === 'false'));
})()

Comment: Yes, thank you, Narendra gave the same technique and Bhojendra provided an alternative, so I think I can get make due for now.


Graph Theoretic model plan? Combinatorics

Question:
For the next Olympic Winter Games, the organizers wish to expand the number of teams competing in curling. They wish to have 14 teams enter, divided into two pools of seven teams each. Right now, they're thinking of requiring that in preliminary play each team will play seven games against distinct opponents. Five of the opponents will come from their own pool and two of the opponents will come from the other pool. They're having trouble setting up such a schedule, so they've come to you. By using an appropriate graph-theoretic model, either argue that they cannot use their current plan or devise a way for them to do so.

I'm stuck on the way to draw the graphs. I have graph drawn to fit one pool, however I'm not sure how to show the opponents of the second pool.
Comment: Please don't simply post homework problems here for others to do. If you have attempted the problem yourself, explain where you got stuck. And give the source of the problem, as well. You can edit the post to add this information.
Comment: What have you tried? What is does the graph of an acceptable configuration look like?
Comment: Yes, sorry its edited now.
Answer: Hint: Look at the graph of a single pool first. There are $7$ nodes, one for each team, and an edge drawn between them if they are playing. Each node has degree $5$.


android.os.BadParcelableException: ClassNotFoundException when unmarshalling

Question: We are facing getting a BadParceableException and we have no idea why. Above is the stacktrace:
    Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.my.app/br.com.my.app.commons.ui.MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.appcompat.widget.AppCompatSpinner$SavedState
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2789)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
       at android.app.ActivityThread.-wrap11()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6543)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

Caused by android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.appcompat.widget.AppCompatSpinner$SavedState
       at android.os.Parcel.readParcelableCreator(Parcel.java:2925)
       at android.os.Parcel.readParcelable(Parcel.java:2851)
       at android.view.AbsSavedState.<init>(AbsSavedState.java:67)
       at android.view.View$BaseSavedState.<init>(View.java:25139)
       at android.view.View$BaseSavedState.<init>(View.java:25128)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState.<init>(DefaultOptionSpinner.java:193)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState.<init>(DefaultOptionSpinner.java:185)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState$1.createFromParcel(DefaultOptionSpinner.java:206)
       at br.com.my.app.commons.ui.custom.DefaultOptionSpinner$SavedState$1.createFromParcel(DefaultOptionSpinner.java:204)
       at android.os.Parcel.readParcelable(Parcel.java:2860)
       at android.os.Parcel.readValue(Parcel.java:2754)
       at android.os.Parcel.readSparseArrayInternal(Parcel.java:3204)
       at android.os.Parcel.readSparseArray(Parcel.java:2416)
       at android.os.Parcel.readValue(Parcel.java:2811)
       at android.os.Parcel.readArrayMapInternal(Parcel.java:3123)
       at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
       at android.os.BaseBundle.unparcel(BaseBundle.java:226)
       at android.os.Bundle.getSparseParcelableArray(Bundle.java:1009)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:772)
       at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
       at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
       at androidx.fragment.app.FragmentManagerImpl.dispatchCreate(FragmentManagerImpl.java:2607)
       at androidx.fragment.app.FragmentController.dispatchCreate(FragmentController.java:235)
       at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:316)
       at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:115)
       at br.com.zalf.prolog.commons.ui.MainActivity.onCreate(MainActivity.java:129)
       at android.app.Activity.performCreate(Activity.java:7009)
       at android.app.Activity.performCreate(Activity.java:7000)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2742)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
       at android.app.ActivityThread.-wrap11()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6543)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

We saw some similars errors here in stackoverflow, but no one actually worked for us.
The exception is saying that the error happens at "super(in)", in this class:
private static class SavedState extends BaseSavedState {
int mSelectedPosition;
SavedState(Parcelable superState) {
    super(superState);
}

private SavedState(android.os.Parcel in) {
    super(in);
    this.mSelectedPosition = in.readInt();
}

@Override
public void writeToParcel(android.os.Parcel out, int flags) {
    super.writeToParcel(out, flags);
    out.writeInt(this.mSelectedPosition);
}

public static final Parcelable.Creator<SavedState> CREATOR =
        new Parcelable.Creator<SavedState>() {
            public SavedState createFromParcel(android.os.Parcel in) {
                return new SavedState(in);
            }

            public SavedState[] newArray(int size) {
                return new SavedState[size];
            }
        };

}
Does anyone have any idea to help us?
Thanks!
Answer: I found a solution. It is needed to indicate a bootloader as constructor parameter. I did it inside the second constructor:
private static class SavedState extends BaseSavedState {
        int mSelectedPosition;

        SavedState(Parcelable superState) {
            super(superState);
        }

        private SavedState(android.os.Parcel in) {
            super(in, DefaultOptionSpinner.class.getClassLoader());
            this.mSelectedPosition = in.readInt();
        }

        @Override
        public void writeToParcel(android.os.Parcel out, int flags) {
            super.writeToParcel(out, flags);
            out.writeInt(this.mSelectedPosition);
        }

        public static final Parcelable.Creator<SavedState> CREATOR =
                new Parcelable.Creator<SavedState>() {
                    public SavedState createFromParcel(android.os.Parcel in) {
                        return new SavedState(in);
                    }

                    public SavedState[] newArray(int size) {
                        return new SavedState[size];
                    }
                };
    }


WCF unable to read data from transport connection

Question: I'm having troubles with my WCF application. When i run the client application and it tries to connect to the server i get the following exception:

unable to read data from the transport connection an existing connection was forcibly closed by the remote host.

when i debug from the system where the service is hosted the application runs fine.
When i tried to debug it from an other pc i get this error.
from this other PC i can open the WSDL file (of the server application) in the browser so the server can be found.
Comment: It might be a good idea to turn on WCF tracing:  http://msdn.microsoft.com/en-us/library/ms733025.aspx - then use the trace viewer - you may see a serialization exception or something.
Comment: This seems like an annoying problem to fix/debug. It looks like the server closed the connection for one reason or another. It may be a server exception closing the call. That the server can be found does not mean that the server can be connected too. Please give more information about the server/client setup and write a little test harness to see if you can get the basics to work.
Comment: Binding/Protocol/Port ? It sounds like a firewall issue.
Comment: Didi you resolve this issue ? please guide me... i am facing same issue
Comment: Me too facing same issue, I am using WCF REST, First Get Request work fine, second POST request fine, all of sudden it start failing in third request which is GET, only change i made is to return json, instd of XML :(
Comment: Are you, by chance, using Entity Framework within your WCF service?
Answer: I agree with user1039947 - absolutely enable end-to-end tracing, because that error message ends up meaning roughly eight thousand different issues, none of which have much to do with (on the surface, at least) the connection being closed.
That being said, once you view the trace, or if for some reason you are unable to enable tracing (but this is your service, so I imagine you can), the culprits I see most often are:

Binding mismatch
Using an interface or abstract type in your data contract
Not using data attributes on your properties and classes when they inherit from an interface or abstract class.

At least you know you're hitting the server. If you can't get the tracing logs, and none of those are the issue, you also could always open two instances of Visual Studio, start a new debugging session of the service host in one, then connect to it from a debugging session of the client in the other. Then you can track down where in the processing the exception is getting thrown. Very often it's in the data serialization (i.e., #2 and #3).
Comment: thanks the project has already been closed so can't test anymore but hopefully it will help others


If I download a shared Playstation game and then buy it, will I keep all my progress?

Question: If I downloaded a game off my friend's account on my PlayStation and then I decide to buy the exact game, would I lose all my progress on the game or not? I'm currently confused as to what to do, and I'm scared of buying it then downloading it and losing all my progress.
Answer: PSN game saves are tied to the account you were signed in to when you play the game.  So if you download the game with your friend's account, switch to yours, and play it, your save created with your account will transfer.  Note, though, that you can only play the game if your friend has set the console this is done on as their primary console.


Access django by WAN IP instead of domain

Question: I'm using the pydanny-cookiecutter, and during the initial prompts, I gave a domain that I no longer wish to use.
How can I update to just be able to access the service by the WAN IP of the digital ocean droplet I am running in?
So far I've opened ports 5000 and 5555 in the droplet and manually (ssh into postgres container) inserted a new record into django_sites with ID 2 and the domain and name both as the WAN IP. I've also updated the SITE_ID=2 in the settings base.py.
I've uploaded the traefik.yml to the following, but still unable to reach the pages when I go to WANIP:5000 or WANIP:5555
log:
  level: INFO

entryPoints:
  web:
    # http
    address: ":80"
    http:
      # https://docs.traefik.io/routing/entrypoints/#entrypoint
      redirections:
        entryPoint:
          to: web-secure

  web-secure:
    # https
    address: ":443"

  flower:
    address: ":5555"

certificatesResolvers:
  letsencrypt:
    # https://docs.traefik.io/master/https/acme/#lets-encrypt
    acme:
      email: "<REDACTED>@gmail.com"
      storage: /etc/traefik/acme/acme.json
      # https://docs.traefik.io/master/https/acme/#httpchallenge
      httpChallenge:
        entryPoint: web

http:
  routers:
    web-secure-router:
      rule: "HostRegexp(`<REDACTED WAN IP>`)"
      entryPoints:
        - web-secure
      middlewares:
        - csrf
      service: django
      tls:
        # https://docs.traefik.io/master/routing/routers/#certresolver
        certResolver: letsencrypt

    flower-secure-router:
      rule: "HostRegexp(`<REDACTED WAN IP>`)"
      entryPoints:
        - flower
      service: flower
      tls:
        # https://docs.traefik.io/master/routing/routers/#certresolver
        certResolver: letsencrypt

  middlewares:
    csrf:
      # https://docs.traefik.io/master/middlewares/headers/#hostsproxyheaders
      # https://docs.djangoproject.com/en/dev/ref/csrf/#ajax
      headers:
        hostsProxyHeaders: ["X-CSRFToken"]

  services:
    django:
      loadBalancer:
        servers:
          - url: http://django:5000

    flower:
      loadBalancer:
        servers:
          - url: http://flower:5555

providers:
  # https://docs.traefik.io/master/providers/file/
  file:
    filename: /etc/traefik/traefik.yml
    watch: true

Thanks!
Answer: Please note that if you use an IP, the SSL certificate generation will not work, and so that'll throw a warning in browser saying :

it's a dangerous site.

What you want to do is open up ports 80 and 443 in the droplet, and access the application through http://[IP].
No ports in the links because you are configuring Traefik to route http (port 80) and https (port 443) requests to Django.
This is not a solution for flower, but I don't have much experience with flower to say.


What are some recommended UX Certification programs?

Question: I have a degree in Distance Education and E-learning. I am suddenly interested in UX/UI. I thought about getting a master's degree in UX but a certification program may be more useful.
What are some useful certification programs from reputable schools that I should consider?
Comment: Questions that are not directly related to actual UX problems and to do with training and education are best discussed in chatrooms or in other forums such as Quora, where there are already plenty of topics and answers.
Answer: you can look at Nielsen Norman Group certification  : https://www.nngroup.com/ux-certification/
Answer: Congrats on this decision!
There are SO many of this type of program, and with such different foci and scope that you want to have some idea of what you want to get out of it, and do good research into the programs that will meet those goals.
My personal "gold standard" is the bootcamps offered by Bentley University (where I did my grad program). It looks like they've changed their format for non-degree classes somewhat, but they have several offerings from a couple of days to a week that offer broad skills and certification.
Another good option to look at, at least as a first pass, is the Google UX Design certificate, which you can still do largely for free on Coursera, I believe. If you have LinkedIn premier you have access to LinkedIn Learning which has a number of excellent UX courses that can give you some digital credential upon completion. There are MANY others, from free online-only courses to fully immersive programs from prestigious academic institutions.
Definitely have some idea what your goals are! Career pivot, larger paycheck, certain types of work, new industry, specific skills... there are a lot of reasons to look into educating yourself, and knowing what those are will help you weed through the options to find what is right for you.
Also try to understand what each program will give you. Some of these courses will focus on "full stack" UX, giving broad overviews of everything from requirements gathering, generative research, and information architecture through workflows and wireframes, prototyping, visual design, usability testing, front end development; others will focus more squarely on one or another part of the UX spectrum. Some may include aspects of human physiology and psychology that can be very valuable to know as underpinnings of things like gestalt design principles and color choices; others may include actual coding and programming essentials to make you a better collaborator with your development partners, or content development and management.
A possibly fruitful path: Take one or two free, "broad-spectrum" online overview programs to get a sense of all the different aspects of UX that a well-rounded UX professional should be at least FAMILIAR with, and then determine which of those really spark your curiosity and find a more in-depth program for that.
In fact, if you want a pretty solid, quick overview to the UX field and ideas for how to break into it, I led a presentation on this very thing at my last company - it was aimed at young folks trying to break in to the field; the concepts in this recording still hold for anyone new to the field, and the resources links at the end could be very useful.
https://vimeo.com/manage/videos/564775896
Also note that if you want credentials to prove you've got some skills you'll need to generally pay more for the certificate or degree; free programs that provide badges and completions are good and the curricula can be very valid and useful, but they might not carry the same cred with employers unless paired with experience and/or portfolio material.
Good luck! It is an exciting and still very badly needed (if still misunderstood) field - let me know if I can help any further.


is second argument in vswprintf_s size of buffer or numberofElements

Question: vswprintf_s : msdn link
int vswprintf_s(
   wchar_t *buffer,
   size_t numberOfElements,
   const wchar_t *format,
   va_list argptr
);

I'm confused about the second element since MSDN states it to be:
numberOfElements Size of buffer.
However name of the argument suggests otherwise: actual number of elements to be copied into output buffer
So, if I were to have:
void print(wchar_t* format, ...){
wchar_t outString[1024];

va_list arguments;

va_start(arguments, format);
vswprintf_s(outString, sizeof(outString), format, arguments);
va_end(arguments);
}

Should I have that (size of buffer) OR:
vswprintf_s(outString, sizeof(outString)/sizeof(outString[0]), format, arguments);

Let me know.
Answer: It's the number of elements.
If you look at a more recent version of the MSDN documentation (remove the (v=vs.80) portion of the URL you cited), it says:

numberOfElements: Size of buffer in characters.

(And "characters" means logical characters (code units, actually), not chars.)
Generally the "wide" versions of Windows functions use character counts, not byte sizes.


How can I make heads in minecraft have specific players skins?

Question: Are there any commands that allow you to use a player's skin on the default heads in Minecraft?
Comment: Related: http://gaming.stackexchange.com/questions/203836/ho-to-get-minecraft-heads-from-a-specific-player-skin
Answer: <code>/give username minecraft:skull 1 3 {SkullOwner:"Notch"}
</code>
Replace the "username" with the player you wish to give the head to (i.e. yourself). Then replace the "Notch" with the player whose skin you would like on that head.
This will work on PC Minecraft 1.7+


Android AndEngine LeadBolt integration

Question: I just finished my android app and I want to try LeadBolt ads.
LeadBolt information:

Java code:
<code>    @Override
public void onLoadComplete() {
    // TODO Auto-generated method stub
    myController = new AdController(this, "169901169");
    myController.loadAd();

}
</code>
LeadBolt notification isn't shown. Why?!
Answer: You are running notifications, but in your code you have the following lines :
myController = new AdController(this, "169901169");
myController.loadAd();
Please change them to (as mentioned in the PDF documentation):
myController = new AdController(getApplicationContext(), "169901169");
myController.loadNotification();
The notification ads should then be working correctly.
Comment: I changed:
myController = new AdController(getApplicationContext(),"169901169");
myController.setAsynchTask(true);
myController.loadNotification();

but does not work :(
Answer: Notifications requires more operations. First of all, change Manifest, then follow LeadBolt documantation

Android AndEngine LeadBolt integration


What can I do about a house with internal concrete floor with no DPM?

Question: My partner and I have just bought our first home.A 1950's bungalow which is need of refurbishment. So far it has thrown us a ton of surprises! The worst so far being the floor in one of the bedrooms. After pulling up the old floor boards we found a concrete poured floor underneath with broken bitumen on it. The concrete has gaps of about 4 inches between it. These concrete "slabs" are separated by very rotten wood.  On closer inspection the concrete is only about 3-4 inches thick with soil directly under that. No damp-proof membrane (DPM)!The depth of the gaps is roughly 10 inches. The damp-proof course (DPC) in the walls seems to be intact.
I think the floor used to be a suspended timber floor but the previous owner decided to pour concrete under the floor boards and between the joists maybe using them to level the concrete and just left them there to eventually sponge up any moisture and rot away.
However, as it stands the concrete feels and seems dry. Possibly because the house is in an elevated position.
I know the best solution would be to dig up existing concrete, dig further down maybe 30 inches then put down insulation board , followed by a DPM and then pour concrete. Unfortunately we don't have the budget to do this.
As a cheaper alternative I have thought about filling the gaps with concrete, then applying an epoxy solution all over the floor, then floating a wooden floor on top of this. However i'm not to sure how to do the concrete mix for this, how much aggregate is required etc.
Here are some images of the floor. I have dug out the rotten timbers.

Any thoughts or recommendations besides the expensive approach would be appreciated
Comment: A late question: what's "DPM" and "DPC"?
Comment: @DanielGriscom DPM = damp proof membrane; DPC = damp proof course
Answer: (I'm assuming that you are in the UK).
Concrete floors without DPM are not unusual in houses of that age, so there is a possibility that it's not a cowboy job. The broken bitumen you mention was probably the remnants of an asphalt DPM over the slab. The wood has (as you suggest) likely been used to level the concrete. If they were previously joists for a suspended floor, some have certainly been removed, as the spacing is way to wide for floor joists.
Without ripping the floor up, I can see two basic options:
1: Fill the gaps with concrete and get an asphalt company to lay an asphalt screed over it to restore the DPM.
2: Fill the gaps with concrete, lay a DPM over it, insulation, then a concrete / fibre screed. Note though that this will raise the floor level by 75-100mm (depending on the insulation).
In terms of concrete, as it looks like it's not a structural element, you could just use a "basic" 4:2:1 concrete mix (4 parts stone, 2 parts concreting sand, 1 part OPC). Add enough water to make it workable, but not so that it gets sloppy.
Comment: Correct I am in the UK. I'm not to keen on option 2 as this would lead me to raising the floor throughout the house and adjusting all doorways etc. I'm pretty sure the same issue exists in every room.

What does "OPC" stand for is that the one part cement? Also should i dig slightly under the existing slabs for a better concrete "bond"?

Rather then asphalt I was thinking about using something like this:
http://www.f-ball.co.uk/product_detail.asp?product=F75&catID=damp

Thanks
Comment: Sorry, OPC is Ordinary Portland Cement - just the bags of cement you can get from DIY stores and builders merchants (some has plasticiser already in for mortar - you don't need that). I wouldn't bother digging under as it won't really help any with bonding. If you really wanted to bond, you could drill into the slabs and use a piece of reinforcement, but I'd not bother. That product sounds like it could do what you want it to do.
Comment: Thanks i'm actually thinking i'm going to go for a tanking slurry. its  product by these guys : http://www.kabuildingproducts.co.uk/page_2350337.html
Answer: I just purchased a house in the United States, Pennsylvania to be specific by a lake and I was considering pouring concrete over the floor which is identical to the floor pictured above. However I was told that this type of floor was designed this way for drainage should water enter the space...makes sense to me now. The wood floors that have since been pulled out were warped because a moisture barrier was not present. I plan on getting expert advice before doing something like pouring concrete that would block the egress of any water between the slabs of concrete.
Comment: This response is actually more commment than answer to davey's question. Recommending expert advice is close to being an answer, but it needs to be qualified. Why is expert advice important, or why would you suspect that the question could not be answered with merit here on the DIY stack exchange?


Multiplicative system in the ring

Question: Let $R$ be a commutative ring with unit element. A nonempty subset $S$ of $R$ is called multiplicative system if
$1. \  0\notin S$
$2. \ s_1,s_2\in S$ implies that $s_1s_2\in S$.
Let $n=pq$ where $p,q$ are prime numbers. We know that $\mathbb{Z}_n$ is a ring with addition and multiplication modulo $n$. Consider the $\mathbb{Z}_n^{\times}=\{x: 1\leq x<n, \ \text{gcd}(x,n)=1\}$.
It's easy to check that $\mathbb{Z}_n^{\times}$ is multiplicative system.
What if we consider $\mathbb{Z}_n^{\times}\cup \{p\}$? I have checked that this is not multiplicative system.
Am I right? If yes, can anyone suggest some other example of multiplicative system in $\mathbb{Z}_n$ distinct from $\mathbb{Z}_n^{\times}$?
Comment: Well, that is not a multiplicative system because $\;pq=0\;$ and $\;0\notin\Bbb Z_n^*\;$ ...And you can take, in a general ring $\;R\;$ , **any** prime ideal $\;I\;$, and then $\;R\setminus I\;$ is a multiplicative system. This is probably the most important example in algebraic number theory, commutative algebra, algebraic geometry and stuff...
Comment: @DonAntonio, Thanks for reply!
Comment: @DonAntonio Are you assuming that also $q\in S$?
Comment: @HagenvonEitzen I was until your comment, so the first part of the first line of my comment is incorrect. Thanks.
Answer: The multiplicative closure of $\{p\}\cup \Bbb{Z}_n^\times$ , namely $\{x: 1\le x< n, \gcd(x,q)=1\}$ is a multiplicative system distinct from $\Bbb{Z}_n^\times$.
Comment: Why the multiplicative closure of $\{p\}\cup \mathbb{Z}_n^{\times}$ is the set which you've written?
Comment: $\Bbb{Z}_n^\times$ is everything without $p$ or $q$ in its factorization.  Letting in $p$ means you have to be able to multiply by any power of $p$, so now you have everything without $q$ in its factorization.

Multiplicative system in the ring


Good colors to indicate presence (in/out)

Question: I'm designing an app that allows people to indicate if they are in or out of the office. When they change state, I'm showing a pop-up screen with an in icon or an out icon.
Currently the background colour for this pop-up is green for arriving and red for departure. Someone suggested that this might not be so good for color blind people.
I was thinking maybe black logo on green background for arrival and white logo on dark grey background for departure? Any other thoughts?
Comment: Given Bevan's response, I suggest making the 'in' icon look like a shining light indicator, while leaving the 'out' icon dull (like an LED which is turned on/off).  The shining effect could be achieved by surrounding the 'in' icon with a little "glow" effect, and adding a few rays radiating outwards.  (Lens flare is also an option, but might be going too far!)
Answer: You don't need to avoid colours to provide support for colour-blind people, you just need to make sure colour isn't the only thing to use.
Check out the "jelly bean" presence indicators used by Microsoft Office Communicator:
         Office Communicator http://neuralyte.org/~joey/images/ux.se/UQY2K_greyscaled.jpg
(Image taken from here)
The indicator for "Available" has a double-ring; "Do Not Disturb" has a horizontal bar and the other three are basically "not available".
I'd suggest that instead of changing the background of the popup, include a prominent icon to indicate the new status - with sufficient difference in shape or detail (e.g. the double ring for "Available" shown above) that colour isn't necessary to the perception, just a nice extra.
Two last comments.
Firstly, you can do much worse than copy UX ideas from companies that spend millions of dollars on the research.
Secondly, I'm writing from the perspective of someone who has a colour vision defect (for example, the "Be Right Back" and "Away" jelly beans look the same to me, but I can tell the rest apart).
Comment: They look the same because they are the same!
Comment: According to the eyedropper tool in Paint.Net, "Be Right Back" is slightly more yellow than "Away" - at least on my work PC. Interestingly, in the screenshot I used above, they *are* the same - can't explain the difference.


Binding for Evernote's android-job

Question: Has anybody got the binding working for Evernote's android-job https://github.com/evernote/android-job ?
Funnily Xamarin docs mention it in an example:
https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/troubleshooting-bindings/#Problem_Name_Collisions_on_Inner_Classes_Properties
I tried to follow https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-an-aar/ but it doesn't generate the JobManager class
Answer: Xamarin binding for android-job on GitHub
What is it?
The Xamarin Android-Job binding allows you to utilize Evernote's android-job library for Android, to run jobs in the background efficiently and robustly. The library checks the Android version on the client device to determine the best method for performing scheduled background work. It will use the most appropriate method for the OS such as JobScheduler, GcmNetworkManager, AlarmManager or WorkManager.
How to use it:
Step 1:
Download the Xamarin binding for Evernote's android-job library.
Step 2:
Build the binding project in Release Mode, then grab the android-job.dll file from the bin/release folder. Add this dll to your own project and reference it.
Step 3:
Add the following into your Android Manifest, within the Application node, for the services and receivers to work properly.
<service android:name="com.evernote.android.job.v21.PlatformJobService" android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name="com.evernote.android.job.v14.PlatformAlarmService" android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name="com.evernote.android.job.v14.PlatformAlarmServiceExact" android:exported="false"/>
<receiver android:name="com.evernote.android.job.v14.PlatformAlarmReceiver" android:exported="false">
  <intent-filter>

    <action android:name="com.evernote.android.job.v14.RUN_JOB"/>
    <action android:name="net.vrallev.android.job.v14.RUN_JOB"/>
  </intent-filter>
</receiver>
<receiver android:name="com.evernote.android.job.JobBootReceiver" android:exported="false">
  <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"/>
    <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
    <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
    <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
  </intent-filter>
</receiver>
<service android:name="com.evernote.android.job.gcm.PlatformGcmService" android:enabled="false" android:exported="true" android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE">
  <intent-filter>
    <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
  </intent-filter>
</service>
<service android:name="com.evernote.android.job.JobRescheduleService" android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE"/>

Also, make sure you have the following permissions:
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

Step 4:
Make sure you have the following references within your project (can be installed via Nuget):

Xamarin.Android.Support.Compat
Xamarin.Android.Support.v4
Xamarin.GooglePlayServices.Gcm (Not required, but will work better and support even more devices)

Step 5:
Create a class for your Job that will be scheduled:
Tip: Refer to the android-job GitHub page for examples of configuring different types of jobs i.e. periodic, one-off, etc.
using Com.Evernote.Android.Job;

namespace MyNamespace
{
    public class MyJob : Job
    {

        public const String TAG = "job_myjob_tag";

        protected override Result OnRunJob(Params parameters)
        {
            // run your job here
            return Result.Success;
        }

        public static void ScheduleJob()
        {
            new JobRequest.Builder(MyJob.TAG)
                .SetRequiresDeviceIdle(false)
                .SetRequiredNetworkType(JobRequest.NetworkType.Connected)
                .SetPeriodic(900000, 300000)
                .SetUpdateCurrent(true)
                .Build()
                .Schedule();
        }

        private void CancelJob(int jobId)
        {
            JobManager.Instance().Cancel(jobId);
        }

    }
}

Step 6:
Create a factory method for your Job/s:
using Com.Evernote.Android.Job;

namespace MyNamespace
{
    public class MyJobCreator : Java.Lang.Object, IJobCreator
    {
        public Job Create(string tag)
        {
            switch (tag)
            {
                case MyJob.TAG:
                    return new MyJob();
                default:
                    return null;
            }
        }

    }
}

Step 7:
Initialise the JobManager singleton, ideally within your GlobalApplication.OnCreate method. If you can't, there's an alternative.
JobManager.Create(this).AddJobCreator(new MyJobCreator());

Step 8:
Schedule your job! You could do this from your starting activity OnCreate method, or wherever you like. For example:
MyNamespace.MyJob.ScheduleJob();

Tips:

The work done within OnRunJob(...) method should be Synchronous, or otherwise not return a Result until all work is finished.
Be careful not to instantiate the same job multiple times. Utilize SetUpdateCurrent on the job builder, or check whether the job already exists by calling JobManager.Instance().GetAllJobRequestsForFlag(MyJob.TAG).

Credit & Reference:

Credit to Dooks123 for the android-job Xamarin.Android binding and Android Manifest configuration instructions.
Credit to Evernote for the android-job library
Comment: Hi. Thanks for taking time to write this.
Comment: Have you used the binding yourself?
Comment: Yes, I implemented it just before I wrote that article. It works well..

Binding for Evernote's android-job


Better alternative to tab targeting?

Question: Decided to start playing through all the classes from scratch to experience firsthand the changes that 5.0.4 have wrought. I'm now up to a Warlock, and I've become painfully reminded of just how inconsistent (and sometimes, lethal) tab-targeting can be.
That being said, is there some sort of mod out there (or heck, even in-game fix that I'm missing) that'd make DOT'ing things up a bit less tricky and less hunt (through the mayhem of a mass of mobs)-and-clicky? Gotta spread the Corruption a lit more uniformly amongst the masses!
A good example of something similar would be Decursive, a neat li'l mod I used on the healing side to streamline decursifyin' things back in the day.
Comment: Mouseover macro targeting may be useful: http://worldofmacros.com/articles/wow-macro-guides/wow-mouseover-target-macro-guide.html
Comment: @Lin An exceptional answer, I'd completely forgotten about the mouseover possibility of macros. Thank you.
Answer: As a former warlock, I feel you pain there.
Like most features of WoW it takes a long time to get a UI built around your preference, and preferences vary dramatically from player to player (I've seen some UI's that make my toes curl).  My warlock's skills consisted of almost exclusively macros to help with targetting.
Here's a small list of targetting assistance I've used to avoid excessive tab usage.
Arena
Gladius is a terrific add-on that's almost vital for arena.  Along with the great customizable UI to keep track of players, it also allows you the ability to build in specific targetting macros.
<code>/target arena1
</code>
This will target the first player on your gladius frame.  By setting up keybinds for my most common arena setups (2's and 3's) I could quickly dot both targets without ever having to tab or click anyone.
Mouse-over
Ok, you've probably noticed this by now.  But the theme here is macros.  As a warlock a lot of the 'one time' spells you use lend themselves very well to mouse-over macros.  Things like banish and fear are natural fits.
<code> /cast [target=mouseover,exists] Lifebloom
</code>
Focus Targets
This is a must as a warlock, the ability to fight two people (or monsters at once) is vital.  In addition to the ability to dot both, you can also enable their casting bars for that well timed silence.
Summary
While this list is by no means exhaustive, it should help you get started and building out your own customization.  Dot timer's can be invaluable as a warlock, as it will allow you the ability to keep track of former targets better as well.  There are some addons that help with targetting such as gladius, but most players make extensive use of macros and focus targets.  You can find Azael's macros here (arguably the best pvp warlock) which should give you an idea of how to set up some of the more gritty macros.
http://www.arenajunkies.com/topic/210672-azaels-macro-list/
Hope this helps.
Comment: Wouldn't your macro be better stated as `/cast [target=mouseover,exists][] Lifebloom`?
Comment: Awesome in-depth answer. Thank you!

Better alternative to tab targeting?


How to Configure Ubuntu to Access Internet only with Wifi Ignoring Wire Connection (Ethernet)

Question: Context:

the Wifi connection works perfectly with the DHCP of the router. Only with this connection, I can navigate the web.
the wire connection is necessary for me to be connected directly with an embedded system. In the middle, there is a Switch and the only thing I do is to set up the address IP of both (laptop and embedded system). The systems speak perfectly using ssh etc. No problem here.
OS Xubuntu 16.04 on my laptop and a Linaro on the embedded (please note: the problem is the same for 18.04 and the solution proposed in the answer works properly).

Problem:
When I am connected to the system with the ethernet connection, it is impossible for me to navigate on the web. I guess it is because the laptop tries to access using the ethernet connection. Of course, the ethernet connection goes only to the embedded system (no web from this side).
Question:
Can I use the ethernet only for the system and the wifi to continue to navigate the web pages? How can I do that?
Please note: I would like to use both (1) the wifi to navigate and (2) the ethernet for the embedded system AT THE SAME TIME. Separately they work perfectly
Comment: I will try it some hours
Comment: The ethernet does not use dhcp but a static address assigned by me only to communicate with the embedded system
Answer: I have a similar setup with an Ubuntu 18.04 LTS with both Ethernet and WiFi connection. The WiFi connects to the router and the Internet. The Ethernet cable connects to a Raspberry Pi.
For Ubuntu 16.04, this answer may be useful: Connecting PC and RaspberryPi using LAN cable
The instructions below are for Ubuntu 18.04
Go to System Setup menu > Network tab on the left margin > The cog icon for the Wired connection as shown below:

Go to the IPv4 tab of the Wired Connection and check the box Use this connection only for resources on its network as shown below.

That was all. I let the desktop assign the IP by DHCP and changed the Pi's setting to request a specific IP address from the desktop. It works for me.
If you manually assign IP addresses then do not specify any Gateway IP address in this setting. A Gateway is not needed in this setup and will confuse the kernel-level packet routing. Thanks Thomas Ward.
Hope this helps
Comment: I have just found it and works. And I do not use dhcp. I will write another answer with the solution on my OS! This was a great help!! thank you!
Comment: +1 because it solve the problem when using ubuntu 18.04. With XUbuntu 16.04 this option does not exist. Any suggestion?
Comment: @Leos313 I am glad I could point you to the right direction and you found the setting in XUbuntu 16.04. Please write your own answer and accept it as the correct one. This will help others.
Comment: For some reason the "Apply" button grey's out once I check that box at the bottom.  Any idea how to actually apply this change?
Comment: @Peter Is IPv4 method set to automatic?
Comment: No it was on Manual (I realized when I set it to Automatic I could again click "Apply").  Though that didn't solve my "internet stopping when I plug in ethernet" problem
Comment: @Peter I don't have this setup any more. So I can't tell you how to fix it.
Comment: I know this is a bit old but for anyone with the same issue as Peter you cannot provide a gateway when you check the box. This makes sense because you are telling it you can only use addresses in it's range which doesn't require a gateway.
Answer: Thanks to @user68186 I have found the solution on Xubuntu 16.04:
Double click on the network connection (in my case the little symbol of wireless on top-right)

Choose > Edit connection... and select the connection you want to edit (in my case the Wire Connection 1):

From the window that will be open, select the tab IPv4:

Organize the network as you prefer (in my case no DHCP but a P2P connection with a little embedded system and a switch in the middle). Now press Routes on the bottom-right side and select the option Use this connection only for resource on this network:

Press Ok and Save the setup.
The wifi for internet and the ethernet for the P2P are working perfectly at the same time. Thanks @user68186
Answer: Another wonderful solution (unfortunately not considered in the beginning) consists of creating an ethernet connection so that the internet access through the wifi is also shared with the embedded system. The solution is very easy to be implemented (and further details can be found surfing on the web, here for an example):

open Edit connection...
create (or open the existing) Wire connection
in the IPv4 Settings tab, select Method: Shared to other computers. This is the main difference with the other solutions for this answer:

Nothing more should be done in the "server part" (i.e., the workstation). You will see that the computer creates its own network. Click on Connection Information to see it or, from the command line, type ifconfig and look the take note of the address, sub-mask, and the other parameters for the ethernet connection (for example under eth0 in my case).
The embedded system (for example a raspberry PI connected with the eth cable) should use the just-create network, using the parameter that you have just observed.
CONCLUSION: that way, you will be able to access the system (using ssh or what you want) and, at the same time, have free access to the web (in case you need to download new packets or programs).


Unable to connect to SQL server using vb.net

Question: I am using Connection string in my web.config. I have given user id, password, data source etc in the connection string. When i tried to connect to the SQL server using "Connection.Open()" I am getting an exception stating The user is not authorized. The user name that is mentioned is my windows user name(yes my windows user name and not the one mentioned in connection string). I am not sure why and how this is happening. I tried several times and the same thing is happening.
Comment: You'd have to show your connection string - (though you can mangle the user/PW info)
Comment: Try testing your connection by [using the Data Link Wizard](http://stackoverflow.com/a/10480011/205233) and compare the generated connection string against the one you use in your we.config.
Comment: Are you using window authentication or SQL authentication to login to sql server?
Comment: @Filburt is right.  Data Link Wizard is always my first step in troubleshooting a DB connection string.
Answer: If you believe that VB.NET is part of the problem, try using the same connection parameters from the same client, but with different client software. For example try connecting from Access or SQL Server Management Studio or Excel. This will help you narrow down whether your problem is with the security configuration versus the code or client software. Often times if you try to connect from a remote workstation you can end up with a failure against a server that has not been configured to allow remote connections.


Any possible way to handle an action between WKWebView and Browser for selecting an image in iOS?

Question: I want to upload a static image on select of button (as described in below screenshot) <input type="file"> on the web url from my app using WKWebView.
On click of Choose File button it will open default action sheet of device and after the selection of image, it will be uploaded on server. I want to interrupt the flow and upload my static image instead of user's selected image.

Is there any observer or listener so from there we can handle request and response. Upload an image using form-data API is not available.
Comment: I know this is not going to solve your issue, but what exactly are you trying to achieve? Why have a file input if you will ignore it? Why not just send your static image to your server without this useless interaction?
Comment: The problem is we don't handle the server and it's the requirement @MihaiFratu
Answer: You can get a callback from WKWebView's element click action but you need to play with JavaScript code and the JSVirtualMachine which will help to get a callback in your swift class. and then you can do any action on click as like normal action
You can follow this link


Windbg loads symbols from an altered location

Question: Using the symbols window(CTRL + S), i have set WinDbg to load my symbols from a specific location.

Now when i attach my debugger and try to view the stack window, it seems like symbols aren't really loaded properly.

Now, when i use the !sym noisy command and .reload /f, i get the following info from the debugger:

So, from the third picture, why is SYMSRV is even defined? and why is it adding the GUID prefix to the end of the file?
It would've worked if it wasn't that guid windbg adds to the path. What am i doing wrong.
EDIT: after reviewing the log furthermore, i see that the debugger attemps to load the symbol from the local drive.
Comment: Windbg has some default search paths preset it will always look for symbols in those path if it  cant find symbols in the preferred path what is the problem
Comment: @blabb, As mentioned, i have defined symbol's path and verified that access is plausible via network. but according the logs, windbg appends GUID to file's name (i believe it tries to download it using windows' symbols server)
Comment: What's the output of `.sympath`?
Comment: The format of directory to symbol path is basedirr/modname/guid/actualsymbolfile. Ieit can be x:/foo/myspecsym/blah.pdb/123456vvvvxxxx/blah.pdb
Answer: There are several different formats in which symbols can be stored. These are 0-tier, 2-tier and 3-tier.
0-tier is basically a flat list of files, which is suitable if you have just built your program and all the PDBs are located in one folder. If you enter a local path like c:\path or server share like \\server, WinDbg should consider a 0-tier store layout, but might try others as well.
The problem is that you can only store one version of PDBs in a 0-tier store, which is why the 2-tier and 3-tier symbol stores exist. When symbols are added to such a store, it will consider the GUID, so it is possible to store several versions of the same program. 2- and 3-tier symbol stores should start with srv*. The exact difference between a 2-tier and a 3-tier store is explained in Channel 9 episode 87 and it's possible to convert a 2-tier store into a 3-tier store.
Do not confuse the srv* symbol path syntax with the SYMSRV: debug output. IMHO the SYMSRV: is just a debug message of the symsrv.dll, so nothing to worry about.
The truth about loading symbols can only be monitored with Process Monitor. Not all location where WinDbg searches for symbols are logged, even in the noisy mode.
In addition to the symbol path, DLLs contain a reference to the local path of the PDB and WinDbg will consider this path, independent of the symbol path settings.
Comment: Perhaps (I never tried) you can disable loading from the DLL path by setting `.symopt+ 0x80` (SYMOPT_IGNORE_CVREC)


Uncaught ReferenceError: someFunction is not defined

Question: Why do I get Uncaught ReferenceError: someFunction is not defined here?:
HTML

custom.js:
$(document).ready(function(){
    function someFunction() {
        // Do something
    }
});

Comment: Your `someFunction()` is in a document ready function. Which means it wont be available until the document is ready. Take it out of this and it should be available on the global level.
Comment: It's not in the global scope mate :-)
Answer: Change this :
$(document).ready(function(){
function someFunction() {
    // Do something
}
});

to :
function someFunction() {
    // Do something
}


Dynamically changing an svg image element depending on data from mySQL DB

Question: I am trying to change an svg element depending on data from a mySQL DB.
For example, I have created an svg image in adobe illustrate that has a rectangle for a table and 4 circles as chairs around the table.
I would like to denote each chair as a 'person' and when that 'individual' logs in, the chair would change to a different color and change back when they log out.
I have used php and mySQL for the login aspect and that all works. This would be a graphical representation of the login.
When the data is changed in mySQL (I have a login time-stamp), the image element would also change. I need javascript to do this but I am stumped.
I would like to know if the above scenario is even possible and if so which direction should I take or are there any other alternatives?
I have looked at jquery and raphael js but this is the first time I am working with vector images and any assistance is greatly appreciated.
EDIT ~
I have taken a good look at Raphael JS and I made a php query to MySQL and display the filtered results onto an html page.
How do I link up MySQL DB with my SVG image so each SVG element will change according to my filtered results?
Comment: try canvg() , let me know
Answer: There are completely no limitations to what you want to achieve, it is actually quite common when using svg . If you have no experience with svg you could take a look at thirt party library such as d3 or RaphaelJS
Answer: This is indeed possible, although from the way you phrased the question it seems like you may be missing some steps:

When your MySQL data changes, the server must notify the client (browser) of this event somehow. Options for this include server-sent events (SSE), websockets, and long-polling. I recommend using SSE, and this looks like a useful question about using them: Server-sent events and php - what triggers events on the server?
When the browser receives notification of the change from the server, it must update the graphic. This is where you want to use a tool like d3 or Raphaël (I think you will find the latter a bit easier to use in this case). You should be able to formulate a more specific question once you get to this point, if needed.
Comment: I am using long-polling, AJAX. I agree SSE is a better choice but I have to use IE. I will take a closer look at Raphael. Thanks.


Can I take my slime downstairs?

Question: I have an ability called "Slime-Herder" that allows me to conjure an ally slime. Is it possible to make this slime follow me when I go downstairs?
I've been trying with no success.
Answer: No, I don't believe so.  It's not spelled out anywhere in the documentation or on the Dredmor wiki, but I've died and rerolled many a character, some who could summon different types of pets, (along with various wands that have pet effects) and none of my pets has ever traveled down stairs with me.

Can I take my slime downstairs?


Creating responsive menus not working

Question: I'm in the process of creating a personal website so I'm not 100% sure what the content breakpoints will be. I'm using 320px (phone), 768px (tablet), and 1024px (desktop) for now. I don't know if I need one specific to tablets as they can probably use full screen, but I have it in place just in case.
I'm having trouble showing the menu links inline when at full screen and I can't figure out how to get a drop down menu when in mobile view mode. I have the meta viewport set to device-width, and 1.
I would like the in-line mode to hover over each one to show a background color with 8px x 20px padded. I'm trying to avoid javascript and jquery all together if possible. And without floats too.
HTML

Home

Blog

Contact

https://jsfiddle.net/xpu9bxjc/
Any help would be greatly appreciated!
Comment: Don't set breakpoints for devices...set them for when your design **needs** them...if  that happens to be at 743.25px so be it.
Comment: I agree with @Paulie_D. Also, in your fiddle, it looks like you have the mobile style for medium+ screens, while your non-mobile style is shown if you shrink the screen to a mobile size. Change your media query to `max-width` instead of `min-width` to correct this.
Comment: I reversed the min/max and got it working the way i want it in regards to displaying inline on larger screens. However, how can I set the drop down in mobile mode?
Comment: Also, wouldn't min-width be better, as it can scale to higher resolutions as they become available on devices? Or does it not make a difference?
Comment: It's just a matter of how you want to apply your styles. If you use min-width, inside that media query you would supply styles for screen sizes >= the value you specify, then smaller screens would use the default styles outside of your media query. If you use max-width, then inside that media query you would supply styles for screen sizes <= the value you specify, then larger screens would use the default styles outside of your media query.
Comment: It depends on which screen-size you want to focus on. I believe the more common approach is to design your site for medium or large screen sizes, then determine breakpoints and use max-width media queries to supply styles for tablet and mobile views.
Comment: That way you can include all the content you want on a large size screen, then scale down components, or remove unnecessary ones to better utilize screen space on smaller devices.
Answer: In your fiddle, you have your mobile menu showing up on screen sizes that are medium and up, while your non-mobile menu is showing when you shrink to a mobile size screen.
To fix this, change your media query from:
@media only screen and (min-width: 320px) {

to:
@media only screen and (max-width: 320px) {

For adding the hover effect, you want to add :hover to your selector, then apply whatever styles you want on hover in there.
.nav-menu a:hover {
    /* put hover styles here */
}

Updated these in your fiddle.
Comment: Awesome. I will try this out tonight and see how it works. Thanks!

Creating responsive menus not working


After installing expansion tank, massive buildup of pressure then a trickle?

Question: I am completely stumped.  You guys helped me out a lot with my previous question here: What could be causing water to drip from the relief valve of my new gas water heater?
Turns out the expansion tank bladder was filled with water and needed to be replaced.  I got a new 2 gallon 100 psi max expansion tank but before putting it on I measured the water pressure at around 100 psi which seemed awfully high to me.  When I turned a faucet on the pressure would drop to around 50 psi and I would get a steady stream of moderate pressure.  It seemed to steady at around 68 psi so I used that as a good starting point.
Instructions that came with the tank said to install at 2 psi below normal cutoff pressure.  Thinking that was awfully specific, I set the air pressure in the new tank to 65 psi and installed it.
I ran the faucets a LOT to make sure I got all the air pockets out but now I notice bizarre fluctuations in my water pressure for the past few days.  I have normal water pressure in the basement, acceptable water pressure on the first floor, and virtually NO pressure at all on the upstairs floor, where this was never a problem before.
Leaving the gauge on downstairs the pressure would slowly continue to rise as high as 100 psi at times EVEN AFTER seriously turning the pressure regulator back.  When I turn the water on I get a good stream of water then 5 seconds later nothing but a trickle as the water pressure only reads 20 psi when the water is running.
So now I only see four possibilities:

The gauge is broke, there is no flippin way that I have my pressure regulator turned back that far and actually have 100psi build up in the pipes all the way from 20 psi.
The pressure regulator is broke, it is extremely old looking and doesn't have a PSI reading on it, just a hex bolt head that when turned out will decrease the pressure.
The new expansion tank is defective and slowly leaking air into the system causing me to have almost no pressure upstairs
I set the air pressure too high/low in the new expansion tank and it is causing havoc with my internal pressure.

About the only positive thing I can say about everything is that my safety relief valve on the water heater is no longer leaking water so I must have done something right.  Maybe I just need to increase the pressure to the house but if my pressure increases to 100 psi slowly while the water heater runs and I have an expansion tank rated for 100 psi then I am afraid I could be creating a dangerous situation.
Any suggestions?  I am going crazy over this and I stink because I can't take a proper shower ;)
Answer: Sorry to hear about your "odor" problem. Maybe there is a local public fountain you can take a dip into!!!
However, the problems you describe are fairly common, but may be tricky to isolate. Let's try some basics:
 Relieve the pressure from the bladder completely. Let the well pump fill the tank completely  and bleed any air from the system using the faucets with the pump running. Again, with the tank full of water, close all outlets and charge up the bladder to about 60PSI.  Most systems work fine between 45 to 65 PSI. Anything over 70 is pushing it. The tank needs to be charged when full, not empty.
Monitor the pressure as you draw water. Does the pump kick on constantly when the pressure reaches the low limit, and off at the high limit? This will help tell if the regulator is working properly.
Is there any pulsating water pressure at the faucets?
When you are sure you have a full tank, no air in the system, is your second floor water flow ample when the tank is reading 60psi?
There are a few "if's" here. Depending on how the pump behaves and the pressure responds, you have to determine if the problem is with the pump and volume of water being delivered to the tank, or if the pressure regulator is properly operating.
If you are still seeing any pulsating water pressure at the taps, then the bladder is water logged again.  If the bladder pressure drops too quickly, then most likely the volume of water from the pump is low. The pressure should remain fairly constant at the tank if all the functions of the pump and regulator are working properly.  Good Luck
Comment: My municipal water has high pressure. And either my PRV or the city's meter has a backflow preventer, so when the hot water tank heats up, the pressure jumps in my home.
Comment: I missed the well pump, assumed the PRV indicated high pressure from the municipality. You're thinking otherwise? +1 for the public fountain shower! :)
Comment: Usually public water supplies run at around 70psi and don't require an additional pressure tank.  I have never seen a tank used in a small residential home with public water unless in a very low pressure area which would be very uncommon and require  completely different regulation as there is no "on/off" like with a well pump.
Comment: I may be misunderstanding his problem. maybe he is talking about a small pressure tank off a furnace slaved to hot water only?????
Comment: @shirlockhomes Thanks but it is municipal water.  It is coming from outside at a high pressure which is why the water authority insists that all homes have a regulator.  It is a 2 gallon expansion tank on the cold line so increased water pressure from the water heater doesn't damage fixtures in the home.
Comment: My water pressure from the city (Fremont, CA) is typically 120 PSI. I put in a pressure regulator that takes it down to 60 PSI.
Answer: If you're seeing it climb to 100psi while the water heater isn't running, then the pressure regulator is broken.
If it's climbing to 100psi while the water heater is running but stays at normal levels all other times, the expansion tank isn't working. Maybe it's defective, or maybe it's not installed properly. It's also possible the tank is undersized for your hot water heater.
If you have full pressure upstairs, but just not enough flow, then you may have a blockage in your pipes. A common place to check for blockages are valves that you hadn't used in a long time but recently shutoff and reopened and aerators or filters in the fixtures.  I'd also take a 5 gallon bucket, place it under your best faucet, and see how fast you can fill it. Then compare that time to how long it takes to do the same at your neighbor's home. Use process of elimination to track down any blockage. If it's every faucet, then you probably have a problem on your main line. If it's only one fixture, then check it's valves, aerator, and any filter.
Comment: How do I tell if I have normal pressure small flow?  I am guessing it is both low pressure and low flow.  Good lord I hope it is not a blockage somewhere, how would I even go about finding a problem like that?!
Comment: You'd need to get that pressure gauge on one of the high fixtures. You may be able to get a piece of flex hose and an adapter to connect at the shutoff valve under the sink or toilet.
Comment: One tell tale sign of high pressure is a difficult to open valve or a sudden burst when you first open the fixture. I'd also keep an eye out for leaking toilets.
Comment: Then it is high pressure then because I have both sudden burst and leaking toilets.  That means when I installed the expansion tank I must have introduced something that blocked the flow.  Any tips on how to locate the blockage?
Comment: @maple_shaft Any shutoff valves that hadn't been used in a long time before your repair are the first suspect. The washers inside tend to degrade over time and either don't close all the way or fall apart when reopened. If you've been adjusting the PRV, it's also possible something in there has broken. But for an easy test, try removing the aerator on the sink to make sure you didn't knock a bunch of sediment loose.
Comment: The only shutoff valve I turned off was the main line shutoff in the basement just before the meter.  If that was bad then I wouldn't even know how to replace it because I think they would have to shut the water off at the street.  I am at a loss, I think its time to call a plumber.
Comment: @maple_shaft you can also remove the shower head to make sure the blockage isn't in there. See if the water flows out quickly without the shower head on. Reinstalling it only requires a little teflon tape.
Answer: Municipal Water systems require a Pressure Reducing Valve (PRV).
It is not recommended to have the house psi above 90. 70 is the norm in most municipal systems. An expansion tank is needed if there is a check valve installed on the in line. If there is a water meter, there is an excellent chance of one being installed. Many water utilities mandate check valves, or also known as RPZ's on their systems, also.
An expansion tank is needed after the meter/check valve. This is due to the expansion of water in the heater (or boiler). If the water pressure drops considerably while running a faucet, it is probably due to a faulty PRV. Adjusting the PRV by turning the adj. screw counterclockwise reduces the psi. Clockwise increases the pressure. (most PRV's). If the pressure is too high, it can wreck even a new expansion tank. Too low of psi, and the bladder will never "squish" to take up expansion. The psi on the in line psi after the PRV, and the precharge on the expansion tank should be the same.
1st step. Check gage after PRV for static water psi read. (nothing running) If the psi is higher than 70, adjust it. Run the water and then turn it off, and read the gage. Repeat as necessary.
    If the proper static psi cannot be achieved (by staying where you had it reading, and not climbing), then condemn and replace the PRV.
2nd step -  install a precharged to house psi expansion tank.
 Run the water and observe. There will be a psi drop as water runs. It should not be a large drop. That would mean a partially closed valve somewhere or an obstruction. When the water is off, the psi should only return to the set 70 psi. Not climb higher. Again, that means a defective PRV.
 Hope the class helps.


Autolayout constraint to a point at a _percentage_ of a view's width?

Question: Consider the following simple diagram:

Our goal is to align some arbitrary point along the width of the yellow view with the horizontal center of the black view. The position and size of the black view, and the size of the yellow view, are unknowns; they can change depending on the circumstances. (In real life, the yellow view is a label whose size depends on its contents, which are dynamic.)
Now then:

I know how to align the leading anchor of the yellow view with the horizontal center of the black view.
I know how to align the trailing anchor of the yellow view with the horizontal center of the black view.
I know how to align the horizontal center of the yellow view with the horizontal center of the black view.

But that's not what I want to do. I want to be able pick an arbitrary percentage of the yellow view's width — say, as in the diagram, about 25% — and align that point with the horizontal center of the black view. This percentage can change in real time, depending on other circumstances.

My first impulse was to tie the yellow view's horizontal center to the black view's horizontal center and give the constraint a multiplier; but that just resulted in a compile error.
So I have to come up with a workaround. Here are some solutions that occurred to me:

Probably the most obvious solution is to add to the yellow view an invisible subview pinned to the leading edge of the yellow view, and whose width is set as a percentage of the yellow view's width. Then the desired constraint is to the invisible view's trailing edge, and (as a mathematician would say) we have reduced the problem to a previously solved problem. (I call this a "spacer" view.)

A less commonly known but actually quite easy solution is to use a layout guide attached to the yellow view. This works exactly like the invisible spacer subview, but it isn't a subview and so we avoid the extra overhead of an unwanted view.

Those solutions are very nice, but is there a solution using just a constraint? It seems I cannot translate the concept "the width of the yellow view", or "a percentage of the width of the yellow view", into a value that I can tie a constraint to.
Answer:
It seems I cannot translate the concept "the width of the yellow view", or "a percentage of the width of the yellow view", into a value that I can tie a constraint to.

Actually, yes you can. There is an incredibly clever and obscure solution built into UIKit and autolayout. (It is sufficiently obscure that I didn't know about it until yesterday, even though I've been doing this sort of thing ever since autolayout was invented.)
Dimensional values in autolayout, such as a view's widthAnchor, are NSLayoutDimension objects. It turns out that you can form a "dynamic" NSLayoutDimension anchor yourself, using the anchorWithOffset method:
https://developer.apple.com/documentation/uikit/nslayoutxaxisanchor/2866024-anchorwithoffset
So, in the example in my question, let the yellow view be called movableView and let the black view be called fixedView. Then we can say:
let anchor = movableView.leadingAnchor
    .anchorWithOffset(to: fixedView.centerXAnchor)

What we now have is not a constraint. It's a dimensional anchor, similar to widthAnchor; in particular, it is the horizontal distance between the leading edge of the leading anchor of the yellow view and horizontal center of the black view. The point is that we can now form and activate a constraint upon  that anchor. This is a constraint which, like a widthAnchor constraint, describes the anchor's length, and for which, like a widthAnchor constraint, we can supply a multiplier. Here it is:
let multiplier: CGFloat = // value representing the desired percentage
let constraint = anchor
        .constraint(equalTo: movableView.widthAnchor, multiplier: multiplier)

Then:

If the multiplier is 0, the yellow view's leading anchor and the black view's center X anchor are directly aligned.

If the multipier is 1, the yellow view's leading anchor and the black view's center X anchor are aligned with an offset equivalent to the yellow view's width. But that is the same as saying that the yellow view's trailing anchor and the black view's center X anchor is aligned!

And so too for any value in between. If the multiplier is 0.5, the horizontal centers of the views are aligned. If the multiplier is 0.25, we get the image shown in the question: the black view's horizontal center is aligned with a point 1/4 of the way along the width of the yellow view.

So if we now activate constraint, we get the desired result.

While writing this Q&A, I was not completely convinced that anchorWithOffset was a better solution than any of my proposed workarounds. Possibly a layout guide was a sufficient solution. Was anchorWithOffset really needed?
But in formulating and reconsidering this answer, I'm more and more convinced of the power and value of this neglected autolayout feature. anchorWithOffset has the advantage of existing in a world of pure one-dimensionality, without even the overhead of a layout guide's two-dimensionality. And unlike a layout guide, it isn't a workaround here; it is the thing itself that I was looking for! An anchorWithOffset allows us to do exactly what the question asks to do: define a certain distance, and then set its size with a constraint that can refer to other sizes and can have a multiplier. It lets us follow one of my favorite rules of programming: SWYM (Say What You Mean).
I do appreciate that this is not the first time anchorWithOffset has been mentioned here. I did find some Stack Overflow answers that propose the use of this method. But they were about equal or otherwise fixed distribution; they didn't describe the use of an arbitrary and variable multiplier in the constraint.
Comment: The concepts and syntax here are so difficult to wrap one's head around that I've embodied this solution in a demo project that you can download and run and play with: https://github.com/mattneub/anchorWithOffset
Answer:
My first impulse was to tie the yellow view's horizontal center to the black view's horizontal center and give the constraint a multiplier; but that just resulted in a compile error.

No errors if using old fashion NSLayoutConstraint(item:,attribute:,relatedBy: ,toItem:,attribute:,multiplier:,constant:)
You just need horizontally align yellow view with its superview (superview will have the same unknown size like yellow view).
Then you can align views using horizontal center:
NSLayoutConstraint(
    item: blackView,
    attribute: .centerX,
    relatedBy: .equal,
    toItem: superview,
    attribute: .centerX,
    multiplier: 2 * proportion,
    constant: 0
)

Comment: P.S. I suggest to not use autolayout if you have such requirement. It will be easier just to set frames in `layoutSubviews`.