Skip to content

Instantly share code, notes, and snippets.

View osbornm's full-sized avatar

Matthew Osborn osbornm

View GitHub Profile
@osbornm
osbornm / gist:4431513
Last active May 28, 2021 18:05
NAudio Playlist
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
var playlist = new List<string>{ @"c:\development\test\sound.MP3",
@"c:\development\test\sound2.MP3" };
var playr = new playr(playlist);
@osbornm
osbornm / useInterval.test.ts
Created April 7, 2021 15:45
React: useInterval
import { renderHook } from '@testing-library/react-hooks';
import useInterval from './useInterval';
describe('useInterval', () => {
beforeEach(() => {
jest.clearAllMocks();
jest.useFakeTimers();
});
it('should run the callback after the delay', () => {
@osbornm
osbornm / useQueryStringState.test.ts
Last active April 1, 2021 22:32
React: useQueryStringState
import {
useHistory,
useLocation
} from 'react-router-dom';
import queryString from 'query-string';
import { renderHook } from '@testing-library/react-hooks';
import useQueryStringState from './useQueryStringState';
const mockHistory = { push: jest.fn() };
@osbornm
osbornm / AsyncTime.js
Created March 8, 2020 20:11
Async Timeout Function (JavaScript)
function timeout(ms = 1000) {
return new Promise(resolve => setTimeout(resolve, ms));
}
### Keybase proof
I hereby claim:
* I am osbornm on github.
* I am osbornm (https://keybase.io/osbornm) on keybase.
* I have a public key whose fingerprint is 8BD9 6E8E FDFC 2468 BE9C E904 71E8 E463 8BA3 B85E
To claim this, I am signing this object:
@osbornm
osbornm / no-array-from.js
Created March 24, 2017 15:42
eslint array.from
/**
* @fileoverview Disallow the use of Array.From()
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
@osbornm
osbornm / handlebars.tmpl.html
Last active July 10, 2016 02:46
ko.handlebars.js template enigne
<script type="text/x-handlebars-template" id="tree-layout-group">
<li>
<div class="tree-row tree-row-header" data-bind="click: $root.toggleTreeNode">
<div class="tree-row-left">
<hgroup>
<h2><i class="{{groupIconClass}}"></i>{{name}}</h2>
<h3>({{serverCount}})</h3>
</hgroup>
</div>
<div class="tree-row-right">
@osbornm
osbornm / index.html
Created December 5, 2013 23:56
Animated Loading Background for i tag style Icons.
<i class="loading-wave"></i>
@osbornm
osbornm / example.js
Created February 27, 2013 05:11
Knockout.js Trackable Observable
var model = ko.trackableObservable(value);
$(".cancel").click(function(){
model.reset();
});
<!-- Simple Binding -->
<input type="submit" value="OK" data-bind='widget: "button"' />
<!-- Complex Binding with options -->
<input id='search' data-bind='widget: { name: "autocomplete", options: { source: searchCompletions(), delay: 500 } }, value: searchString' />