This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spinAnimation: Animation { | |
Animation.easeOut(duration: 3.0) | |
.repeatCount(1, autoreverses: false) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@State private var isAnimating = false | |
@State private var spinDegrees = 0.0 | |
@State private var rand = 0.0 | |
@State private var newAngle = 0.0 | |
let halfSector = 360.0 / 37.0 / 2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sectors: [Sector] = [Sector(number: 32, color: .red), | |
Sector(number: 15, color: .black), | |
Sector(number: 19, color: .red), | |
Sector(number: 4, color: .black), | |
Sector(number: 21, color: .red), | |
Sector(number: 2, color: .black), | |
Sector(number: 25, color: .red), | |
Sector(number: 17, color: .black), | |
Sector(number: 34, color: .red), | |
Sector(number: 6, color: .black), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Color: String { | |
case red = "RED" | |
case black = "BLACK" | |
case green = "ZERO" | |
case empty | |
} | |
struct Sector: Equatable { | |
let number: Int | |
let color: Color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.put('/user/:id/password', checkSchema({ | |
id: { | |
// the location of the field can be one or more of 'body', 'cookies', | |
'headers', 'params' or 'query'. | |
// If omitted, all request locations will be checked | |
in: ['params','query'], | |
isInt: true, | |
errorMessage: 'ID is wrong' | |
}, | |
password: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rateLimit = require("express-rate-limit"); | |
var apiLimiter = rateLimit({ | |
windowMs: 15 * 60 * 1000, // 15 minutes | |
max: 100 | |
}); | |
// only apply to requests that begin with /api/ | |
app.use("/api/", apiLimiter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rateLimit = require("express-rate-limit"); | |
app.set('trust proxy', 1); // add this line only if your server is behind a proxy | |
var limiter = rateLimit({ | |
windowMs: 15 * 60 * 1000, // 15 minutes | |
max: 100, // limit each IP to 100 requests per windowMs | |
delayMs: 0 // disable delaying - user has full speed until the max limit is reached | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<form method="post" action=“changeEmail"> | |
<input type="hidden" name="_csrf" value="_csrf"> | |
<input type="email" name=“newEmail"> | |
</form> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var csrf = require('csurf'); | |
var app = express(); | |
app.use(csrf()); | |
app.use(function(req, res, next) { | |
res.locals._csrf = req.csrfToken(); | |
next(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var napolitana = Pizza(id: 0, size: 8, type: .napolitana, doughType: .thin) | |
print(napolitana.currentState) | |
napolitana.bakePizza() | |
print(napolitana.currentState) | |
napolitana.deliverPizza() | |
print(napolitana.currentState) |