This is a solution by https://github.com/coco98 and https://github.com/tirumaraiselvan from the Hasura team. I put it here because it was too long to copy paste it onto Discord :/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/apps/Login.js | |
import { React, Form, clientCookies, gql } from 'fervor/lib'; | |
import Template from '../components/Template'; | |
import styles from './styles/about.scss'; | |
const authenticate = gql` | |
mutation Authenticate($login: AuthenticateInput!) { | |
authenticate(input: $login) { | |
jwtToken |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses Math.exp() approximation from: | |
// https://www.musicdsp.org/en/latest/Other/222-fast-exp-approximations.html | |
// @ts-ignore: decorator | |
@inline | |
function fastexp9(x: f64): f64 { | |
// prettier-ignore | |
return (362880+x*(362880+x*(181440+x*(60480+x*(15120+x*(3024+x*(504+x*(72+x*(9+x)))))))))*2.75573192e-6; | |
} |
The following sets up a local k3d cluster and deploys Postgres and Hasura GraphQL Engine.
NOTE: All data will be lost when containers restart
# Create the cluster mapping NodePorts to Host ports and set KUBECONFIG
k3d create --publish 5432:30032 --publish 8080:30080 --workers 2
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
# Deploy postgres
TL:DR; assert your input
If you write non-trivial code, inevitably you'll run into a situation where setting up a test is not super readable. Maybe you have to mock a bunch of things, or the input data is a data structure that spans dozens of LOC, or maybe you are testing with a large-ish fixture that was defined in another file because linting or whatever.
Due to the nature of my job, I happen to read a lot of other people's code, so you can imagine how mildly annoying it is when I'm code reviewing something, and the test looks something like this:
test('codemod does what it needs to', async () => {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copied from https://github.com/OneGraph/graphiql-explorer (0.4.5) | |
* We fork because we need to support customizable fields and could not wait for | |
* the PR process to finish. Also converted Flow type to TypeScript. | |
*/ | |
import { Tooltip } from 'antd'; | |
import prettier from 'prettier/standalone'; | |
import parserGraphql from 'prettier/parser-graphql'; | |
import React, { Fragment } from 'react'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// params: y0, y1, interleaved x, coeff, n | |
static EEL_F NSEEL_CGEN_CALL dotprod2(void *opaque, INT_PTR np, EEL_F **parms) { | |
EEL_F **blocks = (EEL_F **)opaque; | |
int xofs = *parms[2]; | |
int cofs = *parms[3]; | |
int n = *parms[4]; | |
*parms[0] = 0.0; | |
*parms[1] = 0.0; | |
if (unlikely(n <= 0 || xofs < 0 || cofs < 0 || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2010 Eric Ryan Harrison <me@ericharrison.info> | |
# Inspired by: | |
# http://daniel.haxx.se/blog/2010/12/14/add-latency-to-localhost/ | |
if [ -n "$1" ] | |
then | |
if [ "$1" = "off" ] | |
then | |
tc qdisc del dev lo root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
#include <reaper_plugin.h> | |
#include <ns-eel.h> | |
/* | |
* If you actually try this, the JS effect that uses the new function should not be the first one loaded, | |
* otherwise you will get an "undefined 'myadd'" error. | |
* Workarounds: recompile/reset or add any JS effect before this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"problemMatcher": [ | |
{ | |
"owner": "hlint", | |
"severity": "warning", | |
"pattern": [ | |
{ | |
"regexp": "^([^:]*\\/)([^:/]*):(\\d+)(-\\d+)?:(\\d+)(-\\d+)?: (Warning|Error): (.*)$", | |
"fromPath": 1, | |
"file": 2, |
OlderNewer