Error messages generated in a table calculation prevent “good” elements of that table being accessed

If I make a batch fitting routine, something like:

FitResultsData =      Table[              SpectrumData = Import[SpectrumList[[i]]];                SpectrumFit = NonlinearModelFit[SpectrumData, Model, {a, b, c}, x];                  aFitOut = a /. SpectrumFit["BestFitParameters"];                  bFitOut = b /. SpectrumFit["BestFitParameters"];                     cFitOut = c /. SpectrumFit["BestFitParameters"];               {i, aFitOut , bFitOut, cFitOut},              {i, 1, Length[SpectrumList]}             ] 

and a fit fails completely, e.g. I get a Power::infy: Infinite expression 1/0.^2 encountered. error or something, I find that when it comes to going on to use FitResultsData after all Table[..] has finished fitting and executing no matter which row I select for example FitResultsData[[1]] the error Power::infy: Infinite expression 1/0.^2 encountered. will be returned. This happens even say the original source of the error was in spectrum i = 99.

Is there a method of escaping such errors, such that even though one spectrum fit might be bad, it doesn’t stop be accessing the 99% successful

Simple Java Question: How to print a random int in one class that was generated in another?

Say that I have two classes, A and B, that are in the package Sample.

In class B, I have generated a random int b that is either a 0 or 1. I want to print int b in class A. What code should I use to do this?

Here is class B:

  package Sample;   import java.util.Random;      public class B {         Random random = new Random();         int b = random.nextInt(2); //b is either 0 or 1     } 

And I need code to go in class A here:

package Sample;   public class A {  //How do I print out the int b here?  } 

How safe is a password generated from words?

I loathe passwords with completely random letters and digits. It’s so much nicer to have a password made up of proper words. Even if the total length is much longer, it’s easier to memorize, transcribe, etc.

So I thought of this password generation scheme:

result = ""  while (result.length < 12)   result += randomWord()  if (result.length < 16)   result += shortRandomWord()  result += randomInteger(1000, 9999) 

In this example, assume that randomWord() returns an English dictionary word of length 4 to 10, and shortRandomWord() returns one of length 4 to 5. This is sure to give you a password of length 16 to 21, made up of 2 to 5 words, plus the 4 random integers.

Is this a good password generator? How does its entropy compare to a function that generates a password of length 8 with random letters and digits?

IIS Log files are not getting generated for the “SharePoint Web Services” webapplication in SharePoint – 2010?

IIS Log files are not getting generated for the “SharePoint Web Services” webapplication in SharePoint – 2010, even though Logging is enabled at the IIS level.

Is that an expected behavior? or this there nothing can be done to trace IIS logs for the “SharePoint Web Services” webapplication?

How to generated random waves

I want to generate a set of $ N$ random waves, where the wave vector and phase are random numbers, this is my code

 `Nwaves = 3;    theta := 2*Pi*RandomReal[];   phi := ArcCos@RandomReal[{-1, 1}] ; alpha :=  RandomReal[{0, 1}]; u = Sum[ Sin[ Cos[theta] Sin[phi]  x +  Sin[theta] Sin[phi]  y  +        Cos[theta] z + alpha], {Nwaves}] v = Sum[-Cos[ Cos[theta] Sin[phi]  x +  Sin[theta] Sin[phi]  y  +        Cos[theta] z + alpha], {Nwaves}]`  

This code changes the parameters for each N. And the problem needs to have the same values for cosine, sine, and alpha. And after each iteration they have to change as N varies.

`google-drive` pattern of generated Google Drive folder ID

$   gdrive list  Id                                  Name                                       Type   Size      Created 1tqeNnGiZqy4EMj8p6d_LG7Js0aD9ao37   9b69f5168c0aa4bbe9cd5f1546169cf3           dir              2019-09-16 14:16:18 1ule-XdDb1JrvAEwqwN80JLs7LGuLGUxC   subFile                                    bin    5.0 B     2019-09-16 14:16:25 1ndFenMDcQbJFpQb3ScpaumdlITzf6Tc3   subFile~                                   bin              2019-09-16 14:16:24 1iTo4NUBe01tWODnFwT9SOQuVARd9nV85   example                                    dir              2019-09-16 14:16:23 1FDxjPDWLnP89miUTVjJ_0WMwdDDy_o5_                                  bin    96.0 B    2019-09-16 14:16:22 146N7bhF2Ev5kvJwprpedSu9EWkYPz1ic                                     bin    197.0 B   2019-09-16 14:16:21 

Id of each file is generated as 33 characters and contains non-alphabetic characters.

=> Is it possible to compress it into 32 characters using base decoding.

I realize that all Id of listed each file starts with 1. So could I assume this pattern on the creation of the Id, where all of them starts with 1 and could I discard the 1 at the beginning.

For social media posts, is it better to post the Constant Contact generated URL or your website URL?

In social media posts, is it better to post the link to your website that advertises a specific event, or the URL to your Constant Contact (or other mass mail program) e-blast that advertises said event?

The details: our company often sends e-blasts out via Constant Contact to advertise training conferences that we produce, with the ultimate goal of increasing registration/attendance. These e-blasts are well-designed and often contain multiple elements pertaining to the conference: a…

For social media posts, is it better to post the Constant Contact generated URL or your website URL?

Running code generated in realtime in JavaScript with eval()

Consider a front-end JavaScript application where menu items needed to be shown or hidden based on somewhat simple logic (roles that user has and some other logical state).

A simple language was introduced to define this logic in a concise human-readable way and every menu item was assigned a string condition, which looks like this: "isLoggedIn() AND NOT role(PARTNER)".

In order to actually check this condition, a simple compiler was implemented, which translates this language into a valid JavaScript code string and executes it using eval() returning the boolean result in the end.

The compiler works by replacing some constructs, like AND, OR and NOT with valid JavaScript equivalents like &&, || and ! using simple regular expressions:

private compileExpression(expression: string) {    // Adding commas around function arguments (to make them strings)   expression = expression.replace(/(\w+)\((.*?)\)/g, `$  1('$  2')`);    // Replacing "AND"   expression = expression.replace(/\sAND\s/g, ' && ');    // Replacing "OR"   expression = expression.replace(/\sOR\s/g, ' || ');    // Replacing "NOT"   expression = expression.replace(/(\s|^)NOT\s/g, ' !');    // Prefixing predicates   expression = expression.replace(/(\w+)\((.*?)\)/g, 'Π.$  1($  2)');    return expression;  } 

This turns "isLoggedIn() AND NOT role(PARTNER)" into "Π.isLoggedIn() && !Π.role('PARTNER)", which is then executed by eval():

public matchCondition = (condition: string): boolean => {    // Using greek letter "P" for predicate (for shortness and uniqueness)   // noinspection NonAsciiCharacters   const Π = this.predicates;    const expression = this.compileExpression(condition);    const result = eval(expression);    return result;  } 

The Π is an object with simple predicate functions, which return boolean values like isLoggedIn(): boolean and role(roleName: string): boolean.

The expressions, that are being translated and executed are stored statically in local object as strings and are not accessible from global context. Also, all expressions are written by the developers and are not coming from users of the application in any way.

Is it safe to use eval() this way or should it be avoided at all costs (e.g. “eval is evil”, “never use eval”, etc)?

What are the possible attack vectors, that could be used to compromise such eval usage?

If expression strings will be loaded from the HTTPS server using XHR/Fetch, will it change the situation security-wise?

How to handle mapping of generated classes with identical fields?

We have a large number of classes that is generated by JAXB. There are a couple that have identical fields and I want to see if there is a clean way to map class A to class B.


public static class ParentA  implements ... {     public static class A implements ... {       protected String name;    } } 
public static class ParentB  implements ... {     public static class B implements ... {       protected String name;    } } 

I want to take an incoming A and map it to B but there are many other classes that I want to map A to. How can I handle this? I see that there is a copyTo method, but it only copies A to another A.