Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Charity benjamincharity

View GitHub Profile
@benjamincharity
benjamincharity / autonomous.txt
Last active Sep 16, 2020
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 / 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 / master.vim
Last active Jul 21, 2020 — 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 textMaskCore.js
!(function (e, r) {
"object" == typeof exports && "object" == typeof module ? (module.exports = r()) : "function" == typeof define && define.amd ? define([], r) : "object" == typeof exports ? (exports.textMaskCore = r()) : (e.textMaskCore = r());
})(this, function () {
return (function (e) {
function r(n) {
if (t[n]) return t[n].exports;
var o = (t[n] = { exports: {}, id: n, loaded: !1 });
return e[n].call(o.exports, o, o.exports, r), (o.loaded = !0), o.exports;
}
var t = {};
@benjamincharity
benjamincharity / CreateGuid.ts
Created Aug 10, 2017
A TypeScript class that generates a guid
View CreateGuid.ts
// http://stackoverflow.com/questions/26501688/a-typescript-guid-class
class Guid {
static newGuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0, v = c === 'x' ? r : ( r & 0x3 | 0x8 );
return v.toString(16);
});
}
}
View ep.html
<div [@detailExpand]="shouldExpand ? 'expanded' : 'collapsed'">
Test
</div>
View skip-ci.yml
- name: Set SHOULD_RUN flag
run: |
if [[ "${{github.event.head_commit.message}}" =~ (skip\ ci|ci\ skip) ]]; then
echo "::set-env name=SHOULD_RUN::false"
else
echo "::set-env name=SHOULD_RUN::true"
fi
- name: Manual build
run: yarn library:build:prod
if: env.SHOULD_RUN == 'true'
@benjamincharity
benjamincharity / deletebranch.gitconfig
Last active Jan 8, 2020
Git alias function to delete local AND remote branch(s). NOTE: If dealing with branches that are not fully merged, the `-d` would need to change to `-D`.
View deletebranch.gitconfig
[alias]
deletebranch = "!f() { \
git push origin --delete "$@"; \
git branch -d "$@"; \
}; f"
# usage:
# git deletebranch my-branch
# git deletebranch branch-1 branch-2 branch-3
View strikethrough.js
{
const sheet = window.document.styleSheets[0];
const rule = '.task-list-item-checkbox:checked+.task-list-item-text{opacity:.5;text-decoration:line-through;}';
sheet.insertRule(rule, sheet.cssRules.length);
const listItems = document.querySelectorAll('.task-list-item');
Array.from(listItems).forEach(item => {
const nodes = Array.from(item.childNodes).filter(item => item instanceof Text || item.tagName === "CODE");
const checkbox = item.querySelectorAll('input')[0];
const originalText = nodes.map(node => node.nodeValue || node.textContent).join('').trim();
@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>
You can’t perform that action at this time.