How can I check how many times my iPhone or iPad has been charged?

On my Macbook Pro, I can see in the “About this Mac”->System Report->Power link how many times the laptop has been charged. It lists the condition (currently as “Normal”) on my laptop. I’ve seen it say something like “Needs Attention” or “Service Battery” when the laptop has over 500 cycle counts.

Is there an app that shows me that same information on my iPhone or iPad? I would like to know this information for the future if I buy a used iPhone or iPad. I don’t want to buy one where there’s over 1000 cycle counts and the battery doesn’t hold a charge longer than 30 min.

I’ve tried a couple battery life apps on my phone but it doesn’t tell me the cycle count. It just tells me the wear level and a percentage, which isn’t exactly what I’m looking for.

Refactor if statements that check for different conditions

Preface: I’ve perused the other related questions before creating this one but I believe that those solutions weren’t applicable to my situation. I’ll concede that its possible that I may not have understood a possible solution (if any).

I’m working on refactoring an old poker game that I created, which is a .NET Framework console application, and I came across this method.

    /// <summary>     /// Evaluates the value of the player hand and computer hand.      /// </summary>     /// <param name="pComputerHand">The computer's current hand.</param>     /// <param name="pPlayerHand">The player's current hand.</param>     /// <returns>Returns true if the player won and false if the player lost. This value is stored in the the bool won variable.</returns>     private static bool CompareHands(SuperCard[] pComputerHand, SuperCard[] pPlayerHand)     {         // Stores the value of the player and computer hands.         int playerHandValue = 0;          int computerHandValue = 0;          // Evaluates the value of computer hand         foreach(SuperCard card in pComputerHand)         {             computerHandValue += (int)card.CardRank;         }          // Evaluates the value of player hand         foreach(SuperCard card in pPlayerHand)         {             playerHandValue += (int)card.CardRank;         }          // If there is a royal flush in the computer's hand and the player's hand, the player lost.         if (PokerHands.RoyalFlush(pPlayerHand) & PokerHands.RoyalFlush(pComputerHand))         {             Console.WriteLine("\nBoth players have a royal flush!");             return false;         }          // If there is a royal flush in the player's hand, the player won.         if (PokerHands.RoyalFlush(pPlayerHand))         {             Console.WriteLine("\nYou have a royal flush!");             return true;         }          // If there is a royal flush in the computer's hand, the player lost.         if (PokerHands.RoyalFlush(pComputerHand))         {             Console.WriteLine("\nThe computer has a royal flush!");             return false;         }          #region Straight Flush         // If there is a straight flush in the computer's hand and the player's hand, the player lost.         if (PokerHands.StraightFlush(pPlayerHand) & PokerHands.StraightFlush(pComputerHand))         {             Console.WriteLine("\nBoth players have a straight flush!");             return false;         }          // If there is a straight flush in the player's hand, the player won.         if (PokerHands.StraightFlush(pPlayerHand))         {             Console.WriteLine("\nYou have a straight flush!");             return true;         }          // If there is a straight flush in the computer's hand, the player lost.         if (PokerHands.StraightFlush(pComputerHand))         {             Console.WriteLine("\nThe computer has a straight flush!");             return false;         }         #endregion           #region Four Of A Kind          // If there is a four of a kind in the computer's hand and the player's hand, the player lost.         if (PokerHands.FourOfAKind(pPlayerHand) & PokerHands.FourOfAKind(pComputerHand))         {             Console.WriteLine("\nBoth players have a four of a kind!");             return false;         }          // If there is a four of a kind in the player's hand, the player won.         if (PokerHands.FourOfAKind(pPlayerHand))         {             Console.WriteLine("\nYou have a four of a kind!");             return true;         }          // If there is a four of a kind in the computer's hand, the player lost.         if (PokerHands.FourOfAKind(pComputerHand))         {             Console.WriteLine("\nThe computer has four of a kind!");             return false;         }         #endregion           #region Full House         // If there is a full house in the computer's hand and the player's hand, the player lost.         if (PokerHands.FullHouse(pPlayerHand) & PokerHands.FullHouse(pComputerHand))         {             Console.WriteLine("\nBoth players have a full house!");             return false;         }          // If there is a full house in the player's hand, the player won.         if (PokerHands.FullHouse(pPlayerHand))         {             Console.WriteLine("\nYou have a full house!");             return true;         }          // If there is a four of a kind in the computer's hand, the player lost.         if (PokerHands.FullHouse(pComputerHand))         {             Console.WriteLine("\nThe computer has a full house!");             return false;         }         #endregion           #region Flush         // If there is a flush in the player hand and the computer hand, the player lost.         if (PokerHands.Flush(pPlayerHand) && PokerHands.Flush(pComputerHand))         {             Console.WriteLine("\nBoth players have a flush!");             return false;         }          // If there is a flush in the player hand, the player won.         if (PokerHands.Flush(pPlayerHand))         {             Console.WriteLine("\nYou have a flush!");             return true;         }          // If there is a flush in the computer hand, the player lost.         if (PokerHands.Flush(pComputerHand))         {             Console.WriteLine("\nThe computer has a flush!");             return false;         }         #endregion           #region Straight         // If there is a straight in the computer's hand and the player's hand, the player lost.         if (PokerHands.Straight(pPlayerHand) & PokerHands.Straight(pComputerHand))         {             Console.WriteLine("\nBoth players have a straight!");             return false;         }          // If there is a straight  in the player's hand, the player won.         if (PokerHands.Straight(pPlayerHand))         {             Console.WriteLine("\nYou have a straight!");             return true;         }          // If there is a straight in the computer's hand, the player lost.         if (PokerHands.Straight(pComputerHand))         {             Console.WriteLine("\nThe computer has a straight!");             return false;         }         #endregion           #region Three Of A Kind         // If there is a three of a kind in the computer's hand and the player's hand, the player lost.         if (PokerHands.ThreeOfAKind(pPlayerHand) & PokerHands.ThreeOfAKind(pComputerHand))         {             Console.WriteLine("\nBoth players have a three of a kind!");             return false;         }          // If there is a three of a kind  in the player's hand, the player won.         if (PokerHands.ThreeOfAKind(pPlayerHand))         {             Console.WriteLine("\nYou have a three of a kind!");             return true;         }          // If there is a three of a kind in the computer's hand, the player lost.         if (PokerHands.ThreeOfAKind(pComputerHand))         {             Console.WriteLine("\nThe computer has a three of a kind!");             return false;         }         #endregion           #region Two Pair         // If there is a two pair in the computer's hand and the player's hand, the player lost.         if (PokerHands.TwoPair(pPlayerHand) & PokerHands.TwoPair(pComputerHand))         {             Console.WriteLine("\nBoth players have a two pair!");             return false;         }          // If there is a two pair  in the player's hand, the player won.         if (PokerHands.TwoPair(pPlayerHand))         {             Console.WriteLine("\nYou have a two pair!");             return true;         }          // If there is a two pair in the computer's hand, the player lost.         if (PokerHands.TwoPair(pComputerHand))         {             Console.WriteLine("\nThe computer has a two pair!");             return false;         }         #endregion           #region One Pair         // If there is a one pair in the computer's hand and the player's hand, the player lost.         if (PokerHands.OnePair(pPlayerHand) & PokerHands.OnePair(pComputerHand))         {             Console.WriteLine("\nBoth players have a one pair!");             return false;         }          // If there is a one pair  in the player's hand, the player won.         if (PokerHands.OnePair(pPlayerHand))         {             Console.WriteLine("\nYou have a one pair!");             return true;         }          // If there is a one pair in the computer's hand, the player lost.         if (PokerHands.OnePair(pComputerHand))         {             Console.WriteLine("\nThe computer has a one pair!");             return false;         }         #endregion          // If the player's hand value is greater than the computer's hand value, the player won.         if (playerHandValue > computerHandValue)         {             return true;         }          // If the player's hand value is less than or equal to the computer's hand value, the player lost.         if (playerHandValue <= computerHandValue)         {             return false;         }          // Satisfies all code paths must return a value error.         else         {             return false;         }       } // end of CompareHands()      

This is what the class diagram for the project looks like: Poker Class Diagram

This is what the console output looks like: Console output

My question is whether its possible to extract a method (or several) out of these if statements, and provided that it is possible, how would I go about doing so? I also appreciate any other advice that you can offer like the regions being bad, for example.

Python Check if Port is in use, otherwise increase it

I have a distributed application (YARN), which runs a WebApp.

This application use a default port to start (8008), before I start I need to check if port is in use.

A container may run in the same virtual machine, hence port may be in use. (Max I have 4 containers in WebApp).

I created the following code which seem to work, but want to see if there are some clean ups/improvements suggested.

def port_in_use(port):     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)     result = sock.connect_ex(('127.0.0.1', port))     if result == 0:       return True     else:       return False   def start_dashboard():         base_port = os.getenv('DASHBOARD_PORT_ENV_VAR', 8008)     scan_ports = True     attempts = 0     max_attempts = 10     while(scan_ports and attempts <= max_attempts):       if port_in_use(base_port):          base_port += 1          attempts += 1       else:          scan_ports = False     if attempts == max_attempts:        raise IOError('Port in use')     dashboard.configure(port=base_port)     dashboard.launch() 

Math Mechanics Perception Check [on hold]

Please forgive me, it’s been over 40+ years since I’ve played DnD and just now trying to reboot the changes. Can someone briefly explain Perception Check math?

Assume I’m a 5 year old or an idiot whichever comes first in your mind.

If a character has a Wisdom of 10 and the DM says “role for Perception Check”… The character then rolls a 1D20 with the hopes of what number ? Higher than or lower than 10 ? Or is it a number only the DM knows about the area/monster/etc..?

Follow up Question: If a character has a high Wisdom wouldn’t the P.C. be easier to achieve ? Assuming a lower roll is easier than a higher roll (yes ?)

Is a Perception Check against an Invisible Target made with Disadvantage?

Here’s the scenario:

  • Creature A is invisible, in an empty room, in an arbitrary location in the room
  • The room is adequately lit (call it Bright Light, for the sake of argument)
  • Creature A is trying to hide (they make a Stealth Check).
  • Creature B enters the room.
  • Creature B is not actively searching for Creature A, so their Passive Perception is compared against Creature A’s stealth check.

Does Creature B’s Perception check have Disadvantage?

I’ve tagged this question rules-as-written to avoid answers that make assumptions about what the rules should do or what they were intended to do, or answers that make assumptions about how rules interact with each other.

what the ‘check the type’ mean and why it need to do that?

I was practice this question on a website. it says that ”Add an .add_grade() method to Student that takes a parameter, grade. .add_grade() should verify that grade is of type Grade and if so, add it to the Student‘s .grades

could anyone please explain to me what “check the type” mean? and when I wrote below coding, the question didnt get checked and pop up a line saying "Does .add_grade() add grade to the instance’s .grades list?". I took a look at the answer, it shows code should write like if type(grade) == Grade:. I could not figure out why

class Grade:   minimum_passing = 65     def add_grade(self, grade):     if type(grade) == type(Grade):       self.grades.append(grade) 

enter image description here

Column Validation check passes on Create but fails on Edit

I’m trying to validate that a month column is within 30 days of the create date in SharePoint online using the validation below:

=AND([Start Month]<(Created+30),[Start Month]>(Created-30)) 

This works as expected when creating a list item, failing when the date is outside of the range, but when editing rows it always gives me an error even if I haven’t changed the Start Month column.

Any ideas what I’m doing wrong?

Validation settings

Error on Edit only

Very old php site, not a CMS, price check for a php7 compatibility update

Hello,

I've got an old site, to which I am sentimentally attached, however its code base is OLD. Not plain old, no, OLD, the uppercase is fully deserved. I didn't write the code base myself (I'm only the latest admin & host to date), I only have enough php skills to maintain it and perform small fixes such as the mysql –> mysqli upgrade many years ago.

At the moment, the site runs under php5.4, on a debian 7 machine, soon due to get an update to Debian 9, which will be the occasion to…

Very old php site, not a CMS, price check for a php7 compatibility update