Skip to content

Instantly share code, notes, and snippets.

@patik
patik / README.md
Last active June 28, 2022 10:14
Combine multiple useInfiniteQuery results from react-query

Merge useInfiniteQuery Results

This utility allows you to make multiple requests with react-query's useInfiniteQuery hook and then combine all of them into a single result. That is, you can fetch data from multiple endpoints, but you'll only need to check one isSuccess status, call only one refetch function, etc.

Allows for sorting and de-duping data, if needed.

Example

const foo = useInfiniteQuery('/api/foo')
@patik
patik / styles.css
Last active August 12, 2024 23:11 — forked from joshbode/numbered_headings.md
Numbered Headings in Markdown via CSS
body { counter-reset: h1counter h2counter h3counter h4counter h5counter h6counter; }
h1 { counter-reset: h2counter; }
h2 { counter-reset: h3counter; }
h3 { counter-reset: h4counter; }
h4 { counter-reset: h5counter; }
h5 { counter-reset: h6counter; }
h6 {}
h2:before {
@patik
patik / format-commas.js
Last active June 22, 2021 00:25
Format number with commas
// Converts "1234567.89" => "1,234,567.89"
function formatNumberWithCommas(number) {
const parts = number.split('.')
return ('' + parts[0]) // Convert to a string
.split('').reverse().join('') // Reverse the order of the characters (which are all digits at this point)
.replace(/(...)/g, '$1,') // Insert a comma after every three digits
.split('').reverse().join('') // Un-reverse the characters
.replace(/^,/, '') // Remove any commas that were added to the beginning (i.e. if the number of digits was a multiple of three)
.concat(parts[1] ? '.' + parts[1] : '') // Re-add the decimal, if any
}
@patik
patik / osx-special-chars.ahk
Last active November 28, 2022 12:02 — forked from aarongustafson/osx-special-chars.ahk
AutoHotKey stuff
#UseHook
!VKC0SC029::Return ; grave -> the grave ` accent gave some probs, used the virtualkey + scancode instead
!e::Return ; acute
!i::Return ; circumflex
!t::Return ; tilde
!u::Return ; umlaut
; 1 2 3 4 5 6 7 8 9 1
; 0
; r g G a A c C t T u U
@patik
patik / file.html
Created March 23, 2016 11:29
upstate web
<!DOCTYPE html>
<html lang="en">
<head>
<script>
window.ts_endpoint_url = "https:\/\/slack.com\/beacon\/timing";
(function(e) {
var n = Date.now ? Date.now() : +new Date,
r = e.performance || {},
@patik
patik / git-setup.sh
Created November 13, 2015 13:24
Git and Node with Zscaler proxy
#!/bin/sh
# Git proxy settings
echo "Configuring Git..."
git config --global http.proxy http://gateway.zscaler.net:80/
git config --system http.proxy http://gateway.zscaler.net:80/
git config --global http.sslVerify false
git config --system http.sslVerify false
git config --global --unset http.sslcainfo
git config --system --unset http.sslcainfo
@patik
patik / popover.md
Last active September 14, 2015 17:26
Popover plugin specifications

Popover

Overview

The popover plugin displays HTML in a container that overlays the page. It is triggered by clicking on a button or other UI element and the container is positioned near the element. The popover can be displayed and hidden at will.

Usage

The plugin must be provided with an options object and a jQuery collection of elements.

@patik
patik / how-to-squash-commits-in-git.md
Last active May 30, 2024 07:59
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@patik
patik / 1.install.md
Last active October 17, 2017 06:08
Proxy config for Git and Node at DTF

Download and install these first:

  • NodeJS
  • Git for Windows
    • During installation, on the options screen with the check boxes about what to install, check the box for TrueType fonts
    • On the screen with three radio button options about the shell and Windows Command Prompt, choose the second option
    • Go with the default options for the rest of the installation
  • SourceTree
    • This is similar to GitHub's app, but more powerful and flexible
@patik
patik / .bashrc
Last active October 13, 2024 15:27
Bash configure proxy for corporate network
# configure proxy for git while on corporate network
# From https://gist.github.com/garystafford/8196920
function proxy_on(){
# assumes $USERDOMAIN, $USERNAME, $USERDNSDOMAIN
# are existing Windows system-level environment variables
# assumes $PASSWORD, $PROXY_SERVER, $PROXY_PORT
# are existing Windows current user-level environment variables (your user)
# environment variables are UPPERCASE even in git bash