Skip to content

Instantly share code, notes, and snippets.

View DaveMBush's full-sized avatar

Dave Bush DaveMBush

  • Cheshire, CT
View GitHub Profile
for(var i = 0;i < 10;i++){
$.ajax({
url: /* url goes here */,
success: function (moduleHtml) {
console.log(i);
}
});
}
@DaveMBush
DaveMBush / BasicObjectWithPrivates.js
Last active June 18, 2016 11:20
Accessing ‘private’ JavaScript variables from Unit Tests
function MyClass(){
function privateMember(){
}
function publicMember(){
privateMember.apply(this);
}
this.publicMember = publicMember;
}
function add(a,b){
return a + b;
}
var newFoo = add.bind(this,3,4);
console.log(newFoo());
@DaveMBush
DaveMBush / FirstTest.spec.js
Last active August 6, 2016 17:43
WebDriverIO-Samples
"use strict";
describe('First test',()=>{
beforeEach(()=>{
browser.url('https://www.google.com');
});
it('should display "Google" in the title',()=>{
expect(browser.getTitle()).toBe('Google');
});
});
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', {
enumerable: true,
configurable: true,
get: function() {
return this.orsc;
},
set: function(f) {
this.orsc = f;
}
});
@DaveMBush
DaveMBush / model-form-patch.ts
Last active April 15, 2017 20:55
Angular(2+) Model Driven Forms Are Superior
this.form.patchValue({
name: contact.name,
sex:contact.sex,
dob:contact.dob.toLocaleDateString()
});
@DaveMBush
DaveMBush / app.component.html
Last active December 21, 2017 17:29
DynamicComponent
<ng-template #dynamicInsert></ng-template>
@DaveMBush
DaveMBush / app.module1.ts
Last active May 20, 2017 15:47
NgRX Sample Code
// standard imports omitted for clarity
import {AppStores} from './app.stores';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
@DaveMBush
DaveMBush / directory-structure.txt
Last active July 14, 2017 15:22
NgRX-With-SubReducers
app/
+-store/
+-route1/
+-sub-reducer1/
--sub-reducer1.actions.ts
--sub-reducer1.effects.ts
--sub-reducer1.model.ts
--sub-reducer1.reducer.ts
+-sub-reducer2/
--route1.actions.ts
@DaveMBush
DaveMBush / create-observable.ts
Last active June 10, 2017 18:24
RxJS Marble Testing
const testScheduler = new TestScheduler();
const hotObservable = testScheduler.createHotObservable(hotMarbleString);
const coldObservable = testScheduler.createColdObservable(coldMarbleString);