Skip to content

Instantly share code, notes, and snippets.

View slmyers's full-sized avatar
💯
crushing code

Steven Myers slmyers

💯
crushing code
View GitHub Profile
@slmyers
slmyers / State.js
Last active August 12, 2018 02:51
Apollo client link example
import { ApolloClient } from 'apollo-client';
import { withClientState } from 'apollo-link-state';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { resolvers, defaults } from './resolvers/message';
const typeDefs = `
interface Node {
id: ID!
}
@slmyers
slmyers / resolvers.js
Last active August 12, 2018 01:15
Apollo Client Link example
import gql from 'graphql-tag';
export const defaults = {
messages: []
};
export const resolvers = {
Mutation: {
addMessage: (_, { content, author }, { cache }) => {
const query = gql`
@slmyers
slmyers / coverage.js
Created February 26, 2018 22:55 — forked from ebidel/coverage.js
CSS/JS code coverage during lifecycle of page load
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*
* Shows how to use Puppeeteer's code coverage API to measure CSS/JS coverage across
* different points of time during loading. Great for determining if a lazy loading strategy
* is paying off or working correctly.
*
* Install:
* npm i puppeteer chalk cli-table
@slmyers
slmyers / my-component.ts
Created July 27, 2017 17:53
my-example-angular-component
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'my-component',
styleUrls: './my-component.css',
template: `
<button [style.color]="color" (click)="bar.emit('bar')"> {{ foo }} </button>
`
})
export class MyComponent implements OnInit{
@slmyers
slmyers / recursion.md
Last active April 15, 2017 23:55
Novosbed Inc application questions

In the context of Computer Science recursion refers to a function that calls itself in order to arrive at a return value. In order to avoid infinite recursion (infinite loop) a base case is established which does not have a recursive call. This
solution is typically employed in Divide and Conquer algorithms or where recursion is more elegant than a loop. A common example is calculating a number's factorial. Here is an example written in es6.

const factorial = number => number === 1 ? 1 : number * factorial(number - 1);
@slmyers
slmyers / lumen.lua
Created March 18, 2017 19:27 — forked from anonymous/lumen.lua
Self-hosted Lisp using vvander's Lua browser runtime: https://cdn.rawgit.com/vvanders/wasm_lua/d68f46a8/main.html
environment = {{}}
target = "lua"
function nil63(x)
return(x == nil)
end
function is63(x)
return(not nil63(x))
end
function no(x)
return(nil63(x) or x == false)
@slmyers
slmyers / example.ts
Created March 14, 2017 01:44
Observable scheduler examles
import * as Rx from 'rxjs/Rx';
function getVal(arr1, arr2){
const obs = Rx.Observable.combineLatest(
Rx.Observable.from(arr1), Rx.Observable.from(arr2)
)
//.let(filterFunc) // defined elsewhere assume somewhat complicated logic
.reduce( (accum, val) => [...accum, val], [] )
.catch( err => Rx.Observable.of(`an error while filtering ${err.data}`))
@slmyers
slmyers / errors.txt
Created March 7, 2017 05:08
Error throwing wasm sqlite
#chrome Version 57.0.2984.0 dev (64-bit)
Uncaught TypeError: Cannot read property 'apply' of undefined
at Object.Module.stackAlloc (sql-debug.js:6069)
at sql-debug.js:6388
at sql-debug.js:7229
#firefox 54.0a1 (2017-03-06) (64-bit)
TypeError: Module.asm.stackAlloc is undefined[Learn More]
interface Position {
left:string;
top: string;
}
@Component({
selector: 'drag-demo',
template: `
<div #target [ngStyle]="boxPosition | async">drag me</div>
`
})
@slmyers
slmyers / drag-and-drop-ng2.ts
Created September 21, 2016 03:10
example of how to do drag and drop in ng2
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import { Store } from '@ngrx/store';
import { AppState } from '../../../reducers';
import { GenYcbQuestion } from '../../../components/question';
import { MD_CARD_DIRECTIVES } from '@angular2-material/card';
import { MD_BUTTON_DIRECTIVES } from '@angular2-material/button';
import { MasterScreenerEditActions } from '../../../actions/master-screener-edit';
import { MasterScreenerActions } from '../../../actions/master-screener';