Posts

Showing posts from September, 2023

JFrame not moving

I want my JFrame to move despite disabling Decorrations. i added a mouseListener after some googling but still didnt help. public static void main(String[] args) { try { UIManager.setLookAndFeel(new FlatDarkLaf()); } catch (Exception errorDesign) { logError(errorDesign); } JFrame frame = new JFrame(); frame.setBounds(1600, 400, 500, 800); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setUndecorated(true); frame.setVisible(true); frame.addMouseListener(new MouseAdapter() { private Point mouseOffset; @Override public void mousePressed(MouseEvent e) { mouseOffset = e.getPoint(); } @Override public void mouseDragged(MouseEvent e) { Point newLocation = e.getLocationOnScreen(); newLocation.translate(-mouseOffset.x, -mouseOffset.y); ...

nginx failing to load ssl certificate

The Problem I used mkcert -install then mkcert my-dev-env.local 127.0.0.1 localhost to make local SSL certificates for a Django project using Docker on Windows but get a "This site can’t provide a secure connection" error when I try to access https://localhost . In the Docker log the output was: 2023-09-26 18:19:47 nginx.1 | 2023/09/27 00:19:47 [error] 38#38: *10 cannot load certificate "data:": PEM_read_bio_X509_AUX() failed (SSL: error:0480006C:PEM routines::no start line:Expecting: TRUSTED CERTIFICATE) while SSL handshaking, client: 172.18.0.1, server: 0.0.0.0:443 What I Tried Followed the directions to set up a new Django project with Docker using the Cookiecutter-Django template. Did everything down through the "Run the Stack" section, and the local development website looked good on localhost. Skipped down to "Developing locally with HTTPS" section and followed those directions. The directions don't specify how to change ...

Does PyTorch support stride_tricks as in numpy.lib.stride_tricks.as_strided?

It is possible to make cool things by changing the strides of an array in Numpy like this: import numpy as np from numpy.lib.stride_tricks import as_strided a = np.arange(15).reshape(3,5) print(a) # [[ 0 1 2 3 4] # [ 5 6 7 8 9] # [10 11 12 13 14]] b = as_strided(a, shape=(3,3,3), strides=(a.strides[-1],)+a.strides) print(b) # [[[ 0 1 2] # [ 5 6 7] # [10 11 12]] # [[ 1 2 3] # [ 6 7 8] # [11 12 13]] # [[ 2 3 4] # [ 7 8 9] # [12 13 14]]] # Get 3x3 sums of a, for example print(b.sum(axis=(1,2))) # [54 63 72] I searched a similar method in PyTorch and found as_strided , but it does not support strides which makes an element have multiple indices referring to it, as the warning says: The constructed view of the storage must only refer to elements within the storage or a runtime error will be thrown, and if the view is “overlapped” (with multiple indices referring to the same element in memory) its behavior is undefined. In particular it says ...

Multiple PopoverTip Modifiers in SwiftUI: Persistent Display Glitch

I've encountered an issue when attempting to add multiple popoverTip modifiers in my SwiftUI code. Regardless of whether there's a specified rule or parameter, the tips begin to constantly appear and disappear. Is this a recognized issue? How can we sequentially display multiple tip popovers on complex views? Even when one tip is invalidated, the glitch persists. Should this be used only for views without any state updates? Here's a sample code that demonstrates the problem: import SwiftUI import TipKit @main struct testbedApp: App { var body: some Scene { WindowGroup { ContentView() } } init() { try? Tips.configure() } } struct PopoverTip1: Tip { var title: Text { Text("Test title 1").foregroundStyle(.indigo) } var message: Text? { Text("Test message 1") } } struct PopoverTip2: Tip { var title: Text { Text("Test title 2").foregroundStyle(.indigo) ...

Sending POST returns 405 while my routes are OK

I have a weird problem. I try to log in with POST (username/password) to my application with this route Route::post('login', 'AuthController@postLogin')->name('login.post'); I get a 405 The POST method is not supported for this route. Supported methods: GET, HEAD In the local development environment everything is fine. In a production server environment I get this error. I use Postman fos testing. This is my route list GET|HEAD | / GET|HEAD | domains GET|HEAD | login POST | login GET|HEAD | research-programs GET|HEAD | researchers GET|HEAD | researchers/profile PUT | researchers/profile POST | researchers/profile/picture GET|HEAD | researchers/random GET|HEAD | researchers/search GET|HEAD | researchers/{id} PUT | researchers/{id} POST | researchers/{id}/picture GET|HEAD | units I added a GET /login route and dumped the \Illuminate\Http\Request object to see what I got. These lines tell me that there is a redirect? "REDIRECT_REDI...

Asymmetric Encryption of data with BCrypt.lib at c++ side and decrypting with RSACryptoServiceProvider at c# side. (Parameter is Incorrect)

I am having a windows service written in .NET (C#) and a library written in CPP. I am generating the Public/Private Key pair in .NET side with RSACryptoServiceProvider and send the Public Key information to CPP side. At c++ end, After importing the Public Key received from C#, I am Encrypting my data with BCrypt.lib library and returning it to .net service by encoding it into base64. Now at .Net side, I am decrypting the encoded data received from c++ using RSACryptoServiceProvider. During RSA.Decrypt() method call I am getting below exception: CryptographicException: 'The parameter is incorrect' It seems some encoding issue to me but I am no expert here. I have tried below solutions: Using Convert.FromBase64String() method to convert the received base64 data into byte array. I have tried to reverse the byte array received from above conversion. Below are the code snippet I am working on. .Net Side Code: var rsa = RSACryptoServiceProvider.Create(1024); var publicKey ...

$wp_customize is not displaying section, control, settings for custom page template - Wordpress

$wp_customize isn't showing the add section, control or settings i've set up for a custom template under the "Customize" feature on wordpress. I figured out that initially my require_once path was wrong and fixed that to the below elseif (is_page('annual-report')) { require_once(TEMPLATEPATH . '\pageFunctions\annualReportFunctions.php'); // include_once(dirname(__DIR__).'/BOAT-wordpress-theme/pageFunctions/annualReportFunctions.php'); } I intentionally made an error in the annualReportFunctions.php file because I wanted to test and be sure if wordpress was actually able to locate and load that file now. Good news is that an error message confirmed it can! The bad news is that when I took the error out although WP is reading the file associated with the page it's on, it's still not showing the options in the customize feature. I reviewed https://developer.wordpress.org/themes/customize-api/customizer-objects/ a few times ...

I want to store and send images to a database using Spring

I'm working on a web application, and I'm trying to send a POST request to a specific endpoint ( /board/writepro ). However, I'm encountering the following error message: I'm using Spring , and I'm getting an error message that says: Content-Type 'application/x-www-form-urlencoded;charset=UTF-8' is not supported when making a POST request. How can I resolve this issue? Here's my controller class: I am working with a React user on a project package org.polyproject.fishinghubpro.controller; import jakarta.transaction.Transactional; import lombok.extern.slf4j.Slf4j; import org.polyproject.fishinghubpro.dto.BoardDto; import org.polyproject.fishinghubpro.entity.Board; import org.polyproject.fishinghubpro.service.BoardService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframewo...

How to send requests to custom pocketbase routes, using the pocketbase javascript sdk?

I am trying to find a 'native' way to send post requests to my pocketbase server, from my svelte frontend : main.go: app.OnBeforeServe().Add(func(e *core.ServeEvent) error { e.Router.AddRoute(echo.Route{ Method: http.MethodPost, Path: "/api/myRoute", Handler: func(c echo.Context) error { // custom logic here: compute custom_value using parameters custom_value := "cool_value" return c.String(200, custom_value) }, }) return nil }) I would like to do something similar to the following : Frontend.ts: onMount(async () => { // ask server for information based on a variable: example const example = "test"; const example_reply = await pb.route(POST, '/api/myRoute', /*here, I would have to specify the fact that example is a form value of the POST request*/ example); // use example_reply if (exa...

Prevent screenshot with 'isSecureTextEntry' is not working on iOS 17

I am using ‘isSecureTextEntry' on iOS 16 with this solution, https://stackoverflow.com/a/76390952/22598343 extension UIView { func makeSecure() { DispatchQueue.main.async { let field = UITextField() field.isSecureTextEntry = true self.addSubview(field) field.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true field.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true self.layer.superlayer?.addSublayer(field.layer) field.layer.sublayers?.first?.addSublayer(self.layer) } } } It looks not working on iOS 17 now. Is there any other solutions? I've tried the DRM way, but got really bad performance.

Twilio Dialogflow cx one-click-integration fails with unspecified error, worked before

Image
@edit Through the browser developer console I was able to extract an actual error message: Invalid AvailableAddOnSid provided But what does that actually mean. I find nothing on the web and in fact have no Twillio Add-Ons installed. Yesterday I successfully integrated Dialogflow and Twilio per one-click-integration. Today I wanted to do the same with another agent but always got an unspecified error when completing the last step in twilio. See screenshot of error in popup of last step in integration: I did not change anything. What can it be and why isn't the error more specified?

How can I avoid that my logged-in user goes back to the login url in angular 16?

I have an angular 16 application and want to avoid that a user that is logged in can return to the login url. It should be possible with an authGuard, but I don't know how I could achieve this. In my app-routing module, I have this: import { authGuard } from './guards/auth.guard'; import { LoginComponent } from './user/login/login.component'; import { ProfileComponent } from './user/profile/profile.component'; const routes: Routes = [ { path: '', redirectTo: '/user/profile', pathMatch: 'full' }, { path: 'user', children: [ { path: 'login', component: LoginComponent }, { path: 'profile', component: ProfileComponent, canActivate: [authGuard] }, { path: '', redirectTo: 'profile', pathMatch: 'full' }, { path: '**', redirectTo: 'profile', pathMatch: 'full' }, ], }, { path: '**', redirectTo: '/user/profile',...

Running different versions of Postgres

I intend to use different versions of PostgreSQL, one for creating a database for an application, and the other for setting up a development environment. How do I do so? When I run PostgreSQL commands like pg_config , it return the version for one of the installed versions. How do ensure there is not conflict?

Grid column span to take full width when remaining columns are empty

I'm working on a calendar element whereby the day events are utilising grid row to span over their specified time frame. However, I seem to be struggling when it comes to setting the event widths. By default they will take up the full width of the day when it's the only event at that time. And if they are concurring events at any point they will reduce their widths accordingly so they can all fit. My problem occurs when I have a group of events happening at the same time, which generates multiple columns, and then an event later in the day which doesn't have any coinciding events. This event is now limited to the widths of the columns created from the events earlier in the day. See image for context: Image of annotated demo See below for a working demo. (function() { function init() { let calendarElement = document.getElementsByClassName('calendar')[0], events = calendarElement.getElementsByClassName('calendar__event'); _positionEvent...

Composer Project - Redash + Redis + Postgres On Synology NAS

I am just diving into how Containers work, and have gotten pretty far, but when orchestrating a few images into one project yml file, I am running around in circles. So I have the following images: redash/redash:latest <-- The primary app... redis:latest postgres:latest I have all my ports open for each service, and tested that I could login to the postgres database from adminer:latest running in the same container. I used a few different examples from the gitrepos, and other stack articles to build the bellow yml file and the help of @David Maze. I believe now that I am missing a database setup file for Redash. The scheduler that interacts with my data base gives me: ProgrammingError: (psycopg2.ProgrammingError) relation “queries” does not exist I found this article: discuss.redash.io ; where the poster is at the same point. A respondent said "Did you create the database tables?" It looks that I need to run this command from from one of the Redash server cons...

STContains, STIntersects and STWithin return wrong result for geography

I'm using SQL server to store customers location info (longitude and latitude) and using leaflet to show them on map. And also I'm using leaflet for drawing polygon to draw city areas, I store polygons in a another SQL table with geography type, finally by using below query I want to know if a customer is inside an area(polygon) or not: DECLARE @latitude DECIMAL(25,18); DECLARE @longitude DECIMAL(25,18); DECLARE @customerId BIGINT; DECLARE @geographicalAreaId INT; DECLARE @coordinates GEOGRAPHY; DECLARE @isInsideArea BIT; declare @insideCOUNT int; SET @insideCOUNT=0; DECLARE @point geography; DECLARE @polygon geography; DECLARE getCustomerGeo_CSR CURSOR FAST_FORWARD READ_ONLY FOR SELECT DISTINCT Fk_CustomerId,ca.Latitude,ca.Longitude FROM Tbl_CustomerAddresses ca WHERE ca.Latitude IS NOT NULL AND ca.Longitude IS NOT NULL; OPEN getCustomerGeo_CSR; FETCH NEXT FROM getCustomerGeo_CSR INTO @customerId,@latitude, @longitude WHILE @@FETCH_STATUS = 0 BEGIN SET @...

How to load a 3d model in .glb file format in ThreeJS?

I have read the official documentation but it seems too incomplete. The web browser display a black screen but not the model. In the browser console there isn't any error. The following is the code: import * as THREE from 'three'; import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'; const loader = new GLTFLoader(); loader.load('cube.glb', function(gltf) { const renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); renderer.outputColorSpace = THREE.SRGBColorSpace; const scene = new THREE.Scene(); scene.add(gltf.scene); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); camera.position.set(0, 0, 10); function animate() { requestAnimationFrame(animate); renderer.render(scene, camera); } document.body.appendChild(renderer.domElement); animate(); }, undefined, function(error) { console.error(er...

Graph (networkit) - create edges from the list of duplicated records for any columns pair in pandas

I'm trying to create graph with edges only for nodes/(records index in dataframe) that have the same values in any 2 or more columns. What I'm doing - I create a list with all possible combination pairs of column names and go through them searching for duplicates, for which I extract indexes and create edges. The problem is that for huge datasets (millions of records) - this solution is too slow and requires too much memory. What I do: df = pd.DataFrame({ 'A': [1, 2, 3, 4, 5], 'B': [1, 1, 1, 1, 2], 'C': [1, 1, 2, 3, 3], 'D': [2, 7, 9, 8, 4]}) A B C D 0 1 1 1 2 1 2 1 1 7 2 3 1 2 9 3 4 1 3 8 4 5 2 3 4 Here, rows 0 and 1 have 2 same values in columns B and C. So, for nodes 0,1,2,3,4 I need to create edge 0-1. Other records have at maximum 1 same field between each other. graph = nk.Graph(num_nodes, directed=False, weighted=False) # Get the indices of all unique pairs...

How do I redirect a subdomain to a subdirectory in primary domain serving as reverse-proxy?

I'll describe the current setup first followed by what I'd like to change it to. Current Setup Primary domain www.example.com pointing to a Ruby on Rails app deployed on Heroku. Wordpress blog blog.example.com running on Flywheel . RoR application serves as reverse-proxy to load Flywheel content under /blog subdirectory. For ex. www.example.com/blog/page1 loads content from blog.spacebox.com/page1. We're using https://github.com/waterlink/rack-reverse-proxy for making this work. All of the above works as expected. What We Want Now the marketing team, wanting to up the SEO game, wants blog.example.com/* to redirect to www.example.com/blog/ * What I've Tried So Far (with failure, of course) Setup a Redirect on Flywheel dashboard to www.example.com/blog/$1 (expectedly resulted in infinite redirects). Deleted A record from DNSSimple for blog.example.com (pointing to Flywheel IP address), and replaced with a CNAME to point to www.example.com (didn't wor...

Microsoft 365 Dynamic group validation rule error (Memberof)

I'm looking to create a dynamic MS365 group, I simply want to apply the following dynamic rule user.memberof -any (group.objectId -in ['objectID1','objectID2']) When going through documentation this should be fully supported, infact I have groups created months ago which use this exact syntax. When copying rules directly from these working groups, created exactly the same way, I get the same error: Failed to create group x. Dynamic membership rule validation error: Wrong property applied Any thoughts? I attempted to create a Microsoft 365 Dynamic groups within Azure AD. When creating it with a specific rule used to capture members from multiple other assigned sec groups I am given the error Failed to create group x. Dynamic membership rule validation error: Wrong property applied Despite this working on groups in prod. I would expect this to function and create without issue.

SQLAlchemy throws no exceptions

I am trying to append a child class to a parent class. The problem is even when I make mistakes on purpose, the code throws no exceptions but doesn't work. I have found no errors in IDE as I've tried multiple IDEs (Spyder, PyCharm, VSC) and none of them show exceptions. I've also tried to print the exceptions explicitly, and this doesn't work either (though it did work in some cases, which completely blows my mind). Moreover, the code doesn't even reach the print command I've set there. Here is what I have: database_append_card.py: async def append_all(message: types.Message, state: FSMContext): async with state.proxy() as data: new_card = CardBase( name=data['card_name'], front=data['front'], back=data['back'], ) await add_child_to_db( child=new_card, column=str(message.from_user.id), parent_class=UserBase, my_async_session=async_session_mak...

Segmentation Fault When Sending Arrays Over a Certain Size with Open MPI

I am writing a program to run with an ifiniband and intel-based cluster using openmpi, pmix, and SLURM scheduling. When I run my program on the cluster with an input matrix over 38x38 on each node, I get a segfault on both send/recv and collective calls. Below 38x38 on each node, there are no issues. Also, the code works on a single node and with IntelMPI. The Segfault only occurs when using multiple nodes and OpenMPI. Here is a minimal sample code that reproduces my error: int main(int argc, char** argv) { int proc_size, p_rank; MPI_Init (&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &proc_size); MPI_Comm_rank(MPI_COMM_WORLD, &p_rank); int x = 1600; MPI_Status status; double* A = calloc(x, sizeof(double)); if (p_rank == 0) for (int i = 1; i < proc_size; ++i) { MPI_Recv(A, x, MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &status); } else MPI_Send(A, x, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD); MPI_F...

How to detect strikethrough text from docx tables?

I'm using python-docx to parse some tables to dictionaries. However, some of those tables contain strikethrough text. This text needs to be excluded. I have already found how to detect strike-through through text in paragraphs or how to apply strike-through text myself , but nowhere can I find how to check for strikethrough text in tables. As far as I can tell from the documentation, neither the Table object nor the cells have a "Run" object, which is something that Paragraphs have that contain style data. Without the Run object, there's no style data.

Why can I not deploy django project with elastic beanstalk?

Image
I have created a zip file with all my programs and it runs well locally. For some reason elastic beanstalk gives several errors when I deploy my zip file. Such as: "Warning: Configuration files cannot be extracted from the application version my_tennis_club2. Check that the application version is a valid zip or war file." "Error: The instance profile aws-elasticbeanstalk-ec2-role associated with the environment does not exist." "Error: Failed to launch environment" I followed the tutorial https://www.w3schools.com/django/django_deploy_eb.php where I always got the same result as the tutorial up until I was gonna upload the zip file containing my entire project to elastic beanstalk edit: I can't open the domain when elastic beanstalk is done loading the zip file containing my django project. I can run my project on a localhost when i write python manage.py runserver on my computer. I created an ec2 instance and an IAM role which I gave administ...

What's wrong with qsort comparator?

So I've been doing my homework on C, and there was this task: "An array of ints is given, write a function that sorts them in following way: first, the even numbers in non-decreasing order, second, the odd numbers in non-increasing". For example, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -> [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]. The task itself is about writing a comparator function for qsort correctly. I wrote the following cmp : int cmp(const void *elem1, const void *elem2) { int p_number1 = *(int *) elem1, p_number2 = *(int *) elem2, diff_flag = 0; if (p_number1 > p_number2) { diff_flag = 1; } else if (p_number1 < p_number2) { diff_flag = -1; } if ((p_number1 & 1) == (p_number2 & 1)) { // same parity return diff_flag == 0 ? 0 : diff_flag ^ ((p_number1 & 1) << 31); /* in even case, diff_flag will be returned, otherwise, * number with sign that is different from diff_flag's will be returned */ ...

How to get the APP Version using a Pre-Render APEX

Image
I'm trying to get the app version so I can log it in a table when inserting or updating data. I'm currently doing this for APP_USER and sysdate which is working fine. PL/SQL Code: I would also like to add the Name and Version. I tested APP_NAME and that does work, but APP_Version returns nothing? I was also wondering what other APP_ variables are available?

How do you iterate over continuous subsequences of a slice that contain equal elements?

I have a sequence of elements of a type which implements PartialEq in a slice. For illustration, let's say it looks like this: let data = [1,1,1,2,2,3,4,5,5,5,5,6]; I would like to iterate over borrowed slices of this sequence such that all elements of such slices are equal as per PartialEq . For example in the above slice data I would like an iterator which yields: &data[0..3] // [1,1,1] &data[3..5] // [2,2] &data[5..6] // [3] &data[6..7] // [4] &data[7..11] // [5,5,5,5] &data[11..12] // [6] It looks like slice::group_by is exactly what I need, but as of Rust 1.72.0, it is not yet stable. Is there any straightforward way to get this functionality in a stable way, either by use of a 3rd party crate or by combining the use of stable std lib APIs?

Can we monitor gstreamer pipeline opened by OPENCV through the gstreamer code?

I am opening an gstreamer pipeline with opencv. Now,as long as data is coming everything works fine. But, when for any reason if data stops coming, then pipeline is stucked and because of that opencv is stucked. Below is the code which i am using: #define UDP_URL "udpsrc port=15004 buffer-size=5000000 ! watchdog timeout=1000 ! tsdemux latency=0 ! h264parse ! v4l2h264dec ! imxvideoconvert_g2d ! video/x-raw,format=BGRA,width=1280,height=960 ! appsink max-buffers=2" int main() { cv::VideoCapture video; cv::Mat frame; video.open(Stream_URL, cv::CAP_GSTREAMER); if (!video.isOpened()) { printf("Error in opening.\n"); return -1; } while(1) { if(video.read(frame)) { // some operation on frame. } else break; } video.release(); return 0; } In above code when there is no data on port 15004, then video.read(frame) function gets stucked, especially the v4l2h264dec de...