Skip to content

Instantly share code, notes, and snippets.

@pc035860
pc035860 / deepGet.js
Created May 19, 2024 18:45 — forked from andrewchilds/deepGet.js
Simple, standalone, vanilla implementation of lodash.get
// Simple implementation of lodash.get
// Handles arrays, objects, and any nested combination of the two.
// Also handles undefined as a valid value - see test case for details.
// Based on: https://gist.github.com/harish2704/d0ee530e6ee75bad6fd30c98e5ad9dab
export function deepGet(obj, query, defaultVal) {
query = Array.isArray(query) ? query : query.replace(/(\[(\d)\])/g, '.$2').replace(/^\./, '').split('.');
if (!(query[0] in obj)) {
return defaultVal;
}
obj = obj[query[0]];
@pc035860
pc035860 / InputGroup.js
Created May 10, 2022 09:00
useDebounceInput demonstration
import React from 'react';
import PropTypes from 'prop-types';
import { InputGroup as BPInputGroup } from '@blueprintjs/core';
import useDebounceInput from './useDebounceInput';
const InputGroup = ({ value, onChange, debounceWait, ...restProps }) => {
const debounce = useDebounceInput({
value,
@pc035860
pc035860 / init.lua
Last active August 16, 2022 18:38
Hammerspoon config on my M1 Mac mini
hs.application.enableSpotlightForNameSearches(true)
hyperKeys = {'cmd', 'alt', 'ctrl', 'shift'}
function bindHyperFocus(shortcutKey, findApplication)
hs.hotkey.bind(hyperKeys, shortcutKey, function()
-- hs.application.find(findApplication):activate()
hs.application.launchOrFocus(findApplication)
end)
end
@pc035860
pc035860 / genFirebaseCommand.js
Created December 19, 2019 10:43
Generate command for setting Firebase Functions Environment
/**
* @param config {object} environment config object
*
* {
* [serviceName]: {
* [key]: "{value}",
* ...
* },
* ...
* }
function gen(config) {
let list = [];
for(let [serviceName, serviceObject] of Object.entries(config)) {
for (let [key, value] of Object.entries(serviceObject)) {
// console.log(`${name}.${key} = ${value}`)
list.push(`${serviceName}.${key}="${value}"`);
}
}
return `firebase functions:config:set ${list.join(" ")}`;
}
@pc035860
pc035860 / README.md
Last active February 18, 2022 06:02
My karabiner settings

My Karabiner Settings

  • Map caps_lock to hyper key

  • Map left_command+caps_lock to caps_lock

  • WOW gameplay support: switch left_command and left_option keys

  • Ducky One 3 support

Tested with Karabiner-Elements 14.3.0 under macOS 12.2.1

@pc035860
pc035860 / FastField.jsx
Last active July 23, 2019 08:12
Enhanced Formik's <FastField />
import React, { useMemo, useCallback } from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import { FastField as BaseFastField } from 'formik';
const nameShouldUpdate = (nextFormik, formik, name) => {
return (
_.get(formik.values, name) !== _.get(nextFormik.values, name) ||
@pc035860
pc035860 / debugUpdate.js
Created May 23, 2019 03:31
HoC for debug component update
/* eslint no-console: 0 */
import _ from 'lodash';
import { diff } from 'deep-object-diff';
import { shouldUpdate } from 'recompose';
export default function debugUpdate(groupLabel, collapsed = true) {
if (typeof groupLabel === 'undefined') {
throw new Error('Should provide `groupLabel`.');
}
@pc035860
pc035860 / chart_colors.txt
Created May 9, 2018 09:32 — forked from there4/chart_colors.txt
[CSS] Chart Color Collection
#3366CC
#DC3912
#FF9900
#109618
#990099
#3B3EAC
#0099C6
#DD4477
#66AA00
#B82E2E
@pc035860
pc035860 / README.md
Last active January 6, 2016 04:57
Better easing timing function in Sass

Usage

SCSS

@import "better-easing";

.foo {
  transition: all 1s easing(circOut);
}