JSHint Error : This character may get silently deleted by one or more browsers - jshint

line 1, col 0, This character may get silently deleted by one or more browsers.
I get this error 4 times, for every .js file I've added.
For instance
error text:
'scripts/models/company.js: line 1, col 0, This character may get
silently deleted by one or more browsers '
scripts/models/company.js content:
import DS from "ember-data";
export default DS.Model.extend({
name: DS.attr('string'),
address: DS.attr('string')
});

This character is the UTF-8 BOM (Byte Order Mark), nothing to worry about. Just open the file in Notepad++ or another editor and change the encoding from 'UTF-8' to 'UTF-8 without BOM'.

Related

print function returning syntax error when used in Python3.6 IDLE (on MacOS)

I have a text file that contains some basic passwords and some variants of those basic passwords. They are typed out together like this:
qwerty, qwerty1
password, password1
default, default 1
123, 12345, 123456
I am trying to take these values and split them, storing them in a tuple and then print out the values as 'Password' and then any variants, but I am getting a syntax error on the print BIF? (I am aware this will not print out the password '123456', I am just trying to solve the syntax error first.)
for each_line in passwords:
(passwd, passwd_variant) = each_line.split(',',1)
print(f'Password: {passwd}, Variant {passwd_variant}')
SyntaxError: invalid syntax
normally if I was writing a script, in the editor I would put print on a new line, however a new line in IDLE simply executes the code above it. is there a shortcut or something to do a carriage return and write the print statement on a new line and if so, is that the cause of the syntax error and why?
Cheers
EDIT: I would like my output to be this
Finally discovered that you need to hit Enter after the for in statement, this will then take you to a new line inside for in statement. Was up all night trying to work it out, maybe my fresh brain helped this morning.

Steps to load a .txt file and convert the strings in it to usable data in a Sage notebook

I am on a Mac with OS 10.11.6, and I'm learning the notebook interface for Sage 7.2. As a start, in a Sage worksheet I created a .txt file containing the string [1, 2, 3] and saved it. I can open the text file directly and verify its contents just by clicking on it, but I can't yet do this in Sage.
I'd like to be able to open it and convert the string to a usable Sage object. I'd appreciate explicit instructions, assuming nothing at all about my Sage background. Thank you.
Note: The procedure to do what I just asked in the Sage documentation under "Saving and Loading Individual Objects" doesn't work in my environment (specs above.) I do A = [1, 2, 3]. Then I do save(A, 'A') and Sage returns a hot link for A.sobj. Then I hit the save-and-quit button. Then I hit "sign out." Then I sign back in and go to the worksheet where I did the steps I just described. I do A = load('A'). This is what Sage says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("QSA9IGxvYWQoJ0EnKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/7n/t9k4hfyn44s2qp7wxt479kn80000gn/T/tmpEa1OkK/___code___.py", line 2, in <module>
exec compile(u"A = load('A')" + '\n', '', 'single')
File "", line 1, in <module>
File "sage/structure/sage_object.pyx", line 1032, in sage.structure.sage_object.load (build/cythonized/sage/structure/sage_object.c:11594)
IOError: [Errno 2] No such file or directory: 'A.sobj'`
I found an answer in Finch's book. First a quote:
“We used a module called os from the Python standard library module to help us write code that can run on multiple platforms. A text file must have a special character to denote the end of each line in the file. Unfortunately, for historical reasons, each family of operating systems (Mac, Windows, and UNIX) uses a different end-of-line character. The os module has a constant called linesep that contains the correct character for the platform that the code is run on. We used the statement import os to make the module available, and accessed the constant using the syntax os.linesep. We also used the function os.path.join to join the path to the file name with the correct character for the current operating system.”
Excerpt From: Craig Finch. “Sage Beginner's Guide.”
Example using a file named "File2.txt" containing a single text character, '1':
import os path='/Users/barrybrent/.sage/sage_notebook.sagenb/home/store/2/21/212/2123/admin/19/data/' fileName='File2.txt' times = [] text_file = open(os.path.join(path, fileName), 'r') line = text_file.readline()
(Comment: is just a character string. To convert it a Sage object useful in computations:)
elements=line.split(',') times.append(float(elements[0].strip()))
(Comment: evaluate:)
times[0]
(Comment: Sage says"1.0". Now can we do arithmetic with times[0]?)
times[0]+1
Sage says "2.0"

"Fre3of9x" Barcode font, won't load

So, I'm trying to load a "Barcode" font that will replace normal text to barcode on my webpage.
Now I'm new of using fonts. The font I'm trying to use is this:
http://www.fontsupply.com/fonts/F/Fre3of9x.html FRE3OF9X.TTF
The error message is this: Failed to decode downloaded font:
I can see, the font is loading 304 in network console. So what is causing this problem?
HTML
<div class="barcode"><span class="barcodeText">*11111*</span></div>
CSS
#font-face {
font-family: 'FRE3OF9X';
src: url('/fonts/FRE3OF9X.TTF');
}
.barcodeText{
font-family: 'FRE3OF9X', 'Georgia', serif;;
}
Result
*11111*
I also got this message OTS parsing error: maxp: failed to parse table. But I do not really know what it is for.
FIDDLE
https://jsfiddle.net/f2a6gcvu/
EDIT
I did not solve this, but changed font. 3 of 9 works just fine.
https://www.searchfreefonts.com/free/3-of-9-barcode.htm
The reason you're getting the decode error is because the font actually is corrupt. Running it through TTX (a utility for switching font representations between binary and XML form) gives us this:
> ttx FRE3OF9X.TTF
Dumping "FRE3OF9X.TTF" to "FRE3OF9X.ttx"...
Dumping 'GlyphOrder' table...
Error: cmap subtable is reported as having zero length:
platformID 1, platEncID 0, format 0 offset 20. Skipping table.
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'hmtx' table...
Error: cmap subtable is reported as having zero length:
platformID 1, platEncID 0, format 0 offset 20. Skipping table.
Dumping 'cmap' table...
Dumping 'loca' table...
Dumping 'glyf' table...
Dumping 'name' table...
Dumping 'post' table...
As the cmap structure contains the information about which character a font supports, a broken cmap subtable is a terminal error. You can try to derive the broken data from other cmap subtables (which is what Photoshop is probably doing) but that's not guaranteed to do the right thing. Browsers err on the side of caution, so this font is simply going to get rejected.
What to do: 1. report this font as broken to the website so they can either have it fixed or removed, 2. pick a new font (I see you already did that), and 3. probably grab yourself a copy of TTX for checking bad fonts in the future.

File could not be found error downloading file in Internet Explorer

I'm having problems when trying to use the Open option in Internet Explorer when serving an excel document from an ASP.NET web app.
Response.AddHeader("content-disposition", "attachment;filename=" + filename.Replace(",", "") + ".xls");
Response.Charset = String.Empty;
Response.ContentType = "application/vnd.xls";
using (StringWriter sw = new StringWriter())
using(HtmlTextWriter hw = new HtmlTextWriter(sw))
{
gridView.RenderControl(hw);
Response.Write(sw.ToString());
}
Response.End();
I didn't write the code but what I have noticed is that if the filename length is <= 177 then it works. Anything over >= 118 I receive a file could not be found error. I've checked the the 118th character is a 0 so doesn't appear to be anything to do with this.
Any ideas what might be causing this as it seems to work fine in Chrome and Firefox.
I think here is the reason: http://support.softartisans.com/kbview_892.aspx
Although the NTFS or FAT32 file systems can support filenames up to
255 characters, it isn't possible to use a file input to upload a file
with a name that long. This is due to the way that IE inserts the
chosen file into the form field.
When you browse to a file and select it using the File input, IE
inserts the full file path. IE also limits you to 255 characters, but
counts the file path against that limit. This means that if you had a
path with a length of 55 characters, the maximum length of the file
name that you could choose to upload would be 200 characters.
also this may be helpful:
https://stackoverflow.com/a/153400/20126
However, there is still a limitation (apparently IE-only) on the
byte-length of the file name (a bug, I assume). So even if the file
name is made of only single-byte characters, the beginning of the file
name is truncated. The limitation is around 160 bytes.

Unicode errors after upgrade to 2.1.0 final

I've recently upgraded a DjangoCMS project from 2.1.0beta3 to 2.1.0
final, and I've started getting Unicode errors during page editing.
There was a large volume of production content that was migrated
forward with South. I get the error while (using TinyMCE) I try to
insert another plugin, such as an image, into a text plugin or when I
try to add a plugin to a placeholder.
URL:
/admin/cms/page/188/edit-plugin/673/edit-plugin/676/
Stack Trace:
File "/srv/wsphp/wspython/virtualenv/iaffe-prod/lib/python2.6/site-packages/django/template/__init__.py", line 849, in render
return _render_value_in_context(output, context)
File "/srv/wsphp/wspython/virtualenv/iaffe-prod/lib/python2.6/site-packages/django/template/__init__.py", line 829, in _render_value_in_context
value = force_unicode(value)
File "/srv/wsphp/wspython/virtualenv/iaffe-prod/lib/python2.6/site-packages/django/utils/encoding.py", line 88, in force_unicode
raise DjangoUnicodeDecodeError(s, *e.args)
DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 12: ordinal not in range(128). You passed in <django.forms.forms.BoundField object at 0xb73cedec> (<class 'django.forms.forms.BoundField'>)
If I repeatedly try to create the plugin, the ID (676 here) increments,
so it looks like the error happens when the form is rendered. This
affects link, picture, and teaser plugins, but not text, file or
snippet plugins.
I'd appreciate any help in isolating the cause here.
Thanks,
Michael
Bit of a late answer, but I had some problems with unicode and solved in with defining source code encodings also see http://evanjones.ca/python-utf8.html
I put
# -*- coding: utf-8 -*-
at the top of the offending files and everything was sorted.
It turns out that this was a data migration issue. The ultimate solution was to force utf8 encoding in the relevant mysql tables using commands like:
alter table cms_page convert to character set utf8;

Resources