Skip to content

Instantly share code, notes, and snippets.

View cdoremus's full-sized avatar

Craig Doremus cdoremus

View GitHub Profile
@cdoremus
cdoremus / app-1.spec.ts
Created October 17, 2016 15:07 — forked from wkwiatek/app-1.spec.ts
Angular 2 test snippets for Angular final version. Codebase for https://developers.livechatinc.com/blog/category/programming/angular-2/
// App
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '<span>{{ sayHello() }}</span>',
})
export class App {
public name: string = 'John';
@cdoremus
cdoremus / webdriverjs_localstorage.js
Created March 18, 2017 22:13 — forked from remarkablemark/webdriverjs_localstorage.js
Get and set localStorage with WebDriverJS `executeScript` and `executeAsyncScript`.
'use strict';
/**
* Module dependencies.
*/
const webdriver = require('selenium-webdriver');
/**
* Build driver.
*/
import {action1, action2} from "myActions";
import {bindActionCreators} from "redux";
const mapDispatchToProps(dispatch) => {
return {
manuallyBoundAction : (...args) => dispatch(action1(...args)),
autoBoundAction : bindActionCreators(action2, dispatch),
multipleActionsTogether : bindActionCreators({action1, action2}, dispatch)
}
};
@cdoremus
cdoremus / dispatching-action-creators.js
Created June 13, 2017 19:17 — forked from markerikson/dispatching-action-creators.js
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
@cdoremus
cdoremus / dispatching-action-creators.js
Created June 13, 2017 19:17 — forked from markerikson/dispatching-action-creators.js
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
@cdoremus
cdoremus / json-placeholder-data.d.ts
Last active December 30, 2020 17:52
TypeScript type definitions for the JSON-Placeholder sample data API (see https://jsonplaceholder.typicode.com/).
/**
* TypeScript type definitions for the JSON-Placeholder
* sample data API.
* @see https://jsonplaceholder.typicode.com/
*/
export interface User {
id: number;
name: string;
username: string;
email: string;
@cdoremus
cdoremus / fast-check.test.ts
Last active September 28, 2024 09:03
How to use the fast-check property-based testing library with Deno
/**
* Running the fast-check property-based testing library in the Deno
* JavaScript/TYpeScript runtime.
* See: https://github.com/dubzzz/fast-check
*
* This file contains all the 'simple' examples from the fast-check
* repo using Deno.test for the test functions and assertions
* from the Deno standard library. I also added some missing type
* annotations.
*
@cdoremus
cdoremus / AllComponents.test.ts
Created May 26, 2022 03:49 — forked from coryhouse/AllComponents.test.ts
Enforce tests exist for each component
// This file assures that a Jest test file and Cypress test file exists for each component.
import path from "path";
import fs from "fs";
function getFiles(filepath: string) {
return fs.readdirSync(filepath).filter(function (file) {
return fs.statSync(path.join(filepath, file)).isFile();
});
}
@cdoremus
cdoremus / deno-sass-compile.ts
Created January 4, 2023 23:10
Compiling SASS with Deno
/*
Compiling SASS with Deno
deno run --allow-read="test.scss" --allow-env="SASS_PATH" --unstable "test.ts"```
*/
import SassLang from "npm:sass@latest";
@cdoremus
cdoremus / markdown.ts
Created September 19, 2023 21:49
Using markdown with Deno
// from Fresh repo at: https://github.com/denoland/fresh/blob/4a8bfc03278068cffb017ed08d3eb891d7509c37/www/utils/markdown.ts#L13
export * as gfm from "https://deno.land/x/[email protected]/mod.ts";
import "https://esm.sh/[email protected]/components/prism-jsx.js?no-check";
import "https://esm.sh/[email protected]/components/prism-typescript.js?no-check";
import "https://esm.sh/[email protected]/components/prism-tsx.js?no-check";
import "https://esm.sh/[email protected]/components/prism-diff.js?no-check";
import "https://esm.sh/[email protected]/components/prism-json.js?no-check";
import "https://esm.sh/[email protected]/components/prism-bash.js?no-check";
import "https://esm.sh/[email protected]/components/prism-yaml.js?no-check";