Wikipedia:Reference desk/Archives/Computing/2014 March 19
Computing desk | ||
---|---|---|
< March 18 | << Feb | March | Apr >> | March 20 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
March 19
[edit]HTML code for 'Numbered Navigation' and 'Back to top' button
[edit]Hi, Can anyone help me by providing the HTML/CSS code for getting Numbered Navigation and Back to top button as in labnol, a blog run by Amit Agarwal?--Joseph 04:24, 19 March 2014 (UTC)
- Do you mean how do you do the circles behind the navigation items?
- HTML:
<div class="pagenav clearfix"> <a href="#">1</a> <a href="#">2</a> <a href="#">3</a> </div>
- CSS:
.pagenav { min-width: 24px; min-height: 20px; text-align: center; margin: 0 3px; padding: 4px 0 0; vertical-algin: middle; display: inline-block; border-radius: 10em; }
--Canley (talk) 05:11, 19 March 2014 (UTC)
- Yes, sir. I need a code to navigate pages with numbers as in the above mentioned blog. Also, I need a Back to top button too...--Joseph 06:32, 19 March 2014 (UTC)
- Sir, I don't have much knowledge in HTML and CSS, so I need complete codes to generate this Numbered Navigation and Back to top button as in labnol. I want to implement this in my own blog. Can you help me?--Joseph 06:47, 19 March 2014 (UTC)
- Canley has given the answer, but it might need some decoding. You need two things a Cascading Style Sheets which should appear at the top of you page in the
<head>
. This defines two CSS classes .pagenav and .back-top which define how particular html elements will look
- Canley has given the answer, but it might need some decoding. You need two things a Cascading Style Sheets which should appear at the top of you page in the
<html>
<head>
<style type="text/css">
.pagenav {
display: inline-block; // make the item behave like a block
background: #000; // black background
color: #fff; // white foreground
min-width: 24px; // smallest width
min-height: 20px; // smallest height
margin: 0 3px; // make some space around the box
padding: 4px 0 0; // make some space between the text in the box and the border of the box
text-align: center; // center text in the box
vertical-algin: middle; // center text in the box vertically
border-radius: 10em; // this makes the border have a large radius giving the circle effect.
}
.back-top {
background: #000; // similar for the back to top button
color: #fff;
font: normal 16px/100% "Times New Roman", Times, serif;
width: 30px;
height: 26px;
padding-top: 4px;
text-align: center;
text-decoration: none;
display: inline-block;
zoom: 1;
border-radius: 10em;
box-shadow: 0 2px 0 rgba(0,0,0,.1);
}
</style>
</head>
Then in the main <body>
of the page you need to give the appropriate class using the class attribute <a class="pagenav">
<body>
<a name="top"></a> <!-- Marks the top of the page -->
Normal text
<a href="page1.html" class="pagenav">1</a>
<a href="#top" class="back-top">↑</a>
</body>
</html>
You could have everything in one line using style. A bit clunky but it works here for demonstration
<span style="background: #000; color: #fff; border-radius: 10em; min-width: 24px;
text-align: center; margin: 0 3px; padding: 4px 0 0;
vertical-algin: middle; min-height: 20px; display: inline-block;">5</span>
Displayed as 5 Its worth reading up a bit on CSS to understand this. You will also need to find how you use CSS with your blogging platform.--Salix alba (talk): 07:48, 19 March 2014 (UTC)
- Sir, This is my blog. Can you help me figure out the errors there?--Joseph 09:05, 19 March 2014 (UTC)
- Did you have it working before? I had a look at your blog about an hour ago and the Back-to-top button had a black circle around it and went back to the top. I just looked again and it's a grey square. --Canley (talk) 10:33, 19 March 2014 (UTC)
- Thanks for your great help, sir. I've made slight modifications in the code and implemented it on my blog. And it appears to be OK now. I need one more help from you...can you provide me the code to give a slight animation, while clicking on the back to top button? ie, the code to move to the top of the page slowly...! Also, is it possible to automatically update the page number according to posts? I used to have 6 posts in my blog and I need to arrange page wise navigation according to that..! Thanks again for your help..!--Joseph 11:06, 19 March 2014 (UTC)
- Smooth scrolling requires javascript see for example[1] and [2] getting this to work in your blog platform might be tricky and seems to require jQuery. Finding how many blog posts you have will require detailed information on the inner workings of blogspot and again require javascript.--Salix alba (talk): 13:19, 19 March 2014 (UTC)
- Thanks for your great help, sir. I've made slight modifications in the code and implemented it on my blog. And it appears to be OK now. I need one more help from you...can you provide me the code to give a slight animation, while clicking on the back to top button? ie, the code to move to the top of the page slowly...! Also, is it possible to automatically update the page number according to posts? I used to have 6 posts in my blog and I need to arrange page wise navigation according to that..! Thanks again for your help..!--Joseph 11:06, 19 March 2014 (UTC)
- Did you have it working before? I had a look at your blog about an hour ago and the Back-to-top button had a black circle around it and went back to the top. I just looked again and it's a grey square. --Canley (talk) 10:33, 19 March 2014 (UTC)
- Sir, This is my blog. Can you help me figure out the errors there?--Joseph 09:05, 19 March 2014 (UTC)
- You can do smooth scrolling with CSS transtions - e.g.[3] -- Finlay McWalterჷTalk 13:34, 19 March 2014 (UTC)
![](http://upload.wikimedia.org/wikipedia/en/thumb/f/fb/Yes_check.svg/20px-Yes_check.svg.png)
Vertically centred tilde in MS PowerPoint
[edit]In MS Notepad and in Firefox on Wikipedia my tildes are vertically centred but in PowerPoint they are aligned at the top. How do I get them to align vertically centred? Thanks :) ~ --129.215.47.59 (talk) 14:18, 19 March 2014 (UTC)
- Are you using different fonts in each program? I suspect that is what causes the difference. —Noiratsi (talk) 14:21, 19 March 2014 (UTC)
- You're right. The default font is Calibri and it puts the tilde at the top for some reason. Thanks! 129.215.47.59 (talk) 18:52, 19 March 2014 (UTC)
arrays
[edit]int arr[3][2]={{1,2},{3,4},{5,6}}; printf("%d %d %d",arr[0][3],arr[1][2],arr[2][0]);
i have this piece of code in c,but i dont understand why does the output is 4 5 5.its a 3*2 matrix then how does column 3 is possible when we number columns from 0.I mean there are 3 rows 0,1,2 and 2 columns 0,1.even if the 3rd column is supposed to contain null entries then how come the output is 4 for [0][3].please sort this out.thanks.101.222.246.14 (talk) 14:32, 19 March 2014 (UTC) thanks,but whatever i know about array this line seemed to blew it off.i also knew that out of index and negative indices are not permitted.14.139.187.94 (talk) 05:30, 21 March 2014 (UTC) it came as a bit of sur prise. thanks anyway
- Even with a 1-dimensional array, if you try to print something outside the array bounds, it will often print whatever is in that memory location, which could be random from your POV, or maybe you can figure it out based on what was put into memory immediately before or after that array. (It might even be a part of a character string which it interprets as integer data.) However, the O/S doesn't necessarily store things in the order you define them, adding another twist. I suggest you try to print every array position inside and outside the bounds, up to the locations you've already printed, then chart them out, to see the pattern, if any. StuRat (talk) 14:51, 19 March 2014 (UTC)
- If the array is defined like this:
0 1 ------ 0 1 2 1 3 4 2 5 6
- It's really stored like this:
1 2 3 4 5 6
- And can possibly be indexed like this:
(0, 0)=1 (0, 1)=2 (0, 2)=3 (0, 3)=4 (0,4)=5 (0,5)=6
(1,-2)=1 (1,-1)=2 (1, 0)=3 (1, 1)=4 (1,2)=5 (1,3)=6
(2,-4)=1 (2,-3)=2 (2,-2)=3 (2,-1)=4 (2,0)=5 (2,1)=6
- I'm not sure about the negative indexes, they might give an error, but give them a try. StuRat (talk) 15:03, 19 March 2014 (UTC)
- The C standard forbids out-of-bounds indices—that is, anything but 0, 1, or 2 for the first index and 0 or 1 for the second. If you use anything else, the effect is undefined. It may work sometimes, or always with some implementations, but the compiler is within its rights to break it with fancy optimizations. -- BenRG (talk) 15:38, 19 March 2014 (UTC)
- I would call that "does not support" versus "forbids". But yes, as I also hinted above, if you reference out-of-bounds values, you do so at your own risk. StuRat (talk) 16:43, 19 March 2014 (UTC)
- "Forbids" in the sense that the behavior is undefined. The compiler is within its rights to do what you expect, or to trap the out-of-bounds references as an error, or to do something completely different such as changing the output to
"Long live the king"
or, as John F. Woods famously put it in 1992, "having demons fly out of your nose".- Same source:
>>At this point, the compiler is at liberty to generate a program which formats
>>your hard disk drive. In fact, it probably should.
- Of course, if a simple application can format a partition, that's a security issue, but that's an entirely different topic. - ¡Ouch! (hurt me / more pain) 07:56, 24 March 2014 (UTC)
- Same source:
- "Forbids" in the sense that the behavior is undefined. The compiler is within its rights to do what you expect, or to trap the out-of-bounds references as an error, or to do something completely different such as changing the output to
- There is one limited exception: you are allowed to compute the address where the next element of an array would be if it was one element longer. So even though
arr[0][2]
produces undefined behavior, it's legitimate to write&arr[0][2]
. This is sometimes a convenience when working with pointers that step forward or backward through the array. --50.100.193.30 (talk) 00:50, 22 March 2014 (UTC)
- There is one limited exception: you are allowed to compute the address where the next element of an array would be if it was one element longer. So even though
- I would only use the word "forbid" for something which should always give an error. StuRat (talk) 15:36, 22 March 2014 (UTC)
- Since when does C have the slightest idea that you're making an out-of-bounds reference, in general? Sure, this example, the compiler might conclude you're doing something screwy because you're using constants, but if those indices were variable, the compiler would have no idea, and there's no run time checking. In C, the array reference a[i] is equivalent to *(a + i) (under the rules for pointer arithmetic) and if this results in an out of bounds access, why, you've just discovered why C is a wondrously powerful tool, and why bad or careless C programmers have been a source of income for good bug hunters from the day C was invented; I made something of a career on other people's buffer overruns.--jpgordon::==( o ) 14:39, 23 March 2014 (UTC)
- The "point to the first element that doesn't exist" is quite useful, though. For traversing an array, one can start at that position, decrement by one element, process one element, decrement etc. in a loop that exits when the pointer equals the origin of the array.
item a[SIZE];
- item *p = a+SIZE;
- do {
- p--;
- process(*p); /* note that p != a+SIZE here */
} while p != a; /* note that this will exit AFTER a[0] has been processed */
- Further note: The C standard defines that there is no run-time checking; even if a compiler can RT-check indices, that feature makes it a non-standard compiler when activated. The only thing the standard allows for is a warning if a constant index is bogus, and that may not be triggered by an a+SIZE case above. (An a[SIZE] access may generate a warning.) - ¡Ouch! (hurt me / more pain) 07:56, 24 March 2014 (UTC)
- The "point to the first element that doesn't exist" is quite useful, though. For traversing an array, one can start at that position, decrement by one element, process one element, decrement etc. in a loop that exits when the pointer equals the origin of the array.
- Since when does C have the slightest idea that you're making an out-of-bounds reference, in general? Sure, this example, the compiler might conclude you're doing something screwy because you're using constants, but if those indices were variable, the compiler would have no idea, and there's no run time checking. In C, the array reference a[i] is equivalent to *(a + i) (under the rules for pointer arithmetic) and if this results in an out of bounds access, why, you've just discovered why C is a wondrously powerful tool, and why bad or careless C programmers have been a source of income for good bug hunters from the day C was invented; I made something of a career on other people's buffer overruns.--jpgordon::==( o ) 14:39, 23 March 2014 (UTC)
- I would only use the word "forbid" for something which should always give an error. StuRat (talk) 15:36, 22 March 2014 (UTC)
How many people still use 4:3 aspect ratio monitors?
[edit]Are there any statistics on how many people still use computer monitors with 4:3 aspect ratios?
When I develop programs, I design them to come up properly on a 4:3 monitor, and I would test on such a monitor. But I'm probably putting my last 4:3 monitor in mothballs today, so I was wondering. Bubba73 You talkin' to me? 17:18, 19 March 2014 (UTC)
- Using one right now... but it is a side monitor to the main 16:10 screen. Company's too tight to splash out on two 16:10 monitors for me. Quite where you would get statistics, I don't know; sorry. Astronaut (talk) 17:50, 19 March 2014 (UTC)
- It could be quite a few [4] shows a screen resolutions used by statcounter which seem to have about 10% with a 1024x768 resolution. As with any web statistics there can be a lot of variation due to sampling methods.--Salix alba (talk): 17:57, 19 March 2014 (UTC)
- If one expands that question beyond monitors, 1024x768 is dominant[5] among the smaller tablets. --Mark viking (talk) 18:14, 19 March 2014 (UTC)
![](http://upload.wikimedia.org/wikipedia/en/thumb/f/fb/Yes_check.svg/20px-Yes_check.svg.png)
Oh, well, looks like I need to keep a 4:3 monitor around, at least. Bubba73 You talkin' to me? 18:22, 19 March 2014 (UTC)
- You don't need to keep one around if your video card supports pillarboxed 4:3 resolutions on widescreen monitors. I think they all do, as an option somewhere in the settings dialogs. -- BenRG (talk) 22:31, 19 March 2014 (UTC)
The Ipad is 4:3 and lots of people use them. 70.36.142.114 (talk) 06:05, 20 March 2014 (UTC)
- My favorite monitors are 1600x1200. I am wondering why manufacturers stopped making them? What is wrong with that ratio? — Preceding unsigned comment added by AboutFace 22 (talk • contribs) 19:56, 21 March 2014 (UTC)
- That is 4:3 and so many things now are designed for widescreen. Bubba73 You talkin' to me? 21:42, 21 March 2014 (UTC)
- The funny thing is that actually, 16:9 is a relic of the past: the oldest cinemas were theaters with projectors, and theater stages were rather wide. More width allows for more seats and thus more tickets, and height doesn't. So, expanding horizontally was more economically sound than vertically.
- With the advent of TV sets, things changed, and the tubes were by default round. The biggest rectangle inside a circle is a square, so a ratio close to 1:1 was chosen. 4:3 is actually only 4% worse than 1:1 WRT area. Because of films, the landscape format was the only one worth taking.
- However, word processing would work better on a portrait format close to 9:7 (US Letter) or 7:5 (DIN), unless you are writing your letters in landscape format. 3:2 and 10:7 landscape, which are close to 4:3, are worth mentioning for catching half the page. Even wider formats are "useful" only for bragging rights, because the same diagonal translates into less square footage, so the manufacturers save money with the wide-screen hype.
- This is not pure WP:OR, but I can't seem to find the source right now. - ¡Ouch! (hurt me / more pain) 07:38, 24 March 2014 (UTC)
- Source. Still can't remember the other, more reliable source. This one wouldn't pass WP:RS criteria :( - ¡Ouch! (hurt me / more pain) 08:53, 24 March 2014 (UTC)
- That is 4:3 and so many things now are designed for widescreen. Bubba73 You talkin' to me? 21:42, 21 March 2014 (UTC)
- Your history is inaccurate. Most films were shot in the Academy ratio (approximately 4:3) until the mid 1950s, and the TV aspect ratio was chosen to match that. Widescreen cinema was introduced to compete with TV (see Panavision#Early history). Also, even in the widescreen era, virtually no films were ever shot in 16:9; that was apparently chosen for TVs as a compromise between aspect ratios ranging from 4:3 to 2.35:1. -- BenRG (talk) 19:31, 24 March 2014 (UTC)
- I'm writing this on a 1600×1200 monitor that I bought used because it was 1600×1200. Solidarity! -- BenRG (talk) 19:31, 24 March 2014 (UTC)
Only secure content is displayed
[edit]Every time I go to a Wikipedia page with IE, it gives the message "Only secure content is displayed...". I don't get it with other websites. There must be a security setting or something that causes this. How can it be fixed (for Wikipedia, at least)? Bubba73 You talkin' to me? 18:21, 19 March 2014 (UTC)
- @Bubba73: I don't think that you should be getting that. I use IE as well, and do not get this error. What version of IE are you using? Perhaps more importantly, do you know how to access the IE developer tools? With it, you can see every HTTP/HTTPS request that gets sent from your browser and you can see which specific request is causing the problem. I just tried loading the main Wikipedia page and it generates 34 (or so) separate HTTP requests. If you're familiar with IE developer tools, you can see which specific request is causing the problem. A Quest For Knowledge (talk) 21:48, 19 March 2014 (UTC)
- Doing a web search on the message finds a Microsoft page that seems related, with suggested configuration setting changes. Tried that? 88.112.50.121 (talk) 22:23, 19 March 2014 (UTC)
- I'm using IE 11, all updated. I'm not familiar with the developer tools. I'll check the link. Bubba73 You talkin' to me? 23:12, 19 March 2014 (UTC)
![](http://upload.wikimedia.org/wikipedia/en/thumb/f/fb/Yes_check.svg/20px-Yes_check.svg.png)
Microsoft recommends against changing that option, but I think Wikipedia is the only place I was getting the "mixed content". It would give me that message on every page load, even if I was going back to a previous page. It was too annoying! Bubba73 You talkin' to me? 23:19, 19 March 2014 (UTC)
- If you changed the "Display mixed content" option, I hope you changed it to "Disable" (which keeps the default behavior but without the popup prompt) and not "Enable" (which loads insecure resources without asking). Either way, I think it would be better to find out what's really going on, as AQFK suggested. Wikipedia over https doesn't normally load resources over http, as far as I can tell, which means the warning indicates something screwy about your setup. It could even be adware/spyware that you don't know about (though you would probably see it on other sites too in that case). -- BenRG (talk) 23:48, 19 March 2014 (UTC)
- Yes, I did change it to disable, and so far no problems. I don't think I've seen it on any other website. But a little over two weeks ago I was having a lot of problems, so I replaced my C HD with a new SSD and did a clean install. I also went to Kaspersky at that time. Bubba73 You talkin' to me? 01:14, 20 March 2014 (UTC)