Skip to content

Instantly share code, notes, and snippets.

View bloadvenro's full-sized avatar

Viktor bloadvenro

View GitHub Profile
@bloadvenro
bloadvenro / recursive-switch-type.ts
Last active September 12, 2018 11:55
Typescript recursive switch type
type Switch<T, CaseList extends CaseLike[], Default> = {
case: ((...caseList: CaseList) => any) extends ((current: infer C, ...rest: infer R) => any)
? C extends CaseLike // we must ensure in that to access 'case' property of C
? C['case'] extends T
? C['then']
: R extends CaseLike[] // we must ensure in that to pass R as the third argument below
? Switch<T, R, Default>
: never // this branch will never occur: R is always CaseLike[]
: 'this branch will never occur: C is always CaseLike'
: never; // this branch will never occur because of condition below
@bloadvenro
bloadvenro / redux-is-smarter-than-you-think.md
Created March 10, 2018 14:58 — forked from armw4/redux-is-smarter-than-you-think.md
Optimizing your react components via redux....shouldComponentUpdate for free and more...

The Beginning

Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.

connect()

connect is the most important thing in redux land IMO. This is where you tie the not between redux and your underlying components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational

@bloadvenro
bloadvenro / grub.cfg
Created February 11, 2018 21:39 — forked from Pysis868/grub.cfg
My own configuration file for GRUB2 to boot various live distributions of Linux-based operating systems, along with some system tools. I tried to include a lot of sample configuration entries, even if I don't currently use them, so it may help others. Exceedingly long blog post: http://tehfishyblog.logdown.com/chips/306146-a-homemade-ultimate-bo…
# Config for GNU GRand Unified Bootloader (GRUB) (2)
# /boot/grub/grub.cfg
# or
# /boot/grub2/grub.cfg
# This grub.cfg file was created by Lance http://www.pendrivelinux.com
# Suggested Entries and the suggestor, if available, will also be noted.
# and then improved by Pysis.
@bloadvenro
bloadvenro / fallback-rule.ts
Last active February 3, 2018 18:02
Webpack boilerplate stuff
const fallbackRule: Webpack.Rule = {
test: function matchEverything() {
return true
},
exclude: [
/\.html$/, // .html files are handled by html-webpack-plugin.
/\.json$/ // .json files are often handled by webpack internally (i.e. hot-update.json).
],
loader: require.resolve('file-loader'),
options: {