Skip to content

Instantly share code, notes, and snippets.

<h3>Checkboxes</h3>
<div>
<input id="checkbox-1" class="checkbox-custom" name="checkbox-1" type="checkbox">
<label for="checkbox-1" class="checkbox-custom-label">First Choice</label>
</div>
@jericbas
jericbas / app.js
Created May 5, 2020 05:23
Check if text is JSON or not
function isJson(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
@jericbas
jericbas / sample.js
Created April 24, 2020 06:16
Move element of array of object to another position/index
const data = [
{id: 1, name: "Sample 1"},
{id: 2, name: "Sample 2"},
{id: 3, name: "Sample 3"}
]
const moveObject = (arr, targetKey, targetValue, newIndex) => {
@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
@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 / 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 / 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 / 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 / .bashrc
Last active October 19, 2019 19:32
Add timestamp on history
# Add timestamp on history
echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc

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: