Jump to content

Wikipedia:Reference desk/Archives/Computing/2016 June 2

From Wikipedia, the free encyclopedia
Computing desk
< June 1 << May | June | Jul >> Current desk >
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.


June 2

[edit]

Thinkpad P50 USB Type-c charging

[edit]

Can the Thinkpad P50 charge from its USB Type-c port? Johnson&Johnson&Son (talk) 02:23, 2 June 2016 (UTC)[reply]

Johnson&Johnson&Son, USB has specifications. The Thinkpad P50 user manual contain the information, USB power is being turned off during stand-by, see page 106 and 160 (in PDF viewer page count). USB ports required to be current limited to prevend burn on shortcut. Depending on the connected device, power can break down for any reason at any computer if over current occurs. Some chargers of mobile phones may have problems to perform a charge from any PC. External 2"5 drives use the trick of an Y-USB cable to use the double current by using two USB ports. --Hans Haase (有问题吗) 17:55, 6 June 2016 (UTC)[reply]

Missing equation images in Wikipedia

[edit]

In Wikipedia suddenly in all pages including historic revisions disappeared all mathematic equations.

In Firefox 3 and some older versions of IE the <math> is not rendered, the <meta> with "background: url()" using svg graphic is not rendered either. The pages without equations are crippled to uselessness. In mid-april 2016 it worked well with using PNG images, and also pages like Help:Displaying a formula refer to using PNG images... There is no mention of changing math technology in your "Tech news" either (at least since March this year, the change occured sometimes after mid-april...)

How to make wikipedia use PNG images for equations, as it did for many years until this april or may...? Is there some configuration?

Why such a major change is not reported in Tech news or anywhere else?

The question is NOT, how do I upgrade to newer browser version! For security and any other reason, the USER chooses software and NOT the content provider... — Preceding unsigned comment added by 79.98.159.114 (talk) 15:13, 2 June 2016 (UTC)[reply]

If you create an account and log in, you can go to the Appearance tab of your preferences and choose "PNG images" instead of "MathML with SVG or PNG fallback". I just tried this with Firefox 3.6.28 for Windows and it seems to work.
If you don't log in, there is probably nothing you can do, because identical HTML is sent to everyone who isn't logged in (this is how Wikipedia manages to serve thousands of pages per second without a huge budget). A Firefox extension could rewrite the HTML to make it work, but someone would have to write that extension.
I have to point out that using unmaintained versions of Firefox and IE is dangerous because they have publicly disclosed but unpatched security vulnerabilities. If you don't like where the Mozilla Foundation has gone with Firefox, please consider using an actively maintained fork such as Pale Moon. -- BenRG (talk) 05:53, 4 June 2016 (UTC)[reply]
Also content providers can choose whether to support software the user has chosen, and it's not uncommon they will choose to not support ancient unsafe browsers that few people use. If you aren't happy about this, you're free to become your own content provider. In other words, people including content providers don't have to support your choice and especially in a case like this where your choice could cause damage including to the content provider (e.g. if your computer gets taken over by malware) it may make sense not to. Nil Einne (talk) 02:39, 5 June 2016 (UTC)[reply]

what's wrong with the following argument proposing lower bound for comparison sorting?

[edit]

Claim: comparison sorting requires at least O(n^2) steps. Proof: we first need to find the largest elements. It requires n-1 comparisons. Then we need to find the second largest. That takes n-2 comparisons, and so on. The entire process takes (n-1) + (n-2) + ... + 1 = O(n^2).

This is definitely not true, but why?

Thanks! — Preceding unsigned comment added by 2.53.63.139 (talk) 15:26, 2 June 2016 (UTC)[reply]

The proposed proof is incorrect because there is nothing in the problem requiring us to find the largest element first. We might for example choose to split the list into two, sort them, and then combine them into one sorted list. Another way of thinking about it is that we can exploit the property that if A>B, and B>C, we can infer that A>C without having to make that comparison, which is how we can avoid the O(n^2) comparisons with a good algorithm. 192.176.1.95 (talk) 15:38, 2 June 2016 (UTC)[reply]
Looks like we need a link to comparison sort. StuRat (talk) 19:58, 3 June 2016 (UTC)[reply]
Quick sort (which uses the algorithm described by 192.176...), and merge sort both run in O(n log n) in the average case. LongHairedFop (talk) 14:33, 4 June 2016 (UTC)[reply]

Getting the concrete class of the object calling a method in C#

[edit]

Today at work, I had a look at NLog and found out that I could use the layout renderer ${callsite} to display what method was calling my log message as described here: https://github.com/nlog/nlog/wiki/Callsite-Layout-Renderer

I had code similar to this:

public abstract class MyAbstractClass
{
  private Logger log;
  protected abstract void DoStuff();
  protected void Assist()
  {
    log.Info("I'm assisting!");
  }
}

public class MyConcreteClass : MyAbstractClass
{
  protected override void DoStuff()
  {
    Assist();
  }
}

Now creating a MyConcreteClass object and calling its DoStuff() method resulted in NLog printing MyAbstractClass as the class where the code was, because that's where I defined the method. I would have wanted it to print MyConcreteClass as that's what the object actually was.

Is there any way to do this kind of thing?

Apparently I can write a custom layout renderer in C#, but the logging happens in a separate Logger object so I can't really use this.GetType() as that would print the class of the logger itself. The renderer is passed a context object containing a StackTrace object, but will that help me in any way? Or will it simply contain a reference to the method in MyAbstractClass where the method is defined? (Yes, I know the variable log is uninitialised and thus the code as written will crash. This is just an example and intended to illustrate my problem rather than actual production code. You should get the idea anyway.) JIP | Talk 15:27, 2 June 2016 (UTC)[reply]

Does this help?
using System;
using System.Diagnostics;

public abstract class MyAbstractClass {
    public void Assist(){
        StackTrace stackTrace = new StackTrace();
        StackFrame[] stackFrames = stackTrace.GetFrames();
        
        Console.WriteLine(stackFrames[1].GetMethod().DeclaringType);
    }
    
    public abstract void DoStuff();
}

public class MyConcreteClass : MyAbstractClass {
    public override void DoStuff() {
        Assist();
    }
}

public class OtherConcrete : MyAbstractClass {
    public override void DoStuff() {
        Assist();
    }
}

public class HelloWorld {
    public static void Main() {
        MyConcreteClass c = new MyConcreteClass();
        c.DoStuff();
        
        OtherConcrete d = new OtherConcrete();
        d.DoStuff();
    }
}
-- Finlay McWalter··–·Talk 16:34, 2 June 2016 (UTC)[reply]
Hmm, it might be just what I want, but I don't know yet. I'm at home right now, but I'll take a look at it when I get back to work. JIP | Talk 19:09, 2 June 2016 (UTC)[reply]
No, that didn't work. It just prints MyAbstractClass. JIP | Talk 15:29, 3 June 2016 (UTC)[reply]
This exact code, compiled with MonoC# 4.2.1.0 on Linux produces, for me:
           MyConcreteClass
           OtherConcrete
which is what I intended. -- Finlay McWalter··–·Talk 15:36, 3 June 2016 (UTC)[reply]
It works fine in Visual C# 2015 on Windows 10 too. -- Finlay McWalter··–·Talk 16:12, 3 June 2016 (UTC)[reply]
I can believe that. But, when I adapted the code to a custom LayoutRenderer in NLog, using the same StackTrace.GetFrames() and GetMethod().DeclaringType, it didn't work. I don't know what's the reason for that. JIP | Talk 21:34, 3 June 2016 (UTC)[reply]
I have figured out the reason. In @Finlay McWalter:'s code, the code in the abstract class is actually being called through a method defined in the concrete class. But in my real code at work, in the place where I would specifically have the concrete class printed, the entire call stack only goes through methods defined in the abstract class. The actual object is of the concrete class, but apparently that's not stored in the method information. It looks like my specific problem can't be fixed. Sorry. JIP | Talk 20:54, 7 June 2016 (UTC)[reply]

Appearance

[edit]

I would like to have my window as this. A step by step guide is sought. Can someone help me please? -- Apostle (talk) 18:37, 2 June 2016 (UTC)[reply]

Those appear to be custom icons. If that artist hasn't shared them, then you'd have to re-draw them yourself. Or maybe you don't want the icons, but just want transparent windows? What version of Windows are you using? SemanticMantis (talk) 19:03, 2 June 2016 (UTC)[reply]
SemanticMantis: Windows 7 Ultimate Service Pack 1. I don't want the icons, just a way to find out how to do this manually/automatically. I'm also guessing, if I know this than I may be able to change individual sections manually/automatically... -- Apostle (talk) 19:10, 2 June 2016 (UTC)[reply]
Ok, here [1] is a discussion of various transparency effects. I don't know anything about windows 7 but now you might get better help from others. SemanticMantis (talk) 19:23, 2 June 2016 (UTC)[reply]
-- Apostle (talk) 20:21, 2 June 2016 (UTC)[reply]

I get alerts for old messages

[edit]

Every time I log on to Wikipedia I get an alert (from 2 months ago) and 3 messages on my talkpage (from 10 days ago), can someone explain how this is possible? If of any importance, I use internet explorer 9. OXYGENE 7-13 (TALKPAGE) 19:02, 2 June 2016 (UTC)[reply]

Have you clicked both the alert button and the messages button? If you don't I'm pretty sure they'll stay around no matter how many times you've logged in or how many times you visit your talk page. Nil Einne (talk) 03:41, 3 June 2016 (UTC)[reply]
@Nil Einne: Yes I have, this started about a week ago. OXYGENE 7-13 (TALKPAGE) 14:26, 3 June 2016 (UTC)[reply]
Is your browser set to not allow cookies? Maybe whether you've clicked the button to read alerts is stored locally. --Thomprod (talk) 15:31, 3 June 2016 (UTC)[reply]
On some webpages I get asked about allowing cookies and when Ido so I get no troubles at all, so... And yes I'm working from a network so that part about locally stored buttons could be just right. (I have no access to the main computer) OXYGENE 7-13 (TALKPAGE) 17:46, 3 June 2016 (UTC)[reply]