on-internet

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 →

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 →

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 →

Could intersystems cache global nodes be ordered by the second node?

I want to sort the string(or number) by the second global nodes(the $o is ordered by the first node then second node ...but i don't care about the first node, i just want the data sorted by the second node, just ignore the first node). as if i want to sort the global ^G("3","2") ^G("1","3") ^G("2","1") . the global would be ordered by the second node, from small to large ,like ^G("2","1") ^G("3","2") ^G("1","3"), so is there any existing function to achieve this ?

Join the discussion →

Asp.Net Core Razor Pages DropDownList selected item values

I'm new to Asp.Net Core Razor Pages. And this is my first question on Stack Overflow. When a client is selected from a drop down list on the create jobs page I want to receive the client details from the clients page where the client is registered on and then display the cell phone number in the corresponding form field on the create a job page. Thank you in advance. Client Model: public class Client { public int ID { get; set; } [Required] [StringLength(50)] [Display(Name = "Last Name")] public string LastName { get; set; } [Required] [StringLength(50, ErrorMessage = "First name cannot be lon

Join the discussion →

Implementing CASL with React and Redux

I will be referencing this article https://medium.com/dailyjs/managing-user-permissions-in-your-react-app-a93a94ff9b40 I will be implementing role based authentication for certain routes in my react application and came across CASL. I see they have a react implementation but theres a certain area which confuses me. Please see the below code and I will explain after. import { AbilityBuilder } from 'casl' function subjectName(item) { if (!item || typeof item === 'string') { return item } return item.__type } export default AbilityBuilder.define({ subjectName }, can => { can(['read', 'create'], '

Join the discussion →

How to non-interactively feed ssh with Time-based One-Time Password? [closed]

Some supercomputers require time-based one-time password (OTP) to login via ssh. I want to avoid typing the password every time and automate login/scp/rsync via bash script, in which I generate the one-time password and then pass the one-time password to ssh by using sshpass: sshpass -p my_password_and_OTP ssh user@hostname This sshpass works for usual ssh, but my testing indicates it does not work for ssh requiring one-time password. I am wondering whether there is a way to non-interactively feed ssh with Time-based One-Time Password.

Join the discussion →

Cannot find module providing package

I'm not sure how to solve a dependency issue I'm finding with "go mod". From what I could gather, it's fetching the wrong version of some sub-dependency which points to a repo that doesn't exist anymore. I very very new to go so I'm sure I'm screwing up, I'd love some help to understand how to fix this. Please check these examples: Getting my only dependency with go get works fine export GOPATH=`mktemp -d` export MYAPP=`mktemp -d` cd $MYAPP cat << EOF > main.go package main import ( "fmt" "os" "github.com/kubernetes/minikube/pkg/storage" ) func main() { if err := storage.StartStorageProvisione

Join the discussion →

Battleship game in Java language

I need some help with my code for my school project. I have done some simple game in Java, it is on 5x5 board, randomly positioned ships. I am stuck with something that I can't manage alone, I need some brains more to help me with it. I need to make a ship which need to position itself on 2 places on board, so if you are playing against PC you'll need two shots to sink that boat. Code is below: public static void main(String[] args) { int[][] board = new int[5][5]; int[][] ships = new int[3][2]; int[] shoot = new int[2]; int attempts=0, shotHit=0; initBoard(board); initShips(ships); System.out

Join the discussion →

FCM Notification not working in oppo(color OS) after allowing Auto Startup

I am using FCM in my android application. Notification working fine when the app is in the background but after killing from the background notification is not working. My mobile is oppo f9 pro I have manually enabled auto startup and enabled allow in the background. Enabled in background My Firebase Service public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "myFirebaseMsgService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.d(TAG, "From : " + remoteMessage.getFrom()

Join the discussion →

Valgrind Install Fails MacOS 10.14 Mojave

I keep seeing mixed results for Valgrind's status on MacOS Mojave. Some responses say to use the head url change workaround ( & brew install --HEAD valgrind), but this did not work as I still get: -bash: valgrind: command not found Some say it's just not compatible at all with OS Mojave. Valgrind is a mandatory spec for my C project. How do I go about this?

Join the discussion →

Angular 6 ngx-mask plugin, multiple masks on same input field

So i use this plugin https://github.com/JsDaddy/ngx-mask to mask an input field dynamically (while user is typing). So for example if my mask only accepts 123 and they type abc nothing will happen. The problem I am having is I need two masks on the same input field so I need for example 123 and abc to both be accepted not just one or the other. Here is my code sample following the docs at the link above. <input id="main-office-phone"type="phone" minlength="10" prefix="+1 " mask="(000)-000-0000">

Join the discussion →

Rank of Sparse matrix Python

I have a sparse csr matrix, sparse.csr_matrix(A), for which I would like to compute the matrix rank There are two options that I am aware of: I could convert it to numpy matrix or array (.todense() or .toarray()) and then use np.linalg.matrix_rank(A), which defeats my purpose of using the sparse matrix format, since I have extremely large matrices. The other option is to compute a SVD decomposition (sparse matrix svd in python) for a matrix, then deduce matrix rank from this. Are there any other options for this? Is there currently a standard, most efficient way for me to compute the rank of a

Join the discussion →
Older stories