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
| function calcAge( | |
| input: Date | null | undefined | string | Person | Car | |
| ): number { | |
| if (!input) { | |
| return 0; | |
| } else if (typeof input === "string") { | |
| return diffInYears(parse(input)); | |
| } else if (input instanceof Date) { | |
| return diffInYears(input); | |
| } else if (input.type === "Car") { |
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
| type Person = { | |
| birthday: Date; | |
| category: "person"; | |
| }; | |
| type Car = { | |
| yearOfConstruction: Date; | |
| category: "car"; | |
| }; | |
| function calcAge( | |
| input: Date | null | undefined | string | Person | Car |
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
| function calcAge(input: Date | null | undefined | string | Person): number { | |
| if (!input) { | |
| return 0; | |
| } else if (typeof input === "string") { | |
| return diffInYears(parse(input)); | |
| } else if (input instanceof Date) { | |
| return diffInYears(input); | |
| } else { | |
| return diffInYears(input.birthday); | |
| } |
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
| class Person { | |
| birthday = new Date(); | |
| } | |
| function calcAge(input: Date | null | undefined | string | Person): number { | |
| if (!input) { | |
| return 0; | |
| } else if (typeof input === "string") { | |
| return diffInYears(parse(input)); | |
| } else { | |
| return diffInYears(input); // failure: can be Date or Person |
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
| [HttpPost] | |
| public async Task<IActionResult> GenerateImage([FromBody] input input) | |
| { | |
| var resp = new ResponseModel(); | |
| using (var client = new HttpClient()) | |
| { | |
| client.DefaultRequestHeaders.Clear(); | |
| client.DefaultRequestHeaders.Authorization = | |
| new AuthenticationHeaderValue("Bearer", APIKEY); | |
| var Message= await client. |
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
| val h1 = MaterialTheme.typography.h1 | |
| val h2 = MaterialTheme.typography.h2 | |
| val h3 = MaterialTheme.typography.h3 | |
| var textStyle by remember { mutableStateOf(h1) } | |
| val animatedTextStyle by animateTextStyleAsState( | |
| targetValue = textStyle, | |
| spring(stiffness = Spring.StiffnessLow) | |
| ) | |
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
| @Composable | |
| fun animateTextStyleAsState( | |
| targetValue: TextStyle, | |
| animationSpec: AnimationSpec<Float> = spring(), | |
| finishedListener: ((TextStyle) -> Unit)? = null | |
| ): State<TextStyle> { | |
| val animation = remember { Animatable(0f) } | |
| var previousTextStyle by remember { mutableStateOf(targetValue) } | |
| var nextTextStyle by remember { mutableStateOf(targetValue) } |
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
| val scope = rememberCoroutineScope() | |
| // Setup animatable float to use in the lerp function | |
| val animation = remember { | |
| Animatable(0f) | |
| } | |
| val h1 = MaterialTheme.typography.h1 | |
| val h2 = MaterialTheme.typography.h2 | |
| // derive the current TextStyle based on the animation position | |
| val textStyle by remember(animation.value) { |
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
| type AddBitsWithCarry< | |
| LHS extends Bit, | |
| RHS extends Bit, | |
| CF extends CarryFlag = Zero | |
| > = LHS extends One | |
| ? RHS extends One | |
| ? CF extends One | |
| ? { value: One; cf: One } | |
| : { value: Zero; cf: One } | |
| : CF extends One |
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
| const requestOptions = { | |
| method: "PUT", | |
| headers: { "Content-Type": "multipart/form-data" }, | |
| body: selectedFile, | |
| }; | |
| //Perform the upload | |
| fetch(fileLocation, requestOptions) | |
| .then((response) => { | |
| if (response.status === 200) resolve(true); | |
| else resolve(false); |