You have a json file with following structure (example)
[
{
"id": 1,
"title": "Hello",
"description": "World"| // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | |
| export default function relay() { | |
| return { | |
| name: 'relay', | |
| transform(code) { | |
| // Use indexOf as its probably ;-) faster | |
| if (code.indexOf('graphql`') > -1) { | |
| const re = /graphql`[^`]+(?<type>query|fragment|mutation)\s+(?<name>[\w_-\d]+)[^`]+`/gm; | |
| let imports = []; |
| // same as `yarn esbuild index.ts src/**/*.ts --platform=node --format=esm --tsconfig=./tsconfig.json --outdir=dist --watch` | |
| // but with respawn server on change | |
| import esbuild from 'esbuild'; | |
| import fg from 'fast-glob'; | |
| import { spawn } from 'child_process'; | |
| const entryPoints = await fg(['index.ts', 'src/**/*.ts']); | |
| const dev = process.env.NODE_ENV !== 'production'; |
| # ------------------------------------------------------------------------------ | |
| # `hashi` - shows all subfolders workspaces | |
| # `hashi test` - switch all subfolders terraform workspaces to test, load test secrets and sets nomad and consul env vars | |
| # `hashi -init-all` - execute terraform init at all subfolders terraform workspaces | |
| # `hashi <tab>` - autocomplete workspaces | |
| # `hashi .<tab>` - autocomlete and cd into | |
| # `hashi -<tab>` - autocomlete commands | |
| alias gitclean="git remote prune origin && git branch -vv | grep 'origin/.*: gone]' | awk '{print \$1}' | xargs git branch -D" |
| /*Parses ICU messages format https://messageformat.github.io/messageformat/guide/ | |
| like | |
| {from} - {to} {results, plural, | |
| one { # result } | |
| many { # results } | |
| } text {vr} rmm | |
| {s, select, | |
| man { He is "#"#"#" } | |
| woman { She is # } | |
| } |
I want to hold ordering of some items in SQL, like field in a table index: 0,1,2,3,4,...
and I have operation moveItem
If I want to move item from index: 1 to index: 3 I can do
delete from table where index = 1;
update table set index = index - 1 where index > 1
update table set index = index + 1 where index >=3
insert into table (index) values (3)| /* @flow */ | |
| import * as React from 'react' | |
| import { compose, withProps } from 'recompose' | |
| import type { HOC } from 'recompose' | |
| // Example of very dirty written fetcher enhancer | |
| function fetcher<Response: {}, Base: {}>( | |
| dest: string, | |
| nullRespType: ?Response | |
| ): HOC<{ ...$Exact<Base>, data?: Response }, Base> { | |
| return BaseComponent => |
| /* @flow */ | |
| import * as React from 'react' | |
| import { compose, withProps } from 'recompose' | |
| import type { HOC } from 'recompose' | |
| function mapProps<BaseProps: {}, EnhancedProps>( | |
| mapperFn: EnhancedProps => BaseProps | |
| ): (React.ComponentType<BaseProps>) => React.ComponentType<EnhancedProps> { | |
| return Component => props => <Component {...mapperFn(props)} /> | |
| } |
| type MyComponentProps = HOCBase<typeof myEnhancer> | |
| class MyComponent extends React.Component<MyComponentProps> { | |
| render() ... | |
| } | |
| const MyEnhancedComponent = myEnhancer(MyComponent) |
| // Extract type from any enhancer | |
| type HOCBase_<A, B, C: HOC<A, B>> = A | |
| type HOCBase<C> = HOCBase_<*, *, C> |