Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖

Benjamin Charity benjamincharity

🤖
View GitHub Profile
@benjamincharity
benjamincharity / autonomous.txt
Last active January 11, 2023 17:51
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 / contacts.js
Last active January 9, 2023 16:06
Create a downloadable file of VCARD formatted address for iOS from a JSON array.
View contacts.js
var contacts =
[
{
"notes": [
{
"description": "Fugiat aute pariatur excepteur elit."
}
],
"tels": [
{
View JS: Hide Address Bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@benjamincharity
benjamincharity / mockActivatedRoute.ts
Created April 12, 2017 16:23
Mock ActivatedRoute with params, data and snapshot.
View mockActivatedRoute.ts
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MdToolbarModule,
],
providers: [
{
provide: Router,
useClass: MockRouter,
},
@benjamincharity
benjamincharity / clearCache.sh
Created March 3, 2017 16:44
Clear the cache for a CircleCI project.
View clearCache.sh
curl -X DELETE https://circleci.com/api/v1/project/:username/:project/build-cache?circle-token=:token
@benjamincharity
benjamincharity / master.vim
Last active September 25, 2022 20:51 — 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)
@benjamincharity
benjamincharity / CreateGuid.ts
Created August 10, 2017 12:15
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);
});
}
}
@benjamincharity
benjamincharity / .travis.sync-s3.yml
Last active May 9, 2021 20:17
Set up TravisCI to sync an S3 bucket.
View .travis.sync-s3.yml
" Two env variables must be added to TravisCI settings:
" AWS_SECRET_ACCESS_KEY
" AWS_ACCESS_KEY_ID
before_deploy:
pip install --user awscli
deploy:
provider: script
script: ~/.local/bin/aws s3 sync dist s3://MY_BUCKET_NAME --region=us-west-2 --delete
skip_cleanup: true
View get-sum.js
function getSum(a: number, b: number): number {
if (a === b) {
return a;
}
const [start, end] = [a, b].sort((a, b) => a - b);
return Array(end - start + 1)
.fill(null)
.map((_, idx) => start + idx)
.reduce((acc, curr) => acc + curr);
}
View html-outlet.directive.ts
import {
Component,
Directive,
NgModule,
Input,
ViewContainerRef,
Compiler,
ComponentFactory,
ModuleWithComponentFactories,
ComponentRef,