Skip to content

Instantly share code, notes, and snippets.

// The tokens data needs to be sent from Backend in the following format.
// Format is same as what we have currently, just we need to put more nested elements based on the requirement.
[{
id: '7',
text: 'Case Fields Group',
children: [
{
id: '10',
text: 'Core Fields',
children: [{
@deb1990
deb1990 / Readme.md
Last active February 20, 2021 21:11
SlashData

1. Prime Number

The 10001st Prime Number is 104743. Please find the code in primenumber.js file.

Technical Notes
  • In the code a cache is used to do the calculation more efficiently. When calculating the number for the 1st time, it takes around 23.35302734375ms, but if we run it again, it takes just 0.260986328125ms.
  • If next time we try to get the 10002nd prime number, The program will only calculate the 10002nd prime, because the previous 10001 numbers are already saved in the cache. This is again a huge performance benefit.

2. When would you choose a NoSQL database instead of a relational database and why?

  • In NoSQL each document can have its own unique structure. So when the schema of the data is not consistent and can change at any time, NoSQL is preferred. Its very flexible to add new kind of data without affecting existing data.
@deb1990
deb1990 / crmCaseTypeEntended.js
Last active April 3, 2018 12:22
Tasks and Workflows
(function(angular, $, _) {
var caseTypeExtendedModule = angular.module('caseTypeExtendedModule', CRM.angRequires('caseTypeExtendedModule'));
// THIS IS A NEW CONTROLLER WHICH WILL OVERRIDE METHODS FROM caseTypeCtrl
caseTypeExtendedModule.controller('caseTypeExtendedController', function ($scope, crmApi, $controller) {
//PCHR-3412
$scope.activityTypeOptions = [];
//GET VALUES FOR ONLY Task and Documents
@deb1990
deb1990 / gist:29d53db17c195ca0697d76d4a72eb3b2
Last active February 14, 2018 10:14
POC for refactoring "leave-request-popup-details-tab.component.spec.js"

POC for refactoring "leave-request-popup-details-tab.component.spec.js

Link to the file

https://github.com/civicrm/civihr/blob/PCHR-2952-error-500-adding-entitlements/uk.co.compucorp.civicrm.hrleaveandabsences/js/angular/test/shared/components/leave-request-popup-details-tab.component.spec.js

Rearranging Previous tests

  1. Create 3 spec files for Leave, Sick and Toil type of requests
  • request-modal-details-leave.controller.spec.js
  • request-modal-details-sickness.controller.spec.js
  • request-modal-details-toil.controller.spec.js
@deb1990
deb1990 / scenario.json
Last active May 4, 2017 10:54
Backstop JS setup for custom logins
{
"scenarios": [
{
"label": "<>",
"url": "<>",
"onReadyScript": "<>",
"credentials": "Do not mention this property if it uses default credentials, otherwise mention 'manager'/'stuff'/etc"
}
]
}
//OLD WAY
//Loading leaveRequests
//leaveRequestsData.list = list of leaveRequests from API
leaveRequests = leaveRequestsData.list;
//Fetching leave request for a date
leaveRequest = _.find(leaveRequests, function(leaveRequest){
return !!_.find(leaveRequest.dates, function (leaveRequestDate) {
return moment(leaveRequestDate.date).isSame(dateObj.date);