jquery.d.ts compilation failed: TsLint: exceeds maximum line length - visual-studio-2013

I am using VS 2013 with version 0.95 of TypeScript, but the linter fails the TS compilation with the error:
TsLint: app.ts checked. TsLint: jquery.d.ts compilation failed:
TsLint: exceeds maximum line length of 140
The jquery.d.ts file indeed has lines well over 140 in length, but I can't find the tslint config file to edit the max-line-length value.
I'm using WebEssentials 2013, I haven't installed tslint as part of a package (NPM or Nuget).
Can anyone point me in the right direction? I'm thinking it might just be easier to set up compile/linting outside of VS for now..
Thanks.

You can modify the tslint configuration file to change the maximum line length threshold. It uses a hierarchical configuration system so you can scope the change depending on where you create/modify the tslint.conf file.
By default, configuration is loaded from tslint.json, if it exists in
the current path, or the user's home directory, in that order. (source...)
On my windows computer the global configuration file was located in C:\Users\My.Username and changes here will apply to all projects. Creating or modifying the file in the root of the Visual Studio will mean the configuration settings will only apply to that project and will override the global configuration file.
The specific configuration option you need to modify for the maximum line-length is called max-line-length and would look something like this:
"max-line-length": [true, 140]
Change the 140 value to extend the allowed length of lines or change true to false to disable the max line length rule.
Alternatively, you can do what Steve has suggested in the other answer but you don't need to completely disable tslint because you can disable specific rules. The syntax for that is:
/*tslint:disable:rule1 rule2 rule3*/
So you would use:
/*tslint:disable:max-line-length*/
to disable the max-line-length rule for that file.
All of the configuration options and the rule-specific disabling are explained fully on the tslint website.

I believe that the max-line-length warning is for the length of a single line, rather than for the number of lines in a file.
You can either break the long lines up to make them smaller, or simply ignore files that aren't "your code".
/* tslint:disable */
// the jquery type definition
/* tslint:enable */
or set up your own config:
-c, --config:
The location of the configuration file that tslint will use to
determine which rules are activated and what options to provide
to the rules. If no option is specified, the config file named
tslint.json is used, so long as it exists in the path.
The format of the file is { rules: { /* rules list */ } },
where /* rules list */ is a key: value comma-seperated list of
rulename: rule-options pairs. Rule-options can be either a
boolean true/false value denoting whether the rule is used or not,
or a list [boolean, ...] where the boolean provides the same role
as in the non-list case, and the rest of the list are options passed
to the rule that will determine what it checks for (such as number
of characters for the max-line-length rule, or what functions to ban
for the ban rule).
From https://www.npmjs.org/package/tslint

Related

How to declare a set of parameters in omnetpp.ini

I have hosts of two types: wirelessHostA[0..N], wirelessHostB[0..N]. I want to declare each of hosts wirelessHostA[0..N] to send messages to respective wirelessHostB[0..N]. Example: A[0] sends to B[0], A[10] sends to B[10]. Expression-wise I have got something like this:
*.wirelessHostA[0..${N}].app[ * ].destAddresses = "wirelessHostB[0..${N}]"
although this one is not correct. I am a bit unsure about how to declare a variable that can be iterated during a run and not a value per run.
You should not see the lines in the INI file as assignments where you can create procedural constructs like loops etc. Instead think about them as pattern matching rules. When a module needs a parameter, it scans the INI file from start, line by line and tries to match the first part (i.e. the part before =) to the current module path. If it matches, it assigns the second part to the parameter. If not, in continues with the next line in the INI file.
So first, write a pattern rule, then a value that can be evaluated in that context. When you specify the value, you may refer to other parameters (that are available in the module's context) or you may refer to other extra contextual information, such as the matching submodule's index (if it is part of a vector). There are other functions to access the index of parent of etc.
In this case, we have a submodule vector of hosts where each one contains a submodule vector of apps. The index operator would return the index of the current context module (which is the position in the app vector), but we need actually the index of the parent of the app vector (which is the host vector). There is a NED function for this too, called parentIndex(). So the solution would look like this:
*.wirelessHostA[*].app[*].destAddresses = "wirelessHostB[" + string(parentIndex()) + "]"
See https://doc.omnetpp.org/omnetpp/manual/#sec:ned-functions:category-ned for more info.

Makecat failure: no members found

I am trying to modify existing input cdf file to use SHA256 instead of SHA1 by adding following two lines under [CatalogHeader] section:
CatalogVersion=2
HashAlgorithms=SHA256
Executing makecat.exe now gives me following failure message even though nothing under [CatalogFiles] has changed:
Failed: CryptCATCDFEnumMembersByCDFTagEx. Last Error: 0x00000057
Failed: No members found. Last Error: 0x00000057
Failed 0x00000057 (87)
Makecat does find and hash all files if I take out two lines I added.
Can anybody give me an idea what might be going wrong here?
Here is an example cdf file for MCVE:
[CatalogHeader]
Name=MCVE.cat
CatalogVersion=2
HashAlgorithms=SHA256
[CatalogFiles]
MCVE.xml=MCVE.xml
MCVE.xml is any old xml file you can find.
I encountered the same problem but was able to get it to work by putting '< HASH >' (without spaces) in front of each file entry. Example:
[CatalogFiles]
<HASH>manifest.json=.\manifest.json
<HASH>bsi.json=.\bsi.json
However, this causes the catalog file's entries to be tagged by their hash, instead of their filename, when viewing the .cat file in Windows Explorer. You can somewhat work around this by adding a custom attribute to display the filename in the catalog entry's details, as follows:
[CatalogFiles]
<HASH>manifest.json=.\manifest.json
<HASH>manifest.jsonATTR1=0x11010001:File:manifest.json
<HASH>bsi.json=.\bsi.json
<HASH>bsi.jsonATTR1=0x11010001:File:bsi.json
The attribute type is composed of (https://learn.microsoft.com/en-us/windows/desktop/seccrypto/makecat):
0x10000000: attribute is included in the catalog's hash
0x01000000: don't create a duplicated attribute with SHA1 hash (when using SHA256 and catalog version 2)
0x00010000: attribute is in plaintext, not base64
0x00000001: attribute is a keyvalue pair (e.g. File=bsi.json)
I discovered this workaround after running into the same problem as you when I found this example here: https://www-user.tu-chemnitz.de/~heha/viewzip.cgi/basteln/PC/USB2LPT/usb2lpt.zip/src/Makefile?auto=MAK
Hope this helps.
Can't add comments yet ---
Just wanted to say Jonathan's example with the 0x11010001 attribute works great, but PowerShell's Test-FileCatalog will still say it fails to parse the file. Using FilePath instead of File fixed this. Not sure if this is in the spec or just a powershell quirk or what, but it's what PowerShell does with New-FileCatalog.
Bonus points for not including the SHA1 hash, thanks!

Beyond Compare 3 folder comparison silent error 100

I am trying to compare between 2 folders in silent mode and get the exit code
However when I run it I always get error 100
C:\Users\admin>"C:\Program Files (x86)\Beyond Compare 3\BComp.com" /qc c:\Temp\source c:\Temp\destination
What am i doing wrong?
Quick Compare (/qc) is only for files and does not work for folders.
Source: Scooter Software
According to _Beyond Compare Command Line Reference, the /qc switch means quick comparison of two files and syntax is /qc=<type> | /quickcompare=<type>. Performs a quick comparison of two files and sets the DOS error level on exit. The specified type can be size, crc, or binary. If a type is not specified, a rules-based comparison will be performed. Error levels are documented in docs linked above.
First: Is a /qc switch allowed for folders as well?
And if so, how to interpret the If a type is not specified condition? I'd say
either omit the type /qc= and retain eguals,
or omit the type /qc,
or omit the switch at all?

How to read firefox's about:config entries using Python?

How could I read about:config entries for firefox version 30.0 using Python ? I tried to use what is pointed by this answer (in JavaScript) but it did not help.
Yeah, that's a problem. Firefox comes with default values for most preferences, and only stores values different from the default in the profile. Added to this, each add-on may come with additional default values and create new preferences at runtime.
The default pref files might be contained within zip files, which complicates matters a little.
Files
Files you'd have to check for default preferences (in a standard Firefox distribution)
$APPDIR/omni.ja:greprefs.js
$APPDIR/omni.ja:defaults/preferences/*.js
$APPDIR/browser/omni.ja:greprefs.js
$APPDIR/browser/omni.ja:defaults/preferences/*.js
$PROFILE/extensions/*/defaults/preferences/*.js
$PROFILE/extensions/*.xpi:defaults/preferences/*.js
While preferences that were overridden from the default reside in $PROFILE/prefs.js.
So first you need to figure out $APPDIR (installation path of Firefox) and then $PROFILE (Firefox user profile path).
Then you need to read some files either in some directories (easy) or in some zip files (hard). A major problem is that you cannot just use zipfile to read omni.ja (and potentially some of the xpi files) because a typical python zipfile implementation is too rigid in the interpretation of the zip structure and fails to open these files. So you'd need your own zipfile implementation that can deal with this.
Format
In the *.js files there are essentially two types of lines (+ blank lines, comment lines):
pref("name", value)
user_pref("name", value)
The pref lines are default preferences, user_pref lines are user preferences (overridden from default).
Values
value is a Javascript expression such as "abc", true, 1 or 2 * 3. The latter is a problem, as you'd need a JS engine to properly evaluate it. But this isn't really a problem in practice, as you won't find expressions computing something in the wild (usually).
Conclusion
Really replicating the preferences system (or about:config) isn't an easy task and full of obstacles. It is probably far easier just reading user pref.js to see what's overridden and knowing the default values.
Example (just prefs.js)
import re
import json
PROFILE = "/path/to/firefox/profile"
def read_user_prefs(preffile):
r = re.compile(r"\s*user_pref\(([\"'])(.+?)\1,\s*(.+?)\);")
rv = {}
for l in preffile:
m = r.match(l)
if not m:
continue
k, v = m.group(2), m.group(3)
try:
rv[k] = json.loads(v)
except Exception as ex:
print "failed to parse", k, v, ex
return rv
with open("{}/prefs.js".format(PROFILE), "rb") as p:
prefs = read_user_prefs(p)
for k, v in prefs.items():
print u"({type:<16}) {key}: {value}".format(
key=k, value=v, type=str(type(v)))
print
print "Chrome debugging enabled:",
print prefs.get("devtools.chrome.enabled", False)
print "Last sync:",
print prefs.get("services.sync.tabs.lastSync", 0.0)
print "Pref that might not exist:",
print prefs.get("does.not.exist", "default")
Alternatives
Write a firefox-addon that dumps interesting Preferences to a known file, or uses another form of IPC (sockets, whatever) to communicate with your python script.

Crystal Reports - change group header suppress formula programmatically

Using Crystal Reports 10 and vb6/classic (although I expect its the same in any language),
is it possible to change a suppression formula on a Group header section dynamically from code.
I'm basically changing the GroupConditionField on a specific group dynamically according to user input, but on that group header there is a suppression field formula containing a check on a grouped sum.
Sum ({#ColourTotal}, {Table.Field}) =0
If this is true, the group gets suppressed. This obviously comes up with an error complaining it can't find the group when the GroupConditionField is changed through code.
So is there a way to change the suppress formula for a specific group from within code?
I apologize this is C# but I had it handy. I need to so something similar so I have a formula that I set to a value from my program. The report checks this value to decide whether to suppress or not. I suspect you can use the same technique to change the formula, but I'm too lazy to test it my self.
report.DataDefinition.FormulaFields["Florida"].Text = (Convert.ToBoolean(option.EffectiveValue) == true ? "1" : "0");
This code just sets the formula field, "Florida" to either 0 or 1.
I believe I have found a way to do it using the Group Selection Formula under
Report->Selection Formulas-> Group inside the actual report.
Not ideal and will involve some reformatting but should work.

Resources