天道酬勤,学无止境

问答

Sample without replacement, or duplicates, in R

I have a long list, which contains quite a few duplicates, say for example 100,000 values, 20% of which are duplicates. I want to randomly sample from this list, placing all values into groups, say 400 of them. However, I don't want any of the subsequent groups to contain duplicate values within them - i.e. I want all 250 members of each group to be unique. I've tried using various permutation methods from vegan, picante, EcoSimR, but they don't do quite what I want, or seem to struggle with the large amount of data. I wondered if there was just some way of using the sample function that I can

2022-05-03 07:20:23   r   permutation   random-sample

Understanding a Linked List

The Following code is used as an example as an into to Generics. // type parameter T in angle brackets public class GenericList<T> { // The nested class is also generic on T private class Node { // T used in non-generic constructor public Node(T t) { next = null; data = t; } private Node next; public Node Next { get { return next; } set { next = value; } } // T as private member data type private T data; // T as return type of property public T Data { get { return data; } set { data = value; } } } private Node head; // constructor public GenericList() { head = null; } // T as method parameter

2022-05-03 07:20:19   c#   linked-list

Hashtable key with point

How do I issue a hash table key with a point character, such as FlatAppearance.BorderSize, so that it is correct? $Button = [System.Windows.Forms.Button] @{ # This is not a valid entry FlatAppearance.BorderSize = 0 } $Button = [System.Windows.Forms.Button] @{ # This is not a valid entry too "FlatAppearance.BorderSize" = 0 } $Button = [System.Windows.Forms.Button] @{ # This is not a valid entry too too FlatAppearance = @{ BorderSize = 0 } } Of course, I can write it like that $Button = [System.Windows.Forms.Button] @{} $Button.FlatAppearance.BorderSize = 0 However, it is more convenient to

2022-05-03 07:20:15   powershell   constructor   hashtable   object-initializers

Query to convert an array to a map of documents with n attributes

I'm converting an array to a map in mongo. "items":[ { "id":"AB-02", "qty":2 }, { "id":"AB-03", "qty":0 }, { "id":"AB-03", "qty":9 } ] becomes "items":{ "AB-02":{ "id":"AB-02", "qty":2 }, "AB-03":{ "id":"AB-03", "qty":0 }, "AB-04":{ "id":"AB-03", "qty":9 } } in the array version, it's quite easy to query based on how many elements inside items, but how do I do that with the latter format of items? as in, to query those documents whose items has lets say 7 elements?

2022-05-03 07:20:09   mongodb   mongodb-query   aggregation-framework

On the difference between a data model vs data format

I recently had to explain to an audience what is the difference between a data model and a data format. They wanted to explain why we just don't use XML to do the basic thing we do with RDF. Although I could explain a bunch of things, such as a distributed data model, reasoning and etc.. I was somewhat enable to explain the difference between a data model and a data format. I wonder if there is a simpler answer to this. I think instead of giving many points, like I did and that are not easy to understand for a simple user, it would clearly expose, why we need a data model over simply XML. Then

2022-05-03 07:20:01   xml   rdf   semantics   semantic-web   semantic-markup

Inserting multiple checkbox values to MySQL

I know there are multiple questions here on SO regarding this same issue already and I've looked into them but didn't quite get a satisfying answer. So here goes my question, I have a form which consists of a few textboxes and checkboxes. It looks like this, The user can select multiple checkboxes. I'm trying to insert the values(not the displaying text string) of those checkboxes into a MySQL table. It should look like this, One Service ID(SID) can have multiple Locations(Loc_Code). Those location codes (CO, GQ) are the values of the checkboxes. I've written this following code so far. <html>

2022-05-03 07:19:55   php   mysql   checkbox

How to remove shopping cart from WooCommerce plugin in Wordpress?

I'm using the Virtue Theme in Wordpress and have installed the WooCommerce plugin for setting up my online store. I want to remove the shopping cart function completely and instead place an order form on individual product page. Help is sought to remove the shopping cart.

2022-05-03 07:19:45   wordpress   woocommerce

Adding GTK library to CLion

I'm new to GTK and I'm using CLion IDE to code. I'm on Ubuntu and I've installed libgtk-3.0-dev . The headers I've added to my code is: gtk-3.0 gtk-3.0/gtk/gtk.h but when I want to build the project I get this error : fatal error: gtk-3.0: No such file or directory

2022-05-03 07:19:36   gtk3   clion

Java Netbeans override paint() method in a JPanel

Hi I'm a newbie programmer I want to develop a Java program's GUI using Netbeans IDE Using Netbeans GUI Builder, First, I create a new JFrame Form Then, I add a JPanel from the toolbar/palette Question is, How can I override the paint() function of the newly created JPanel ? I want to draw a background and some spheres inside the JPanel, I tried using getGraphics() function to paint and draw, it does the job, but it won't draw anymore when I call repaint() Should I create a new class implementing JPanel or JComponent, with my custom paint() function, instead ? (If it so, how can I do it with

2022-05-03 07:19:30   java   swing   netbeans

When should we use default interface method in C#?

In C# 8 and later, we have default interface methods, so: Doesn't it ruin the principle of interface? When should we use default interface methods instead of base (abstract) class?

2022-05-03 07:19:19   c#   interface   c#-8.0   default-interface-member