Skip to content

Instantly share code, notes, and snippets.

@ivanalejandro0
ivanalejandro0 / use-query.js
Created July 8, 2019 17:58
Temporary useQuery hook implementation
/**
* React hook to execute an Apollo query and keep the data up to date according
* what's newest on the cache.
*
* @param { DocumentNode } query: the GraphQL query you want to run
* @param { Object } variables: the variables you want to interpolate on the query
* Note: you may want to memoize your object to prevent the query to run multiple times.
*
* Read more about param types on Apollo's watchQuery docs:
* https://www.apollographql.com/docs/react/api/apollo-client/#ApolloClient.watchQuery
@ivanalejandro0
ivanalejandro0 / counter.sh
Created October 18, 2019 14:59
Spawn and kill a bash script from js. Handle signal from bash.
#!/bin/bash
trap 'handle_signal SIGINT' SIGINT
trap 'handle_signal SIGQUIT' SIGQUIT
trap 'handle_signal SIGTERM' SIGTERM
trap 'handle_signal SIGHUP' SIGHUP
trap 'handle_signal SIGKILL' SIGKILL # we can't handle this
handle_signal() {
echo "received: $1. Exiting..."