Jump to content

Wikipedia:Reference desk/Computing

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 173.228.123.39 (talk) at 01:59, 3 March 2020 (→‎How do I eliminate this standard error?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Welcome to the computing section
of the Wikipedia reference desk.
Select a section:
Want a faster answer?

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.
See also:


February 25

Putting an App Icon on the Home Screen

I have a Samsung Galaxy J7, running Android version 8.1.0. What I want to do is to add another application icon to the home screen. The icon for it is currently in the Applications window that I can open by clicking on the Applications window icon, but I want to display it on a page of the home screen. At this time the application is Spotify, and I want to be able to launch Spotify and Maps conveniently at the same time. However, I think that my question is more general, and is how to put an icon for an application on the home screen that is installed but isn't on the home screen. Robert McClenon (talk) 01:15, 25 February 2020 (UTC)[reply]

You should be able to move the app to your home screen by dragging it. Long-press if necessary or tap, hold, and move your finger; the home screen(s) should appear and allow you to release your finger and drop the app onto it. Elizium23 (talk) 01:18, 25 February 2020 (UTC)[reply]
Yep, long press and hold the icon in the start menu (I guess that's what's called the Applications window). After a second or two the home screens should appear in the background, then you can drag the icon where you want it. You can also long press an empty space on the home screen and you'll get a popup menu allowing you to add stuff like app shortcuts. 93.136.117.148 (talk) 02:29, 25 February 2020 (UTC)[reply]
Long-press (hold down) was it. Thanks. Robert McClenon (talk) 15:14, 26 February 2020 (UTC)[reply]

February 26

Brother DCP-7030 driver for ubuntu

After following the installation instructions over and over again, I can't seem to install it Thegooduser Life Begins With a Smile :) 🍁 00:51, 26 February 2020 (UTC)[reply]

Problems using the wikipedia dump bz2 file

Please see this post on the Miscellaneous desk. 2606:A000:1126:28D:8095:BB24:F64A:E5FC (talk) 03:21, 26 February 2020 (UTC)[reply]

February 27

Opening different URLs using different browsers in Windows 10

In Windows 10, is there an easy way to implement a solution so that different URLs can be opened using different browsers based on configured rules? This only needs to be done when URLs are opened using the default handler. — Preceding unsigned comment added by 134.242.92.97 (talk) 22:41, 27 February 2020 (UTC)[reply]

You can read about some options here. Ruslik_Zero 20:25, 1 March 2020 (UTC)[reply]

February 28

MediaWiki back up

Sorry, this is a run on from my previous question here (now archived) but I wondered if there was a relatively simple way of doing the above? I mean, I'd really like the answer to be something in the realms of "Yeah, copy the folders to an external" or something; but things are rarely that easy  :) and i'm prepared to not understand the answer. But any advice would be greatly appreciated! Happy Friday, all. ——SN54129 11:04, 28 February 2020 (UTC)[reply]

Is this (mw:Manual:Backing up a wiki) any use? - X201 (talk) 11:29, 28 February 2020 (UTC)[reply]
Well, yes, X201, thanks  :) it rather says complicatedly what I hoped could be spelt out more simply! Have a good weekend! ——SN54129 12:00, 29 February 2020 (UTC)[reply]

February 29

Short descriptions, Wikidata, and SQL/SPARQL

Hi, I would like to know how to search for items on Wikidata with descriptions longer than, say, 150 characters; I've noticed that the very long ones tend to be unsuitable for use as short descriptions on Wikipedia. (example example) I've tried writing something based on the quarry query for descriptions of length 1, but had absolutely no success. (My knowledge of SQL is very minimal.) I would be grateful for any assistance or pointers. Cheers, gnu57 15:34, 29 February 2020 (UTC)[reply]

Doesn't LENGTH(term_text) > 150 work? 2602:24A:DE47:B270:A096:24F4:F986:C62A (talk) 00:49, 1 March 2020 (UTC)[reply]
I tried that a while ago; when I submit the query, it runs for a long time and eventually times out without completing. Cheers, gnu57 01:04, 1 March 2020 (UTC)[reply]
There is probably no index on the term length, i.e. it's doing a linear scan. Your options: 1) create index or ask someone to create one (it will be even slower than the linear scan, but will allow future such queries to run fast); 2) get your timeout increased or get someone with higher limits to run the query for you; or 3) download the db to your own machine and run the queries on your own db instance. The last is the best if you want to muck with the data a lot, but of course it's more work and takes resources (your own machine or VM, basically). 173.228.123.39 (talk) 00:56, 2 March 2020 (UTC)[reply]

March 2

(Web) development novice

I'm a CS dropout with a bit of programming experience but not much. It's also been years since I coded anything. I consider myself pretty good at working out the logic side of things but I usually get stuck when trying to figure out the best way to do something or if there is a standard way of achieving a certain result. I want to get back into coding by starting a web development project and already I am unsure how to achieve a desired result.

A basic website usually has for example a logo/home page link, a navigation bar, a footer, and the content of the particular page. So a basic way of doing this would be to include the logo, navigation bar, and footer on each page. However, for a (dynamic) site that is constantly adding content this seems less than ideal.

So I was thinking maybe of having a template php page which includes the logo, nav bar, etc. but then would also have some php code that would include the required content.

I don't want to be given the answer (at least for now) as I'd rather figure it out for myself but am I along the right lines? If not maybe a bit of a nudge in the right direction. What sort of problems would this approach present?

--Polyknot (talk) 05:33, 2 March 2020 (UTC)[reply]

Are you using a PHP-dependent content management framework or system such as Drupal or WordPress? If not, than now is perhaps a good time to switch to Django/Python. The learning curve is not very steep, there are excellent tutorials, the community is very helpful to novices, and in the end you will probably enjoy the greater flexibility.  --Lambiam 08:01, 2 March 2020 (UTC)[reply]
You can use the include function in PHP to include whatever you like. So, you can create a file that makes the navigation bar, such as "nav.inc". Then, include it where you want it: include("nav.inc"); You can have files that include other files. For example, all the stuff that comes before the main contant might be in a file named "top.inc". That file includes the header, styles, css, title bar, nav, etc... Then, everything after the content might be in "bottom.inc". So, your web page becomes include("top.inc"); include("mycontent.inc"); include("bottom.inc");. The content one is where you handle dynamic content. Normally, you query a database, get content, and format it properly. But, you could just as well include a text file. Warning: You will find zealots that claim switching from one programming to another programming language will solve all your problems, including obesity, acne, and erectile dysfunction. The rule is always the same: The language you know is the best language to use. 135.84.167.41 (talk) 12:41, 2 March 2020 (UTC)[reply]

How do I eliminate this standard error?

Here is a kata/programming practice exercise that I recently did:

https://www.codewars.com/kata/55b3425df71c1201a800009c/train/python

Here is my own solution to this kata:

def findMedian(list):
    list = sorted(list)
    length = len(list)
    if length % 2 == 1:
        halfLen = int(length / 2)
        median = list[halfLen]
    elif length % 2 == 0:
        num1 = int(length / 2) - 1
        num2 = int(length / 2)
        median = int((list[num1] + list[num2]) / 2)
    return median

def findRange(list):
    list = sorted(list)
    range = list[-1] - list[0]
    return range

def findMean(list):
    list = sorted(list)
    sum = 0
    for i in range(0,len(list)):
        sum += list[i]
        i += 1
    mean = sum/len(list)
    return int(mean)

def convertFormat(num):
    num = int(num)
    hours = int(num / 3600)
    minutes = int((num % 3600) / 60)
    seconds = ((num % 3600) % 60)
    return format(hours,'02d')+"|"+format(minutes,'02d')+"|"+format(seconds,'02d')

def stat(strg):
    lisst = strg.split(', ')
    lyst = []
    for item in lisst:
        lyst.append(item.split('|'))
    numSec = []
    for i in range(0,len(lyst)):
        numSec.append([int(lyst[i][0])*3600, int(lyst[i][1])*60, int(lyst[i][2])])
    numSecTotal = []
    for i in range(0,len(numSec)):
        numSecTotal.append(numSec[i][0]+numSec[i][1]+numSec[i][2])
    numSecTotal = sorted(numSecTotal)
    formattedMedian = convertFormat(findMedian(numSecTotal))
    formattedRange = convertFormat(findRange(numSecTotal))+" "
    formattedMean = convertFormat(findMean(numSecTotal))+" "
    str = "Range: "+formattedRange+"Average: "+formattedMean+"Median: "+formattedMedian
    return str

This website actually accepted my solution as valid--which is why this solution of mine (by Futurist110, aka myself) is visible here:

https://www.codewars.com/kata/55b3425df71c1201a800009c/solutions/python/all/newest

However, when I clicked on the "Train Again" button and attempted to once again submit this solution with minor modifications, I got this error message in spite of my program passing all of the tests for it on this website:

 STDERR
Traceback (most recent call last):
  File "main.py", line 75, in <module>
    randomTests()
  File "main.py", line 73, in randomTests
    test.assert_equals(stat(a), stat1221(a))
  File "/home/codewarrior/solution.py", line 41, in stat
    numSec.append([int(lyst[i][0])*3600, int(lyst[i][1])*60, int(lyst[i][2])])
ValueError: invalid literal for int() with base 10: ''

What exactly in this program do I actually need to fix in order to eliminate this error message--and just how exactly do I fix the relevant part of this computer program of mine? Any thoughts on this? Futurist110 (talk) 22:53, 2 March 2020 (UTC)[reply]


  • It looks like you are passing an empty string to the int() function, maybe because of badly formatted input data. Rather than try to debug it for you, I'll suggest a way to debug it yourself: put try/except around the line where the error is happening, and print the relevant values in the event that the exception triggers. So in this case, replace line 41 with:
try:
    numSec.append([int(lyst[i][0])*3600, int(lyst[i][1])*60, int(lyst[i][2])])
except ValueError as e:
    print (e, i, lyst[i])
    raise

Use the printed info to either figure out what is wrong, or figure out what other info you need to diagnose the error, then modify the program again to get the additional info. It will often take quite a few iterations of that to diagnose a bug. Debuggers can avoid some of that, but print-based tracing is something every programmer has to do some of the time.

Unrelated: I notice in your findMean function, you sort the list unnecessarily. I'd have just written sum(list) / len(list). 173.228.123.39 (talk) 01:58, 3 March 2020 (UTC)[reply]

March 3