Posts

Showing posts from January, 2024

Issue while executing the multi-layer commands on windows

The below is executing on windows : C:\cygwin\bin\bash.exe -c "echo abc; echo 1 ; c:/cygwin/bin/bash.exe -c "c:/cygwin/bin/tcsh.exe echo def; pwd " " Running the above command, and getting the output as: abc 1 [PPP@machine1 ...Users/PPP]$ Desired Output: abc 1 def C:\Users\PPP In all, I want the commands under tcsh to also work (In above command, it is "echo def; pwd"). How can I have the progress on it?

Sitecore instance styles are not available after installation [closed]

After Installing sitecore instance, My login page is looking like this enter image description here after login it is looking without styling you can find the image below enter image description here Can you please help me in this I don't have any idea what to do next

Problem moving lines (one by one) from one text file to another

I try to create a program that moves the first line in a text file to another and then remove said line in the first file (i.e. they are moved one by one). This should continue until there aren't any more lines in the first file to be moved to the second file. The problem I have is that the program freezes and won't quit properly. I have experimented with the code and reached the conclusion that the error probably is in the counting of lines but that's all... Here is the code: # Create the second file open("file2.txt", 'w', encoding="utf-8-sig").close() # Find out how many lines in file one lines = open("file1.txt", 'r', encoding="utf-8-sig").readlines() # Loop the amount of lines while range(len(lines)) != 0: # Get the first line in the first file first_line = open("file1.txt", 'r', encoding="utf-8-sig").readline() # Write the line to the second file out = ope...

.NET core minmal APIs not connecting with react native app (Expo CLI)

Image
I am trying to connect my .Net core minmal apis backend with react native but it keeps giving me network error, I dont know what I am doing wrong. I have double checked the url the ip address too many times but still could not make it to work. Please , I would appreciate your help. I have tried the same application with a node backend it worked fine for node, may be because node was using http while .net backend is using https but I still do not understand if there is any thing wrong.

Moengage Push Notification Click Not Redirecting While App On Foreground/Running in Background

Hello I am currently running a Flutter app that is using Moengage to send push notifications. Currently, the notification is receiving just fine. But, there is a problem that only occurs in iOS: the notification is not redirecting to specified link when the notification is clicked when the application is currently opened/running in background. Is there any specific configuration that I might have missed? Sorry I am unable to give a piece of code but based on the documentation I don't think there is much things to be done in the setup after push notifications are received perfectly right?

Cycles per element in out-of-order execution

Problem your text Consider the following code on a machine that run a multiplication in 5 cycles. double aprod(double a[], int n) { int i; double x, y, z; double r = 1; for (i=0; i < n-2; i += 3){ x = a[i]; y=a[i+1]; z=a[i+2]; r = r * (x * (y * z)); } } Compute the theoretical Cycles per Element (CPE), where the only limiting factor is the data dependencies. Reference The problem is part of the Problem 5.9, p. 589, in Computer Systems: A Programmer's Perspective from Bryant et al. My solution: You have basically three multiplications per iteration. 1. dummy1 := (y * z) dummy2 := x*(dummy1) r*(dummy2) The dummy1 and dummy2 were just introduced to clearly state the multiplications. In the code, they are replaced by their definition, e. g. dummy1 is replaced by (y*z) . The 3. multiplication of an iteration has no data dependency to 1. and 2. multiplication of the following iteration. Thus, the 3. multiplication of an iteration and 1. as well as 2. multipli...

R: Merging Parts of a Graph Together

Image
I am working with the R programming language. I have the following "Tree" that depicts the results of a coin flipping game (start at 5 points, and 0.5 prob of +1 and 0.5 prob of -1 at each turn): outcomes <- c(-1, 1) combinations <- expand.grid(rep(list(outcomes), 10)) colnames(combinations) <- paste("Turn", 1:10) library(data.tree) generate_tree <- function(node, depth, total) { if (depth == 0) { node$Set(total = total) return(node) } else { for (outcome in outcomes) { child <- node$AddChild(name = as.character(total + outcome), total = total + outcome) generate_tree(child, depth - 1, total + outcome) } return(node) } } root <- Node$new("Start", total = 5) root <- generate_tree(root, 4, 5) print(root, "total") plot(root, "total") My Question: Is it possible to reformat (i.e. merge) this graph such that at each turn, all "...

Optimization with a nested set of constraints

I am trying to use Gekko to find an optimal solution for a camera lens distortion calibration problem ( Undistort ). In my case I am interested in solving a simpler problem that is only concerned with determining two or four variables (K1 K2 || K1 K2 CX CY). I was able to use scipy.optimize.minimize to come to some reasonable solutions that I know are within a good range, however, my solution relies on a rather complex invertibility constraint of the final result and I found that this was not possible to implement in scipy. So, I am looking for some help on how to model this invertibility constraint using Gekko. The invertibility constraint is as follows ( see div_constraint_invertibility() ): def get_rad_norm_k(dc, w, h): dmi = get_max_dist(dc=dc, w=w, h=h) r2 = m.sqrt(dmi) / 2 r2_2 = r2*r2 r2_4 = r2_2*r2_2 denk1 = -12 * r2_2 denk2 = -12 * r2_4 return denk1, denk2 def get_max_dist(dc, h, w): corner_distances = [(dc[0] - 0)**2 + (dc[1] -...

Keyboard input with pynput on a Mac

keyboard fails on a Mac and I would like to use pynput but fail to execute successfully. from pynput import keyboard import time def on_press(key, ts, gt_forward, rb, extent, aoi, aoibuffer, jparams): if key == keyboard.Key.enter: print("\nYou pressed Enter... we continue with osm_LoD1_3DCityModel.") ...lots of code that saves something. def on_release(key): if key == keyboard.Key.esc: # Stop listener return False def main(): start = time.time() ...code here... print('') print("Have a look at the matplotlib render that might highlight errors (red) in the 2D vectors.\n\nIf there are no challenges press 'Enter' to continue; else press 'Esc' to exit: ") with keyboard.Listener( on_press=lambda key: on_press(key, ts, gt_forward, rb, extent, aoi, aoibuffer, jparams), on_release=keyboard) as listener: listener.join() src_ds ...

Blocking the clock signal

Let's say I need to find out that the BLOCK signal came earlier than the 5 clk signal. These signals are asynchronous to each other, so I can't use the classic construction as shown below. always(posedge clk) if(cnt==4 && !BLOCK) flag<=1; else flag<=0; //The flag will be set to 1 only if the BLOCK signal does not arrive before 5 clk. always(posedge clk) cnt <= cnt + 1; But I can block clk when the BLOCK signal arrives so that it stops clocking flag and the flag is not set to 1. wire clk_flag = clk & !BLOCK; always(posedge clk_flag) if(cnt==4) flag<=1; else flag<=0; //The flag will be set to 1 only if the BLOCK signal does not arrive before 5 clk always(posedge clk) cnt <= cnt + 1; Is it acceptable to mix signals through "and" for clk in design? I have not seen such solutions, but I do not see anything dangerous for the design here, I do not know how to solve the problem with signals in another way. Or maybe someone knows how to...

Why is it adding me a random pixel on the screen?

Image
I'm making the snake game and I got to the part where there are (for now) 3 asterisks that make the snake. When I move from vertical to horizontal and from horizontal to vertical it adds another asterisk And for some reason just adds another * to the row of * s in the same place every time For now my code is: IDEAL MODEL small STACK 100h DATASEG ; -------------------------- ; Your variables here ; -------------------------- saveal db, ' ' ;used in line 223-233 app dw 0 ;place of the apple st_am dw 3 stars dw 0, 0, 0 ;places of the * CODESEG proc black body: mov [es:si], ax add si, 2 cmp si, 25*80*2 jnz body ret endp black proc up mov di, 80*2 cmp si, di jb not_move_up cmp si, [app] jnz move_up call apple move_up: call delete mov di, [stars+2] mov [stars+4], di mov di, [stars] mov [stars+2], di sub di, 80*2 mov ah, 156 mov al, '*' mov [es:di], ax mov [stars...

Axios methods GET and POST do not respond in Vercel deploy

I have a MERN project in my Vercel account which is divided into two parts: client and server. Both pages are perfectly deployed and available but my Axios methods related to the server page don't work in my deploy when they do in my local PC. The only one that responds correctly is the hero, which brings me six images from my database and renders what I need. However, when I go into another route the browser console throws an error 500. For instance, I am in a route where I have an useEffect hook with an Axios POST method and I have no response from the server. Axios from the front: useEffect(()=>{ async function getList(){ try{ const response = await axios.post("https://pelis-mern-server-five.vercel.app/lists/get-my-list", {id:user._id, profId:profileId}, {withCredentials:true, headers:{"Content-Type":"application/json"}}) console.log(response) if(response.data.list.length > 0){ console.log("ha...

Process URL in the same way as Express does to get request parameters in a get command

I want to be able to get the parameters from a uri string in the exact same way as Express does. I can do it with regex or other string methods, but then I have a risk that it is not interpretted the same way as Express. I would prefer a way that even if Express has a bug and a URI gets interpretted wrongly, that the function does that as well. I have Ajax commands that execute a specific get/post command and use the referer to know where they originated eg. req.headers.referer which would be something like http://localhost:3000/data/theme-chalkboard/black I have a non standard get in Express, for example: app.get('/data/theme-:theme/:piece', (req, res, next) => { // server code } Where the parameters in question are: { theme: "chalkboard", piece: "black" } However I have other parts that also have similar incorporated variables within the route. The reason for this is because the route gets dynamically created and updated as the website is us...

grep - RegEx multiple-criteria select

Given a file containing this string: IT1*1*EA*VN*ABC@SAC*X*500@REF*ZZ*OK@IT1*1*CS*VN*ABC@SAC*X*500@REF*ZZ*BAR@IT1*1*EA*VN*ABC@SAC*X*500@REF*ZZ*BAR@IT1*1*EA*VN*ABC@SAC*X*500@REF*ZZ*OK@ The goal is to extract the following: IT1*1*EA*VN*ABC@SAC*X*500@REF*ZZ*BAR@ With the criteria being: The IT1 "line" must contain *EA* The REF line must contain BAR Some notes for consideration: "@" can be thought of as a line break A "group" of lines contains lines starting with IT1 and ending with REF I am running GNU grep 3.7. The goal is to select the "group" of lines meeting the criteria. I tried the following: grep -oP "IT1[^@]*EA[^@]*@.*REF[^@]*BAR[^@]*@" file.txt But it captures characters from the beginning of the example. Also tried to use lookarounds: grep -oP "(?<=IT1[^@]*EA[^@]*@).*?(?=REF[^@]*BAR[^@]*@)" file.txt But my version of grep returns: grep: lookbehind assertion is not fixed length

Azure WebJobs CD ereasing wwwroot content

Image
I'm publishing 2 web jobs to the respective paths: But, every time, the content inside site\wwwroot is erased, and I have an API project published there, so, every time I need to republish the API after. I can't find a solution anywhere about this, why is this happening? This is my web jobs CD: I was expecting having to republish my API every time I publish my web job.

Why am I getting" invalid as a react child" error?

I'm encountering an error in React saying 'Objects are not valid as a React child (found: object with keys {})'. This occurs during the rendering phase, where React is expecting elements or an array of elements but is instead receiving an object. The error trace includes functions like reconcileChildFibers, updateHostComponent, and performUnitOfWork. How can I resolve this issue so that React correctly renders the intended components or data? I think the issue is with the below code: import React from "react"; const Select = ({ name, label, options, error, ...rest }) => { return ( <div className="form-group"> <label htmlFor={name}>{label}</label> <select {...rest} name={name} id={name} className="form-control"> <option value="" /> {options.map((option) => ( <option key={option._id} value={option._id}> {option.name} </option...

Azure Pipeline for SonarCloud analysis using Gradle is successful but no results are published

I have tried to analyze a Java repository, build using Gradle wrapper, and publish the results in my SonarCloud organization. I am using an Azure DevOps Pipeline for the build, however, I cannot see any results in the SonarCloud account, even though my pipeline build is successful. I am using Sonarcloud Prepare task, Sonarcloud Run Analysis and Sonarcloud Publish, as well as Gradle build step with following settings: task: Gradle@2 inputs: gradleWrapperFile: 'gradlew' options: '-P offlineVersion=$(Build.SourceBranchName)-SNAPSHOT' tasks: 'publish' publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.8' gradleOptions: '-Xmx3072m' env: RUNONCI: 'true' REPO_USER_NAME: '$(RepoUserName)' REPO_USER_PASSWD: '$(RepoUserPasswd)' SNAPSHOTURL: Could you please help me out? I do not receive any error, only 2 warnings: When using Maven or Gradle, don't ...

queryClient.setQueryData() updating issues and inconsistences in next js application

I am using @tanstack/react-query in my frontend application and I really enjoy it. I also use it as the state manager for everything that has to do with async network calls and data fetching. Right now, I am building a kanban board with drag and drop functionality and we intend to preserve the columns and the items arrangement to the backend whenver the user performs a drag and drop action. After every drag and drop action, I manipulate the array and update the indices of the columns or items being moved. Since I want the action to be instantaneous even before I get a response from the server, I modify the state on the frontend and display the updated data arrangement to mimic an instantaneous update to the user. To achieve this using react query, I get my query cache using queryClient.getQueryData(queryKey) , manipulate the cache and then update the cache using queryClient.setQueryData(queryKey, updatedData) . The issue I have is that it doesn't work and I don't understand w...

AppAttest -- Can a Swift program that uses DCAppAttestService be run on Linux?

Image
I need to be able to run the code that issues an Apple attest but preferably Linux. Or, at the very least, on an MacOS VPS . I expect there to be new customers daily, therefore this code will be run regularly, for each new client. As such, using an Apple physical device for this, if indeed required, will inconvenient: import DCAppAttest func generateKeyAndAttestation() { guard let attestationKey = DCAppAttestService.shared.generateKey() else { print("Error generating attestation key.") return } // Generate a nonce (you may need to use a more secure source for your actual use case) let nonce = Data.random(count: 32) // Prepare the data to be attested let dataToAttest = "Data to be attested".data(using: .utf8)! // Concatenate nonce and data var attestationData = nonce attestationData.append(dataToAttest) // Use DCAppAttestService to attest the data guard let attestation = DCAppAttestService.shared.at...

Reading a fixed width file with Rust

I am trying to read a fixed width file with Rust , with the goal to load the data into a Polars dataframe, however, I can't parse the file correctly. I am trying to use the fixed_width crate as polars lacks the utility to parse such files. Unfortunately, the fixed_width documentation does not have any example where a file is read, all the examples read data from a string... Here is my failed attempt (the commented code works as it is a copy-paste from the docs) and obviously, the file contains same data as the string: use serde::{Serialize, Deserialize}; use fixed_width::{FixedWidth, FieldSet, Reader}; fn main() { let r_file = "path/to/file.r01"; // let data = String::from("R 5001.00 1001.00 513777.5 2093285.7 0.0\nR 5001.00 1002.00 513786.6 2093281.6 0.0\nR 5001.00 1003.00 513795.7 2093277.4 0.0\nR 5001.00 1004.00 513708.8 20932...

How do you idiomatically implement a nontrivial typestate pattern in Rust? [closed]

I'm trying to build the FSM of a simple CPU, which consists of about 40 states, with loops, and many conditionals across many variables of the overall CPU state. This FSM operates like a simple Turing Machine; reading memory cells (think vector of u16), computing some results, and storing them back into memory. My question is: how is this implemented idiomatically in Rust? The way I've considered it, you would do something like this: Have a base enum representing the states. Have another enum for each state which represents transitions (but maybe all in the same enum?). Somehow you'd have to access the CPU state (value of all the different registers etc) to know how to emit the next state transition, but to be efficient about it, you'd need to be able to pass different subsets of the CPU state, yet somehow only mutate a single copy that represents the CPU state after the computation. You could probably build a vector of "state diffs" which you could ap...

MacOs Tkinter - App terminating 'Invalid parameter not satisfying: aString != nil'

When im launching my app via CLI, it works without issue ./org_chart.app/Contents/MacOS/org_chart however when I launch via double click I met with the error *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: aString != nil' I used py2app to build the app. Im not sure where to begin debugging this, if someone could point me in the right direction? Thanks for your help! here's the full code for the small app import os, shutil import tkinter as tk from tkinter import filedialog, messagebox, Tk, Canvas, Entry, Text, Button, PhotoImage from tkinter import font as tkFont def build_org_chart(): print("im making a chart") return 'Done chart created!' if __name__ == "__main__": window = Tk() window.title("Org Chart Spreadsheet Generator") # Variables to store file paths window.geometry("1012x506") window.config...

Login redirects in Django

I have a auth system with django-allauth library, and i have some login, logout functionally implemented and it works fine. But I want to implement a profile page on my own. With this I'm so confusing right with Django redirects. I have a class based view called HomeRequestHandler that inherits a LoginRequiredMixin : from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import TemplateView class HomeRequestHandler(LoginRequiredMixin, TemplateView): template_name = "home.html" And in my urls i just call it to "": from django.views.generic import TemplateView from django.urls import path from . import views urlpatterns = [ path("", views.HomeRequestHandler.as_view(), name="home"), path("profile/", TemplateView.as_view(template_name="account/profile.html"), name="profile"), ] In my settings.py , I have a constant for LOGIN_REDIRECT_URL : LOGIN_REDIRECT_URL = reve...

Telerik Blazor responsive grid

Image
i'm using telerik blazor grid. i tried adaptive grid layout example Reference link Telerik Adaptive Grid but it does provide responsiveness on listing of elements. For example if there is static grid like one row with two columns, one column have any image and second column any text or form. is there any way to make responsive grid for all devices.

Access violation when calling stbi_load()?

The following function throws an access violation exception on line with stbi_load, but I don't see any reasons for it unsigned int TextureFromFile(const char* path, const string& directory, bool gamma) { std::string filename = std::string(path); filename = directory + '/' + filename; unsigned int textureID; glGenTextures(1, &textureID); int width; int height; int nrComponents; unsigned char* data = stbi_load(filename.c_str(), &width, &height, &nrComponents, 0); if (data) { GLenum format; if (nrComponents == 1) format = GL_RED; else if (nrComponents == 3) format = GL_RGB; else if (nrComponents == 4) format = GL_RGBA; glBindTexture(GL_TEXTURE_2D, textureID); glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL...

Livewire: Bind refresh not working from server to client for input type

I have a laravel livewire (v3) component that contains an input field. I'm trying to get the displayed field to refresh after the bound (bind-ed) property is updated server-side. Livewire component: <?php namespace App\Livewire\MyNamespace; use Livewire\Component; class Create extends Component { public function rules() { return [ 'doSomething' => 'required', ]; } public $doSomething = ''; public function add() { $this->doSomething = 'Welcome'; $this->dispatch('$refresh'); } public function render() { return view('livewire.create'); } } The view is simple: <div> <button class="btn btn-primary" wire:click="add">Press me</button> <input type="text" wire:model.live="doSomething"> Label: </div> When I press the button, the input field displayed isn't ...

Make a Strong Wordlist white special character with python

I wanted to make a password list For Brute Forceand . I need your help. An 8-digit password list where the characters 4, 8 and (p or P) should be used, and it consists only of numbers and lowercase and uppercase characters, and there are no special characters in it. Thanks for your advice on what software to use in Python and Windows to create this password list. tanks I still haven't found a way to use special characters for this.