Incoherent local/global line numbering in Scinotes - user-interface

When I switch on the "local line numbering" option in SciNotes, I get a strange effect. The line numbers show as local (starting with the "function" line) for some of my functions, but global (counting from the beginning of the code file) for others.
My first thought was that a function wasn't ended properly (too few "end" instructions wrt the number of opened loops, ifs and other such), but then my code would crash, which it doesn't. Also, indentation looks fine when I auto-adjust it.
It doesn't very much get in my way, but I wonder if it isn't a symptom of something more serious cooking under the surface. Has anybody had a similar experience?
FWIW I'm using Scilab 6.0.2 under Windows 10.

I think I have found the source of the "problem". Line numbering only gets local in a function whose first line (the one with the "function" keyword) is not terminated with a semicolon.
Like this:
1 // This is my fantastic power program
2 clear;
3 clc;
4 cd "c:\myDir\Scilab\Sandbox\FunAndGames"
5
6 function S=square(x); // <-- now you see it
7 S=x*x; // (the semicolon, I mean)
8 endfunction;
9
1 function C=cube(x) // <-- now you don't
2 C=x*x*x;
3 endfunction;
13
14
15 // Now the body of my program:
16
17 X=zeros(5,5);
18 ....

Related

How to see the graphical representation of emoji codepoints in R Studio Windows?

I have in a data frame a column with code points corresponding to emoji.
They look something like this:
1F1E8
I am using the remoji library, but as you can see my code points do not have \U in front of them, which is necessary for the methods of this library, as far as I know.
Example:
#This works
message (sub_emoji ("This is silly \U1f626"))
#this does not work
message (sub_emoji ("This is silly 1f626"))
The most I've managed to do is transform the code points to \\U1f626 but it doesn't work either.
Thanks in advance
The solution I was trying was to paste the string "\U" at the beginning of the code points, but being the \ an escape character I couldn't do it. But with some "tricks" it can be done:
I transformed all the code points to the following structure (8 hex digits):
\\U000xxxxx (000 if 5 hex digits in the original code point)
\\U0000xxxx (0000 if 4 hex digits in the original code point)
I have not delved into their implication ("fill" with 0), but the truth is that they work the same way, as far as I've tried:
message(sub_emoji("This is silly \U0001f626"))
This is silly 🤦
and
message(sub_emoji("This is silly \U1f626"))
#This is silly 🤦
I "filled" with 0 because I used the function stri_unescape_unicode() to un-escape the code points \\Uxxxxxxxx and get the desired result \Uxxxxxxxx (one \) to pass it to sub_emoji()
And this function, stri_unescape_unicode(), only gives this result (one \) if the code point has 8 hex digits, I did not study why, I only noticed this by messing around. I also noticed that if the u is lowercase it has another effect.
For example:
#it does not work
stri_unescape_unicode("\\U1F926")
#[1] NA
#Warning message: .....
stri_unescape_unicode("\\U1F926\\U1F3FB")
#[1] NA
#Warning message: .....
#it works
stri_unescape_unicode("\\U0001F926")
#[1] "\U0001f926"
stri_unescape_unicode("\\U0001F926\\U0001F3FB")
# [1] "\U0001f926\U0001f3fb"
A complete example:
em = stri_unescape_unicode("\\U0001f626")
message(sub_emoji(paste("This is silly", em)))
#This is silly 🤦
emc = stri_unescape_unicode("\\U0001F926\\U0001F3FB")
message(sub_emoji(paste("This is silly", emc)))
#This is silly 🤦🏻
Pay attention to this last emoji, it has a different skin and hair color, there is the effect of ZWJ Sequence.

cudnn without any framework

Does anyone have an idea, what is matched wrong.
It compiles without any error, etc., but the Output goes always from Predict class 5 to 3 to 1 and doesnt change.
Code(important here PropagationHelper&Network&Layer):
Output:
Update Weight(Value of ConvGradConv is to huge!)
Networkflow(first 5 and last 5 data in each layer)
Okay one Error corrected(FullyBackward used inchannel insteed of inputsize), but there must be another one with the ConvLayer.

How do I properly parse the range information in a unified diff?

Basically, what I want to do is look at the range information of a unified diff and know exactly which lines of code I should pay attention to.
For instance, this:
## -1827,7 +1827,7 ##
This tells me that in total only 1 line has changed, because the diff shows 3 lines above and below the change (so 7 - 6 = 1), and it also points me to the line 1830 (i.e. 1827 + 3).
To be more pedantic, this particular range information actually tells me that at line 1830, a line was removed (-), and at line 1830 a line was added (+).
Or to make that more obvious consider this range information for another diff:
## -878,15 +878,13 ##
What this is telling me is that at line 881 (878 + 3) 9 lines were deleted (15 - 6), but at line 881 only 7 lines were added (13 - 6).
So the question is, using a regex or some other Ruby string method, how do I pull out the above information easily?
i.e. how do I easily pull out this info:
Both The line numbers (i.e. just the 1827 or 878), which I can then add + 3 to determine the actual inline number I care about. It has to be both because both lines may not always be identical.
The number of lines affected (aka the 7, 15 or 13 right after the , in the above examples)
While I do that, how do I make sure to track the operation (addition or deletion) for each of the operations.
I tried slicing the string and going directly for a character -- e.g. myString[3] which gives me -, but that's the only character it reliably works for because the line numbers can be 1, 10, 100, 1000, 10000, etc. So the only way is to just scan the string and then parse it.
Edit 1
To add some code to show what I have tried.
Assume I have the contents of a diff in a variable called #diff_lines:
#diff_lines.each do |diff_line|
if diff_line.start_with?("##")
del_line_num_start = diff_line.split(/## /).second.split.first.split(/-/).second.split(/,/).first.to_i + 3
num_deleted_lines = diff_line.split(/## /).second.split.first.split(/-/).second.split(/,/).second.to_i - 6
add_line_num_start = diff_line.split(/## /).second.split.second.split(/\+/).second.split(/,/).first.to_i + 3
num_added_lines = diff_line.split(/## /).second.split.second.split(/\+/).second.split(/,/).second.to_i - 6
As you can see, the above works....but it is quite horrendous to look at and is OBVIOUSLY not very DRY.
Ideally I would like to be able to achieve the same thing, but just cleaner.
The general idea is to write a regular expression that has capture groups in it ((...)) to pick apart that string into something useful. For example:
diff_line.match(/\A##\s+\-(\d+),(\d+)\s+\+(\d+),(\d+)\s+##/)
This yields a MatchData object on a successful match. You can then apply this to some variables like:
if (m = diff_line.match(...))
a_start, a_len, b_start, b_len = m[1..4].map(&:to_i)
end
Then you can do whatever computations you need to do with these numbers.
If you're ever having trouble visualizing what a regular expression does, try a tool like Rubular to better illustrate the internals.

Why is Visual Studio dropping me into a disassembly window when debugging?

I am facing a strange problem while I am debugging my program.
I developed a program that was working fine. Even when I made a minor change (added a hard-coded statement instead of putting watch for a variable and changing its value) in one part of the code, it was still working fine. But then I removed those changes, and from that point onward the program has been behaving very oddly. The variable that was hard-coded is still keeping the hard-coded value and not the one it should have according to flow.
I changed the line number 24 with the statement
return "shweta#2k7.com";
and again reverted the change to make it similar to the previous one, except that I deleted one blank line. So the total number of lines in the current code is 1 fewer than the previous code as shown below.
Now when I debug it, the control goes up to line no 26 even though there is nothing written there, and it returns the previous value "shweta#2k7.com" (which occurs nowhere in the code), instead of " ".
Current Code:
1 public string GetUserEmail(string userName)
2 {
3
4 if (!UserExists(userName)) return "";
5 try
6 {
7 DirectorySearcher search = new DirectorySearcher(_directoryEntry);
8 search.Filter = "(SAMAccountName=" + userName + ")";
9 search.PropertiesToLoad.Add("mail");
. .
. .
. .
19 }
21 catch
22 {
23 return ""; //"username#domain.com";
24 }
25 }
Previous Code:
1 public string GetUserEmail(string userName)
2 {
3 if (!UserExists(userName)) return "";
4 try
5 {
6 DirectorySearcher search = new DirectorySearcher(_directoryEntry);
7 search.Filter = "(SAMAccountName=" + userName + ")";
8 search.PropertiesToLoad.Add("mail");
. .
. .
. .
18 }
22 catch
23 {
24 return "username#domain.com"; //line number 24
25 }
26 }
After returning from this function, control passes to the Disassembly window where some assembly code is displayed.
Why is this happening?
Yes you are correct, It is running older version.
I am using Visual studio 2008. I did all such things like cleaning solution prior to Build/rebuild. But no gain.
I know the line inside catch executes only if try block fails, but here scenario is different(confusing too). It is not looking whether try failed or succeed, it is just looking line numbers. because when there is nothing in the line 26, then also control goes there.
I tried by removing blank line at 26, then control went to line 27(26 after removing blank line). you'll wonder by knowing that there was comment at line 27!!
However I have checkout the last safe version from SVN, and that worked fine.
But I'm also curious to know about this.
Shweta,
Line 24 is inside a catch statement, which is executed only if the try() fails. Is it possible that the try() succeeds, so Line 24 never executes?
On second thought, this smells like a case of not running the code that you think you're running: is it possible that your new source hasn't compiled properly, so you're still running the old version? If you're using an IDE (or a good makefile), you might try running clean, or manually deleting the object and executable files, and then rebuilding from scratch.
When you find the problem, please post a follow-up. I'm curious!
Good luck.

Code block in numbered list (Wiki syntax)

In MediaWiki (wikipedia's) wiki syntax, is there a way to have a numbered list with a code block in the middle?
For example:
# Number 1
# Number 2
Indented section that will become a code block
# Number 3
# Number 4
What happens in MediaWiki is you end up with something like this:
1. Number 1
2. Number 2
Indented section that will become a code block
1. Number 3
2. Number 4
(Note how "Number 3" and "Number 4" are reset as 1 and 2... It looks like StackOverflow is much smarter than MediaWiki, i had to put my example in PRE tags to make it screw up!)
I know you can indent text using "#:" syntax...
# Number 1
# Number 2
#: Indented section that will merely be indented
# Number 3
# Number 4
...but I really would like to get the same visual CSS class for my code even if it's in a numbered list.
It gets even more entertaining with nested lists. This syntax...
# MainEntry 1
## Number 1
## Number 2
# MainEntry 2
## Number 1
## Number 2
Indented section that will become a code block
## Number 3
## Number 4
...becomes...
1. MainEntry 1
1. Number 1
2. Number 2
2. MainEntry 2
1. Number 1
2. Number 2
Indented section that will become a code block
1. 1. Number 3
2. Number 4
(Note how "Number 3" is now "1. 1.")
You could try the following wiki syntax, it works for me on 1.17
# one
#:<pre>
#::some stuff
#::some more stuff</pre>
# two
It is not perfect, because you end up with a more indent but it does allow one to use the wiki syntax for correctly formatted pre blocks over multiple lines.
As previously mentioned, the other proper way would be to use HTML mark up.
<ol>
<li>one</li>
<li>two</li>
<pre>some stuff
some more stuff</pre>
<li>three</li>
</ol>
Use html:
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
it will work in mediawiki.
Note from the example that I posted below, it is the </li> that makes it work properly.
This works fine in MediaWiki 1.17.0:
===Alternative way of using pre in numbered lists.===
# Numbered line 1.
# Numbered line 2.<pre>code line 1
code line 2</pre>
# Numbered line 3.
The secret is to replace the newlines with the
entity and write everything in one line.
Your issue is the subject of two bugs filled in the MediaWiki bug tracker in late 2004 and 2005 :
Bug 1115 - Newline as list item terminator is troublesome
Bug 1584 - Need method for multiparagraph list items, continuing numbered lists, and assigning specific numbers to list items
By reading them, you will find the solution is to not use the MediaWiki syntax but to rely on "pure" HTML.
I'm suggesting a different answer: don't do it.
I've attempted to use all the workarounds for this basic Mediawiki issue and found that they are all very imperfect. I've learned to live without numbers, and instead:
Use the splat (*) instead of (#) for all my lists
Continue to use the leading space for all my code blocks
This is far far simpler and maintainable than any workaround. Besides, use of any reference to a number is subject to change as the steps are edited - and this then becomes another maintenance issue.
In the above example the second indentation (::) is not necessary.
Just one indentation works fine (:) as follows:
# one
#:<pre>
#:some stuff
#:some more stuff</pre>
# two
Produces:
1. one
some stuff (just one indent level, not two)
some more stuff
2. two
You can also try adding a "blockquote" tag surrounding the "pre" tag, makes it look a little more polished.
== HAProxy Configuration ==
#'''File:''' /etc/haproxy/haproxy.cfg
<blockquote>
<pre>
global
log 127.0.0.1 local1 notice
maxconn 4096
#daemon
debug
crt-base /usr/local/haproxy/ssl
</pre>
</blockquote>
Which will indent the gray box in line with your bullets/numbers without using colons.

Resources