Skip to content

Instantly share code, notes, and snippets.

Benjamin Charity benjamincharity

Block or report user

Report or block benjamincharity

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@benjamincharity
benjamincharity / mockActivatedRoute.ts
Created Apr 12, 2017
Mock ActivatedRoute with params, data and snapshot.
View mockActivatedRoute.ts
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MdToolbarModule,
],
providers: [
{
provide: Router,
useClass: MockRouter,
},
@benjamincharity
benjamincharity / autonomous.txt
Last active Nov 8, 2019
Instructions on how to reset the autonomous desk. This fixes a problem where the desk will not lower (also reportedly fixes incorrectly reported heights).
View autonomous.txt
> Thank you for reaching out to Autonomous! I am sorry to hear that you are having some trouble with your SmartDesk
> but I will be glad to assist. It sounds like your system needs a "hard reset" can I please have you follow these
> steps thoroughly.
Reset Steps:
1. Unplug the desk for 20 seconds. Plug it back in. Wait a full 20 seconds.
2. Press the up and down buttons until the desk lowers all the way and beeps or 20 seconds pass.
3. Release both buttons.
4. Press the down buttons until the desk beeps one more time or 20 seconds pass.
@benjamincharity
benjamincharity / Local Fallback for jQuery and Modernizr
Created Jan 6, 2012
Include jQuery and Modernizr from a CDN and add local fallbacks in case the CDN fails. Versions written in HTML and HAML.
View Local Fallback for jQuery and Modernizr
HTML
=====
<script type='text/javascript'>
window.jQuery || document.write('<script src="js/jquery-1.7.1.js">\x3C/script>')
</script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js' type='text/javascript'></script>
<script type='text/javascript'>
window.Modernizr || document.write('<script src="js/modernizr-2.0.6.js">\x3C/script>')
</script>
View component.ts
public readonly headerCellResizes: Observable<TsHeaderCellResizeEvent> | Observable<{}> = defer(() => {
if (this.headerCells && this.headerCells.length) {
return merge(...this.headerCells.map(cell => cell.resized));
}
// If there are any subscribers before `ngAfterViewInit`, `headerCells` may be undefined.
// In that case, return a stream that we'll replace with the real one once everything is in place.
return this.ngZone.onStable
.asObservable()
.pipe(take(1), switchMap(() => this.headerCellResizes));
@benjamincharity
benjamincharity / zepto.smoothScroll.js
Last active Oct 4, 2019 — forked from austinpray/zepto.smoothScroll.js
Smooth scrolling with Zepto.js
View zepto.smoothScroll.js
function smoothScroll(el, to, duration) {
if (duration < 0) {
return;
}
var difference = to - $(window).scrollTop();
var perTick = difference / duration * 10;
this.scrollToTimerCache = setTimeout(function() {
if (!isNaN(parseInt(perTick, 10))) {
window.scrollTo(0, $(window).scrollTop() + perTick);
smoothScroll(el, to, duration - 10);
View qeury.ts
public queryStates(query: string): State[] {
query = query.toLowerCase();
if (query) {
const letters = query.split('').map(l => `${l}.*`).join('');
const regex = new RegExp(letters, 'ig');
return this.states.filter(s => !!s.name.match(regex));
} else {
// if no query, return first 10 states
return STATES.slice(0, 10);
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
@benjamincharity
benjamincharity / master.vim
Last active Aug 14, 2019 — forked from gmccreight/master.vim
Master Vim with this interactive tutorial.
View master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
View html-outlet.directive.ts
import {
Component,
Directive,
NgModule,
Input,
ViewContainerRef,
Compiler,
ComponentFactory,
ModuleWithComponentFactories,
ComponentRef,
@benjamincharity
benjamincharity / circle.yml
Last active Apr 23, 2019
CircleCI deploy to NPM
View circle.yml
machine:
node:
version: 6.9.5
dependencies:
pre:
- 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
test:
override:
- rm -rf $CIRCLE_ARTIFACTS/coverage
You can’t perform that action at this time.