on-internet

How to upload an image to a server using http request in kotlin?

I have written code to upload images to the server using kotlin, that is, the user takes a picture through the camera then displays the image in the imageView when the user clicks the send button, I want the image from ImageView to be sent to the server, but I don't know how to change the image from ImageView be a file that can be sent to the server. I have designed code to capture image and set the image in image view to preview it but not getting idea to upload it to the server using http request. for opening camera and setting image into imageview: private fun openCamera(){ val values = Con

Join the discussion →

ASP.NET Core type converter methods not called

I'm trying to configure ForwardedHeadersOptions which is part of Microsoft.AspNetCore.HttpOverrides. I've added options to my appsettings.json "ForwardedHeadersOptions": { "ForwardedHeaders": 5, "ForwardLimit": 1, "KnownProxies": [ "111.111.111.111" ] }, First two properties (ForwardedHeaders and ForwardLimit) are mapped properly, while KnownProxies is not. It is expected, because the type of KnownProxies is IList<IPAddress>. So, in order to map this property, I've created type converter: public class IPAddressTypeConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorC

Join the discussion →

Injecting 360 metadata into an MP4 file

For my library that should inject metadata into an MP4 file to be displayed as a 360 video, input is a standard MP4 file in equirectangular format. Just pasting the metadata into the file doesn't work. Metadata injected by Google's Spatial Media which I am trying to achieve: <?xml version="1.0"?><rdf:SphericaVideo xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:GSpherical="http://ns.google.com/videos/1.0/spherical/"><GSpherical:Spherical>true</GSpherical:Spherical><GSpherical:Stitched>true</GSpherical:Stitched><GSpherical:StitchingSoftware>Spherical Metadata Tool</GSpherical:Stit

Join the discussion →

What's the rationale for UTF-8 to store the code point directly?

UTF-8 stores the significant bits of the code point in the low bits of the code units U+0000-U+007F 0xxxxxxx U+0080-U+07FF 110xxxxx 10xxxxxx U+0800-U+FFFF 1110xxxx 10xxxxxx 10xxxxxx U+10000-U+10FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx That requires the decoder to check for over long sequences (like C0 80 instead of 00) and also reduces the number of code points encodable up to a fixed number of bytes. If it uses the same encoding but maps the code points like this First 128 code points (U+0000—U+007F): 1 byte Next 2048 code points (U+0080—U+087F): 2 bytes. E.g. C0 81: U+0081 Next 65536 code po

Join the discussion →

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.([Ljava/lang/Object;)V

I am writing simple application to be familiar with spring batch. I wanted to learn spring batch admin but I found that it is deprecated so I have to use spring cloud data flow instead. I've found a tutorial about spring cloud data and did first steps: Added dependency: compile("org.springframework.cloud:spring-cloud-starter-dataflow-server-local:1.7.4.RELEASE") And marked my spring boot application class with additioanl annotaion: @EnableDataFlowServer Now I am trying to run it using idea but it prints: 10:24:09.590 [main] ERROR org.springframework.boot.SpringApplication - Application run fai

Join the discussion →

Spring WebFlux: set max file(s) size for uploading files

I'm using flux of FileParts to upload files @RequestPart(FILES) Flux<FilePart> files And trying to limit maximum size of files. Looks like old way does not work: spring.servlet.multipart.max-file-size=1MB spring.servlet.multipart.max-request-size=1MB And I dont have any methods to get file size in FilePart interface. So is ther any way to limit max size of uploaded file in webflux, whithout copying it? I know that there are headers like Content-Length, but it does not look secure way.

Join the discussion →

How to set a pandas dataframe column as index when generating a loading matrix for PCA

I am using scikit-learn in Python to perform principal component analysis (PCA) on gene expression data. My data is loaded as a pandas dataframe, for which I can call df.head() and the df looks good. I am using scikit-learn to generate a loading matrix, but the matrix only displays a generic index, and will not accept a column name for an index. I have 1722 genes, so it is important that I obtain the loading score for each gene computationally. Here is my code for PCA: import pandas as pd from sklearn.decomposition import PCA from sklearn import preprocessing # Load the data as pandas datafram

Join the discussion →

How to add contains filter from Kibana dashboard?

I want to add a filter say to display all the @log_name and log that contain say test keyword. I am seeing following fields on Kibana dashboard. log @log_name _id _index hostname When I add a filter with @log_name is test it is not returning any results but when I add log is test it returns all the values that contain this keyword. I also tried @log_name is *test* and @log_name.keyword is *test* and I am not getting any results. I have following three questions here: 1. How can I add a filter that returns the values that contain test in @log_name? Update: I figured out the way to add wildcard

Join the discussion →

How do I check the version of a running service?

I am trying to locate the version of a service that starts at bootup. For question sake lets say its "xyz". I am aware of the common actions for a service. I just need to locate what version that service is. I searched the man pages for the service action and came up with nothing. I need this command line for both Ubuntu and CentOS platforms. I have tried something as simple as; service xyz --version or ./xyz -version or ./xyz -v ...etc So far I have not be able to find anything (document, command, start, stop, etc) to provide this info. Any suggestions are appreciated Thanks

Join the discussion →

Laravel Nova Resource, combine fields in layout?

I'm using Laravel and Nova, I have a Collection resource which has multiple fields, now when you define the fields for example: Text::make('Meta 1 Label')->hideFromIndex(), Text::make('Meta 1 Value')->hideFromIndex(), Text::make('Meta 2 Label')->hideFromIndex(), Text::make('Meta 2 Value')->hideFromIndex(), Text::make('Meta 3 Label')->hideFromIndex(), Text::make('Meta 3 Value')->hideFromIndex(), Text::make('Meta 4 Label')->hideFromIndex(), Text::make('Meta 4 Value')->hideFromIndex(), Each field will take up one row, in the html. Now I'm wondering if it's possible to have custom layout options (

Join the discussion →

Method does not exist or incorrect signature

I am trying to implement a simple change for an apex class in production. I have the proper class and proper test class. The test class runs successfully in sandbox without errors, but apparently the error is coming from the TestHelper default test class in Salesforce. When trying to deploy in production it throws the error "Method does not exist or incorrect signature: void createUser(Id, String, String, Date, Integer) from the type TestHelper" I've tried the usual of changing the method it references to public static void, but to no avail, it throws errors in code This is my test class: @isT

Join the discussion →

Gmock matcher to match against type

In gmock is there anyway to match against a type rather than value? The class is something like: struct Blob { template<class T> bool is(); // if blob holds data of type T template<class T> T get(); // get data as type T } My matcher looks like this: MATCHER_P(BlobIs, T, "") { return arg->is<T>(); } But the build failed with: error: expected primary-expression before ')' token

Join the discussion →

Pandas df write to Excel template with prepared styles

I have DataFrame df. I have Excel file template_with_styles.xlsx in which there is a color table ready. I want to write df to a template. from openpyxl.utils.dataframe import dataframe_to_rows wb = load_workbook('template_with_styles.xlsx') ws = wb.active for r in dataframe_to_rows(df, index=None, header=True): ws.append(r) wb.save('my.xlsx') As a result, I get: first comes my table with styles, and below is the data without styles. How can I write DataFrame to a Ecxel using a prepared template?

Join the discussion →

I have problem with firebase.messaging.requestPermission() always result in exception whatever I choose 'allow' or 'Not Allow'

react-native firebase request permissions always result in an exception. I am trying to give the user the option to allow notifications in my react-native app. So, when the user install my react-native app an alert will be shown and he can choose whether to allow notifications on the app or not. I am using react-native-firebase to handle this. however, the firebase "requestPermission" function always fails whatever I click "allow" or "Not Allow". firebase.messaging().requestPermission() .then(() => { console.log('User Now Has Permission') }) .catch((error) => { console.log('Error', error) })

Join the discussion →

How can I execute code received from dis.dis() python?

How can I execute code received from dis.dis() python? import dis class A(): def __init__(self): print("hello") dis.dis(A) '''It returns: 3 0 LOAD_GLOBAL 0 (print) 2 LOAD_CONST 1 ('hello') 4 CALL_FUNCTION 1 6 POP_TOP 8 LOAD_CONST 0 (None) 10 RETURN_VALUE ''' I want something like this: import dis dis.run(''' 3 0 LOAD_GLOBAL 0 (print) 2 LOAD_CONST 1 ('hello') 4 CALL_FUNCTION 1 6 POP_TOP 8 LOAD_CONST 0 (None) 10 RETURN_VALUE ''') i.e. Execute python disassembler.(I can execute .pyc from python ,can i execute disassembler?)

Join the discussion →

How to make a bot that listens for messages and sends them to another server?

I'm trying to make a bot that listens for messages in a channel and sends them to my private server. I don't fully understand coding stuff so I relied on some online sources. I already have done a bot that gets the new messages in a channel then brings them to a private channel. I cannot find the GitHub where the code was located since I moved to another OS. Now that's out of the way, I need the bot to send the logs to my private server in case some of my staff accidentally deletes one of the logs/multiple log. Then I came across this similar question: How to send a message to a different serv

Join the discussion →

How to change the dtype of a Raster using Rasterio

I've been having trouble dealing with no data values in Python's rasterio package when applying a polygon mask on a raster data set. This particular raster is Landsat uint8 with 7 bands and the no data value is not inherently specified because 255 is the reserved value for no data. However, sometimes uint8 data is compressed from uint16 data, and the 255 value is a valid data value which I do not want considered as 'no data' (the data are full bit range). The default for rasterio's mask function is to consider 0 as a 'no data' value if this argument isn't specified, which is problematic in the

Join the discussion →

TypeError: 'coroutine' object is not callable

Im trying to get my bot to create a server (guild) and im having the issue of it saying its not awaiting even though i made it await. ive tried awaiting it import discord, random, string, asyncio from discord.ext import commands def randomString(stringLength=10): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(stringLength)) Token = "" client = discord.Client() print("-----------------------------------") print("| Choices |") print("| (1) Token Banner |") print("-----------------------------------") Choice = input("Which choice would you like to choose?: "

Join the discussion →

Retrying 'FindPackagesByIdAsync' for source

I have a dotnet core project which builds fine locally but throws the following error many times: Retrying 'FindPackagesByIdAsync' for source 'https://mycontrol.pkgs.visualstudio.com/_packaging/f8292c33-blah-blah-blah-e5e14bb9ba87/nuget/v3/flat2/microsoft.net.test.sdk/index.json'. Response status code does not indicate success: 401 (Unauthorized). This error appears in the VSTS build log for every package used in the project. Opening the link shows this: { $id: "1", innerException: null, message: "Can't find the package 'microsoft.net.test.sdk' in feed 'MyFeeds'.", typeName: "Microsoft.VisualS

Join the discussion →

Load data with base64 encoding with loadDataWithBaseURL

I have an app which use WebView to show some local html to users. The app worked fine in last 2 years, but recently I'm getting too many reports that the app is showing some kind of error like this: "Web page not available The web page at data:text/html; charset=utf-8;charset=utf-8;base64, could not be loaded because: net::ERR_INVALID_RESPONSE" obviously something changed in android or WebView, and it did, the doc is saying: Stricter UTF-8 decoder In Android 9, the UTF-8 decoder for Java language is stricter and follows the Unicode standard. so, I tried to load my data with base64 encoding to

Join the discussion →

How to set FontFamily globally for all controls in the project with text property in Xamarin.Form app?

I'm creating a Xamarin.Form app for Android and iOS, and some users replace system default font with their own fonts, and FontSize property in Xaml doesn't work with these fonts, and these fonts are not so readable in my App. 1. So can I force the font used in my App to be system default font even the user changed font in their system config page? 2. If I can't do the above, can I set the FontFamily of all controls in my App with a text property to the font I included in my Android and iOS assets folder globally once and for all? I've searched for some global font solution, but found no Xamari

Join the discussion →

kotlin : unit test with mock injection (mockK)

I followed step by step instructions from many blogs for implementing a mock with MockK: class SWServiceImplTest { @MockK lateinit var externalApi: ExternalApiService @InjectMockKs lateinit var SWService: SWServiceImpl @Before fun setUp() = MockKAnnotations.init(this) @Test fun SWCharacterReturnsCorrectValues() { every { externalApi.get<Characters>(Utils.SW_API) } returns mockCharacters() val result = SWService.swCharacter!! assertEquals("blue", result.first().color?.toLowerCase()) assertEquals(result.size, 3) } } I want to inject externalApi into my SWService service and mock the get method o

Join the discussion →

Export Distribution Groups, Members and Email Addresses

I'm trying to get this command to list all distribution groups to include all email addresses (not just primary) and this works, although I'd like it comma delimited instead of space delimited if possible. The only thing that's missing are the Members which I'd also like to include the in the results. Can someone tell me how to do that? Get-DistributionGroup -Resultsize unlimited | Select Name,PrimarySmtpAddress, @{L="EmailAddresses";E={$_.EmailAddresses | ? {$_.PrefixString -ceq "smtp"} | % {$_.SmtpAddress}}} | Export-Csv c:\Results.csv -NoTypeInformation Essentially I should have the require

Join the discussion →

Errno 61: Connection refused error when trying to connect to python server

I've recently been trying to experiment with creating simple online multiplayer games with python's socket module. I made a first draft of a server and client program, and though they work perfectly when I run them both from the same computer, my attempts to connect the client when running on another computer results in the following error message: Traceback (most recent call last): File "/Users/Admins2-Admins_In_Space/Downloads/gameclient.py", line 22, in <module> client.connect((host,port)) ConnectionRefusedError: [Errno 61] Connection refused (both computers are connected to the same router

Join the discussion →

How to force GTM to add tag in the ?

I've followed the below steps for adding AdSense script inside of my website: Now that you have the code head over to GTM. Create a new tag. Provide a name. Select custom HTML as the tag template. Copy and paste the code into the text field. Set the trigger to fire on All pages or the pages you want to serve ads on. Click Save and Submit to push the code live. I did it and all fine. Here is my full code: (define as a tag in google tag manager) <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <script> (adsbygoogle = window.adsbygoogle || []).push({ go

Join the discussion →

How to name the list of the group_split output in dplyr

I have the following process which uses group_split of dplyr: library(tidyverse) set.seed(1) iris %>% sample_n(size = 5) %>% group_by(Species) %>% group_split() The result is: [[1]] # A tibble: 2 x 5 Sepal.Length Sepal.Width Petal.Length Petal.Width Species <dbl> <dbl> <dbl> <dbl> <fct> 1 5 3.5 1.6 0.6 setosa 2 5.1 3.8 1.5 0.3 setosa [[2]] # A tibble: 2 x 5 Sepal.Length Sepal.Width Petal.Length Petal.Width Species <dbl> <dbl> <dbl> <dbl> <fct> 1 5.9 3 4.2 1.5 versicolor 2 6.2 2.2 4.5 1.5 versicolor [[3]] # A tibble: 1 x 5 Sepal.Length Sepal.Width Petal.Length Petal.Width Species <dbl> <dbl> <d

Join the discussion →

TypeScript: Error: Cannot find module when using paths

I have a monorepo containing the Back-end(NodeJS), Front-end(Angular) and Shared directory (container models shared by the front-end and back-end.) preagree-mono/ preagree-api/ preagree-app/ preagree-shared/ The angular app is working perfectly and being build correctly using the shared types, after adding the folder into the paths preagree-app/tsconfig.json { "compileOnSave": false, "compilerOptions": { "baseUrl": "src", "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, "lib": ["es2018", "dom"], "module": "es2015", "moduleResolution":

Join the discussion →

Redshift: 500310 Invalid Operation

I am using talend to insert data into a table on Amazon Redshift. The java code is producing by talend but today() function is not supported by Amazon Redshift. I am trying to load a table from Salesforce and put it in Redshift using talend. When I am running the job from talend I have following error: Exception in component tRedshiftOutput_1 java.sql.SQLException: [Amazon](500310) Invalid operation: function today() does not exist; at com.amazon.redshift.client.messages.inbound.ErrorResponse.toErrorException(ErrorResponse.java:1830) at com.amazon.redshift.client.PGMessagingContext.handleError

Join the discussion →

What is the difference between a function and an object literal?

In JS functions belong to the object type. Objects can be converted to primitive types with [Symbol.toPrimitive](hint). This pure-object conversion works fine: let obj = { [Symbol.toPrimitive](hint) { switch(hint) { case "string": return "all right"; case "number": return 100; default: return "something else"; } } }; alert(obj); // all right alert(+obj); // 100 However, something is wrong with function conversion: function fun() { [Symbol.toPrimitive](hint) { // JS engine starts to complain here switch(hint) { case "string": return "all right"; case "number": return 100; default: return "somet

Join the discussion →

Schengen Visa Photo requirement - conflict

I visited Schengen visa photo requirement on their official website. I found the photo size to be 35–40mm in width. On some other websites, I have seen the photo requirement to be 35 - 45 mm , 32 - 45mm. People who have successfully applied for Schengen visa recently, what is the photo size pls ? Thank you.

Join the discussion →
Older stories