Blocking a command from execution in ubuntu

I have a shared PC with Ubuntu in it, My friends may also want to use sudo. But I know they often play with the command

chmod -R 777 / 

I need to know is there a way to specifically block this command from execution even by the root user. As no one gonna has to use this command on the usual purpose.

But I may need friends to use chmod on other dirs.

2013: Crawler failing execution of proc_MSS_GetNextCrawlBatch due to datediff overflow

Up front disclosure: I am not a sharepoint admin. We don’t have a sharepoint admin. I just try to solve problems.

I was hearing reports of connection problems with one of our UAT SQL instances.

Querying connection metadata for the instance, I found that it had ~1000 connections against the sharepoint 2013 crawl store database. Almost all executing (or last tried to execute) the stored procedure procedure dbo.proc_MSS_GetNextCrawlBatch.

Since I have the necessary permissions to be able to connect to the sharepoint server, I spelunked through central admin until I found what seemed like a relevant error page. With more spelunking and some googling I found the location of the sharepoint log file, where I see the following error repeated many times:

ManagedSqlSession caught a SqlException executing the following command: 'proc_MSS_GetNextCrawlBatch'. Connection string was: '[redacted]' Original exception message: 'The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart.'

OK good, familiar territory. Pulling apart the guts of the stored procedure and using parameters I found from a SQL trace, I have determined that one of the query columns is defined as datediff(millisecond, CrawlQueue.TimeInsertedInQueue, getutcdate()), and that there are rows in the MSSCrawlQueue table with a TimeInsertedInQueue value back in 2017. Clearly the number of milliseconds between a date in 2017 and today’s date is going to overflow.

So, I have the problem diagnosed down to this very specific issue. What I don’t know is: how do I fix it? Or rather, what is the correct way to fix it? I mean, I could simply delete all the rows from the MSSCrawlQueue table, but I expect there is a right way to solve this problem which is more subtle than taking off and nuking it from orbit.

Ensuring Thread Execution Order when Writes Must Occur Before Reads

I’m currently designing a server with the following structure:

  • A TCP thread pool that receives data from the network
  • A queue that holds these requests
  • A worker thread pool of a fixed size that takes requests from the queue and executes some work where a ConcurrentHashMap is read, and results analyzed. After the work is complete, the results are posted to a write queue.
  • The write queue stores write requests for ConcurrentHashMap
  • A write thread pool of a fixed size that takes requests from the write pool and writes them to the ConcurrentHashMap

Server constraint:

  • For a particular entry in ConcurrentHashMap, a write will get posted to the network several seconds before a read gets posted to the network. The threads must never allow the read to get scheduled before the write occurs.

My ideas so far:

  • First, I’m hoping that the 3-5 seconds or so is a big enough head start for a write to get through before the read
  • Set the write threads to have high priority and the read threads to have low priority
  • A read can check the last write time, and if large enough (like several minutes or hours ago), it knows to ignore the last write because it is out of date. However, it then knows that it can’t make an informed decision. I could have the thread retry like twice in the case of an outdated entry, but this feels clumsy.
  • Added the write queue so that the TCP pool can post directy to the write queue (write requests don’t need to be processed by the worker pool) instead of the job queue while read requests are put in the worker thread queue, and then post some logging info to the write queue later. after the worker pool

Are there any ways to ensure that reads have a low chance of occurring before a write or are the precautions I’ve already taken sufficient? Should I use the read retry mechanism?

Also, is a write queue actually needed or can I just use worker threads more generally to also handle writes? Write order is not important.

How to control JavaFX’s animations execution order when animations “queue” is being altered in run-time?

Is there a best practice regarding synchronization between GUI animations’ execution order and the user’s dynamic input?

More specifically, I would like to know how to best enforce some logical conditioning on the execution’s order. While remembering, that the user’s input can not be foreseen.

For instance, a greatly simplified example:

  • 9 rectangles are shown on a screen.
  • A click on a rectangle fades it out.
  • The user clicks whichever rectangle he wants in whatever order he likes and as fast as he feels is right.
  • The condition here breaks into two simple ones:
    • The rectangles must not fade out simultaneously.
    • The rectangles’ fade out effect occurs in the same order as their clicks.

SSCCE:

FunExperiment class:

import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import javafx.stage.StageStyle; import model.startup.Skedaddle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;  public class FunExperiment extends Application {    private static Logger logger = LogManager.getLogger(Skedaddle.class);    public static void main(String[] args) {     launch(args);   }    @Override   public void start(Stage primaryStage) {     logger.traceEntry();      Parent rootG = new Group();      for (int i = 0; i < 9; i++) {       Rectangle rectangle = new Rectangle(90, 90, Color.GREENYELLOW);       rectangle.setTranslateX(100 * (i / 3));       rectangle.setTranslateY(100 * (i % 3));        rectangle.setOnMouseClicked(e -> {         Thread newThread = new Thread(new AnimationPlayer(rectangle));         newThread.start();       });       ((Group) rootG).getChildren().add(rectangle);     }      Scene scene = new Scene(rootG, 300, 300, Color.TRANSPARENT);     primaryStage.setScene(scene);     primaryStage.initStyle(StageStyle.TRANSPARENT);      logger.debug("Showing stage...");     primaryStage.show();   }  } 

AnimationPlayer class:

import java.util.ArrayList; import javafx.animation.FadeTransition; import javafx.scene.Node; import javafx.util.Duration; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;  class AnimationPlayer implements Runnable {    private static final Logger logger = LogManager.getLogger(AnimationPlayer.class);    private static Object aLock = new Object();    private static ArrayList<Integer> order = new ArrayList<>();   private static int counter = 1;   private Integer myNumber;   private Node node;    public AnimationPlayer(Node nodeToTransition) {     this.node = nodeToTransition;     myNumber = counter++;     logger.traceEntry("Thread with number " + myNumber + " was instantiated.");   }    @Override   public void run() {     order.add(myNumber);     order.sort(Integer::compareTo);     synchronized (aLock) {       while (!order.get(0).equals(myNumber)) {         logger.traceEntry("MyNumber: " + myNumber + ", I'm gonna wait.");         try {           aLock.wait();         } catch (InterruptedException e) {           logger.error(e);           e.printStackTrace();         }       }        logger.traceEntry("MyNumber: " + myNumber + ", I'm in!, initializing animation...");       FadeTransition fadeTransition = new FadeTransition();       fadeTransition.setNode(node);       fadeTransition.setToValue(0);       fadeTransition.setDuration(Duration.seconds(1));       fadeTransition.setOnFinished(handler -> {         synchronized (aLock) {           logger.traceEntry("MyNumber: " + myNumber + ", animation is over, notifying others...");           order.remove(myNumber);           order.sort(Integer::compareTo);           aLock.notifyAll();         }       });       fadeTransition.play();       logger.traceEntry("MyNumber: " + myNumber + ", Okay, got to go, bye bye.");     }   } } 

Log after clicking 4 rectangles:

Please note that the “i” in “Thread-i” and “MyNumber: i” aren’t the same number.

18:19:18.458 JavaFX Application Thread - Enter  18:19:18.580 JavaFX Application Thread - Showing stage...  18:19:19.688 JavaFX Application Thread - Enter Thread with number 1 was instantiated.  18:19:19.690 Thread-3                  - Enter MyNumber: 1, I'm in!, initializing animation...  18:19:19.693 Thread-3                  - Enter MyNumber: 1, playing animation...  18:19:19.877 JavaFX Application Thread - Enter Thread with number 2 was instantiated.  18:19:19.878 Thread-4                  - Enter MyNumber: 2, I'm gonna wait.  18:19:20.096 JavaFX Application Thread - Enter Thread with number 3 was instantiated.  18:19:20.096 Thread-5                  - Enter MyNumber: 3, I'm gonna wait.  18:19:20.290 JavaFX Application Thread - Enter Thread with number 4 was instantiated.  18:19:20.291 Thread-6                  - Enter MyNumber: 4, I'm gonna wait.  18:19:20.708 JavaFX Application Thread - Enter MyNumber: 1, animation is over, notifying others...  18:19:20.708 Thread-4                  - Enter MyNumber: 2, I'm in!, initializing animation...  18:19:20.708 Thread-4                  - Enter MyNumber: 2, playing animation...  18:19:20.708 Thread-6                  - Enter MyNumber: 4, I'm gonna wait.  18:19:20.709 Thread-5                  - Enter MyNumber: 3, I'm gonna wait.  18:19:21.716 JavaFX Application Thread - Enter MyNumber: 2, animation is over, notifying others...  18:19:21.716 Thread-6                  - Enter MyNumber: 4, I'm gonna wait.  18:19:21.716 Thread-5                  - Enter MyNumber: 3, I'm in!, initializing animation...  18:19:21.717 Thread-5                  - Enter MyNumber: 3, playing animation...  18:19:22.724 JavaFX Application Thread - Enter MyNumber: 3, animation is over, notifying others...  18:19:22.724 Thread-6                  - Enter MyNumber: 4, I'm in!, initializing animation...  18:19:22.724 Thread-6                  - Enter MyNumber: 4, playing animation...  18:19:23.731 JavaFX Application Thread - Enter MyNumber: 4, animation is over, notifying others...  

Since all the UI manipulations happen from within the JavaFX Application Thread, all the AnimationPlayer does is enforce an order rather than taking some work off the hands of the main thread.

Is there a better and/or a more correct way of implementing said example?

How about a more complicated condition?
In order to keep my question short and readable, I omitted other conditions I had in mind. If a more interesting challenge piques your interest, please let me know and I will add it as a comment.

I understand this might be a very broad question, nevertheless, any recommendation on what should one read in order to learn more about the different options, caveats, etc… would be greatly appreciated.

The difference between “concurrent” and “parallel” execution?

What is the difference between the terms concurrent and parallel execution? I’ve never quite been able to grasp the distinction.

The tag defines concurrency as a manner of running two processes simultaneously, but I thought parallelism was exactly the same thing, i.e.: separate threads or processes which can potentially be run on separate processors.

Also, if we consider something like asynchronous I/O, are we dealing with concurrency or parallelism?

How can I solve error “Exceeded maximum execution time” in Google Sheets?

I found a script which I really need (link):

function getTotalSum(cell) {     var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();     var sum = 0;     for (var i = 0; i < sheets.length ; i++ ) {         var sheet = sheets[i];         var val = sheet.getRange(cell).getValue();          if (typeof(val) == 'number') {             sum += val;            }            }      return sum; } 

but it gives an error (Exceeded maximum execution time) generally.

How can I solve this error?

Throttling promise execution (api requests, etc)

I was working on a client for a remote api and realized that i needed to throttle requests to < 4/second. I wrote a simple typescript class to do it and wanted to solicit code review- it basically should accept a () => Promise and return a Promise that resolves once executed by the queue.

My prototype solution is here, and I’d just like to solicit feedback for it. Original code here: https://codesandbox.io/s/throttled-promises-3pscr

/**  * Request throttle has an add() method which takes a () => Promise<string>  * and queues the promise to be executed in order.  * add() returns a promise that resolves with the original promise result.  */ class RequestThrottle {   stack = [];   spacing = 1000;    add: (req: () => Promise<string>) => Promise<string> = req => {     let executor;     const requestPromise: Promise<string> = new Promise((resolve, _reject) => {       let localExecutor = () => {         resolve(req());       };       executor = localExecutor;     });      this.stack.push(executor);     return requestPromise;   };    pullAndExecute = () => {     const op: () => Promise<string> = this.stack.shift();     // if (op) console.log("throttle found:", op);     if (op) op();   };    interval = setInterval(this.pullAndExecute, this.spacing);    stop = () => clearInterval(this.interval); }  const throttle = new RequestThrottle();  /**   * Promise tester - to add a bit of extra async operations  * (eg a network request to an api)  * */  const addChild: (c: number | string) => Promise<string> = count => {   const list = document.getElementById("list");   const node = document.createElement("LI");   node.innerHTML = count.toString();   list.appendChild(node);   const promise: Promise<string> = new Promise(resolve =>     setTimeout(() => {       log(`added "$  {count}"`);     }, 500)   );   return promise; };  const log = (s: string) => {   const list = document.getElementById("log");   const node = document.createElement("pre");   node.innerHTML = s;   list.appendChild(node); };  addChild("Starting a List").then(console.log);  const enqueue: (i: number | string) => () => Promise<string> = i => {   console.log("enqueueing " + i);   return () => {     return addChild(i);   }; };  for (var i in [1, 2, 3, 4, 5, 6]) {   throttle.add(enqueue(i)).then(console.log); } ``` 

How to fix “cudnn status execution failed” error in specific environment?

I have a problem on using cudnn function.

I’m using cuda function in cudnn library. In many other environment cases, it doesn’t have any problems. But, in specific environment, it makes error when using some functions like cudnnConvolutionForward, cudnnAddTensor.(cudnn_status_execution_failed)

I tested exactly same process in multiple environments but in just 1 case, this problem happens.

For accurate information transmission, I give my computer environment.

CPU : Intel i7-9800X GPU : 2080Ti Mainboard : Asus WS X299 SAGE, BIOS version : 1001 Graphic Card Driver : 425.31 and 430.86 both tested Windows 10 Pro CUDA : 10.0 Cudnn : 7.5