Certain Vim digraphs do not display properly - vim

Superscript 2,3,+ subscript 4 do not display properly. Superscript 2 displays as <8e> and superscript 3 displays as <8f>, and subscript 4 displays as ㄙ, superscript + displays as ס.
In my .vimrc the following is set:
execute "digraphs 0S " . 0x2070
execute "digraphs 1S " . 0xB9
execute "digraphs 2S " . 0xB2
execute "digraphs 3S " . 0xB3
execute "digraphs 4S " . 0x2074
execute "digraphs 5S " . 0x2075
execute "digraphs 6S " . 0x2076
execute "digraphs 7S " . 0x2077
execute "digraphs 8S " . 0x2078
execute "digraphs 9S " . 0x2079
execute "digraphs +S " . 0x207A
execute "digraphs -S " . 0x207B
execute "digraphs =S " . 0x207C
execute "digraphs (S " . 0x207D
execute "digraphs )S " . 0x207E
execute "digraphs nS " . 0x207F
execute "digraphs 0s " . 0x2080
execute "digraphs 1s " . 0x2081
execute "digraphs 2s " . 0x2082
execute "digraphs 3s " . 0x2083
execute "digraphs 4s " . 0x2084
execute "digraphs 5s " . 0x2085
execute "digraphs 6s " . 0x2086
execute "digraphs 7s " . 0x2087
execute "digraphs 8s " . 0x2088
execute "digraphs 9s " . 0x2089
There are some other anomalies but I would imagine any solution that addresses those 4 can be applied to the rest. I've tried setting encoding to utf-8 and using decimal values instead of hex but the problem persists. I feel like it's the font but I've tried about a dozen different fonts and each results in the same weird characters. Any ideas?

Why, exactly, are you redefining all those digraphs to their built-in values? And How, exactly did you determine that subscript 4 was ㄙ?
₄ is obtained with <C-k>4s while ㄙ is obtained with <C-k>s4 so it looks to me like you are simply pressing the keys out of order.

Related

How to time a vimscript execution?

I try to compare two versions of a same vim function. How can I time them and compare?
What I'm looking for is a simple way to benchmark the first version of the function against the second one, with some kind of precise time echo.
Thank you!
Here is a simple demonstration of the use of :help reltime() and :help reltimestr():
function! Foo()
" do your thing
for i in range(1,8)
let #a = i
endfor
endfunction
" save current time
let start_time = reltime()
" call your function
call Foo()
" echo elapsed time expressed in seconds
echo "elapsed time:" reltimestr(reltime(start_time))
It should output something like:
elapsed time: 0.000165

Adding numbers in bash script says "not found"

I'm making a bash script in Vim editor for my operating systems fundamentals class, and I am having an extremely simple yet frustrating error occur where I cannot add variables together and set the sum to another variable. I've tried numerous formats to get this done, however it either prints out each value or a ": not found" error. Here is the code I have so far, I simply want to set the sum of the values for each test into the variable 'finalgrade' and print the output.
echo "Enter assignment mark (0 to 40): " ; read assignment
echo "Enter test1 mark (0 to 15): " ; read test1
echo "Enter test2 mark (0 to 15): " ; read test2
echo "Enter final exam mark (0 to 30): " ; read exam
finalgrade = $assignment + $test1 + $test2 + $exam
echo "Your final grade is : "$finalgrade
This is an example of what I get when I run it:
$ sh myscript
Enter assignment mark (0 to 40):
1
Enter test1 mark (0 to 15):
2
Enter test2 mark (0 to 15):
3
Enter final exam mark (0 to 30):
4
myscript: 5: myscript: finalgrade: not found
Your final grade is :
I instead expected the last line to be:
Your final grade is : 10
Thanks,
This line
finalgrade = $assignment + $test1 + $test2 + $exam
will not perform any math. Googling "bash math" will provide various ways to do this but here is one;
finalgrade=$((assignment + test1 + test2 + exam))
It is worth noting that your actual problem is that you have spaces beside the assignment = which causes bash to interpret this as a command "finalgrade" (not found) instead of an assignment. Variable assignments must not have spaces beside the =.

Test::MockTime does not mock time in certain cases

I have a very simple script which mocks time using Test::MockTime, but the output of time call is different in two parts of the code.
Here is the script:
package mocker;
use strict;
use warnings;
sub abcd {
print "in abcd, time is " . time . "\n";
}
BEGIN {
use Test::MockTime qw(set_absolute_time restore_time);
set_absolute_time(0);
};
sub do_mock {
print "Current epoch in do_mock is: " . time . "\n";
abcd;
restore_time();
}
1;
I call mocker::do_mock in my script:
use strict;
use warnings;
use mocker;
mocker::do_mock;
I expect output to have "0" as current time in both print statements but strangely I have this output:
Current epoch in do_mock is: 0
in abcd, time is 1450343385
So, WHY in abcd time is restored to current time?
The documentation for Test::MockTime explains that "it overrides localtime, gmtime and time at compile time." So:
print "Before: " . time; # Uses CORE::time()
use Test::MockTime; # Override time()
print "After: " . time; # Uses overridden time()
You can see this using B::Deparse:
$ perl -MO=Deparse foo
print 'Before: ' . time;
use Test::MockTime;
print 'After: ' . &CORE::GLOBAL::time();
foo syntax OK
The second call to time() actually uses CORE::GLOBAL::time(), which is the overridden version.
To fix, make sure Test::MockTime is compiled before you call time():
package mocker;
use strict;
use warnings;
use Test::MockTime qw(set_absolute_time restore_time);
sub abcd {
print "in abcd, time is " . time . "\n";
}
BEGIN {
set_absolute_time(0);
};
sub do_mock {
print "Current epoch in do_mock is: " . time . "\n";
abcd;
restore_time();
}
1;
You can see this answer to better understand how a BEGIN block woks.
The point here is that it's executed before the main body, but it also has to be compiled. This means that the order in which you put your declarations and your BEGIN block is relevant.

Strings with WPML and Wordpress

I have a really impossible task for me. I know how put string content in wordpress ( )
but i don't know how put in this code. I want delete call and show text string.
if (!is_page_template('splash.php')) {
echo '<!-- _________________________ Start Custom HTML _________________________ -->' .
'<div class="header_html">' . "\n" .
'<div class="header_html_outer">' . "\n" .
'<div class="header_html_inner">' . "\n";
if ($cmsms_option[CMSMS_SHORTNAME . '_header_custom_html']) {
echo stripslashes($cmsms_option[CMSMS_SHORTNAME . '_header_html']) . "\n";
}
echo '<div class="cl"></div>' .
'</div>' . "\n" .
'</div>' . "\n" .
'</div>' . "\n" .
'<!-- _________________________ Finish Custom HTML _________________________ -->';
}
i can change it with the nexxt code, but show in front : _e( "text i want translate", "comercialdelmotor");
if (!is_page_template('splash.php')) {
echo '<!-- _________________________ Start Custom HTML _________________________ -->' .
'<div class="header_html">' . "\n" .
'<div class="header_html_outer">' . "\n" .
'<div class="header_html_inner">' . "\n" . '_e( "text i want translate", "comercialdelmotor");';
echo '<div class="cl"></div>' .
'</div>' . "\n" .
'</div>' . "\n" .
'</div>' . "\n" .
'<!-- _________________________ Finish Custom HTML _________________________ -->';
}
I hope I understood your question correctly. You are correct in using _e() to echo a string. Your syntax use is wrong though. Never ever use " to enclose a translatable string, the translator does not recognise it, so your string is skipped/ignored.
The correct way is to use '. So your string should look something like this _e( 'string to be translated', 'domainname' ); Note that domainname is optional, so using _e( 'string to be translated' ); is also correct.
You can go and read more about translating your theme in this great tutorial. http://code.tutsplus.com/tutorials/translating-your-theme--wp-25014

i am having problems passing a variable from a php page to another php page using a hyperlink

I had the code working at one time but i changed something and it quit working.
The $id gets passed to the address bar on the browser but not to the next page.
I used the session_start
while($row = mysql_fetch_array($resultd))
{
$id = $row['id_num'];
echo "Edit "; //ln68
echo "<a href='del.php?id_num = $id'>Delete</a>";
echo $row['id_num'] . " " . $row['first_name'] . " " . $row['last_name'] . ", " . $row['title'] . ", " . $row['city'] . ", " . $row['phone_pri'] . ", " . $row['email_addr'];
echo ""; }
The receiving page is not getting the variable. I have used $_SESSION, $_GET, $_POST and nothing seems to work. I have even reversed the values in the href line and still nothing works. I used session_start here also.
this is page 2
$id = $_POST['id_num'];
// send query
$sql = 'delete FROM `delegate` WHERE `id_num`= $id';
Your comments would be most appreciated.
You are using GET request for passing the data via link
but in your second page, you are using POST
change it to $id = $_GET['id_num']; and try
and dont use spaces in href "
change it to "
space will be counted as a character

Resources