Skip to content

Instantly share code, notes, and snippets.

@patik
patik / wysihtml5.multi.example.html
Created September 3, 2012 19:59
wysihtml5 mulitiple editors issue
<div id="alpha-toolbar"><!-- Toolbar commands here --></div>
<textarea id="alpha"></textarea>
<div id="bravo-toolbar"><!-- Toolbar commands here --></div>
<textarea id="bravo"></textarea>
<div id="charlie-toolbar"><!-- Toolbar commands here --></div>
<textarea id="charlie"></textarea>
@patik
patik / adn-auth.php
Created October 11, 2012 17:17
ADN auth issue
<?php
require_once('keys.php'); // Where my constants are defined
require_once('AppDotNet.php');
$clientId = ADN_CLIENT_ID;
$clientSecret = ADN_CLIENT_SECRET;
$redirectUri = ADN_REDIRECT_URI;
# User has authorized:
if (isset($_GET['code']) && !empty($_GET['code'])) {
// @name Redirect from WikiTravel to WikiVoyage
// @description Automatically switch from a WikiTravel.org article to the same article on WikiVoyage.org
// @namespace http://patik.com/code/user-scripts/
// @include http://wikitravel.org/*
// @version v20130218.1
// ==/UserScript==
(function _wikivoyage_redir (win) {
// Example
// Before: http://wikitravel.org/en/Bangkok/Sukhumvit
@patik
patik / insertAfterEveryFromRight.js
Last active December 17, 2015 11:19
A CodePen by Craig Patik (http://cdpn.io/mtHBd)
var insertAfterEveryFromRight = function _insertAfterEveryFromRight(str, insert, every) {
var result = '';
str.split('').reverse().forEach(function(s, idx) {
if (idx !== 0 && idx % every === 0) {
result += insert;
}
result += s;
});
@patik
patik / app.css
Last active December 22, 2015 11:48
Transition height/width to `auto` by defining the transition in CSS
.expandable {
transition-property: none;
transition-duration: .5s;
transition-timing-function: ease-in-out;
}
/* Vary the transition with different classes */
.expandable.molasses {
transition-duration: 3s;
}
@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 / 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 / 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 / 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 / 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