Skip to content

Instantly share code, notes, and snippets.

View markmur's full-sized avatar
📱

Mark Murray markmur

📱
View GitHub Profile
@markmur
markmur / apollo.config.js
Created February 2, 2022 22:26
Example Shopify config file for Apollo GraphQL VSCode extension
module.exports = {
client: {
service: {
name: 'Shopify',
url: 'https://{YOUR_STORE}.myshopify.com/api/unstable/graphql.json',
headers: {
'x-shopify-storefront-access-token': '{YOUR_PUBLIC_STOREFRONT_ACCESS_TOKEN}',
'Content-Type': 'application/graphql',
},
},
@markmur
markmur / docker-compose.yml
Last active November 18, 2021 22:21
Cassandra & NodeJS (docker-compose)
services:
node-server:
build: .
ports:
- "3000:3000"
links:
- cassandra
depends_on:
cassandra:
condition: service_healthy
@markmur
markmur / wifi.sh
Created September 22, 2021 15:20
Get Wifi password for current SSID
# Get Wifi SSID
function get-ssid {
/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F: '/ SSID/{print $2}'
}
# Get wifi password for current SSID
function wifi-password {
security find-generic-password -wa $(get-ssid)
}
@markmur
markmur / async-debounce.ts
Last active August 19, 2022 13:13
Debounce
function debounce<T>(fn: (...args: any[]) => Promise<T>, ms: number = 300) {
let timer: number | undefined
return (...args: any[]): Promise<T> => {
clearTimeout(timer)
return new Promise((resolve, reject) => {
timer = window.setTimeout(
() =>
fn(...args)
@markmur
markmur / retry-action.ts
Created February 19, 2020 09:16
TypeScript retry util helper
export interface RetryConfig {
timeout: number
max: number
}
export const retryAction = (
fn: (...args: any[]) => Promise<any>,
{ timeout, max }: RetryConfig
): Promise<any | void> => {
// Keep a count of the retries
@markmur
markmur / handle-click-outside.tsx
Last active February 16, 2020 14:46
Handle Click Outside
const handleClickOutside = (Component, useCapture = true) => {
return class extends React.Component {
// Create a reference to the component instance
instance = React.createRef()
// Create a reference to the component DOM element (forwardedRef)
node = React.createRef()
componentDidMount() {
document.addEventListener('click', this.handleClick, useCapture)
@markmur
markmur / .eslintrc.js
Created January 16, 2020 12:36
Eslint for typescript
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
@markmur
markmur / index.ts
Created January 15, 2020 13:17
Function overloading
export enum Events {
LOGIN = 'login',
LOGOUT = 'logout'
}
interface LoginPayload {
login: true
}
interface LogoutPayload {
@markmur
markmur / tsconfig.json
Created January 14, 2020 13:12
TSConfig
{
"compilerOptions": {
/* Basic Options */
"target": "es5",
"module": "commonjs",
"lib": ["es2015"],
/* Strict Type-Checking Options */
"strict": true,
"typeRoots": [
@markmur
markmur / docker-compose.yaml
Created May 21, 2019 14:01
Run Grafana & Prometheus through Docker
version: '3'
services:
grafana:
image: "grafana/grafana"
ports:
- "3000:3000"
prometheus:
image: "prom/prometheus"
ports:
- "9090:9090"