Skip to content

Instantly share code, notes, and snippets.

View jaroslav-kubicek's full-sized avatar

Jaroslav Kubíček jaroslav-kubicek

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jaroslav-kubicek on github.
  • I am kubajz_pb (https://keybase.io/kubajz_pb) on keybase.
  • I have a public key ASA5pEMcdSLPJ_sxYOlHoEmeVqcEZQ2bTdsfvnK3gggcIwo

To claim this, I am signing this object:

@jaroslav-kubicek
jaroslav-kubicek / codeshift-remove-alias.js
Last active November 30, 2022 17:51
Codeshift script to remove import alias
const path = require("path");
function replacePathAlias(currentFilePath, importPath, pathMap) {
// if windows env, convert backslashes to "/" first
console.log(currentFilePath)
currentFilePath = path.posix.join(...currentFilePath.split(path.sep));
const regex = createRegex(pathMap);
return importPath.replace(regex, replacer);
/* @flow */
import * as React from "react"
type Sex = "MALE" | "FEMALE" | "UNDEFINED"
type Props = $ReadOnly<{|
name: string,
sex: Sex,
address: ?React.Node,
/* @flow */
// uncomment this comment :) // flowlint unclear-type:error
// SEE https://flow.org/en/docs/linting/rule-reference/#toc-unclear-type
// "any" type - not very helpful
const foo: any = 42;
foo.bar.baz
// @flow
import * as React from 'react';
import { mount } from 'enzyme';
import { QueryRenderer, graphql } from '@adeira/relay';
import { createMockEnvironment, MockPayloadGenerator } from 'relay-test-utils';
describe('Component', () => {
it('Shows something', () => {
const environment = createMockEnvironment();
// @flow
import * as React from 'react';
import { createFragmentContainer, graphql } from 'react-relay';
import { ThemeContext } from 'styled-components';
import { withRouter } from 'react-router-dom';
import {
Ticket,
Airplane,
InformationCircle,
module.exports = {
entry: {
main: './src/app.js',
},
output: {
// `filename` provides a template for naming your bundles (remember to use `[name]` or `[contenthash]`)
filename: '[name].bundle.js',
// `chunkFilename` provides a template for naming code-split bundles (optional)
chunkFilename: '[name].bundle.js',
// `path` is the folder where Webpack will place your bundles
@jaroslav-kubicek
jaroslav-kubicek / cypress_mockGraphQL.js
Last active September 11, 2019 09:08
Snippet how to mock GraphQL request in cypress
// --------------------------------------
// Mock GraphQL requests with stubs.
// Inspiration: https://github.com/cypress-io/cypress-documentation/issues/122
// --------------------------------------
Cypress.Commands.add('visitWithMockedGraphQL', (page, stubs) => {
cy.visit(page, {
onBeforeLoad: win => {
cy.stub(win, 'fetch', handleFetch(stubs));
},
});
{
"additional_bookings": {
"details": []
},
"arrival": {
"when": 0,
"where": {
"code": "VKO",
"name": "Moscow"
}

Keybase proof

I hereby claim:

  • I am jaroslav-kubicek on github.
  • I am kubajz (https://keybase.io/kubajz) on keybase.
  • I have a public key ASAjeFyASDvCCG5hc_OWLNVagezGhhiDQqK_uCrvGxYvRgo

To claim this, I am signing this object: