Skip to content

Instantly share code, notes, and snippets.

@jericbas
jericbas / App.js
Created March 4, 2019 05:48
Add Rematch with existing Redux implementation
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
// actions
import getOldAction from 'actions/getOldAction';
// component
const App = ({ getOldAction, newAction }) => {
return <div>App</div>;
@jericbas
jericbas / range.js
Created March 12, 2019 17:37
Javacript: Create number range in array
const range = (start, end) =>
new Array(end - start + 1).fill(undefined).map((_, i) => i + start);
@jericbas
jericbas / search.tests.js
Created June 21, 2019 05:05
Mock `window.location.search`
it('mocks search', () => {
delete window.location;
window.location = { search: '?query=phone' };
expect(window.location.search).toEqual('?query=phone');
});

Keybase proof

I hereby claim:

  • I am jericbas on github.
  • I am jericbas (https://keybase.io/jericbas) on keybase.
  • I have a public key ASDADkKMIOaIZHDCJfK4dl-FttO2p-R8yPHiGzOxUKJjyAo

To claim this, I am signing this object:

@jericbas
jericbas / .bashrc
Last active October 19, 2019 19:32
Add timestamp on history
# Add timestamp on history
echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
@jericbas
jericbas / schema.graphql
Created October 19, 2019 19:30
Check authorization header using schema directives
directive @isAuth on FIELD_DEFINITION
type Mutation {
addPost(title: String!, content: String! ): Post @isAuth
}
@jericbas
jericbas / app.js
Created October 21, 2019 10:12
extend type is not working in importSchema
# const { importSchema } = require("graphql-import");
# importSchema("app/graphql/schema.graphql")
# Fixed
const {
ApolloServer,
gql
} = require("apollo-server-express");
const fs = require("fs");
const typeDefs = gql`
@jericbas
jericbas / app.js
Last active October 21, 2019 10:20
extend types in GraphQL is not working in importSchema
# const { importSchema } = require("graphql-import");
# importSchema("app/graphql/schema.graphql")
# Fixed
const {
ApolloServer,
gql
} = require("apollo-server-express");
const fs = require("fs");
const typeDefs = gql`
@jericbas
jericbas / checkoutWithShippingRates.js
Last active November 29, 2019 11:54
Shopify Checkout With availableShippingRates
const query = await client.graphQLClient.query(root => {
root.add('node', {
args: {
id: checkoutId
},
alias: 'checkout'
}, node => {
node.add('id')
node.addInlineFragmentOn('Checkout', Checkout => {
Checkout.add('subtotalPrice')
@jericbas
jericbas / Linux.md
Last active April 21, 2020 02:53
Kll a process running on a port
sudo lsof -i:5000

kill -9 12345