Wikipedia:Reference desk/Computing
of the Wikipedia reference desk.
Main page: Help searching Wikipedia
How can I get my question answered?
- Select the section of the desk that best fits the general topic of your question (see the navigation column to the right).
- Post your question to only one section, providing a short header that gives the topic of your question.
- Type '~~~~' (that is, four tilde characters) at the end – this signs and dates your contribution so we know who wrote what and when.
- Don't post personal contact information – it will be removed. Any answers will be provided here.
- Please be as specific as possible, and include all relevant context – the usefulness of answers may depend on the context.
- Note:
- We don't answer (and may remove) questions that require medical diagnosis or legal advice.
- We don't answer requests for opinions, predictions or debate.
- We don't do your homework for you, though we'll help you past the stuck point.
- We don't conduct original research or provide a free source of ideas, but we'll help you find information you need.
How do I answer a question?
Main page: Wikipedia:Reference desk/Guidelines
- The best answers address the question directly, and back up facts with wikilinks and links to sources. Do not edit others' comments and do not give any medical or legal advice.
August 11
Hide Tab Bar With One Tab
I despise tabs, and when using Firefox, I hardly ever have multiple tabs open in a window. I used to use the "Hide Tab Bar With One Tab" add-on so that the tab bar would stop taking up space when I didn't have multiple tabs open. About 3 years ago they changed Firefox so that this add-on broke, but I learned that I could achieve the same effect through CSS. Specifically, I set toolkit.legacyUserProfileCustomizations.stylesheets to true in about:config, and created a userChrome.css file in the appropriate place, containing the following:
tab:only-of-type, tab:only-of-type + #tabs-newtab-button { display: none !important; } #tabbrowser-tabs, #tabbrowser-arrowscrollbox { min-height: 0 !important; }
But sometime recently, Firefox has been changed again to break this. Unfortunately I don't really speak CSS; I copied the above code from a posting someplace. I have confirmed (by making another change to it) that Firefox is still processing the userChrome.css file, so it must be something about the above code that stopped working. Can someone suggest a fix? --174.95.81.219 (talk) 23:11, 11 August 2022 (UTC)
- I use this and haven't seen breakage yet:
#tabbrowser-tabs, #tabbrowser-tabs arrowscrollbox { min-height: 0 !important; } #tabbrowser-tabs tab { height: var(--tab-min-height); } #tabbrowser-tabs tab:first-child:last-child { display: none !important; } #tabbrowser-tabs tab[first-visible-tab="true"][last-visible-tab="true"] { visibility: collapse; }
- I don't now if they are all needed. 12:20, 14 August 2022 (UTC) — Preceding unsigned comment added by 85.76.72.63 (talk)
- I tried it, but I regret to say I see no difference in behavior. Is there a place where I could read about what things like #tabbrowser-tabs and the rest of it mean?
- By the way, I have Firefox 103.0.1 running on Fedora 36 Linux. --174.95.81.219 (talk) 05:16, 15 August 2022 (UTC)
August 14
USB-C Power Cords
I have multiple USB-C cords but they are not labeled, and I don't know remember where they came from or how old they are. My understanding is that USB-C cords aren't all the same. Some support USB fast charging and some don't. Some support a propriety form of fast power charging. If I remember correctly, there were vendors selling on Amazon selling cheap cords that didn't support the full USB specification. My question is, is there any way to tell what each USB-C cord supports in terms of charging? A Quest For Knowledge (talk) 18:31, 14 August 2022 (UTC)
- Only by actually trying to charge something. Ruslik_Zero 20:03, 14 August 2022 (UTC)
- I wouldn't recommend blindly using unknown cables to charge something, as mismatched cables can damage equipment. You could use a USB C breakout board, a USB A breakout board, and a multimeter to determine which pins on one end are connected to which pins on the other end. Looks like you could get both breakout boards for less than $15. CodeTalker (talk) 03:35, 15 August 2022 (UTC)
For clarity, are you referring to C to C or (full) A to C or C to micro A? My assumption from you comment is C to C, but it is slightly ambiguous and CodeTalker seems to be assuming A to C. I have to say, while there may be rare cases when CodeTalker's advice will be helpful, a lot of time it won't catch the big issues. For C to C, the risk is probably somewhat low provided both the charger and device are fairly standard and the cable likewise isn't something from some ultra weird device. Under the USB-PD standards, cables capable of more than 3A need to have an emarker chip [1] [2] [3]. It's quite likely cables with such a chip will be appropriately marked but in any case, using such a cable with any device is unlikely to cause harm. I'm sure you can test for such a chip in various ways but I doubt a simple pin connection test will detect it. The biggest risk might be for an ultra cheaply made cable which has an emarker chip but shouldn't really since it's not properly designed for more than 3A, but unfortunately that isn't something that's so easy to test for. (You could check the voltage drop or cable resistance, also a cable especially a longish one with a emarker chip reporting more than 3A but which seems very thing probably isn't very good. More sophisticated, you could see what the emarker chip reports and investigate that.)
A to C is the area which has received a lot of attention especially with Benson Leung's work. There are genuine concerns here. The problem is that USB C signals the charging current via pull up resistance. Properly made A to C cables need to have a 56kΩ pull up resistor indicating the maximum current is 500 mA. However the problem is many cables used a different resistor or even had none. This is probably in part because of the way a lot of modern manufacturing works, where the person designing the cable may not have even read the standard let alone understand it.
But I suspect another big reason is the unfortunate reality of consumer perceptions. If you use such a cable to charge a device, unless it uses some other proprietary signalling algorithm or ignores the pull up resistor, it's only going to charge at 500 mA which is very slow for most modern devices. Since a lot of power sources are capable of significantly more, most of the time it seems better to the consumer when the cable is improperly made since it charges at a higher speed. So a simplistic reviewer will complain this cable is poor quality, it charges my device very slowly even if that might be intentional. The risk is when the source isn't capable of supplying such a high current and especially if it doesn't handle an overdraw gracefully, it may catch fire or otherwise be destroyed but this is rare enough that few encounter it.
To be clear, I'm not saying such cables are a good idea or it's not something you have to worry about simply that it's what's happening. Further although concerns over improperly made cables still gets some attention, it's died down since the heyday of Benson Leung's work and I think many cables are probably again being improperly made.
Note while this is something you can test, you need to do more than a simple connection test. It's something to watch out for although the risk is low if you're not connecting the device to something incapable of 3A, or maybe 1.5A. (I think putting a 22kΩ pull up resistor to indicate 1.5A might be more common than 10kΩ for 3A, because again most sources are capable of that or at least most of the time won't be destroyed by a device drawing 1.5A. But 3A is more likely a step too far.)
There are also various proprietary cables designs that support different things, e.g. Huawei has their 5A Supercharging spec, and Oneplus/Oppo have their VoC. Generally, connecting these cables to a device without any proprietary charging specs is relatively low risk since the designers account for that. The big concern is whether any of these proprietary specs might conflict, and the device will think it can do something it shouldn't, but to be honest this is more likely a problem between device and power source than the cable. Sometimes these cables may have their own internal marking e.g. Huawei ones use a purple colours USB A plug.
Note I haven't really touched on USB2.0 or USB3.2 cables. both C to C and A to C can be either, and also support the various speeds of 3.2. This is something you could easily test for and especially, maybe also with C you can generally see by whether the pins are present. While it may make a big difference to transfer speeds, there shouldn't be any risk connecting a 2.0 only cable.
- First, thanks to everyone for their responses.
- Second, just to clarify, the origin of these cables are not something I picked up off the ground somewhere. They either came with some kind of device I bought or I bought them from Amazon. In the future, I will try to remember to label them.
- @Nil Einne: They are C to C or A to C.
- A Quest For Knowledge (talk) 07:13, 15 August 2022 (UTC)
August 15
Is there any manual OCR which allows us to assign characters manually for identical glyphs?
Rather than a conventional OCR or an OCR trainer, is there any engine that would group identical glyphs and allows us to manually assign characters to each occurrence of the glyph? This would help in digitizing old multilingual or handwritten documents faster and with better accuracy. Basically something that would output identical glyphs under same code which we can search-and-replace with the required characters. Thanks. - Vis M (talk) 07:47, 15 August 2022 (UTC)
- The idea seems sound, and the best OCR software must contain components that already do a great deal of the job (isolating glyphs and edge tracing), but I have not found anything that matches. Two scanned glyphs are unlikely to be identical images; at best they are very similar. So the full task involves cluster analysis as an essential and non-trivial (but doable) component. --Lambiam 08:32, 17 August 2022 (UTC)
August 17
Need help interpreting JavaScript code
I am currently learning HTML and I was viewing the source code of my website that I had pre-built using a web hosting service. Included in the source code was the following JavaScript:
(function () { var on = addEventListener, $ = function (q) { return document.querySelector(q) }, $$ = function (q) { return document.querySelectorAll(q) }, $body = document.body, $inner = $('.inner'), client = (function () { var o = { browser: 'other', browserVersion: 0, os: 'other', osVersion: 0, mobile: false, canUse: null, flags: { lsdUnits: false, }, }, ua = navigator.userAgent, a, i; a = [['firefox', /Firefox\/([0-9\.]+)/], ['edge', /Edge\/([0-9\.]+)/], ['safari', /Version\/([0-9\.]+).+Safari/], ['chrome', /Chrome\/([0-9\.]+)/], ['chrome', /CriOS\/([0-9\.]+)/], ['ie', /Trident\/.+rv:([0-9]+)/]]; for (i = 0; i < a.length; i++) { if (ua.match(a[i][1])) { o.browser = a[i][0]; o.browserVersion = parseFloat(RegExp.$1); break; } } a = [['ios', /([0-9_]+) like Mac OS X/, function (v) { return v.replace('_', '.').replace('_', ''); }], ['ios', /CPU like Mac OS X/, function (v) { return 0 }], ['ios', /iPad; CPU/, function (v) { return 0 }], ['android', /Android ([0-9\.]+)/, null], ['mac', /Macintosh.+Mac OS X ([0-9_]+)/, function (v) { return v.replace('_', '.').replace('_', ''); }], ['windows', /Windows NT ([0-9\.]+)/, null], ['undefined', /Undefined/, null],]; for (i = 0; i < a.length; i++) { if (ua.match(a[i][1])) { o.os = a[i][0]; o.osVersion = parseFloat(a[i][2] ? (a[i][2])(RegExp.$1) : RegExp.$1); break; } } if (o.os == 'mac' && ('ontouchstart' in window) && ((screen.width == 1024 && screen.height == 1366) || (screen.width == 834 && screen.height == 1112) || (screen.width == 810 && screen.height == 1080) || (screen.width == 768 && screen.height == 1024))) o.os = 'ios'; o.mobile = (o.os == 'android' || o.os == 'ios'); var _canUse = document.createElement('div'); o.canUse = function (property, value) { var style; style = _canUse.style; if (!(property in style)) return false; if (typeof value !== 'undefined') { style[property] = value; if (style[property] == '') return false; } return true; }; o.flags.lsdUnits = o.canUse('width', '100dvw'); return o; }()), trigger = function (t) { dispatchEvent(new Event(t)); }, cssRules = function (selectorText) { var ss = document.styleSheets, a = [], f = function (s) { var r = s.cssRules, i; for (i = 0; i < r.length; i++) { if (r[i] instanceof CSSMediaRule && matchMedia(r[i].conditionText).matches) (f)(r[i]); else if (r[i] instanceof CSSStyleRule && r[i].selectorText == selectorText) a.push(r[i]); } }, x, i; for (i = 0; i < ss.length; i++)f(ss[i]); return a; }, thisHash = function () { var h = location.hash ? location.hash.substring(1) : null, a; if (!h) return null; if (h.match(/\?/)) { a = h.split('?'); h = a[0]; history.replaceState(undefined, undefined, '#' + h); window.location.search = a[1]; } if (h.length > 0 && !h.match(/^[a-zA-Z]/)) h = 'x' + h; if (typeof h == 'string') h = h.toLowerCase(); return h; }, scrollToElement = function (e, style, duration) { var y, cy, dy, start, easing, offset, f; if (!e) y = 0; else { offset = (e.dataset.scrollOffset ? parseInt(e.dataset.scrollOffset) : 0) * parseFloat(getComputedStyle(document.documentElement).fontSize); switch (e.dataset.scrollBehavior ? e.dataset.scrollBehavior : 'default') { case 'default': default: y = e.offsetTop + offset; break; case 'center': if (e.offsetHeight < window.innerHeight) y = e.offsetTop - ((window.innerHeight - e.offsetHeight) / 2) + offset; else y = e.offsetTop - offset; break; case 'previous': if (e.previousElementSibling) y = e.previousElementSibling.offsetTop + e.previousElementSibling.offsetHeight + offset; else y = e.offsetTop + offset; break; } } if (!style) style = 'smooth'; if (!duration) duration = 750; if (style == 'instant') { window.scrollTo(0, y); return; } start = Date.now(); cy = window.scrollY; dy = y - cy; switch (style) { case 'linear': easing = function (t) { return t }; break; case 'smooth': easing = function (t) { return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1 }; break; }f = function () { var t = Date.now() - start; if (t >= duration) window.scroll(0, y); else { window.scroll(0, cy + (dy * easing(t / duration))); requestAnimationFrame(f); } }; f(); }, scrollToTop = function () { scrollToElement(null); }, loadElements = function (parent) { var a, e, x, i; a = parent.querySelectorAll('iframe[data-src]:not([data-src=""])'); for (i = 0; i < a.length; i++) { a[i].src = a[i].dataset.src; a[i].dataset.src = ""; } a = parent.querySelectorAll('video[autoplay]'); for (i = 0; i < a.length; i++) { if (a[i].paused) a[i].play(); } e = parent.querySelector('[data-autofocus="1"]'); x = e ? e.tagName : null; switch (x) { case 'FORM': e = e.querySelector('.field input, .field select, .field textarea'); if (e) e.focus(); break; default: break; } }, unloadElements = function (parent) { var a, e, x, i; a = parent.querySelectorAll('iframe[data-src=""]'); for (i = 0; i < a.length; i++) { if (a[i].dataset.srcUnload === '0') continue; a[i].dataset.src = a[i].src; a[i].src = ''; } a = parent.querySelectorAll('video'); for (i = 0; i < a.length; i++) { if (!a[i].paused) a[i].pause(); } e = $(':focus'); if (e) e.blur(); }; window._scrollToTop = scrollToTop; var thisURL = function () { return window.location.href.replace(window.location.search, '').replace(/#$/, ''); }; var getVar = function (name) { var a = window.location.search.substring(1).split('&'), b, k; for (k in a) { b = a[k].split('='); if (b[0] == name) return b[1]; } return null; }; var errors = { handle: function (handler) { window.onerror = function (message, url, line, column, error) { (handler)(error.message); return true; }; }, unhandle: function () { window.onerror = null; } }; loadElements(document.body); var style, sheet, rule; style = document.createElement('style'); style.appendChild(document.createTextNode('')); document.head.appendChild(style); sheet = style.sheet; if (client.mobile) { (function () { if (client.flags.lsdUnits) { document.documentElement.style.setProperty('--viewport-height', '100dvh'); document.documentElement.style.setProperty('--background-height', '100lvh'); } else { var f = function () { document.documentElement.style.setProperty('--viewport-height', window.innerHeight + 'px'); document.documentElement.style.setProperty('--background-height', (window.innerHeight + 250) + 'px'); }; on('load', f); on('resize', f); on('orientationchange', function () { setTimeout(function () { (f)(); }, 100); }); } })(); } if (client.os == 'android') { (function () { sheet.insertRule('body::after { }', 0); rule = sheet.cssRules[0]; var f = function () { rule.style.cssText = 'height: ' + (Math.max(screen.width, screen.height)) + 'px'; }; on('load', f); on('orientationchange', f); on('touchmove', f); })(); $body.classList.add('is-touch'); } else if (client.os == 'ios') { if (client.osVersion <= 11) (function () { sheet.insertRule('body::after { }', 0); rule = sheet.cssRules[0]; rule.style.cssText = '-webkit-transform: scale(1.0)'; })(); if (client.osVersion <= 11) (function () { sheet.insertRule('body.ios-focus-fix::before { }', 0); rule = sheet.cssRules[0]; rule.style.cssText = 'height: calc(100% + 60px)'; on('focus', function (event) { $body.classList.add('ios-focus-fix'); }, true); on('blur', function (event) { $body.classList.remove('ios-focus-fix'); }, true); })(); $body.classList.add('is-touch'); } })();
I don't think there is anything on my website that would require JavaScript and so naturally I am very confused. I am not very proficient at JavaScript and I was wondering if someone more knowledgeable than me could help me to interpret this code.
What does it do? Would my website still work if it was removed? Any comment is greatly appreciated.
-- WongSeo (talk to me!) 23:49, 17 August 2022 (UTC)