Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
| var Books = Backbone.Collection.extend({ | |
| // Lets create function which will return the custom URL based on the method type | |
| getCustomUrl: function (method) { | |
| switch (method) { | |
| case 'read': | |
| return 'http://localhost:3000/api/Books/' + this.id; | |
| break; | |
| case 'create': | |
| return 'http://localhost:3000/api/Books'; | |
| break; |
| @isTest static void User_can_get_contact_email() | |
| { | |
| // Arrange | |
| System.runAs(createUser()) | |
| { | |
| // Act | |
| // Assert | |
| system.assertEquals('contact@place.com', contact.Email, 'Email does not match'); | |
| } |
| List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime, NextFireTime, OwnerId, PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey from CronTrigger where State = 'Waiting' or State='Running']; | |
| System.debug('No of jobs: '+listCronTrigger.size()); | |
| if (listCronTrigger.size() > 0) { | |
| for (Integer i = 0; i < listCronTrigger.size(); i++){ | |
| System.abortJob(listCronTrigger[i].Id); | |
| System.debug('Job details ::'+String.valueOf(listCronTrigger[i])); | |
| } | |
| } |
| export ORG_ALIAS='DummyScratchOrg' | |
| export PROJECT_NAME='DummyProject' | |
| export PERMISSION_SET='DummyPermSet' | |
| export IMPORT_PLAN='Dummy-plan.json' | |
| # Create a Salesforce DX project | |
| sfdx force:project:create -n $PROJECT_NAME | |
| # Regist development/sandbox org | |
| sfdx force:auth:web:login [-d] -a $ORG_ALIAS |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
var Article = require('../../../models/article');Those suck for maintenance and they're ugly.
| var myScript = document.createElement('script'); | |
| myScript.src = 'http://code.jquery.com/jquery-2.1.4.min.js'; | |
| myScript.onload = function() { | |
| console.log('jQuery loaded.'); | |
| }; | |
| document.body.appendChild(myScript); |
| package se.hellsoft.simpleservicecallbackdemo; | |
| import android.app.Activity; | |
| import android.content.ComponentName; | |
| import android.content.Intent; | |
| import android.content.ServiceConnection; | |
| import android.graphics.Color; | |
| import android.os.Bundle; | |
| import android.os.Handler; | |
| import android.os.IBinder; |