Wednesday, July 7, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Resample distribution to new distribution with maximum possible data records

Posted: 07 Jul 2021 08:37 AM PDT

Context

Recently, I asked here how to resample a dataset with some random distribution to a particular distribution over some classes which should retrieve the maximum possible datapoints for each class.

The problem was solved - Anyhow, only in a Python-implementation. For my use case I now require to do it in pure SQL or rather SQL that is compatible with Impala or HiveQL.

To better understand the problem at hand, this is a fictive example of the data (how looks and how it should look like). It is a distribution of three classes per calendar week:

| Week | Class | Count | Distribution | Desired Distribution |  |------|-------|-------|--------------|----------------------|  | 01   | A     | 954   |     0.36     |         0.55         |  | 01   | B     | 554   |     0.21     |         0.29         |  | 01   | C     | 1145  |     0.43     |         0.16         |  | 02   | A     | 454   |     0.21     |         0.55         |  | 02   | B     | 944   |     0.44     |         0.29         |  | 02   | C     | 748   |     0.35     |         0.16         |    

As can be seen, the distribution is random and does not match the ground truth (Desired Distribution). Moreover, the desired distribution differs quite strongly from the status quo.

Problem

It is required to get the maximum possible data records per class and calendar week. Thus, it is not possible to only multiply the desired distribution with the sum of the count for each week (sum(count_per_week) * desired_distribution). More challenging, the class with the highest desired data points has sometimes the fewest in the actual data (Class="A"") which is why this precondition is crucial. Ultimately, the numbers have to be used to restrict the data-records to the required amount.

Therefore, it is required to find a solution grouping each calendar week, calculating the maximum possible datapoints and select the data records accordingly while doing this in SQL.

Question

How can I resample a distribution of class-counts per calendar week to a desired other distribution in SQL while maintaing as much data as possible per class?

Display an Error for invalid input in JAVA

Posted: 07 Jul 2021 08:37 AM PDT

I have written a JAVA program that takes input from the user and check if the user has entered the correct thing or not. I have taken the input from the Scanner class. If the user enters an invalid character like a String, I want to display 'Invalid Input'.

public class Main {  public static void main(String[] args) {      Scanner takeInteger = new Scanner(System.in);      System.out.println("Enter a number");      int enteredNumber = takeInteger.nextInt();    }  

}

How to set Angular Kendo grid button text on center?

Posted: 07 Jul 2021 08:37 AM PDT

Currently I am using grid view of Kendo UI for angular. Here I have some button on grid but the problem is the text of the button is not in center, however I have applied some styles like (text-align:center) but nothing works. Here is my button template

<kendo-grid-command-column title="SPO Item Count" width="120">                                              <ng-template kendoGridCellTemplate let-dataItem>                                                  <button pButton type="button"                                                          style="margin-bottom:10px;margin-right:10px; width: 100px; text-align:center" (click)="onEditCostClick(dataItem);"                                                          class="p-mr-2 p-mb-2 p-ripple p-button p-component">                                                      {{dataItem.spoItemCount}}                                                  </button>                                              </ng-template>                                          </kendo-grid-command-column>  

and here is what I get in browser

enter image description here

Parallelizing tensor operations in TensorFlow

Posted: 07 Jul 2021 08:37 AM PDT

I'm trying to parallelize different tensor operations. I'm aware that tf.vectorized_map and/or tf.map_fn can parallelize input tensor(s) with respect to their first axis, but that's not what I'm looking for. I'm looking for a way to parallelize a for loop on a set of tensors with possibly different shapes.

list_of_tensors = [a,b,c,d,e] # different tensors not necessarily has the same shape  for t in list_of_tensors:      # some operation on t which may vary depending on its shape  

Is there a possible way to parallelize this for loop on GPU with TensorFlow? (I'm open to any other library if possible i.e. JAX, numba etc.)

Thanks!

how to train a csv data with tensorflow?

Posted: 07 Jul 2021 08:37 AM PDT

I am currently trying to train my csv data using tensorflow. However, my epoch is always started directly at the start with an accurancy of 1.0000. How can I train my csv data using Tensorflow? I'm working with tensorflow for the first time and unfortunately I'm not getting anywhere.

Epoch 1/200  1294/1294 [==============================] - 1s 623us/step - loss: 0.0327 - accuracy: 0.9982  Epoch 2/200  1294/1294 [==============================] - 1s 619us/step - loss: 9.4261e-04 - accuracy: 1.0000  Epoch 3/200  1294/1294 [==============================] - 1s 636us/step - loss: 4.6745e-04 - accuracy: 1.0000  Epoch 4/200  1294/1294 [==============================] - 1s 597us/step - loss: 3.0330e-04 - accuracy: 1.0000  ....  
    df = pd.read_csv('my_data.csv')      X = pd.get_dummies(df.drop(['ID'], axis=1))      y = df['ID'].apply(lambda x: 0 if x == '' else 1)      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.2)        model = Sequential()      model.add(Dense(units=32, activation='relu', input_dim=len(X_train.columns)))      model.add(Dense(units=64, activation='relu'))      model.add(Dense(units=1, activation='sigmoid'))      model.compile(optimizer='sgd', loss='binary_crossentropy', metrics='accuracy')      model.fit(X_train, y_train, epochs=200, batch_size=32, verbose=1)      model.save('model')  

this is how my data looks like

Express.js POST request returns 404

Posted: 07 Jul 2021 08:37 AM PDT

My server returns 404 when I try to submit a post request. I've stripped out nonessential logic. Nothing gets logged to the console. Somewhat at a loss here. Could the error be due to misconfiguration upstream of my server.js code? Also, a question that perhaps betrays some fundamental misunderstandings: Does it matter what url (or view) the client has accessed when pressing submit? Does the url have any bearing on the endpoint defined in the form / handled by server.js?

 const express = require('express')   const connect = require('connect')   const serveStatic = require('serve-static')   const bodyParser = require('body-parser')     const app = express()   const port = 8080     app.use(bodyParser.urlencoded({extended: false}))     app.use((req, res, next) => {     console.log('A new request received at ' + Date.now());     next();   });     app.post('/', function(request, response){      console.log(request.body);   })     connect()       .use(serveStatic(__dirname))       .listen(port, () => console.log('Server running on 8080...'))  

<form action="/" id="contact-form" method="post" role="form">

Calculate Errors using loop function in R

Posted: 07 Jul 2021 08:37 AM PDT

I have two data matrices both having the same dimensions. I want to extract the same series of columns vectors. Then take both series as vectors, then calculate different errors for example mean absolute error**(mae)**, mean percentage error (mape) and root means square error
(rmse). My data matrix is quite large dimensional so I try to explain with an example and calculate these errors manually as:

mat1<- matrix(6:75,ncol=10,byrow=T)   mat2<- matrix(30:99,ncol=10,byrow=T)   mat1_seri1 <- as.vector(mat1[,c(1+(0:4)*2)])  mat1_seri2<- as.vctor(mat1[,c(2+(0:4)*2)])  mat2_seri1 <- as.vector(mat1[,c(1+(0:4)*2)])  mat2_seri2<- as.vector(mat1[,c(2+(0:4)*2)])  mae1<-mean(abs(mat1_seri1-mat2_seri1))  mae2<-mean(abs(mat1_seri2-mat2_seri2))  For mape   mape1<- mean(abs(mat1_seri1-mat2_seri1)/mat1_seri1)*100  mape2<- mean(abs(mat1_seri2-mat2_seri2)/mat1_seri2)*100  

similarly, I calculate rmse from their formula, as I have large data matrices so manually it is quite time-consuming. Is it's possible to do this using looping which gives an output of the errors**(mae,mape,rmse)** term for each series separately.

Sed - How to read a file line by line and go the path mentioned in the file then replace string

Posted: 07 Jul 2021 08:36 AM PDT

I am on a new project where I need to add some strings to all the API names, which are exported Someone hinted this can be done with simple sed commands.

What really needed is : Example :

In my project say 100 files and many files have something like the below pattern in file1 export(xyx); in file2 export (abc);

What is needed here is to replace the xyz with xyz_temp and abc with abc_temp.

Now the problem is these APIs are in different folders and different files.

Fortunately, I got to know we can export the result of cscope to some file with matching patterns. so I did export the result of a search of the "export" string and it indeed exported as bellow.

Say file I have exported the scope result - export_api.txt as below.

  1. /path1/file1.txt export(xyz);
  2. /path2/file2.txt export(abc);

Now, I am not sure how to use sed to do this automation of

  1. Reading this export_ap.txt
  2. Reading each line
  3. Replacing the string as above.

Any direction would highly appriciated.

Thanks in advance.

Authentication error accessing sharepoint api with phpSPO

Posted: 07 Jul 2021 08:36 AM PDT

I'm working with phpSPO library to upload genereted files in a laravel PHP App. I'm using user credential auth (the user is admin and owner of the SP site) and i follow this guide to granting access at the app https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs.

I always get this error {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}.

Trying create azure app and assign xml permissions don't solve it.

This are the permissions:

<AppPermissionRequests AllowAppOnlyPolicy="true">    <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />  </AppPermissionRequests>  

and this is the code used to connect with sharepoint site:

$url_sp = "https://domain.sharepoint.com/sites/SITENAME";  $ctx = ClientContext::connectWithUserCredentials($url_sp,"user@domain.com","usr-password")  $target="/sites/SITENAME/Documents/FOLDER";  $parentFolder = $ctx->getWeb()->getFolderByServerRelativeUrl(dirname($target));  $folder = $parentFolder->getFolders()->add(basename($target));  $ctx->executeQuery();  

Using client ID and secret for auth i get this error "Undefined index: token_type"

I think it's about app registration with sharepoint/azure domain but i don't know how to solve it.

Thanks!

Is it possible to run a 4 dimensional work item in pyopencl?

Posted: 07 Jul 2021 08:36 AM PDT

I have a pyopencl based code which runs perfectly fine for 3-dimensional work groups, but when moving to 4-dimensional work groups, it breaks down with the error:

pyopencl._cl.LogicError: clEnqueueNDRangeKernel failed: INVALID_WORK_DIMENSION

Digging around, I found this answer to another question, which implies that OpenCl in fact allows higher dimensional work groups.

So my question is if it is possible to change this setting in pyopencl. From this other answer elsewhere, I understand that pyopencl immediately inputs the dimensions, but given the error I have, I think there must be some issue.

This is a minimal sample code to replicate this error. The code works well for the first kernel function, it breaks down on the second one.

  import pyopencl as cl  import numpy as np    context = cl.create_some_context()   queue = cl.CommandQueue(context)        kernel_code = """  __kernel void fun3d( __global double *output)  {      size_t i = get_global_id(0);      size_t j = get_global_id(1);      size_t k = get_global_id(2);      size_t I = get_global_size(0);      size_t J = get_global_size(1);      #      size_t idx = k*J*I + j*I + i;      #       output[idx] = idx;  }    __kernel void fun4d( __global double *output)  {      size_t i = get_global_id(0);      size_t j = get_global_id(1);      size_t k = get_global_id(2);      size_t l = get_global_id(2);      size_t I = get_global_size(0);      size_t J = get_global_size(1);      size_t K = get_global_size(2);      #      size_t idx = l*K*J*I + k*J*I + j*I + i;      #       output[idx] = idx;  }  """    program = cl.Program(context, kernel_code).build()    I = 2  J = 3  K = 4  L = 5    output3d = np.zeros((I*J*K)).astype(np.float64)  cl_output3d = cl.Buffer(context, cl.mem_flags.WRITE_ONLY, output3d.nbytes)    program.fun3d(queue, (I,J,K), None, cl_output3d)  cl.enqueue_copy(queue, output3d, cl_output3d)  queue.finish()      import code; code.interact(local=dict(globals(), **locals()))  # 4d attempt    output4d = np.zeros((I*J*K*L)).astype(np.float64)  cl_output4d = cl.Buffer(context, cl.mem_flags.WRITE_ONLY, output4d.nbytes)    program.fun4d(queue, (I,J,K,L), None, cl_output4d)  cl.enqueue_copy(queue, output4d, cl_output4d)  queue.finish()  

How to retrieve a list of processes and close them

Posted: 07 Jul 2021 08:36 AM PDT

was looking to block some processes while running my script in py, how can i check all the processes and kill only some of them which are basically "flagged" by my script(stored into variables)? I'm quite a newbie regarding those stuff so please understand my lack of knowledge. If you have any kind of suggestions for this please answer to this post.

Before flagging it for the lack of explanations/code examples make questions please, as i said before i do not have any kind of code due to my lack of knowledge, i'm here for learning as an autodidact.

** Edit: found out that i can close them by doing that but how can i scan the list and then close only some of them?

import os  os.system('taskkill /im Charles.exe')  

How to convert SQL-style `decimal(4,2)` to Go code

Posted: 07 Jul 2021 08:36 AM PDT

Not sure if there is a shortcut on how to allow total of 4 digits 2 of which are after decimal point in Go, is there a built-in way to convert SQL's decimal(4,2) to Go code?

How to change title of columns dynamically while adding columns to table

Posted: 07 Jul 2021 08:37 AM PDT

Here is a working codepen for editing table cells: https://codepen.io/gges5110/pen/GLPjYr?editors=0010

the adding column function is as below:

handleAddColumn = () => {      const { columns } = this.state;      const newColumn = {        title: 'age',        dataIndex: 'age',      };  

How do I make it so that for every time I click on 'add a column' it will change the column title to 'age 1', 'age 2', 'age 3', ...?

Why is cordova picking up the wrong JDK version?

Posted: 07 Jul 2021 08:36 AM PDT

On macOS, when running the terminal command

cordova build android  

I get an error:

Checking Java JDK and Android SDK versions  ANDROID_SDK_ROOT=/Users/arnas/Android/Sdk (recommended setting)  ANDROID_HOME=/Users/arnas/Android/Sdk (DEPRECATED)  Requirements check failed for JDK 1.8.x! Detected version: 15.0.2  Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.  

although running java -version returns java version "1.8.0_291"

My bash_profile settings are:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`    export ANDROID_HOME=$HOME/Android/Sdk  export ANDROID_SDK_ROOT=$HOME/Android/Sdk  export PATH=$PATH:$ANDROID_HOME/tools  export PATH=$PATH:$ANDROID_HOME/platform-tools  

What could be wrong here?

Jquery UI -> collision detection does not work?

Posted: 07 Jul 2021 08:37 AM PDT

I would like to use jQuery UI to detect collisions between dynamically generated rectangles. I've made the dynamically generated rectangles draggable and it works, but whenever I try to make them collide with each other they just pass through and I don't really know why.

let elementCounter = -1    $(document).ready() {    $('#newRectangle').on('click', () => {      elementCounter += 1      const newElement = document.createElement('div');      newElement.draggable = true      newElement.className = 'individualRectangle butNotHere';      newElement.id = 'individualRectangle';      newElement.style.position = 'relative'      const newElementGrid = document.querySelector('.individualRectangle');      newElementGrid.appendChild(newElement);        $('.individualGamePanel').draggable({        obstacle: "butNotHere",        preventCollision: true,        containment: '.adminPanelContainer',        start: function(event, ui) {          $(this).removeClass('butNotHere');        },        stop: function(event, ui) {          $(this).addClass('butNotHere');        },        create: function() {          let offset = $(this).offset()          let x_pos = offset.left          let y_pos = offset.top          let classNamee = $(this).attr('class')          let widgetNumber = classNamee.split(' ')[1]          let width = $(this).width()          let height = $(this).height()        },        drag: function() {          let offset = $(this).offset()          let x_pos = offset.left          let y_pos = offset.top          let classNamee = $(this).attr('class')          let widgetNumber = classNamee.split(' ')[1]        }      })    })  }
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>    <div class="adminPanelContainer" id="adminPanelContainer">    <div class="rectanglesContainer">      <div class="individualRectangle" id="individualRectangle"></div>    </div>  </div>

Caused by: java.lang.ClassNotFoundException: javax.annotation.Generated

Posted: 07 Jul 2021 08:37 AM PDT

I am using Android studio 4.2

Execution failed for task ':app:kaptDebugKotlin'.  > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction  > java.lang.reflect.InvocationTargetException (no error message)    * Try:  Run with --scan to get full insights.    * Exception is:  org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'.  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$3(ExecuteActionsTaskExecuter.java:186)  at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:268)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:184)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:173)  at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)  at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)  at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)  at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)  at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)  at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)  at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)  at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:411)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:398)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:391)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:377)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)  at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)  at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)  at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)  Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction  at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:336)  at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:142)  at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:94)  at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForAll(DefaultAsyncWorkTracker.java:80)  at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:68)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:502)  at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)  at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)  at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:479)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:462)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$400(ExecuteActionsTaskExecuter.java:105)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:273)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:251)  at org.gradle.internal.execution.steps.ExecuteStep.lambda$executeOperation$0(ExecuteStep.java:65)  at org.gradle.internal.execution.steps.ExecuteStep.executeOperation(ExecuteStep.java:65)  at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:34)  at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:47)  at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:44)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)  at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)  at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)  at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:34)  at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:72)  at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:42)  at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:53)  at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:39)  at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:44)  at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:77)  at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:58)  at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:54)  at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:32)  at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:57)  at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:38)  at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:63)  at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:30)  at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:176)  at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:76)  at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:47)  at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:43)  at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:32)  at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:39)  at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:25)  at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:102)  at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:95)  at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)  at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)  at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:83)  at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44)  at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)  at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)  at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:96)  at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:52)  at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:83)  at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:54)  at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)  at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:88)  at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:88)  at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)  at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)  at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:46)  at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:34)  at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:43)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution$3.withWorkspace(ExecuteActionsTaskExecuter.java:286)  at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:43)  at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:33)  at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:40)  at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:30)  at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:54)  at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:40)  at org.gradle.internal.execution.impl.DefaultExecutionEngine.execute(DefaultExecutionEngine.java:41)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:183)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:183)  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:173)  at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)  at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)  at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)  at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)  at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)  at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)  at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)  at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:411)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:398)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:391)  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:377)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)  at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)  at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)  at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)  at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)  Caused by: java.lang.reflect.InvocationTargetException  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  at org.jetbrains.kotlin.gradle.internal.KaptExecution.run(KaptWithoutKotlincTask.kt:232)  at org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction.execute(KaptWithoutKotlincTask.kt:198)  at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)  at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67)  at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63)  at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)  at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63)  at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)  at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)  at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)  at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)  at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)  at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)  at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)  at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)  at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)  at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60)  at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)  at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214)  at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)  at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)  ... 3 more  Caused by: java.lang.reflect.InvocationTargetException  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:81)  at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:31)  at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:45)  ... 31 more  Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.NoClassDefFoundError: javax/annotation/Generated  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:707)  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:786)  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:881)  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222)  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1334)  at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)  ... 37 more  Caused by: java.lang.NoClassDefFoundError: javax/annotation/Generated  at dagger.internal.codegen.SourceFileGenerator.<clinit>(SourceFileGenerator.java:43)  at dagger.internal.codegen.ComponentProcessor.initSteps(ComponentProcessor.java:108)  at dagger.shaded.auto.common.BasicAnnotationProcessor.init(BasicAnnotationProcessor.java:119)  at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.init(incrementalProcessors.kt:36)  at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.init(annotationProcessing.kt:175)  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:686)  ... 42 more  Caused by: java.lang.ClassNotFoundException: javax.annotation.Generated  ... 48 more  

How to solve the issue?

Laravel year, sum, count, group by eloquent query

Posted: 07 Jul 2021 08:37 AM PDT

Can someone show me how I would build this query with eloquent, or is this required to be written with a DB:Raw query, or would it be best to be a raw sql query?

select `pay_week`,         year(`start_timestamp`) as year,         sum(`total_duration`) as 'duration',         count(`pay_week`) as 'entries'  from `time_clock`  group by year(`start_timestamp`),`pay_week`;  

Any help to better understand would be greatly appreciated.

Thank you.

$entries = TimeClock::select(     'pay_week',      DB::raw('count(pay_week) as entries'),      DB::raw('YEAR(start_timestamp) as year'),      DB::raw('sum(total_duration) as duration')  )  ->where('user_id', $user->record_id)  ->sum('total_duration')  ->groupBy('pay_week')  ->get();  

results in a

Call to a member function groupBy() on float  

modify_at to remove NA values in each element in a list

Posted: 07 Jul 2021 08:36 AM PDT

I have a big list of small datasets like this:

>> my_list    [[1]]  # A tibble: 6 x 2     Year FIPS     <dbl> <chr>  1  2015 12001  2  2015 51013  3  2015 12081  4  2015 12115  5  2015 12127  6  2015 42003    [[2]]  # A tibble: 9 x 2     Year FIPS     <dbl> <chr>  1  2017 04013  2  2017 10003  3  2017 NA     4  2017 25005  5  2017 25009  6  2017 25013  7  2017 25017  8  2017 25021  9  2017 25027    ...  

I want to remove the NAs from each tibble using modify_at because looks like is a clean way to do it. This is my try:

my_list %>% modify_at(c("FIPS"), drop_na)  

I tried also with na.omit, but I get the same error in both cases:

Error: character indexing requires a named object  

Can anyone help me here, please? What I'm doing wrong?

Why does OpenJDK Platform Binary stucks open and use too much ram?

Posted: 07 Jul 2021 08:37 AM PDT

I started learning flutter recently and i noticed even if vscode closed OpenJDK Platform Binary stays open and uses too much ram. Should i force close it on task manager everytime i finished working on vscode? Is there any way to automatically close it? enter image description here

Required param state missing from persistent data

Posted: 07 Jul 2021 08:36 AM PDT

I've an issue with php-graph-sdk, I've those functions

 protected function getFacebook()      {          static $facebook = null;          if($facebook == null){              $facebook =  new Facebook\Facebook([                  'app_id' => $this->getAppId(),                  'app_secret' => $this->getAppSecret(),                  'default_graph_version' => 'v2.10'              ]);          }          return $facebook;      }  
public function getLoginUrl($url)      {          $fb = $this->getFacebook();                    $helper = $fb->getRedirectLoginHelper();                    $autorisations = ['email'];           return $helper->getLoginUrl($url , $autorisations);      }  
 public function callback(&$error = null)      {          $fb = $this->getFacebook();                    $helper = $fb->getRedirectLoginHelper();                    try {              $accessToken = $helper->getAccessToken();          } catch(Facebook\Exception\ResponseException $e) {              // When Graph returns an error              $error = 'Graph returned an error: ' . $e->getMessage();              return false;          } catch(Facebook\Exception\SDKException $e) {              // When validation fails or other local issues              $error = 'Facebook SDK returned an error: ' . $e->getMessage();              return false;          }          ....    }  

And I do

 $url = $Facebook->getLoginUrl(URL);  

And in the callback file

$token = $Facebook->callback($error);  

When I click on the link, the callback file is executed and $helper->getAccessToken(); Uncaught Facebook\Exceptions\FacebookSDKException: Cross-site request forgery validation failed. Required param "state" missing from persistent data.

I've seen posts about that and no fix works for me

Thanks in advance

Chilkat sample, linkSample.cpp program, could not be compiled

Posted: 07 Jul 2021 08:37 AM PDT

I have downloaded "Chilkat C/C++ Library Downloads for Qt, CodeBlocks, MinGW, TDM-GCC, and MinGW-w64" version of Chilkat library in order to run above ftp c++ code.

#include <stdio.h>  #include "include/CkZip.h"  #include "include/CkFtp2.h"  #include "include/CkMailMan.h"  #include "include/CkXml.h"  #include "include/CkPrivateKey.h"  #include "include/CkRsa.h"  #include "include/CkHttp.h"  #include "include/CkMime.h"  #include "include/CkMht.h"  #include "include/CkSsh.h"  #include "include/CkSFtp.h"  void DoNothing(void)  {  // Instantiate the objects...  CkZip zip;  CkMailMan mailman;  CkFtp2 ftp2;  CkXml xml;  CkPrivateKey privKey;  CkRsa rsa;  CkHttp http;  CkMime mime;  CkMht mht;  CkSsh ssh;  CkSFtp sftp;    printf("Zip version: %s\n",zip.version());  }  int main(int argc, const char* argv[])  {  DoNothing();  return 0;  }  

I have read the README fille and tried to run sample C++ sample linkSample.cpp. for that reason I have read the linkSample.sh file which places in the Chilkat for Mingw folder. I have worked in windows and loaded mingw and the path of g++ added to the cmd. When I directly run the .sh folder command to the cmd I have received following error!

C:\Users\emma\Desktop\chilkat-9.5.0-x86_64-8.1.0-posix-seh-rt_v6-rev0>g++ -Wl,--enable-auto-import linkSample.cpp -o"linkSample.exe" -L. -lchilkat-9.5.0 -L/c/MinGW/lib -lcrypt32 -lws2_32 -ldnsapi    C:\Users\emma\AppData\Local\Temp\cciL4ofa.o:linkSample.cpp:(.text+0x10): undefined reference to `CkZip::CkZip()'  C:\Users\emma\AppData\Local\Temp\cciL4ofa.o:linkSample.cpp:(.text+0x1d): undefined reference to `CkMailMan::CkMailMan()'  C:\Users\emma\AppData\Local\Temp\cciL4ofa.o:linkSample.cpp:(.text+0x2a): undefined reference to `CkFtp2::CkFtp2()'  

Could you guide me about compileing and running sample chilkat cpp program?

Thanks

How to call of SetThreadExecutionState correctly?

Posted: 07 Jul 2021 08:36 AM PDT

The following snippet is supposed to prevent a Windows machine to go to sleep while an important operation is finished (running a different thread):

[Flags]  private enum EXECUTION_STATE : uint  {      ES_AWAYMODE_REQUIRED = 0x00000040,      ES_CONTINUOUS = 0x80000000,      ES_DISPLAY_REQUIRED = 0x00000002,      ES_SYSTEM_REQUIRED = 0x00000001  }    [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]  private static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);    public async Task KeepAwakeAsync(CancellationToken cancellationToken = default)   {    while (!cancellationToken.IsCancellationRequested)      var result = SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED); // (XXX)      if (result == 0)      {        throw new InvalidOperationException("SetThreadExecutionState failed.");      }        await Task.Delay(TimeSpan.FromMinutes(1)).ConfigureAwait(false);    }  }  
  1. I'm not sure whether ES_CONTINUOUS is needed too (i.e. var result = SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED);).

    Can anyone explain the difference between ES_CONTINUOUS | ES_SYSTEM_REQUIRED and ES_SYSTEM_REQUIRED when used in the sample above?

  2. I read somewhere that SetThreadExecutionState applies only to the current thread. Is that true? Can anybody elaborate on the precise meaning?

I have read [1] and for some reason it confuses me every time I read it.

Resources:

NameError and Incorrect number of bindings supplied SQLite code

Posted: 07 Jul 2021 08:36 AM PDT

I have a temp table u that has two columns, keyword and URL with the actual keywords and URLs. I have two more tables, one that contains IDs for each keyword and one that contains IDs for each URL. I need to pull the keyword ID and the URL ID for the appropriate pairs from u into my permanent table URL_Keyword.

This is what I have so far, but I realize it's not working, I keep getting either:

  tabU = cur.execute("SELECT * FROM u")  to_db=[( i['keyword'], i['URL']) for i in tabU]  cur.execute("INSERT INTO URL_Crawl_by_Keyword(Keyword_ID, URL_Crawl_ID) VALUES ((SELECT Keyword_ID FROM Keyword WHERE Keyword=?),(SELECT Unique_URL_ID FROM Unique_URL WHERE URL=?));", to_db))      ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 1500 supplied.  

OR:

cur.execute("INSERT INTO URL_Crawl_by_Keyword(Keyword_ID, URL_Crawl_ID) VALUES ((SELECT Keyword_ID FROM Keyword WHERE Keyword=?),(SELECT Unique_URL_ID FROM Unique_URL WHERE URL=?));",(Keyword_ID, URL_Crawl_ID))  NameError: name 'Keyword_ID' is not defined  

Swift/AlamoFire: Unable to decode JSON response

Posted: 07 Jul 2021 08:37 AM PDT

I'm trying to make requests using AlamoFire and decode them using the built-in .responseDecodable handler. The API endpoint I'm hitting is https://api.linode.com/v4/regions.

Request.swift:

import Foundation  import Alamofire    func getRegions() {                AF.request("https://api.linode.com/v4/regions")          .validate()          .responseDecodable(of: Region.self) { (response) in              guard let regions = response.value else { return }              print(regions)              debugPrint("Response: \(response)")          }        }  

When I built and run the binary and call getRegions(), I get no output in the console (debug or otherwise). When I change getRegions() and remove .responseDecodable, like this, I get the raw JSON in the console:

    let regionRequest = AF.request("https://api.linode.com/v4/regions")      regionRequest.responseJSON { (data) in          print(data)  

Here is my Region model:

Region.swift:

import Foundation    struct Region: Decodable {            enum resolvers: String, Decodable {          case ipv4, ipv6      }            let capabilities: Array<String>      let country: String      let id: String      let resolvers: Set<resolvers>      let status: String      let page: Int      let pages: Int      let results: Int            enum CodingKeys: String, CodingKey {                    case capabilities          case country          case resolvers          case status          case id          case page          case pages          case results                }        }  

And here is the JSON response from the API:

data =     (                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  "GPU Linodes",                  Kubernetes,                  "Cloud Firewall",                  Vlans              );              country = in;              id = "ap-west";              resolvers =             {                  ipv4 = "172.105.34.5,172.105.35.5,172.105.36.5,172.105.37.5,172.105.38.5,172.105.39.5,172.105.40.5,172.105.41.5,172.105.42.5,172.105.43.5";                  ipv6 = "2400:8904::f03c:91ff:fea5:659,2400:8904::f03c:91ff:fea5:9282,2400:8904::f03c:91ff:fea5:b9b3,2400:8904::f03c:91ff:fea5:925a,2400:8904::f03c:91ff:fea5:22cb,2400:8904::f03c:91ff:fea5:227a,2400:8904::f03c:91ff:fea5:924c,2400:8904::f03c:91ff:fea5:f7e2,2400:8904::f03c:91ff:fea5:2205,2400:8904::f03c:91ff:fea5:9207";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  Kubernetes,                  "Cloud Firewall",                  Vlans              );              country = ca;              id = "ca-central";              resolvers =             {                  ipv4 = "172.105.0.5,172.105.3.5,172.105.4.5,172.105.5.5,172.105.6.5,172.105.7.5,172.105.8.5,172.105.9.5,172.105.10.5,172.105.11.5";                  ipv6 = "2600:3c04::f03c:91ff:fea9:f63,2600:3c04::f03c:91ff:fea9:f6d,2600:3c04::f03c:91ff:fea9:f80,2600:3c04::f03c:91ff:fea9:f0f,2600:3c04::f03c:91ff:fea9:f99,2600:3c04::f03c:91ff:fea9:fbd,2600:3c04::f03c:91ff:fea9:fdd,2600:3c04::f03c:91ff:fea9:fe2,2600:3c04::f03c:91ff:fea9:f68,2600:3c04::f03c:91ff:fea9:f4a";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  Kubernetes,                  "Cloud Firewall",                  Vlans              );              country = au;              id = "ap-southeast";              resolvers =             {                  ipv4 = "172.105.166.5,172.105.169.5,172.105.168.5,172.105.172.5,172.105.162.5,172.105.170.5,172.105.167.5,172.105.171.5,172.105.181.5,172.105.161.5";                  ipv6 = "2400:8907::f03c:92ff:fe6e:ec8,2400:8907::f03c:92ff:fe6e:98e4,2400:8907::f03c:92ff:fe6e:1c58,2400:8907::f03c:92ff:fe6e:c299,2400:8907::f03c:92ff:fe6e:c210,2400:8907::f03c:92ff:fe6e:c219,2400:8907::f03c:92ff:fe6e:1c5c,2400:8907::f03c:92ff:fe6e:c24e,2400:8907::f03c:92ff:fe6e:e6b,2400:8907::f03c:92ff:fe6e:e3d";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  Kubernetes,                  "Cloud Firewall"              );              country = us;              id = "us-central";              resolvers =             {                  ipv4 = "72.14.179.5,72.14.188.5,173.255.199.5,66.228.53.5,96.126.122.5,96.126.124.5,96.126.127.5,198.58.107.5,198.58.111.5,23.239.24.5";                  ipv6 = "2600:3c00::2,2600:3c00::9,2600:3c00::7,2600:3c00::5,2600:3c00::3,2600:3c00::8,2600:3c00::6,2600:3c00::4,2600:3c00::c,2600:3c00::b";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  Kubernetes,                  "Cloud Firewall"              );              country = us;              id = "us-west";              resolvers =             {                  ipv4 = "173.230.145.5,173.230.147.5,173.230.155.5,173.255.212.5,173.255.219.5,173.255.241.5,173.255.243.5,173.255.244.5,74.207.241.5,74.207.242.5";                  ipv6 = "2600:3c01::2,2600:3c01::9,2600:3c01::5,2600:3c01::7,2600:3c01::3,2600:3c01::8,2600:3c01::4,2600:3c01::b,2600:3c01::c,2600:3c01::6";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Cloud Firewall",                  Vlans              );              country = us;              id = "us-southeast";              resolvers =             {                  ipv4 = "74.207.231.5,173.230.128.5,173.230.129.5,173.230.136.5,173.230.140.5,66.228.59.5,66.228.62.5,50.116.35.5,50.116.41.5,23.239.18.5";                  ipv6 = "2600:3c02::3,2600:3c02::5,2600:3c02::4,2600:3c02::6,2600:3c02::c,2600:3c02::7,2600:3c02::2,2600:3c02::9,2600:3c02::8,2600:3c02::b";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  "Object Storage",                  "GPU Linodes",                  Kubernetes              );              country = us;              id = "us-east";              resolvers =             {                  ipv4 = "66.228.42.5,96.126.106.5,50.116.53.5,50.116.58.5,50.116.61.5,50.116.62.5,66.175.211.5,97.107.133.4,207.192.69.4,207.192.69.5";                  ipv6 = "2600:3c03::7,2600:3c03::4,2600:3c03::9,2600:3c03::6,2600:3c03::3,2600:3c03::c,2600:3c03::5,2600:3c03::b,2600:3c03::2,2600:3c03::8";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  Kubernetes,                  "Cloud Firewall"              );              country = uk;              id = "eu-west";              resolvers =             {                  ipv4 = "178.79.182.5,176.58.107.5,176.58.116.5,176.58.121.5,151.236.220.5,212.71.252.5,212.71.253.5,109.74.192.20,109.74.193.20,109.74.194.20";                  ipv6 = "2a01:7e00::9,2a01:7e00::3,2a01:7e00::c,2a01:7e00::5,2a01:7e00::6,2a01:7e00::8,2a01:7e00::b,2a01:7e00::4,2a01:7e00::7,2a01:7e00::2";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  "Object Storage",                  "GPU Linodes",                  Kubernetes              );              country = sg;              id = "ap-south";              resolvers =             {                  ipv4 = "139.162.11.5,139.162.13.5,139.162.14.5,139.162.15.5,139.162.16.5,139.162.21.5,139.162.27.5,103.3.60.18,103.3.60.19,103.3.60.20";                  ipv6 = "2400:8901::5,2400:8901::4,2400:8901::b,2400:8901::3,2400:8901::9,2400:8901::2,2400:8901::8,2400:8901::7,2400:8901::c,2400:8901::6";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  "Object Storage",                  "GPU Linodes",                  Kubernetes              );              country = de;              id = "eu-central";              resolvers =             {                  ipv4 = "139.162.130.5,139.162.131.5,139.162.132.5,139.162.133.5,139.162.134.5,139.162.135.5,139.162.136.5,139.162.137.5,139.162.138.5,139.162.139.5";                  ipv6 = "2a01:7e01::5,2a01:7e01::9,2a01:7e01::7,2a01:7e01::c,2a01:7e01::2,2a01:7e01::4,2a01:7e01::3,2a01:7e01::6,2a01:7e01::b,2a01:7e01::8";              };              status = ok;          },                  {              capabilities =             (                  Linodes,                  NodeBalancers,                  "Block Storage",                  Kubernetes              );              country = jp;              id = "ap-northeast";              resolvers =             {                  ipv4 = "139.162.66.5,139.162.67.5,139.162.68.5,139.162.69.5,139.162.70.5,139.162.71.5,139.162.72.5,139.162.73.5,139.162.74.5,139.162.75.5";                  ipv6 = "2400:8902::3,2400:8902::6,2400:8902::c,2400:8902::4,2400:8902::2,2400:8902::8,2400:8902::7,2400:8902::5,2400:8902::b,2400:8902::9";              };              status = ok;          }      );      page = 1;      pages = 1;      results = 11;  })  

What am I doing wrong here? I suspect it's something with the Region struct but I haven't been able to figure it out. Any help would be appreciated, thanks!

Update:

I simplified my Region model a bit and also added optionals:

struct Data: Codable {            let data: [Region]      let page, pages, results: Int        }  struct Region: Codable {            let capabilities: [String]?      let country, id: String?      let status: String?      let resolvers: Resolvers?            enum CodingKeys: String, CodingKey {          case country          case id          case status          case capabilities          case resolvers      }  }    struct Resolvers: Codable {      let ipv4, ipv6: String  }  

I'm now getting a successful response using AlamoFire (though the everything is nil – progress though!):

success(.Region(capabilities: nil, country: nil, id: nil, status: nil, resolvers: nil))  

How to retrieve the current cluster name in k8s from python?

Posted: 07 Jul 2021 08:37 AM PDT

I need to set my environment in my code based on kubernetes(in AKS) cluster name in python. I have 2 clusters stg-my-cluster, prod-my-cluster, How can I access to this info from inside my pod? there is a better way ? thx

How to change the Swiper height or slide width in React JS without using fixed CSS

Posted: 07 Jul 2021 08:37 AM PDT

I have a card game where the player selects a card from one deck to add to a second. Pushing the button on the active card will move it to the other deck and then make it active. The active deck should be larger when in focus, while the inactive is minimized like so:

Example showing larger selected slider above smaller inactive slider

I have implemented it using the Swiper Coverflow effect in both SwiperJS and React-Swiper, but in either case the height is tied to the .swiper-slide CSS class. The width on this class is set to a fixed size which drives how the rest of the Swiper is rendered. It seems that the only way to change the slide width (and resulting Swiper height) is to apply fixed width classes to the slide based on state.

JSX:

 <SwiperSlide              key={index}              className={                props.selected                  ? "swiper-fixed-width-300 "                  : "swiper-fixed-width-100 "              }            >  

CSS:

.swiper-fixed-width-100 {    width: 100px;  }    .swiper-fixed-width-300 {    width: 300px;  }  

However this approach has no easing or transition like other interactions so it feels too abrupt. I would like to find a way to do the same using the Swiper API functions. How can this same interaction be achieved with the API or without manipulating the CSS class?

Example Sandbox

Google Chrome not showing microphone permission prompt

Posted: 07 Jul 2021 08:36 AM PDT

I have a web application that uses the microphone for WebRTC through getUserMedia. I currently have this application running on multiple subdomains, like test.example.com, staging.example.com, production.example.com, etc. On most of them, it works properly.

On one of the domains (test), I am unable to use the microphone. My code calls getUserMedia with a callback, but the callback is never executed, and the browser's permission prompt is never shown.

I have also reproduced this behavior using the Developer Tools console using the new Promise-based API:

navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(console.log).catch(console.log)  

(Yes, I know it does the same thing for then and catch, but it doesn't matter for this case.)

On the working site (stage, for example) here is the result in the console:

Promise {<pending>}  MediaStream {id: "RANDOM_CHARS", active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}  

On the non-working site, it only shows Promise {<pending>}, but the neither then nor catch logs anything because it never resolves either way.

I have found that if I go into the site settings (chrome://settings/content/siteDetails?site=https%3A%2F%2Ftest.example.com) and change Microphone to Allow, then I can refresh the page and it works properly. If I change it back to Ask, I get the same behavior again - that it doesn't ask.

This behavior is true about any site and any permission that I have tested - changing an Allowed permission back to Ask doesn't ask. However, on this particular test site, I had never before today tried to use it, so there's no reason it would have been set to Allow and then back to Ask to trigger that behavior.

In all these cases, navigator.permissions.query({name: "microphone"}).then(console.log) returns PermissionStatus {state: "prompt", onchange: null} as expected.

How can I get Chrome to prompt for microphone permission again?

How to add custom font in python-flask?

Posted: 07 Jul 2021 08:37 AM PDT

I have tried using @fontface css style, but the font doesn't get rendered. Is there another way of doing this using python/flask??

<!DOCTYPE html>  <html>  <style type="text/css">  @font-face {  font-family: trial;  src: url_for('CENTRALESANSCND-BOLD.otf') ;  font-weight:bold; }    </style>  <body>    <p style="font-family:trial; font-weight: bold"> Hello </p>    </body>  </html>  

The above is my HTML template. Unfortunately, when I render it using Flask, it doesn't reflect the font. The following is my .py code:

from flask import Flask, render_template    app=Flask(__name__)  app.secret_key='1234'    @app.route('/', methods=['post', 'get'])  def output():      c=2+3      print c        return render_template('f.html', c=c)    if __name__=='__main__':      app.run(port=9876)  

What causes keytool error "Failed to decrypt safe contents entry"?

Posted: 07 Jul 2021 08:37 AM PDT

I am trying to convert a standard PKCS #12 (.p12) key store into a Java JKS key store with this command:

keytool -importkeystore -srckeystore keystore.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore keystore.jks

It is failing with:

keytool error: java.io.IOException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded  

Do you have any idea how to solve this problem?

Orchestration vs. Choreography

Posted: 07 Jul 2021 08:36 AM PDT

What are the differences between service orchestration and service choreography from an intra-organization point of view.

No comments:

Post a Comment