on-internet

Set charset different from UTF-8 in JSON Response

I have this get request in my controller in ASP.NET Core project [HttpGet] [Route("api/controller/getlastresult/{id}")] public IActionResult GetLatestResultForController(string id) { Response.ContentType = "application/json"; var list = _dbAccessLayer.GetAllVoteResults(); var appropriateResults = list.Where(item => item.DeviceId.Equals(id) && item.Status == "Finished") .OrderBy(item => item.TimeStarted); if (appropriateResults.Any()) return Ok(Json(appropriateResults.Last().Result)); return BadRequest(); } It works fine, but in the headers there is Content-Type: application/json; charset=utf-8

Join the discussion →

Using two html index pages with the same name but different extensions

I'm using two index pages with different contents and different extensions on my html site root folder, html and htm. The problem is that sometimes when I open my site in Chrome (or other browsers) I see the htm index file and sometimes vice versa. For various reasons (e.g avoiding 302 or 404 errors), I can't delete the htm index file. My questions are: 1. Why is this happening? 2. Which extension is more important in terms of priority in browsers view? 3. What are my options to overcome this problem? I have checked my html index file with applications like HTMLValidator and other services to

Join the discussion →

React Native : Flatlist and Array

it is a common question surely, but I can not render a FlatList with array source. I follow this example :https://medium.com/javascript-in-plain-english/how-to-loop-through-arrays-in-react-3eaa8a14445 The example begins with : let shoppingCart = [ {id: 35, item: 'jumper', color: 'red', size: 'medium', price: 20}, {id: 42, item: 'shirt', color: 'blue', size: 'medium', price: 15}, {id: 71, item: 'socks', color: 'black', size: 'all', price: 5}, ] This how I actually work to fill an array in my work. Then, I follow the instructions, with an arrangement : this.items = this.shoppingCart.map((item, k

Join the discussion →

How to create a bootstrap-table dynamically?

I'm having trouble developing a bootstrap-table by clicking a button. My goal is to add a sort feature for each columns on a table. So for my user case, when a user clicks on the button, it calls an ajax to grab a data from Database and sends back a result (it works so no worries on it). So i need to display the results as a bootstrap-table so i can use the sort feature for each column. Plus, I'm using pagination.js which uses Array of json objects and table to display the result. When I develop the table and append it into a div, I dont see the sort feature on each columns. It works when I cr

Join the discussion →

Generate "GET PROCESSING OPTIONS" (GPO) for EMV card (APDU) by PDOL

GPO Command is defined like this as an APDU command: CLA INS P1 P2 Lc Data Le 80 A8 00 00 Lc Data 00 So the missing parts is Lc & Data which we have to compute from the PDOL (if it is given). If it is not given, we can use: 80 A8 00 00 02 8300 00 That works for mastercards, but for VISA I am given a PDOL & trying to construct the missing APDU part (Lc & Data). STEP 1 - I get this PDOL from my EMV card: 9F66049F02069F03069F1A0295055F2A029A039C019F3704 STEP 2 - Splitting it up by commands: 9F6604 9F0206 9F0306 9F1A02 9505 5F2A02 9A03 9C01 9F3704 STEP 3 - Splitting it again by byte length: 9F66 0

Join the discussion →

How to serialize in .NET MessagePack and deserialize in Node.js

I have a RabbitMQ queue and two applications. First application is written in .NET core to generate send the payload to queue and the second one is in Node.js to read from the queue. Producer Application I use MessagePack-CSharp to serialize and compress (LZ4) the payload. Here is the serialization code in .NET: using MessagePack; namespace uBeac.Serialization { public class MessageSerilizer { public static byte[] Serialize(object message) { MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolver.Instance); return LZ4MessagePackSerializer.Serialize(message);

Join the discussion →

Remover um valor de uma lista

Quero remover dois valores de uma lista. Do tipo tenho um vetor: vet[0]*3 for i in range(3): vet[i]=input('Digite um valor: ') Quero remover o máximo e o mínimo. Como faço? Já tentei fazer vet.remove(max(vet)), mas não dá.

Join the discussion →

How do I get user details in controller of Spring Boot OIDC app?

I have adapted the code from here to call a MitreID OIDC server. My controller: public final String home(Principal p) { final String username = SecurityContextHolder.getContext().getAuthentication().getName(); ... returns null and is null for all userdetails. I have also tried: public final String home(@AuthenticationPrincipal OpenIdConnectUserDetails user) { final String username = user.getUsername(); and @RequestMapping(value = "/username", method = RequestMethod.GET) @ResponseBody public String currentUserNameSimple(HttpServletRequest request) { Principal principal = request.getUserPrincipa

Join the discussion →

PHP-FPM performance tuning - bursts of traffic

I have a web application written in Laravel / PHP that is in the early stages and generally serves about 500 - 600 reqs/min. We use Maria DB and Redis for caching and everything is on AWS. For events we want to promote on our platform, we send out a push notification (mobile platform) to all users which results in a roughly 2-min long traffic burst that takes us to 3.5k reqs/min At our current server scale, this completely bogs down the application servers' CPU which usually operate at around 10% CPU. The Databases and Redis clusters seem fine during this burst. Looking at the logs, it seems a

Join the discussion →

How do I change my Powershell script so that it writes out-file in ANSI - Windows-1252 encoding?

I have a banking application script that generates a “filtered” output file by removing error records from a daily input bank file (see How do I create a Windows Server script to remove error records, AND the previous record to each, from a file with the results written to a NEW file). The “filtered” output file will be sent to the State for updating their system. As a side note, the original input files that we receive from the bank show as Unix 1252 (ANSI Latin 1) in my file editor (UltraEdit), and each record ends only with a line feed. I sent a couple of test output files generated from bo

Join the discussion →

How to define guild in discord.py?

async def find_channel(guild): for c in guild.text_channels: if not c.permissions_for(guild.me).send_messages: continue return c @bot.event async def on_server_join(member): channel = await find_channel(guild) await channel.send('blah') This is my code and when I start the bot and it joins to the channel, this error occurs: line 48, in on_server_join channel = await find_channel(guild) NameError: name 'guild' is not defined How can I define guild?

Join the discussion →

Why Google API for QR code is not working now?

I am using the this API since 1 year but now I don't know why it stops working. Image of QR code creates but its not readable by browser. I sharing the test URL of the API https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=World&choe=UTF-8

Join the discussion →

SSL Security error when trying to connect to SQL Server 2016 from an udl test file

I am trying to test a SQL connection from my local PC(Win 7) to a SQL Server 2016 machine (Win 2016 Standard X64). I have just created a dummy .udl file, provided the server name, SQL credentials but I am receiving the following error: [DBNETLIB][ConnectionOpen (SecDoClientHandshake().]SSL Security error. If I connect through SQL Management Studio is works. If I try to use the ODBC tool to test data source, I am receiving the following error message in the test connection window Microsoft SQL Server Native Client Version 11.00.2100 Running connectivity tests... Attempting connection [Microsoft

Join the discussion →

what is the error : "ValueError: assignment destination is read-only"?

When I am opening a jpg file using cv2.imread() and it fails sometimes which is likely due to BGR format I used. So I switched to PLT to use RGB. import matplotlib.pyplot as plt import numpy as np def rgb_to_gray(img): grayImage = np.zeros(img.shape) R = np.array(img[:, :, 0]) G = np.array(img[:, :, 1]) B = np.array(img[:, :, 2]) R = (R *.299) G = (G *.587) B = (B *.114) Avg = (R+G+B) grayImage = img for i in range(3): grayImage[:,:,i] = Avg return grayImage image_file = 'C:\A.jpg'; img = plt.imread(image_file,0) gray = rgb_to_gray(img).copy() How ever I am getting an error when I convert the

Join the discussion →

SPI interface 3-wire serial Si471X [closed]

I tried to find an answer to this question by searching SDIO which is related to my question based on Silicon Labs naming of data channels. However, I was flooded with topics related to the SDIO protocol for serial comms with an SD memory card - a totally different concern. I want to interface a PIC MCU (SPI bus) with Silicon Labs FM TX/RX 47XX chips which describe a serial control interface and the multiple ways to use it - what they call 2-wire (basically I2C) or what they call 3-wire and refer to as "SPI". The 3 lines are SLCK, SEN and SDIO (clock, enable, and data input/output half-duplex

Join the discussion →

$Lookup and $addField in mongodb

I have the following two collections and I want to be able to join them and output the number total number of games played by player A and player B. profiles collection [ { name: 'A' player_id: 1 }, { name: 'B' player_id: 2 } { name: 'C' player_id: 3 } ] games collection [ { game_id: 1 player_id: 1 }, { name: 2 player_id: 2 }, { game_id: 3 player_id: 1 }, { name: 4 player_id: 2 } { name: 5 player_id: 3 } ] Now the goal is the output the total number of games played by player A and B but not C when I am given their names but not ID. So the following SQL Statement: SELECT * FROM (results for A)

Join the discussion →

How to remove SVG background in the Inkscape by command?

Here is the situation. I use the Inkscape command to transform png file to svg file. Like this in cmd: inkscape image.png --export-plain-svg=image.svg However, I need to remove the background of the svg file. The GUI process is (1) open up the file, (2) select all(Alt + A) and (3) selecet "Path" -> Trace BitMap -> click the Remove Background. Finally, save it. Is there any command which can insert in the terminal or cmd even in python to do this process??? i might have thousands of svg files...

Join the discussion →

How to create .jar file in IntelliJ for Maven scala+spark project

IntelliJ-IDEA is new for me .. I used to work with SCALA-IDE. for current project i have to use IntelliJ. I tried in stackoverflow to find "How to crate .jar file of scala maven project created in Intellij" I found: install SBT and on CMD type "sbt package" install maven and on cnd type "maven package" some says in intellij at right hand side there will be two options, one is maven, one is ant. Click on maven. U can see the modules. Click on the module un want to build. Expand module, expand the life cycle, click on install My question is: what is the best way to create .jar file in Intellij f

Join the discussion →

Google Colab custom module has no attribute

What I am trying to do is to define a function in a custom module on Google Colab. I created a *.py file to define the function. It is /content/gdrive/My Drive/Colab/myfunc.py Then I created a *.ipynb file at the same folder. It is /content/gdrive/My Drive/Colab/test.ipynb In myfunc.py, the code is def somefunc(a) return a*2 In test.ipynb, the code is cd /content/gdrive/My\ Drive/Colab import myfunc myfunc.somefunc(2) Then it occurs error "AttributeError: module 'myfunc' has no attribute 'somefunc'" I also used dir(myfunc) in test.ipynb, which shows ['__builtins__', '__cached__', '__doc__', '_

Join the discussion →

Type is missing the following properties from type

I have the following interface in a typescript file. export interface TempContext { FriendlyName?: boolean; hList: SelectFilterListItem[]; } SelectFilterListItem is an interface in another file export interface SelectFilterListItem { name: string; value: any; } I then want to use this in a function in the same file filterDef: new SelectFilterDef({ filterList: (context: TempContext) => context.hList, }), I get the following error Type '(context: TempContext) => SelectFilterListItem[]' is missing the following properties from type 'SelectFilterListItem[]': pop, push, concat, join, and 25 more.

Join the discussion →

Is there a reasonable way to have different versions of None?

I am working in Python 3. Say you have a million beetles, and your task is to catalogue the size of their spots. So you will make a table, where each row is a beetle and the number in the row represent the size of spots; [[.3, 1.2, 0.5], [.6, .7], [1.4, .9, .5, .7], [.2, .3, .1, .7, .1]] Also, you decide to store this in a NumPy array, for which you pad the lists with None (NumPy will convert this to np.nan). [[.3, 1.2, 0.5, None, None], [.6, .7, None, None, None], [1.4, .9, .5, .7, None], [.2, .3, .1, .7, .1]] But there is a problem. Values represented as None can be None for one of three rea

Join the discussion →

How to display MySQL database entries in HTML table using JavaScript?

I have successfully displayed the MySQL table in HTML data table, however, there is a bug that makes the display incorrect. see image: this is the code behind the display. JAVASCRIPT: $(document).ready(function(){ loadAccountList(); }); function loadAccountList() { $.ajax({ /*url: "../srtdash/php_functions/account_list.php", type: "POST", dataType: "JSON", data: {}, //this is data you send to your server*/ type: 'POST', url: '../srtdash/php_functions/account_list.php', dataType: 'json', data: {}, contentType: 'application/json; charset=utf-8', success: function(res) { for (var i = 0; i < res.l

Join the discussion →

Lightning Web Component to display JSON String is not working

I have the following lightning web component to read a JSON string and display them in Contact record Details page. Please note that I am new to lighting web components and making a considerable amount of effort to learn. MyComponent.html <template> <lightning-record-form object-api-name={contactObject} fields={myFields} onsuccess={handleContactCreated} onload={handleContactInitialized} > </lightning-record-form> </template> MyComponent.js import { LightningElement, wire, track } from 'lwc'; import findDetails from '@salesforce/apex/JSONDemoController.getContactWithRelatedDataById'; import CON

Join the discussion →

MaybeEncodingError: Error sending result: ''

I am getting the below error when I am downloading files using multiprocessing. I am downloading Wikipedia page views and they have it by hour so it might include a lot of downloading. Any recommendation to why this error is caused and HOW TO SOLVE IT? Thanks MaybeEncodingError: Error sending result: ''. Reason: 'TypeError("cannot serialize '_io.BufferedReader' object",)' import fnmatch import requests import urllib.request from bs4 import BeautifulSoup import multiprocessing as mp def download_it(download_file): global path_to_save_document filename = download_file[download_file.rfind("/")+1:

Join the discussion →

How to read SharePoint Online (Office365) Excel files into Python specifically pandas with Work or School Account?

The question is very similar to the link below. How to read SharePoint Online (Office365) Excel files in Python with Work or School Account? Essentially I would like to import an excel file off SharePoint into pandas for further analysis. The issue is when I run the code below I get the following error. XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'\r\n<!DOCT' My code: from office365.runtime.auth.authentication_context import AuthenticationContext from office365.sharepoint.client_context import ClientContext from office365.sharepoint.file import File url = 'https

Join the discussion →

Temporary mute command doesn't mute and throws deprecation warning

I'm trying to create a temporary mute command for my Discord bot. It creates the role muted, but the user can still write messages even though I've changed the perms. On top of that, I'm getting the following deprecation warning: (node:15956) DeprecationWarning: Collection#find: pass a function instead const Discord = require("discord.js"); const ms = require("ms"); module.exports.run = async (bot, message, args) => { //!tempmute @user 1s/m/h/d let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0])); if(!tomute) return message.reply("Couldn't fin

Join the discussion →

How do I access content in a script tag using bs4

I'm trying to use beautiful soup to find a script tag on a page that has the dataLayer and then retrieve the value of postNo and print it. <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <!-- Data Layer - Begin --> <script> dataLayer = [ { 'country': 'UnitedKingdom', 'site': 'Blog', 'postNo': '34', 'pageType': 'Home', 'pageType2': 'Blog', 'pageType3': 'Top Tips' } ]; </script> <!-- Data Layer - End --> </head>

Join the discussion →

Pandas: Partial dependence plots + One hot encoding

I am currently working through this tutorial. What I am currently trying to display is how 'survival' was influenced by gender (Sex in the dataset). As that is category data I must first transform that data. I tried it with one hot encoding, but that doesn't seem to be the right approach. titanic_data = pd.read_csv('../input/titanic/train.csv') titanic_y = titanic_data.Survived clf = GradientBoostingClassifier() titanic_sex = titanic_data.Sex one_hot_encoded_training_predictors = pd.get_dummies(titanic_sex) titanic_X_colns = ['PassengerId','Age', 'Fare', one_hot_encoded_training_predictors] ti

Join the discussion →
Older stories