Skip to content

Instantly share code, notes, and snippets.

@MiradorOne
MiradorOne / quickSort.js
Created August 1, 2023 21:18
Quick Sort algorithm
const quickSort = (array) => {
if (array.length < 2) {
return array
}
const pivot = array[0]
const arrayWithoutPivot = array.slice(1)
const less = arrayWithoutPivot.filter((n) => n < pivot)
const greater = arrayWithoutPivot.filter((n) => n > pivot)
@MiradorOne
MiradorOne / react.js
Created January 22, 2017 11:05
React Router - multiple components per page
// think of it outside the context of the router, if you had pluggable
// portions of your `render`, you might do it like this
<App children={{main: <Users/>, sidebar: <UsersSidebar/>}}/>
// So with the router it looks like this:
const routes = (
<Route component={App}>
<Route path="groups" components={{main: Groups, sidebar: GroupsSidebar}}/>
<Route path="users" components={{main: Users, sidebar: UsersSidebar}}>
<Route path="users/:userId" component={Profile}/>