on-internet

Calculate "age" from date/time table

I have a Date/Time column in format "13.10.2020 06:08:43" and I need to calculate the "age" from current time. Output should be like from given example: "4h" since its 10:08 atm - Date/Time column was 4h ago. I need this to be in M language to use in visual studio 2019. I used: let Source = Sql.Database("xxxx", "xxxxx", [Query="SELECT#(lf)#(tab)storeid as 'Shop'#(lf)#(tab), concat('SCO', posnr) as POS#(lf)#(tab), concat(datediff(hour,[LastTransactionDate]#(lf)#(tab), CURRENT_TIMESTAMP),' h') as 'Age'#(lf)#(tab), POSIPaddress as 'IP'#(lf)#(tab),[PosNr]#(lf) ,[AdapterPosOrGroupId]#(lf) ,[Updated

Join the discussion →

Plotting a pie chartof value_counts() using plotly express

How does one plot a pie for value_counts() using plotly express for the following series: import pandas as pd import string, random s = pd.Series(random.choice(string.ascii_uppercase) for _ in range(100)) I can see that it can be done through go using: import plotly.graph_objects as go go.Figure(data=[go.Pie(labels=s.value_counts().index, values=s.value_counts().values)])

Join the discussion →

SOCKs proxy settings for java webstart app (jnlp)

I have a server remote console webstart application - jnlp file which needs to connect via a SOCKS proxy. The challenge I have is that I do not want to change the IE proxy or common Java network settings to use the jnlp file as it's 1) tedious to change it every time, 2) interferes with other java applications parallelly running connecting to intranet/internet I would like to know if its possible to set the proxy like below. This will help me to run the jnlp file using a batch file and the proxy settings will be confined to this instance of the jvm. javaws -JsocksProxyHost=127.0.0.1 -JsocksPro

Join the discussion →

Optional chaining for Python objects: foo?.bar?.baz

In JavaScript, if I'm not sure whether every element of the chain exists/is not undefined, I can do foo?.bar, and if bar does not exist on foo, the interpreter will silently short circuit it and not throw an error. Is there anything similar in Python? For now, I've been doing it like this: if foo and foo.bar and foo.bar.baz: # do something My intuition tells me that this isn't the best way to check whether every element of the chain exists. Is there a more elegant/Pythonic way to do this?

Join the discussion →

ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db when using Pyinstaller

I have found some issues opened about this error but I cannot find a solution that works for me. I am getting errors related to proj.db when running an executable file I have created using pyinstaller. I have Windows 10, Python 3.5 and I have in my environment pyproj 2.4.2 and gdal 3.0.4 I am using GDAL in a python script and I have an environment that it is working fine for me when I test the script using Pycharm. So my pycharm interpreter is pointing to that environment with python 3.5, pyproj 2.4.2 and gdal 3.0.4 and the script runs with no issues. However, when I build a standalone script

Join the discussion →

Como guardar imagenes en una carpeta usando php

Estoy usando una base de datos en phpmyadmin para realizar un ejercicio de clase, en el que tengo que crear una clase para insertar contenido de un formulario y se crearía el post, yo consigo guardar en la base de datos el contenido del formulario, pero la imagen que inserto, se guarda solo como el nombre de la imagen en la base de datos, por lo tanto necesito que al guardar en nombre en la base de datos también guarde el archivo de la imagen en una carpeta llamada blog, situada donde tengo mi proyecto, he estado buscando tutoriales pero no logro saber que estoy haciendo mal, dejo por aquí mi

Join the discussion →

Send a new config to gtag when a new "page" is loaded in an SPA does not show the new path in realtime analytics

I'm using React SPA. When I use gtag to track users in Google Analytics, I am confused about the data that I see in Real-Time Google Analytics. When the app starts or the user is routed to a new react route, I fired an event like this to set the correct page and log pageView: window.gtag('config', UA-123456789-1, { groups: 'MYGROUP', page_path: '/contacts', }) When the user clicks on the button or makes some interesting action I fire an event like this: window.gtag('event', 'Some button click', { sendTo: 'MYGROUP', event_category: 'buttons on main page', }) Many events are button clicks on pag

Join the discussion →

npm ERR! [email protected] install: `node-gyp rebuild`

I am new to AWS ec2 instance, I have tried to host my server code on ec2 I have done my instance setup successfully based on the following reference from "https://ourcodeworld.com/articles/read/977/how-to-deploy-a-node-js-application-on-aws-ec2-server". On the ec2 ubuntu server, I am getting "npm ERR! [email protected] install: node-gyp rebuild" error when I install node-modules using npm I cmd. I have tried many examples from StackOverflow no one solved my issue. The error message is following below npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install: `node-gyp rebuil

Join the discussion →

Request Focus on TextField in jetpack compose

How to auto focus on textfield in jetpack compose. When i click on textfield and start typing on it. Meantime when i click back button,then when i'm try to click on textfield, nothing happens. val textState = remember { mutableStateOf(TextFieldValue()) } TextField( modifier = Modifier.fillMaxWidth(), value = textState.value, onValueChange = { value : TextFieldValue -> textState.value = value } )

Join the discussion →

How to get a the ID of a field in a type F#

How do I create a function to search on a database and return just the ID of a type? Actually, I have a database, where I can search for a pair. The pair is a Type, in F#: module Types = [<CLIMutable>] type Pair = { Id :int64 PairName : string } My objective is to create a function, that return just the value of the ID (int) given a PairName. I Already have a function that returns a Pair, given this name. module Query = let GetSingleByName name = querySingleAsync<Types.Bird> { script "SELECT * FROM Pair WHERE PairName = @Name LIMIT 1" parameters (dict ["Name", box name]) } How can I return jus

Join the discussion →

FAT32 maximum partition size and FAT table size

I have two questions about FAT32: The first: If I want to format a partition with FAT32 using a 32 KB block size, I think the maximum partition size I can get is: 2^28 * 32 = 8 TB But why do I see them list it as the maximum partition size is 2 TB in every reference, and Windows limits it to 32 GB only?! The second question: If I want to know the size of the FAT Table in memory (to know memory consumption) assuming I'm use a 32 GB partition size with a 32 KB block size, how to calculate that?! This is what I know, but not sure about it: First, I have to know the number of entries which is 32 G

Join the discussion →

java.sql.SQLRecoverableException: IO Error: Connection reset by peer

I'm trying to start up my application on k8s using the image Linux 4.14.165-133.209.amzn2.x86_64 and using openjdk 11 with maven, but the application does not start because of the following error java.sql.SQLRecoverableException: IO Error: Connection reset by peer, Authentication lapse 0 ms. at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:874) ~[ojdbc8-19.3.0.0.jar!/:19.3.0.0.0] at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793) ~[ojdbc8-19.3.0.0.jar!/:19.3.0.0.0] at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57) ~[ojdbc8

Join the discussion →

How to resolve RootTagMissingFromViewException error while adding new Livewire component in Laravel 8 with Jetstream

I'm trying to add a new Livewire component to Laravel 8 Jetstream but looks I'm doing something wrong and getting the following error. Error: Livewire\Exceptions\RootTagMissingFromViewException Livewire encountered a missing root tag when trying to render a component. When rendering a Blade view, make sure it contains a root HTML tag Route: // web.php Route::middleware('auth')->group(function() { Route::get('/newEmployee', NewEmployee::class); }); Controller: // app/Http/Livewire/NewEmployee.php namespace App\Http\Livewire; use Livewire\Component; class NewEmployee extends Component { public f

Join the discussion →

Using Youtube Data API makes my videos private on upload

I've just made an "app" that uploads videos in a given folder, the program works, however whenever I upload a video through my program, it makes the video private (locked). I then get a mail saying that my program has not yet been approved. I have tried setting status.privacyStatus to both unlisted and public, without succes. Any idea on how to get my application approved so I can upload public videos? I suspect it might have to do with Oauth, however I am not sure where I went wrong

Join the discussion →

googleapis-common throwing error in UUID dependency

I'm trying to get OAuth to work in a Node.js app with Express and Google APIs. The application throws TypeError in the UUID dependency which is included with the googleapis-common module: Exception has occurred: TypeError: Cannot assign to read only property 'name' of function 'function generateUUID(value, namespace, buf, offset) { if (typeof value === 'string') { value = strin...<omitted>... }' at _default (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\googleapis-common\node_modules\uuid\dist\v35.js:71:23) at Object.<anonymous> (C:\Users\ficar\OneDrive\Desktop\Frontend\node_modules\go

Join the discussion →

How can I cluster a large dataset based on similarity?

I would like to cluster a huge dataset into clusters based on similarity. How can I approach this problem? I have tried MinBatchK means and DBSCAN, but I am not getting great results. The problem I am facing with MinBatchKMeans is I have to specify the number of clusters beforehand and with DBSCAN most are classified as noise. Can someone please guide me on how to approach this problem? I am using TFIDF to convert text into vectors. For example, when I am using a dataset of 80,000 records, it takes around 2-3 hours to form a cluster of size 500. This makes it very difficult to find optimal num

Join the discussion →

unsupported data type: &[] error on GORM field where custom Valuer returns nil?

I was trying to create a GORM model for a postgres database, containing a type with a custom Scanner and Valuer that converts a string slice to and from a string, to be saved as a single database column. If the slice is either empty or nil, I want the database column to also be nil (as opposed to an empty string). type MultiString []string func (s *MultiString) Scan(src interface{}) error { str, ok := src.(string) if !ok { return errors.New("failed to scan multistring field - source is not a string") } *s = strings.Split(str, ",") return nil } func (s MultiString) Value() (driver.Value, error)

Join the discussion →

Mapping issues from Sqlalchemy to Pydantic - from_orm failed

I'm trying to get my result dictonary from sqlalchemy automatically to the Pydantic output for Fastapi to maps using the from_orm method, but I always get a validation error. File "pydantic\main.py", line 508, in pydantic.main.BaseModel.from_orm pydantic.error_wrappers.ValidationError: 2 validation errors for Category name field required (type=value_error.missing) id field required (type=value_error.missing) If I create the objects with the Pydantic schema myself and add them to the list, the method works. What would I have to change for from_orm to work? Did I possibly miss something in the d

Join the discussion →

How to implement pagination for PagerDuty API results in my Power Query code

My company uses Power BI and we are trying to get incidents data from PagerDuty API. I have been struggling to find a way to get all the data but I am not knowledgeable about PowerBI, PowerQuery, or dealing with APIs. I am in a database role. I used Get Data option in Power BI and selected Web as data source. Entered My API link, and passed the headers. The result I get is limited to 25 by default, I can change it to up to 100 but my main issue is with not being able to get next set of results. I need to have some kind of loop to increase the offset parameter and refresh the query. My current

Join the discussion →

How to make a MongoDB Upsert truly idempotent?

I want to insert a document into a MongoDB in an idempotent way. The explanation provided by the MongoDB documentation, and also here on SO, is to use the upsert=True modifier. However, to my understanding, this does not guarantee idempotence, because an already existing document could be modified. The operation I am looking for is as follows: If the document, identified by some key, does not exist, insert it. If a document with the given key already exists, there are two things that might happen: The existing document and the provided document are exactly the same. Then, return the same resul

Join the discussion →

Xcode 12 GM runs into infinite loop

I am developing an iOS app and it works well on Xcode 11.7, but when I run the same code in Xcode 12 and when I enter a UIPageViewController, the app runs into an infinite loop and the cpu usage shows 99%. Here is a screenshot I made after pause the app in debugger. It shows Application violated contract by causing UIApplicationMain() to return. This incident will be reported.

Join the discussion →

Use svg image as map layer for mapbox GL JS

How do I use SVG image as the base map for mapbox GL JS ? I know, that OpenLayers and Leaflet provide such opportunity for developers. Leaflet: var svgUrl = 'image.svg', imageBounds = [[0, 0], [100, 100]]; L.imageOverlay(svgUrl , imageBounds).addTo(map); OpenLayers: var svgUrl = 'image.svg', var imgLayer = new ImageLayer({ source: new Static({ url: svgUrl, projection: projection, imageExtent: extent, imageLoadFunction: function (image, src) { image.getImage().src = src; image.getImage().width = olExtent.getWidth(extent); image.getImage().height = olExtent.getHeight(extent); }, }), }); map.addL

Join the discussion →

XBRL / Finstr issue with SEC EDGAR data in R

I am trying to download the XBRL data from the SEC site, using the finstr package in R. The vignette references Apple financial statements from 2013-14. I am going after Abbott (CIK 1800) for mine. I've looked through the data records on the SEC site and the submission is in this folder: https://www.sec.gov/Archives/edgar/data/1800/000110465920023904 The Apple xml file is named aapl-20140927.xml (the CIK followed by the submission date). I've gone into the file through a browser and identified the relevant data. The Abbott xml file that has the same info is named abt-20191231x10k59d41b_htm.xml

Join the discussion →

Lazy-load imports from barrel file in Jest

I'm using React and have a file tree like this: src/ common/ common-comp1/ common-comp1.js common-comp1.test.js index.js common-comp2/ common-comp2.js common-comp2.test.js index.js index.js app/ app-comp1/ app-comp1.js app-comp1.test.js index.js app-comp2/ app-comp2.js app-comp2.test.js index.js index.js All of the index.js files are barrel files that export * from '...';. I have path aliases set up so that I can import CommonComp1 from 'common'; in src/app/app-comp1/app-comp1.js. Unfortunately, this loads/transforms the code from src/common/common-comp2/* as well, even though app-comp1.js doe

Join the discussion →

Can I perform a post hoc on principal component analysis (PCA)?

I performed a PCA on my data, and I have four principal components. However, it is very difficult to interpret my results with principal components. Therefore, I was wondering can I do a post hoc, by taking the variable with the highest variance in PC1 (say X1) and the variable with the highest variances in PC2 (say X2) and perform a regression analysis, with an outcome variable y, to test their association? (i.e., lm(Y~X1+X2)) Here's an example: I have four independent variables: memory test, cognition test, attention test, and processing speed test. I have one dependent variable, brain conne

Join the discussion →

Does the nuget package Microsoft.Data.SqlClient work with Entity Framework?

My application runs on .NET framework 4.7 and I'm using Entity Framework 6.1.3. Currently, my code uses some classes from the namespace System.Data.SqlClient such as SqlParameter. I want to switch to Microsoft.Data.SqlClient. However, I'm not sure if EF6 is compatible with Microsoft.Data.SqlClient. This is an old article from Microsoft, it says that EF Core, EF 6 etc. haven’t yet made the transition to the new provider Microsoft.Data.SqlClient. So, I'm a bit confused. Everything has been working well with System.Data.SqlClient for the below code public async Task<ICollection<int>> GetChildCust

Join the discussion →
Older stories