Skip to content

Instantly share code, notes, and snippets.

View yury-sannikov's full-sized avatar

Yuriy Sannikov yury-sannikov

View GitHub Profile
@yury-sannikov
yury-sannikov / componentControllerSpec.js
Last active August 6, 2017 15:41
mocha-aura globals
const { auraFactory, eventFactory } = require('mocha-aura/aura')
describe('Component Controller', () => {
let sandbox, clock;
before(() => {
global.$A = auraFactory({
// Define all your labels you're using in a test suite
'$Label.c.My_Label': 'My_Label',
// Define all global events
@yury-sannikov
yury-sannikov / apexCallTest.js
Created August 7, 2017 20:50
mocha-aura Apex & Callbacks
const { apexCallFactory, apexErrorResult, apexSuccessResult, componentFactory } = require('mocha-aura/aura')
const helper = require('path/to/aura/helper')
describe('Apex Call Test', () => {
it('should set component v.object to Apex result', apexTest(false));
it('should set v.error if Apex call failed', apexTest(true));
})
@yury-sannikov
yury-sannikov / timersTest.js
Last active August 8, 2017 20:53
mocha-aura timeouts
let clock;
before(function() {
clock = sinon.useFakeTimers();
});
describe('Create Component', function() {
it('should create component after timeout of 500 ms', function() {
// Make helper call which uses setTimeout(..., 500) to call GlobalHelper.showLoadedData()
if (event.getParam('panelId') === this.PANELS.INFO) {
if (event.getParam('id') === component.get('v.id')) {
...
}
}
poolForChanges(so) {
// Prepare environment
const component = componentFactory({});
const callback = sinon.spy();
// Invoke component helper method
helper.poolForChanges(component, callback);
// helper method should call another helper method.
// It's second parameter has a callback we are going to test
expect(helper.pullSummary).to.have.been.called;
const [{args: [,pullTicketSummaryCallback]}] = helper.pullSummary.getCalls();
// inputFieldAdapter.js
const sinon = require('sinon');
exports.inputFieldAdapter = function inputFieldAdapter(componentInstance, params = {}) {
const setParam = (cmp, name, value) => cmp.params[name] = params.hasOwnProperty(name) ? params[name] : value;
// Set default property values on a component instance
setParam(componentInstance, 'label', '');
setParam(componentInstance, 'fieldType', '');
...
// Add component-specific methods on component instance
@yury-sannikov
yury-sannikov / Dockerfile
Created September 2, 2017 18:12
GPU Docker
FROM nvidia/cuda:8.0-cudnn7-devel
RUN apt-get update && \
apt-get -y dist-upgrade && \
apt-get -y install \
kmod \
make \
build-essential \
cmake \
cpp \
g++ \
@yury-sannikov
yury-sannikov / ethereum-vpc.template
Created September 6, 2017 23:59
Ethereum Virtual Private Cloud Template for Amazon CloudFormation
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Ethereum Cluster VPC with two availability zones'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: 'VPC Parameters'
Parameters:
- ClassB
@yury-sannikov
yury-sannikov / gpu-docker-task-definition.json
Created September 9, 2017 18:43
GPU Docker Task Definition
{
"taskDefinition": {
"status": "ACTIVE",
"networkMode": "bridge",
"family": "gpu-docker",
"placementConstraints": [],
"volumes": [],
"taskDefinitionArn": "arn:aws:ecs:us-east-1:217509956792:task-definition/ethminer-docker:1",
"containerDefinitions": [
{
@yury-sannikov
yury-sannikov / ec2-spot-cluster.template.yaml
Created September 10, 2017 18:01
EC2 Spot Instances Launch Configuration and Autoscaling Group for GPU ECS Cluster
AWSTemplateFormatVersion: '2010-09-09'
Description: Creates environment for running GPU workload on EC2 Container Service
Parameters:
ECSInstanceType:
AllowedValues: [g2.2xlarge, g2.8xlarge, p2.xlarge, p2.8xlarge, p2.16xlarge]
ConstraintDescription: Must be g2.2xlarge, g2.8xlarge, p2.xlarge, p2.8xlarge,
p2.16xlarge
Default: g2.2xlarge
Description: ECS instance type
Type: String