Skip to content

Instantly share code, notes, and snippets.

View cassiozen's full-sized avatar
:atom:

Cassio Zen cassiozen

:atom:
View GitHub Profile
@cassiozen
cassiozen / TypeUtilities.ts
Created September 19, 2022 17:51
Typescript Type Utilities (by https://github.com/devanshj)
export namespace TypeUtils {
/**
* Casts a type (unless it's already narrower)
* @example
* // returns 'hey'
* Cast<'hey', string>
* @example
* // returns string
* Cast<unknown, string>
*/
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>
);
@cassiozen
cassiozen / .gitconfig
Created December 21, 2020 18:59
GitConfig
[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)
[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)
plugins: [
"hyper-one-dark",
"hyper-search",
"hyper-opacity",
"hyper-alt-click",
"hyper-sync-settings"
],
val name = nullableUser?.name ?: "Guest"
val name = nullableUserName ?: "Guest"
val currentCity: String? = user?.address?.city
val a = "Kotlin"
val b: String? = null
println(a?.length) // 6
println(b?.length) // null
val len = if (nullableGreeting != null) {
nullableGreeting.length
} else {
0
}