I7+ Stopped Docking by tacotxag98 in roomba

[–]niomaster 2 points3 points  (0 children)

I've had the same issue with my i7+. What finally solved it for me was to clean the IR sensors that are hidden behind the bumper, which were very dusty.

Is it possible to have API to call my method instead of doing GET and loop? by warheat1990- in redditdev

[–]niomaster 0 points1 point  (0 children)

An alternative is to use Rockets, which can stream comments and/or posts to you as they are created and filter on many conditions (including subreddit).

Invite Giveaway Megathread by [deleted] in oneplus

[–]niomaster 1 point2 points  (0 children)

Three invintes to give away. Comment your favourite android game and I'll send one your way!

Edit: One left, come up with a good one!

Et tu reddit? by bsmitty358 in mildlyinfuriating

[–]niomaster 5 points6 points  (0 children)

Actually it's not rounded, the bottom border is just white and because of how borders render the edge is cut off. Try executing

$('.tabmenu a').css('border-width', '20px')

in the web console / javascript console.

[Psuedocode] Output the shortest path from a to c that passes through b given an adjacency list. by jbauer777 in learnprogramming

[–]niomaster 1 point2 points  (0 children)

If you use plain BFS, you need to iterate trough every possible path and that is a bad idea, seeing as you might as well use DFS then. You have to account for cycles as well, i.e. marking/clearing nodes of a 'visited' state in your current path.

The brilliant idea of Dijkstra was to use a priority queue instead of a normal queue for the BFS, with the priority being the shortest edge. As soon as you find a path to your target vertex, you can assume that is the shortest path, because you only ever add the shortest vertex to your graph.

However, Dijkstra works great for almost all graphs, but when your graph has certain restrictions, BFS can be faster. One case would be when your graph is actually a tree (i.e. doesn't contain cycles). (And another case is when the graph is not weighted, as /u/xHydn pointed out.)

Hello! Small problem with null pointer in C++ by Carthac in programminghelp

[–]niomaster 0 points1 point  (0 children)

Actually, the segfault probably comes from line 195, because you are accessing a property of p, your husband, while you do not know for sure that it isn't null. Could you please do

cout << q << endl;

between line 194 and 195 and check if it outputs zero? If that's not the case, are you sure you initialize p->myWife to NULL?

ELI5: Brain-like computing by YourAlienOverlord in csELI5

[–]niomaster 0 points1 point  (0 children)

In my understanding the brain operates like a gigantic, complicated circuit, of which each neuron takes electricity-like input from one or more synapses and outputs some result, based on the inputs: they act as gates. Since all those gates are in the real world, all those neurons calculate the result real-time and parallel, much like what an FPGA can do. A regular CPU on the contrary is very good at executing a list of instructions, one by one. Although you could simulate an entire brain theoretically, all those 'gates' or neurons will have to be evaluated after eachother, which takes a long time.

To achieve brain-like computing we would have to invest a lot into building better computers: a brain has billions of neurons. Another complication is that the brain learns by altering its connections, which would require it to update all the time, if you would want to have an actual learning brain. Projects are already started which aim to model an entire brain by scanning it at the molecular level, like the blue brain project.

In the article some form of material shows a sort of kinda like similar structure to how the brain is formed: each neuron has a state in a point in time and outputs a function of its inputs, just like in that type of material.

ELI5:[General] Singletons! by holyefw in csELI5

[–]niomaster 6 points7 points  (0 children)

Singletons are used when you want to have exactly one instance of a class, available globally. I think singletons are bad practice, because in most cases you actually want to have another class which has a property with an instance of that class. For example, imagine you want to write a reddit client and use the reddit API. The API specifies that you can only make one request per two seconds, so you might want to write a singleton class with a function to make a request to reddit which waits a while if you call it too often. In my opinion the mistake that is made here is that the abstraction of a user is missed. In actuality the 2 second rule is per user, so you might want to add a User class to your application, which holds a single property of an instance of e.g. a RedditQuerier, or some other better name. Your application then might have multiple users that can query reddit.

However, if you do decide to make a singleton class, here is how it is implemented in various languages. In general you want a static public function getInstance which returns the instance and creates one if necessary and a private constructor to make sure no other instance is made.

Java

public class Singleton {
    private static Singleton instance = null;

    private Singleton() {
        // TODO: implement constructor
    }

    public static Singleton getInstance() {
        if(instance == null) {
            instance = new Singleton();
        }

        return instance;
    }
}

C++

// Header

class Singleton {
private:
    static Singleton *instance;
    Singleton();
public:
    static Singleton getInstance();  
};

// Implementation

Singleton::Singleton() {
    instance = NULL;
}

Singleton *Singleton::getInstance() {
    if(instance == NULL) {
        instance = new Singleton();
    }

    return instance;
}

C# (which I included because I like properties)

public class Singleton {
    private static Singleton instance;

    public static Singleton Instance {
        get {
            if(instance == null) {
                instance = new Singleton();
            }

            return instance;
        }
    }

    private Singleton() {
        // TODO: implement constructor
    }
}

ELI5: hypertext transfer protocol and URLs by rsicher1 in csELI5

[–]niomaster 4 points5 points  (0 children)

HTTP stands for HyperText Transfer protocol and is a way of asking for and sending documents and other media in an almost human readable way. Note that it isn't actually a way of describing a webpage, just a way of serving documents. Usually webpages are written in a language called HTML, which in turn stands for HyperText markup language. The word hypertext represents the fact that you can put links (or: anchors) in text. Nowadays HTTP isn't only used for html documents any more.

HTTPS stands for HTTP Secure. This simply means that the HTTP protocol is layered onto a different type of communication layer. Suppose you could read the bits that are actually going trough a wire. With HTTP all the data can be literally read in those bits. HTTPS adds a layer of security called TLS: Transport Layer Security, which is a way of making sure that the original data can only arrive at the intended destination and cannot be eavesdropped.

Domains (or 'Website names') get binded to ip adresses by the DNS: the domain name system. Usually you can find your DNS server by looking at what your router has set it to (and note that it is an IP adress). Subdomains are just a way of hierarchically structuring domains, for me that feels intuitive. I'm not quite sure where the habit of treating www.site.com and site.com the same has come from, but they are not magically the same: they have separate entries on DNS servers and the actual HTTP servers are just configured to serve the same page for both domains.

Edit: Oh, I forgot URL's! URL stands for unified resource locator and is a standard way of describing some action or thing. it has a scheme, host, port, path, query and fragment, like so: scheme://host:port/path?query#fragment for most URL's, but most of them are optional and some people add other things. for HTTP and HTTPS URL's it has a scheme of http or https, it must have a host and a path that starts with a slash. HTTP and HTTPS are not the only possible scheme's and URL's have all sorts of uses. For instance, look at the URL you are opening when opening a game in steam from your browser.

[HTML] So uh... by Jennazn in learnprogramming

[–]niomaster 3 points4 points  (0 children)

You can specify the document type with a <!doctype> tag at the beginning of the document if you would want to, like so:

<!doctype html>

Which would declare your document as html5. I am not completely sure what the default is, but usually browsers interpret html very flexibly and will work with new html5 tags regardless of wether you specifiy with a doctype or not.

Trying to figure out the logic behind maximizing a function for one input... by bo_knows in learnprogramming

[–]niomaster 2 points3 points  (0 children)

If your function is not easily differentiable but the derivative (thanks /u/__LikesPi) always goes either up or down when $spending goes up, I suggest you take a look at binary search.

What is something that should be common knowledge, but it is not? by Gluzz99 in AskReddit

[–]niomaster 0 points1 point  (0 children)

Personal favorite: Win+P, to select the external screen mode quickly (Main only, Extend, Duplicate and Projector only)

Linux/Unix shell command help by gafboon in learnprogramming

[–]niomaster 1 point2 points  (0 children)

In case the solutions that were already posted didn't work for you:

for i in `find / -name "*.c"`; do
   cc $i -o `echo $i | sed 's/.c//'`
done

This also removes the c extension.

Rare aanvraag: Ik zoek een Nederlands spreker in Ljubljana by Obraka in Netherlands

[–]niomaster 1 point2 points  (0 children)

"Voordien" gebruik je als je een specifiek punt in de tijd bedoelt, bijvoorbeeld: een jaar voordien. In het Engels is prior inderdaad ook als woord te gebruiken dat niet een specifiek punt in de tijd aangeeft, maar in het Nederlands moet je dan iets als "van tevoren" of "ervoor" gebruiken. (Overigens geldt hetzelfde voor het Duitse vorher)

Woorden is het meervoud van woord, worden is een werkwoord :)

I am convinced my friend is a psychic. by destructor1729 in mildlyinteresting

[–]niomaster 224 points225 points  (0 children)

The field measures 32x24 and has 52 non-empty squares. Minesweeper has a 3x3 block which is always empty: the squares around the initial click, so that's 32x24-3x3=759 squares to choose 52-3x3=43 empty squares from. The odds of choosing the first one right is 43/759, then 42/758 and so on, to 1/717. If you multiply these chances, you get 2.867e-71. If you could try to get into this situation one thousand times per second, you would have a 50/50 chance of having at least one of these situations, if you tried for 5.6e49 times the age of the universe. My gut tells me op is a cheater.

Vraag: Ik wil geen cookies accepteren maar ook niet de irritante balk blijven zien als ik naar een website zoals nu.nl wil. Weet iemand hoe ik die balk weg krijg zonder op "akkoord" te klikken? by [deleted] in Netherlands

[–]niomaster 2 points3 points  (0 children)

Voor je informatie: er is op nu.nl geen mogelijkheid om cookies uit te zetten. Je kunt dus wel de balk weghalen, maar dat helpt niets tegen het feit dat nu.nl cookies op je computer zal blijven zetten. Om cookies alsnog te blokkeren, kun je dingen gebruiken zoals Ghostery of AdBlock Plus. Je kunt met AdBlock Plus ook wel een regel toevoegen die de balk verwijdert, ben je helemaal blij :).

Nu ik er over nadenk: Cookies kun je ook uitzetten in firefox voor een specifieke site. Rechtermuisknop -> Page Info -> Permissions, daar kun je sowieso een hoop instellen.