How to enable function keys
echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode
https://blog.colinwaddell.com/keychron-function-keys-configuration/
How to enable function keys
echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode
https://blog.colinwaddell.com/keychron-function-keys-configuration/
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next" | |
// checkout NextJS 'NextApiResponse' generic, | |
// TL;DR | |
// calling response.send & response.json can be type, NextApiResponse<your_interface_or_type> | |
interface API_Response { | |
ok: boolean, | |
status?: number, | |
data?: any | |
} |
import { ApolloServer, gql } from 'apollo-server-micro'; | |
const typeDefs = gql` | |
type Query { | |
sayHello: String | |
} | |
`; | |
const resolvers = { | |
Query: { |
import withData from '@/lib/withData' | |
import { ApolloClient } from 'apollo-boost' | |
import App, { AppProps, Container } from 'next/app' | |
import { ApolloProvider } from 'react-apollo' | |
export default withData( | |
class extends App<MyAppProps> { | |
public static async getInitialProps({ Component, ...ctx }) { | |
let pageProps = {} |
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |
export function withAppContext< | |
P extends { appContext?: AppContextInterface }, | |
R = Omit<P, 'appContext'> | |
>( | |
Component: React.ComponentClass<P> | React.StatelessComponent<P> | |
): React.SFC<R> { | |
return function BoundComponent(props: R) { | |
return ( |
const grandParent = document.getElementById("grandParent") | |
const parent = document.getElementById("parent") | |
const counter = document.getElementById("counter") | |
let count = 0 | |
function increaseCounter(event) { | |
event.preventDefault() | |
// if we don't stop propagation, the this function will run on both event listeners, thus increasing count by 2 | |
// event.stopPropagation() | |
count += 1 |
Document for the best design choices you can make for your software.
Terminology
components
containing all component files.File Structure
Structuring applications is hard, here are a few resources to help.
import { withRouter } from 'next/router'; | |
import Link from 'next/link'; | |
import React, { Children } from 'react'; | |
const ActiveLink = ({ router, children, ...props }) => { | |
const child = Children.only(children); | |
let className = child.props.className || ''; | |
if (router.pathname === props.href && props.activeClassName) { | |
className = `${className} ${props.activeClassName}`.trim(); |
If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need.
Thus, you should keep the .vim
directory along with your .vimrc
version-controlled.
But when you have plugins installed inside .vim/bundle
(if you use pathogen), or inside .vim/pack
(if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.
Initialize a git repository inside your .vim
directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:
cd ~/.vim
/** | |
* Filters an array of objects using custom predicates. | |
* | |
* @param {Array} array: the array to filter | |
* @param {Object} filters: an object with the filter criteria | |
* @return {Array} | |
*/ | |
function filterArray(array, filters) { | |
const filterKeys = Object.keys(filters); | |
return array.filter(item => { |