crossfilter.all() not working as per the docs + cf.size works - crossfilter

as per the docs I cannot get cf.all() to work
I am using this as an example here in the console in the broswer.
This is what i see in the console.
cf
Object {}
cf.all()
VM1818:1 Uncaught TypeError: cf.all is not a function(…)(anonymous function) # VM1818:1
cf.size()
2692
I can get cf.size() to work but not cf.all()

crossfilter.all was added in the version 1.4 alphas. The page you are looking at uses version 1.3.12, so it doesn't include that method. I've updated the documentation to reflect this.

Related

"HV000183 - EL dependencies not found" using hibernate-validator 7.0.0.Final / jakarta.el 4.0.1

I've a kotlin spring boot project with org.hibernate:hibernate-validator:7.0.0.Final and org.glassfish:jakarta.el:4.0.1.
For testing validation constraints I create a javax.validation.Validator, like so:
val factory = Validation.buildDefaultValidatorFactory()
validator = factory.validator
This results in the following error: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead. Which I find strange, since I included them per the instructions: https://hibernate.org/validator/documentation/getting-started/
If I combine org.hibernate:hibernate-validator:7.0.0.Final and org.glassfish:javax.el:3.0.0 it works, but it looks like 7.0.0.Final should not be used with javax.el, but with jakarta.el, without me knowing the reason why at the moment: https://in.relation.to/2021/01/06/hibernate-validator-700-62-final-released/
Any ideas on what I need to do to use hibernate-validator v7?

How to use Moment.js in ServiceNow?

Our team is trying to use Moment.js in our instance, but can't seem to get it to work. Here are a couple questions we have about it:
We noticed that there is a dependency out of the box called moment-timezone-with-data-2010-2020-v0.5, is this the same as moment.js? If so, does this mean we don't need to bring in moment.js as a new dependency?
We tried using the above ootb dependency AND tried to bring in moment.js to use in a widget, and we keep getting a console error saying that moment is undefined. Can someone provide some instructions on how to correctly get either one of these dependencies to work?
If we wanted to use moment.js on a platform business rule, what do we have to do to make that happen? Are you able to access a dependency via business rule?
Thanks!
Here's how I was able to do it:
Create a Script Include with the following attributes:
script name is "moment" (it needs to have this exact name)
scope is either global or the same scope as your project (I used global)
set as client callable
Paste the code from MomentJS 2.22.1 into the script body.
To verify that you can access your Script Include, open a Background Script and run the following test code:
var calendar = moment().add(1, 'days').calendar();
gs.log("calendar test: " + calendar);
var dayCount = moment().diff('1809-02-12', 'days');
gs.log('Abraham Lincoln was born ' + dayCount + " days ago!");
To answer your question on moment-timezone-with-data-2010-2020-v0.5: no's it's not the same; here's a link to Moment Timezone which is a different library by the same organization.
As of the time of this post, 2.22.1 is the newest version that runs in ServiceNow. There are newer versions of MomentJS, but they're too new for the SN interpreter.
You can also create a UI Script with version 2.22.1.
Load the code for Moment.js into a script include and then you can call that like any other script include.
If you are going to use the timezone functions you would need to rewrite the calls to moment from the timezone javascript to use the above script include.
moment.js
On April 1st, 2022, the most recent version of moment.js to work on SNOW San Diego is 2.22.1:
https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js
Any version > 2.22.1 will give you the following error:
Could not save record because of a compile error: JavaScript parse error at line (1) column (37954) problem = missing name after . operator (<refname>; line 1)
moment-timezone.js
On April 1st, 2022, the most recent version of moment-timezone.js to work in SNOW San Diego is 0.5.28:
https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.28/moment-timezone.min.js
Any version > 0.5.28 will give you the following error:
Could not save record because of a compile error: JavaScript parse error at line (1) column (236) problem = missing name after . operator (<refname>; line 1)
sadly you can not use momentjs on the server side in ServiceNow. Here are the installation instruction for momentjs for Rhino (the javascript interpreter SNOW uses): https://gist.github.com/UnquietCode/5614860
As you can see you would need to write new Java classes which SNOW will not allow you to do.
On the Client on the other hand you can use it, just copy paste the "Browser" implementation and include it as a global ui script: https://momentjs.com/docs/#/use-it/browser/

SinonJS is failing to resolve "resolve" as a function

I have the following code.
getCallStub.returns(new Promise((resolve)=>{
resolve([item]);
}));
But there has to be an easier way so I look at the Sinon docs and see something like getCallStub.resolve([item]); should work but I get...
TypeError: getCallStub.resolve is not a function
I also tried getCallStub.usingPromise(Promise).resolve([item]); and got the same...
TypeError: getCallStub.usingPromise(...).resolve is not a function
I double checked the node_modules and I am at a version greater than 2 (6.3.5) so why can't I use the resolve function?
From the docs:
stub.resolves(value);
Seems you just forgot an s and your code should be
getCallStub.resolves([item]);

Turbo Pascal BGI Error: Graphics not initialized (use InitGraph)

I'm making a Turbo Pascal 7.0 program for my class, it has to be on Graphic Mode.
A message pops up
BGI Error: Graphics not initialized (use InitGraph).
I'm already using InitGraph and graph.tpu and I specified the route as "C:\TP7\BGI".
My S.O is Windows 7 and I'm using DosBox 0.74, I already tried to paste all the files from the folder BGI into BIN.
What should I do?
Since dos doesn't have system graphic drivers, the BGI functions as such for BP7.
So in short, use a BGI suitable for your videocard. The ones supplied with BP7 are very old, there are newer, VESA ones that you could try.
Afaik 3rd party BGI needs to be registered explicitly in code though.
At first I have had this "missing Graph.tpu"- ... and later the "Use Initgraph"-issue too.
After hours trying (and reading some not politeful comments in the internet) I finally got Turbo Pascal 7 succesfully running (in Windows 10, x64). In summary I want to share "some secrets":
install the "TP(WDB)-7.3.5-Setup.msi" (comes from clever people in Vietnam)
make sure, that there's the CORRECT PATH to the "BGI"-directory in your program-code. For example:
driver := Detect;
InitGraph (driver, modus, 'c:\TPWDB\BGI');
(By the way: This is ALL, what's there to do with "Initgraph".)
make sure, that in TP7 under "Options" --> "Directories" are the CORRECT PATHS both to "C:\TPWDB\UNITS" and Your actual working dir e.g. "C:\TPWDB\myPrograms"
THAT's IT.
Annotations: The "Graph.TPU" (usually) is already in "UNITS" (together with "Graph3.tpu" by the way).
Hazzling around old driver's isn't needed even... :)
Just the correct paths... :)
Hope, that can help ...

Clear console for each run of Testacular/Karma + Jasmine

It is difficult for me to catch with the eye a boundary between test runs.
Is it possible to clear console for each run of Testacular/Karma + Jasmine or at least put there something easily catched by the eye, for example a series of newlines?
Note
Currently it is an abandoned question because I am no longer trying to perform tasks described in it. Please do not ask for additional info. Write only if you know for sure what to do. It will help other people.
Write your own reporter, and do whatever you want with it.
Also, if you're on a Mac and use Growl, take a look at karma-growl-reporter
I am not sure to fully understand your need but karma-spec-reporter can give you a detailed review of your test execution. Output example from karma-spec-reporter-example:
array:
push:
PASSED - should add an element
PASSED - should remove an element
FAILED - should do magic (this test will fail) expected [] to include 'magic'
at /home/michael/development/codecentric/karma-spec-reporter-example/node_modules/chai/chai.js:401
...
PhantomJS 1.8.1 (Linux): Executed 3 of 3 (1 FAILED) (0.086 secs / NaN secs)
There's now a reporter available for this: https://github.com/arthurc/karma-clear-screen-reporter
It's working for me on OSX.

Resources