Reset failed decrypts counter Android 10

Hi everyone!

I have a locked phone (forgotten PIN). And due to many incorrect attempts, the gatekeeper timeout or cooldown period is stuck at 480s.

Is there anyway to reset this failed decrypts counter, so that brute forcing could be done feasibly?

network scanners – is the UDP or TCP protocol best suited for a so called stealth counter scan for open or closed ports

network scanners – is the UDP or TCP protocol best suited for a so called stealth counter scan for open or closed ports – Information Security Stack Exchange

8 – Grouping in Views jumbles row numbers returned by Result Counter

Grouping in a View is being used to show a list of items in a table, each row is numbered using Result Counter. However, the View uses grouping which causes the results to be jumbled. See enclosed image.

Any ideas how to renumber the rows correctly, also is there a way list the row numbers in reverse order.

raycasting – How to find if a Ray intersects a Triangle Clockwise or Counter Clockwise

Assume the triangle’s vertices are wound in the order A, B, C

Form a normal to the triangle N = (B – A) x (C – A)

Now you can detect whether your triangle is clockwise or counter-clockwise by the sign of the dot product between this normal and the ray direction

In a left-handed coordinate system:

• Negative = Clockwise from ray’s point of view
• Positive = Counter-clockwise from ray’s point of view

In a right-handed coordinate system, it’s the opposite:

• Negative = Counter-clockwise from ray’s point of view
• Positive = Clockwise from ray’s point of view

time complexity – Changing binary counter structure such that increament and decreament methods will work in O(1) amortized

Just trying to solve the second part of a question with two parts.
First part was to prove that you can’t add decrement method to a standart binary counter without hurting the amortized complexity and change it to be more than O(1).
This part i have done with no problems.

Solution in a nutshell – after some method you are going to be in a dead end when you have a number like this: 100…0 so when you decrease by 1 you will get 0111…1 and then when you will increase by 1 you will get again 100…0 and those decreasment and increament are cost n and you will do them m times so its not O(1) amortized.

The second part, is to tell how you can change the structure such that it will support decreament and increase methods and the amortized complexity will stay O(1).
I never saw something like this and it really confusing me what they want me to do.
Their solution is that anytime you want to change 0 to 1 you change it to minus 1.
Problem is, i can’t understand what they meant, i mean, on which stracture you are inserting this change and how does it improved the complexity (if you change to -1 you stil going to the same dead end).

python – Could this balance counter code be simpler?

All your `win1`, `win2` and `win3` functions are essentially the same. When you have multiple functions/pieces of code that are nearly identical, look at what parts of them are the same, and what parts are different. Make the identical parts the body of a function, and the differing parts parameters of the function.

In the case of those three functions, they’re all the same; except for the bonus factor. Simply make that a parameter:

``````def win(bonus_factor):
amount_won = bet * bonus_factor
# I did different wins, the win1,2,3 function contains them
print("WIN!WIN!WIN! n You won " , amount_won, "credits! ")
a.append(a(-1) + amount_won)
print("Actual balance : ", a(-1))
``````

Then change the callsite to use the same function:

``````elif reel_1 + reel_2 + reel_3 == 8:
win(6)

elif  reel_1 + reel_2 + reel_3 == 7:
win(4)

elif  reel_1 + reel_2 + reel_3 == 6:
win(2)
``````

And better yet, the `6`, `4` and `2` should be extracted out into constants at the top of the file so they’re named and easily modifiable.

That reduced the duplication of those three functions, but there’s multiple things that need to be said about `a`:

• It’s a terrible name. The name you associate with an object should be descriptive and let readers know its purpose. Which makes more sense to you?:

``````a.append(a(-1) + (bet * 4))
balance_history.append(balance_history(-1) + (bet * 4))
``````

You’ll find that overwhelmingly, the latter will be easier to understand. Not only is `a` completely non-descript, but it’s also so simple that you can’t search for usages of it using simple “find” tools, since `a` is such a common letter.

• It’s not necessary. If you do a search for usages of `a`, you’ll see that it’s only used for two things: `a(-1)`, and `a.append`. While there’s something to be said about anticipating future needs, you’re currently accumulating a history of balances that you never use. This not only uses up more memory than is needed, but it also convolutes the logic. If you’re maintaining a history, that suggests that the history is used somewhere. It never is though. You could safely change `a` to `balance = 1000`, then just do simple math on it directly. That would make a lot of this code cleaner and more sensical.

Speaking of memory usage, you’re using recursion for basic looping, which is not a good thing. Your `spin` function is essentially:

``````def spin():
# Logic
reels(), spin()
``````

Every single time your player takes another turn, `spin` is allocating another stack frame, and taking up more memory. If your player were to take ~1000 turns, your program would crash due to the stack being exhausted. Change that function to a basic `while` loop:

``````def spin():
global balance
while True:
# And this is the main function, the spin
spin1 = input("Balance : " + str(balance) + " Press enter to spin the wheel ")

if spin1 == "":
print("****************************THE WHEEL IS SPINNING**************************** n")
balance -= bet
print("Balance : ", balance)
reels()
else:
print("You can only spin the wheel with enter")
``````

• I changes `balance` to be a simple integer and discussed above (notice how much more sense `balance -= bet` makes).
• It’s using a `while` loop. This does not eat up memory as the program is used. Recursion should be reserved for the very specific cases where it’s the proper choice, like when iterating a recursive structure. Especially in a language like Python, recursion should be avoided unless you’re very familiar with it and know about its strengths/weaknesses.
• I rearranged the `if` branches. You originally had it so if `if spin1 == "":` was true, all it would do is `print`; then the actual functionality happened at the bottom of the function. I think it makes much more sense as I have it here; where everything is grouped.
• I did a lot of small touchups (more on that below).

You’re making heavy use of global variables. This is quite common when starting out, but it’s a habit you should work to fix quickly. General rules of thumb to follow unless you have good reason to do otherwise:

• All the changing data that a function requires to operate (`balance`, for example) should be explicitly passed to the function as arguments. This means you can test the function by simply passing it data, and you don’t need to alter global state. This isn’t a big deal now, but needing to alter mutable globals to test a function will become a disaster once your function is larger.
• All data that the function produces should be returned from the function. Again, this means you can test the function all you want without affecting any other code.

As an alternative, you may also find that creating a class to maintain a state is a cleaner choice as well. That’s getting a little more advanced though.

I’m going to show the full final code below, but I needed to make many small fixes to make it clean. Please be aware of formatting. Yes, it is very important. You have many places in your code where care was not taken to make it consistent and readable:

``````elif reel_1 + reel_2 + reel_3 == 8:
win3()

elif  reel_1 + reel_2 + reel_3 == 7:  # Too many spaces after the elif
win2()

"Balance : "+ str(a(-1))+ " Press enter to spin the wheel "  # Inconsistent spacing around +

def spin() :  # There shouldn't be a space before the colon
``````

If you’re going to write Python, you should spend an afternoon to read over PEP8 at least once. The look of your code reflects strongly on that care that was taken while writing it. You want you code to look sharp, and clean. You may have your own stylistic preferences, but be consistent when applying them, and when in doubt, stick to PEP8.

The final code:

``````import random

balance = 1000
bet = 20

def win(bonus_factor):
global balance
amount_won = bet * bonus_factor
# I did different wins, the win1,2,3 function contains them
print("WIN!WIN!WIN! n You won ", amount_won, "credits! ")
balance += amount_won
print("Actual balance : ", balance)

def reels():
global balance
# Here is the random number calculation.As you can see, theres a pretty good chance to win so it
# would not be a good casino game for the house :)
reel_1 = random.randint(1, 3)
reel_2 = random.randint(1, 3)
reel_3 = random.randint(1, 3)

if reel_1 + reel_2 + reel_3 == 9:
print("Jackpot!!!!!!!!!!")
balance += bet * 100
print("Actual balance : ", balance)

elif reel_1 + reel_2 + reel_3 == 8:
win(6)

elif reel_1 + reel_2 + reel_3 == 7:
win(4)

elif reel_1 + reel_2 + reel_3 == 6:
win(2)
else:
print("No win this time")

def spin():
global balance
while True:
# And this is the main function, the spin
spin1 = input("Balance : " + str(balance) + " Press enter to spin the wheel ")

if spin1 == "":
print("****************************THE WHEEL IS SPINNING**************************** n")
balance -= bet
print("Balance : ", balance)
reels()
else:
print("You can only spin the wheel with enter")

spin()
``````

olympus – Can I continue shooting when film camera counter was reset to 1 after opening film door?

First off sorry for the bad terminology but I’m a newbie and would really appreciate some help – I’ve bought my first film camera, it is an Olympus MJU zoom 70 from an as-is sale and everything seemed to be working fine.

I took 9 shots with it already but the lens got stuck while I was playing with the zoom functions. I couldn’t turn the camera off, and I read online that I should open the film door to reset the whole camera. I pressed the release door button (while holding the door down so the door wouldn’t open and films inside wouldn’t get exposed to light), and it managed to “unstick” my camera lens, but I didn’t know that it would reset the film counter back to 1.

I honestly don’t know how a film camera works, so questions below:

1. Can the films inside still be used?
2. Can I continue taking photos with it as per normal?

I don’t really want to get the film developed right now as there are still quite a lot of exposures left and it’s quite expensive to get it developed where I live. Thanks!

film camera counter reset to 1 after opening film door

first off sry for the bad terminology but im a newbie and would really appreciate some help – i bought my first film cam, an olympus mju zoom 70 from an asis sale and everything seemed to be working fine, i took 9 shots with it already until the lens got stuck when i was playing with the zoom functions. i couldn’t turn the camera off and i read online that i should open the film door to reset the whole camera. i pressed the release door button (while holding the door down so the door wouldn’t open and films inside wouldn’t get exposed to light), and it managed to “unstuck” my camera lens but i didn’t know that it would rewind the film and reset the counter back to 1. i honestly don’t know how a film camera works so can the films inside still be used? can i continue taking photos with it as per normal? don’t really want to get it developed now as there are still quite a lot of films left and it’s quite expensive to get it developed where i live. thanks!

2d – How to display the counter in pygame.time.set_timer?

This is expected as `time` is passed “by value” (you copy the content of the variable “into the function”).

Perhaps you need to change your approach to “timer” as there appears to be no equivalent to “get_timer” to get the time left before the event is fired.

I’m not exactly sure how your whole game is developed, but you probably need to track the time yourself so that you can check the time left.

I’m not fluent in pygame, but, based on your previous question and pygame’s documentation, perhaps something like this would work:

``````...

class Singlebullet(object):

def __init__(self):
self.speed = 0
self.firerate = 700 # assuming ms
# this is new:
self.bullet_time_left = self.firerate
self.clock = pygame.time.Clock()

def shoot(self):
if current_bullet_type == 'single':
self.x = myplane.x + 71
self.y = myplane.y
elif self.state == 'fire': # use elif instead of if
self.speed = -13

for event in events:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and self.state == 'ready':
self.clock = pygame.time.Clock()
self.bullet_time_left = self.firerate
self.state = 'fire'

delay = self.clock.tick()
if self.state == 'fire':
self.bullet_time_left -= delay
if self.bullet_time_left <= 0:
self.bullet_time_left = self.firerate
else:
myfont.render(self.bullet_time_left, True, 'black')

MyScrollingScreen.blit(self.img, (self.x, self.y))

self.y += self.speed
s1 = Singlebullet()
...
while running:
...
s1.shoot()
...
``````

That’s the gist of it. You start a “Clock” when you fire the bullet; each update, you “update” it via it’s tick() method to check how much time has passed since the last “tick()”. You remove that time from the “time left”; once that counter gets below 0, you know that you’re done and should clean it up. You have access to the time left so you can use it to update your label.

You’ll probably want to rearrange some of what I wrote to suit your needs.

As I mentioned, I’m not fluent with pygame, and so maybe someone else has a better approach to propose.

jsx – React.js How to make a global win counter?

I’m making my first card game with React.js and I’m stuck at one point.
How can I display the total win count?
For example, if in this game the computer scored 10 points and won, and in the next 15 more points the global counter should show 25.

App.js

``````import React from "react";
import './App.css';
import Start from "./components/Start";
import Game from "./components/Game";
import Result from "./components/Result";
import {game, result, start} from "./utils/constants";

class App extends React.Component{
constructor(props) {
super(props);
this.state = {
page: start,
name: 'You',
compWins: 0,
playerWins: 0,
countWinsPlayer: 0,
countWinsComp: 0
}
}

changePage = page => {
this.setState({page});
}

changeName = name => {
this.setState({name});
}

changeResult = (compWins, playerWins, countWinsPlayer,countWinsComp) => {
this.setState({compWins, playerWins,countWinsPlayer,countWinsComp})
}

render() {
switch (this.state.page) {
case game:
return <Game
name={this.state.name}
switchPage={this.changePage}
setResult={this.changeResult}/>;
case result:
return <Result
switchPage={this.changePage}
compWins={this.state.compWins}
playerWins={this.state.playerWins}
countWinsPlayer={this.state.countWinsPlayer}
countWinsComp={this.state.countWinsComp}
/>;
default:
return <Start
switchName={this.changeName}
switchPage={this.changePage}/>;
}
}
}

export default App;

``````

Start.js

``````import React from 'react';
import {game} from "../utils/constants";

class Start extends React.Component {
constructor(props) {
super(props);
this.state = {
name: ''
}
}

render() {
return (
<div>
<input
onChange={(e) => this.setState({name: e.target.value})}
value={this.state.name}
type='text'
<button onClick={() => {
this.props.switchPage(game);
this.props.switchName(this.state.name)
}}>Start</button>
</div>
);
}
}

export default Start;
``````

Game.js

``````import React from 'react';
import {deck, result, shuffle} from "../utils/constants";

class Game extends React.Component {

constructor(props) {
super(props);
this.state = {
playerCard: 'Player card',
compCard: 'Computer card',
compWins: 0,
playerWins: 0,
countWinsPlayer: 0,
countWinsComp: 0
};
}

componentDidMount() {
const cards = shuffle(deck);
this.compCards = cards.slice(0, deck.length / 2);
this.playerCards = cards.slice(deck.length / 2, deck.length);
}

handleClickNext = () => {
if (this.playerCards.length) {
const player = this.playerCards.pop();
const comp = this.compCards.pop();

if (player.rank > comp.rank) {
//this.setState({playerWins: this.state.playerWins + 1});
this.setState((state, props) => ({playerWins: state.playerWins + 1}));
this.setState((state, props) => ({countWinsPlayer: state.countWinsPlayer + 1}));

}
if (player.rank < comp.rank) {
this.setState({compWins: this.state.compWins + 1});
this.setState({countWinsComp: this.state.countWinsComp + 1});
}
this.setState({
playerCard: `\${player.rank}, \${player.suit}`,
compCard: `\${comp.rank}, \${comp.suit}`
});
} else {
this.props.setResult(this.state.compWins, this.state.playerWins, this.state.countWinsPlayer, this.countWinsComp);
this.props.switchPage(result);
}
}

render() {
return (
<div>
<h1>Computer</h1>
<p>{this.state.compCard}</p>
<p>{this.state.playerCard}</p>
<h1>{this.props.name}</h1>
<button onClick={this.handleClickNext}>Next</button>
</div>
);
}
}

export default Game;
``````

Result.js

``````import React from 'react';
import {game} from "../utils/constants";

const Result = ({playerWins, compWins, switchPage, countWinsPlayer,countWinsComp}) => {
const getResult = () => {
if (playerWins > compWins) {
return 'WIN';
}
if (playerWins < compWins) {
return 'LOSE';
}
return 'DRAW';
};
return (
<div>
<h1>{getResult()}</h1>
<h3>This game:</h3>
<h3>Your wins {playerWins} - {compWins} Computer wins</h3>
<h3>Total wins:</h3>
<h3>Your wins {countWinsPlayer} - {countWinsComp} Computer wins</h3>
<button onClick={() => switchPage(game)}>Again ?</button>
</div>
);
};

export default Result;
``````

constans.js

``````export const start = 'Home';
export const game = 'Game';
export const result = 'Result';
export const createDeck = () => {
const deck = ();
const suits = ('spade', 'club', 'diamond', 'heart');
for (let i = 0; i < suits.length; i++){
for (let j = 1; j <= 13; j++){
deck.push({rank: j, suit: suits(i)});
}
}
return deck;
};
export const deck = createDeck();
export const shuffle = arr => {
const res = (...arr);
res.sort(() => Math.random() - 0.5);
return res;
}

``````