This file contains 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
export namespace TypeUtils { | |
/** | |
* Casts a type (unless it's already narrower) | |
* @example | |
* // returns 'hey' | |
* Cast<'hey', string> | |
* @example | |
* // returns string | |
* Cast<unknown, string> | |
*/ |
This file contains 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
import React, { createContext, Fragment, useEffect, useState } from 'react'; | |
import PropTypes from 'prop-types'; | |
function MyComponent({ name, show }: { name: string; show: boolean }) { | |
const [isEnabled, setIsEnabled] = useState<boolean>(false); | |
return ( | |
<Fragment> | |
<p>hi {show ? name : 'stranger'}</p> | |
</Fragment> | |
); |
This file contains 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
[user] | |
name = XXX | |
email = XXX | |
[alias] | |
ci = commit | |
co = checkout | |
st = status | |
# update local branch with latest stuff from origin and rebase any local commits | |
up = !git pull --rebase --prune $@ && git submodule update --init --recursive | |
# Get the current branch name (not so useful in itself, but used in other aliases) |
This file contains 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
[user] | |
name = xxx | |
email = xxx | |
[alias] | |
ci = commit | |
co = checkout | |
st = status | |
# update local branch with latest stuff from origin and rebase any local commits | |
up = !git pull --rebase --prune $@ && git submodule update --init --recursive | |
# Get the current branch name (not so useful in itself, but used in other aliases) |
This file contains 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
plugins: [ | |
"hyper-one-dark", | |
"hyper-search", | |
"hyper-opacity", | |
"hyper-alt-click", | |
"hyper-sync-settings" | |
], |
This file contains 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 name = nullableUser?.name ?: "Guest" |
This file contains 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 name = nullableUserName ?: "Guest" |
This file contains 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 currentCity: String? = user?.address?.city |
This file contains 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 a = "Kotlin" | |
val b: String? = null | |
println(a?.length) // 6 | |
println(b?.length) // null |
This file contains 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 len = if (nullableGreeting != null) { | |
nullableGreeting.length | |
} else { | |
0 | |
} |
NewerOlder