Referential integrity problem in Cassandra

Cassandra does not support referential integrity.) across tables.

Normalisation is not supported in Cassandra.


How to design the database in Cassandra that does not have duplication of data(column) across tables?

complexity theory – NP-complete problem of partitioning into several sets with a Hamiltonian cycle

How to prove the $NP$-completeness of the language $L$ = ${$$(G, k)$: the vertices of an undirected graph $G$ can be partitioned into $k$ pairwise disjoint sets of pairwise different sizes so,
that all the corresponding induced subgraphs have a Hamiltonian cycle}.
I had no problems how to prove that this language is in the $NP$, but it is not clear to me how to prove that this language is in the $NP-hard$ class.

shortcode – Pagination list user problem number of pages

I have to do a pagination that retrieves a list of contributors from the site, there are three (no problem). With docs, tutorials … My pagination works. I set the number of contributors to two per page (no problem). But I don’t understand why I have a continuation of page which goes up to 7. When I click on this 7th page for example I arrive on page with an empty list (normal). Normally it should stop at three pages maximum. I was told to indicate the number of post / page but by searching the documents and tutorial I do not understand.

    $total_users = count_users();
    $total_users = $total_users('total_users');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    $number = 1;
    $offset = $paged ? ($paged - 1) * $number : 0;
    $total_pages = floor($total_users / $number);

    $contributor_member = array(
        'role' => 'Contributor',
        'orderby' => 'user_nicename',
        'order' => 'ASC',
        'offset' => $offset,
        'number' => $number,
    );
    ob_start();
    $authors = get_users($contributor_member);
    foreach ($authors as $users):
        echo '<div class="column-member">';
        echo '<div class="info-member">';
        echo '<span class="comite-description-name"><a href=' . get_author_posts_url($users->ID) . '>' . $users->display_name . '</a></span>';
        echo '<span class="comite-description">' . $users->institution_rattachementUser . '</span>';
        echo '<span class="comite-description">' . $users->fonctionUser . '</span>';
        echo '</div>';
        echo '<div class="button-member">';
        echo '<a href=' . get_author_posts_url($users->ID) . '>En savoir plus</a>';
        echo '</div>';
        echo '</div>';
        echo '<hr class="separator-member">';
    endforeach;
    if($total_users > $number){
      echo '<div class="pagination-list">';          
          echo paginate_links (array(
             'total' => $total_pages,
             'prev_next' => false,
             'base' => get_pagenum_link(1) . '%_%',  
             'format' => 'page/%#%/', 
             'show_all' => true,
          ));
      echo '</div>';
    }
    $short_list = ob_get_clean();;
    return $short_list;

Is there a library or algorithm I can use to solve this type of problem efficiently in C# (.NET Core 3.0)?

I’m having trouble defining this problem space (example below), where to look, what to search etc. and would appreciate any help with suggestions of algorithms or libraries that I should look into. I’ve spent some time looking into constraint programming & OR-Tools but most problems seem to be scalar and I haven’t yet been able to figure out how to use any of the solutions effectively to solve my problem. My project is in C# (.NET Core 3.0)

EXAMPLE:

Say I have 3 objects (o) that each have associated attributes (a):

//object 1 has attributes 1, 2, and 3
o1 { a1, a2, a3 }
//object 2 has attributes 1 and 3
o2 { a1, a3 }
//object 3 has attributes 2 and 3
o3 { a2, a3 }

Then say that a person is able to select certain attributes they are interested in, specifically in this example the person is interested in:

//the person wants to see objects or groups/sets of objects that have attributes 1 and 2
a1 and a2

The goal then would be to return to the person set(s) of the objects that best contain the selected attributes with the least number of objects needed. In this case the desired return result would be:

//object 1 is the best solution because it contains attributes 1 and 2 by itself
1. o1 
//object's 2 and 3 together is the 2nd best solution because they contain attributes 1 and 2 between themselves
2. o2 and o3

This is a very simple example but the actual scale of the objects and attributes associated to those objects will require something much more efficient than brute force. Thanks in advance!

macos – Docking Station Problem

I bought a Asus SimPro Dock. I know it is not officially compatible, but I had a friends that uses it at works without problems. I connected it to my MacBook Pro 16 (2019) and it works for all the functionalities, except for the external monitor, the docking station instead works with a dell notebook and with my MacBook Pro 15 (2016). Initially I thought that the problem was Big Sur (my old MacBook has Catalina), but after a clean installation of Catalina also on the 16″, the docking station continues to not working. Any advices?

html – Problem of URLs with internal links with ‘base href’

I’ve got a website with includes the following directive in the HEAD section:

<base href="https://foo.com" />

Now, I want to create internal links to sections within the page ‘https://foo.com/product/name-of-the-product’

<a href="#photos">Photos</a>

But, instead of linking to ‘https://foo.com/product/name-of-the-product#photos’, it links to ‘https://foo.com/#photos’.

Any tip to fix this? Thank you.

Problem in the table for the case where there is no number

For different values of time & force in At formula, I have a problem with the first case, which requires the first At, and I can not fix it. Also, in the table, how can I automatically enter values? I want to say that I want a table from 1 to n with At,time,forc

m = 1266.5 ;
k = 50   ;
Pt = ( {
    {0, 0},
    {.2, 1000},
    {.4, 0},
    {.6, -1000},
    {.8, 0}
   } );
ListLinePlot(Pt);
(Omega) =  N(Sqrt((k*1000)/m), 5);
Round(T = (2*N(Pi, 5))/(Omega), 0.1);
(CapitalDelta)t = Round(T/10, 0.1)
time = NestList(# + (CapitalDelta)t &, Part(Pt, 1, 1), 
  Round(FixedPoint((#) &, (Part(Pt, 5, 1)/(CapitalDelta)t))))
forc = Table(p1 = Interpolation(Pt, InterpolationOrder -> 1); 
  P1 = p1(time((i))), {i, 1, Length@time - 1})
At = Table(
  At((i - 1)) + 
   1/(Omega)*(time((i)) - (forc((i)) - forc((i - 1)))/(
       time((i)) - time((i - 1)))*
       time((i - 1)))*(Sin((Omega)*time((i))) - 
      Sin((Omega)*time((i - 1)))) + 
   1/(Omega)^2*(forc((i)) - forc((i - 1)))/(
    time((i)) - 
     time((i - 1)))*(Cos((Omega)*time((i))) - 
      Cos((Omega)*
        time((i - 1))) + (Omega)*(time((i))*Sin((Omega)*time((i))) -
          time((i - 1))*Sin((Omega)*time((i - 1)))))
  , {i, 1, Length@time - 1})
data = {{{Subscript(t, i), s}, {Subscript(p, i), N}}, {Part(time, 1), 
    Part(forc, 1)}, {Part(time, 2), Part(forc, 2)}, {Part(time, 3), 
    Part(forc, 3)}, {Part(time, 4), Part(forc, 4)}, {Part(time, 5), 
    Part(forc, 5)}, {Part(time, 6), Part(forc, 6)}, {Part(time, 7), 
    Part(forc, 7)}, {Part(time, 8), Part(forc, 8)}};
Grid(data, Alignment -> Center, Spacings -> {2, 1}, Frame -> All, 
 ItemStyle -> "Text", Background -> {{Gray, None}, {LightGray, None}})

php – Is there a general solution to the problem of “sudden unexpected bursts of errors” in software?

Let me explain what I mean.

I have made a complex, highly polished over years PHP framework/library for my own use. I very aggressively log the smallest notice and immediately deal with it as soon as it pops ups, always trying to predict potential errors in my code as to never have them occur even in rare situations, but rather handling them automatically before they get logged.

However, in spite of all my efforts, inevitably, I wake up (such as today) to find that some third-party service has fiddles around with their file format for one of their CSV files of data that they provide on their website and which my system fetches and imports every day.

Then I get a flood of ugly PHP errors. Ouch.

Even though it looks scary at first, it’s typically just a pretty simple fix, and it’s typically really just ONE error, which cascades into tons of apparent errors because the chain of function calls “fall apart” as each one expects something that they no longer get.

I fix the issue, clear the errors, re-run the logic, verify that it no longer causes any errors, and then it’s fixed. For now. Until the same thing happens again, with some other part of the system.

I can personally “deal with” this, but it really bothers me in terms of giving away my system to somebody else to run on their machines. If/when the same kind of thing happens for them, they will doubtlessly blame me and think I’m incompetent (which may be true).

But even for myself, this is quite annoying and makes me feel as if my system is very fragile and a house of cards waiting to fall apart, in spite of there normally being not a single little notice or warning logged during “normal operation”.

Short of predicting every possible change and writing enormous amounts of extra “checking” code to verify that all data is always exactly what is expected, is there anything I can do to fix this general problem? Or is this like asking for a pill that cures any disease instantly?

Please don’t get hung up on the fact that I mentioned PHP. I’d say that this question goes completely regardless of the programming language or environment. It’s really more of a philosophical question than a technical one IMO.

I fear that the answer will be: “There is no way. You have to bite the bullet and verify, verify and verify everything all the time!”

18.04 – Kernel Problem with Docker

just to send to inform you, because we don’t know what to do for our part other than updating ubuntu OS. Also, you may fix this in your development.
We had issued with docker that suddenly stop,this is how our log capture of the problem. Starting up docker deamon will do the resolution. We deployed in Azure Virtual Server on ubuntu 18.04 with 8 GB RAM and 30 GB HDD configuration.
Thank you.

java – timing out on one case, USACO 2018 US Open Contest, Silver Problem 3. Multiplayer Moo1

Referring to this question: http://usaco.org/index.php?page=viewproblem2&cpid=836

Hi! So I’m working on this problem, and my approach was to search ever possible ways, but it time out on one case:enter image description here

And here is my code:

import java.io.*;
import java.util.*;

public class main {
    public static int()() grid;
    public static boolean()() went, went2;
    public static int cnt;
    
    public static void dfs1(int x, int y, int wanted) {
        if(x < 0 || y < 0 || x >= grid.length ||  y >= grid.length) {
            return;
        }
        
        if(went(x)(y) || grid(x)(y) != wanted) {
            return;
        }
        went(x)(y) = true;
        cnt++;
        
        dfs1(x + 1, y, wanted);
        dfs1(x - 1, y, wanted);
        dfs1(x, y + 1, wanted);
        dfs1(x, y - 1, wanted);
    }
    
    public static void dfs2(int x, int y, LinkedList<Integer> wanted) {
        if(x < 0 || y < 0 || x >= grid.length || y >= grid.length) {
            return;
        }
        
        if(went2(x)(y)) {
            return;
        }else if(!wanted.contains(grid(x)(y)) && wanted.size() >= 2) {
            return;
        }else if(wanted.size() < 2 && !wanted.contains(grid(x)(y))) {
            wanted.add(grid(x)(y));
        }
        
        cnt++;
        if(wanted.size() < 2) {
            went(x)(y) = true;
        }
        went2(x)(y) = true;
        
        dfs2(x + 1, y, wanted);
        dfs2(x - 1, y, wanted);
        dfs2(x, y + 1, wanted);
        dfs2(x, y - 1, wanted);
    }
    
    
    public static void main(String() args) throws IOException{
        //BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        BufferedReader input = new BufferedReader(new FileReader("multimoo.in"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("multimoo.out")));
        
        StringTokenizer st = new StringTokenizer(input.readLine());
        int n = Integer.parseInt(st.nextToken());
        grid = new int(n)(n);
        went = new boolean(n)(n);
        went2 = new boolean(n)(n);
        
        for(int i = 0;i<n;i++) {
            st = new StringTokenizer(input.readLine());
            
            for(int j = 0;j<n;j++) {
                int num = Integer.parseInt(st.nextToken());
                grid(i)(j) = num;
            }
            
        }
        
        
        int best = 0;
        //int best2 = 0;
        
        for(int i = 0;i<n;i++) {
            for(int j = 0;j<n;j++) {
                if(!went(i)(j)) {
                    cnt = 0;
                    dfs1(i, j, grid(i)(j));
                    if(cnt > best) {
        //              best2 = best;
                        best = cnt;
                    }
                }
            }
        }
        
        //best2 += best;
        //System.out.println(best);
        out.println(best);
        best = 0;
        
        went = new boolean(n)(n);
        
        
        for(int i = 0;i<n;i++) {
            for(int j = 0;j<n;j++) {
                if(!went(i)(j)) {
                    cnt = 0;
                    LinkedList<Integer> wanted = new LinkedList<Integer>();
                    wanted.add(grid(i)(j));
                    went2 = new boolean(n)(n);
                    dfs2(i, j, wanted);
                    best = Math.max(best, cnt);
                }
            }
        }
        
        //System.out.println(best);
        out.println(best);
        out.close();
    }

}

So my question was, how can I pass the one case? I sure I just need a little change somewhere, since I’m only having a time limit exceeded on one case. Thanks!