How hard is learning Java script (for web dev. , react) [closed] Posted: 27 Jan 2022 03:11 AM PST I know average c++. and some data structures. i dont know much about class , structure etc. ON a scale of 1 to 10 how hard it will be. |
Python drama with variable Posted: 27 Jan 2022 03:11 AM PST in python I have this set of variable variable.py #--------------Project 1--------------# ip_server = '10.10.55.98 username = 'user_1' distro = 'debian' #--------------Project 2--------------# ip_server = '10.10.55.96' username = 'user_2' distro = 'opensuse' #--------------Project 3--------------# ip_server = '10.10.55.95' username = 'user_3' distro = 'ubuntu' In the script main.py I just want to import variable of Project 2, how to this? main.py from variable import * ho_to_import_variable_of_project2? thanks to all for answers anche time to dedicate my question |
In android studio Card view is going out of screen on my phone . But while developing , on emulator it is working perfectly responsive and fine Posted: 27 Jan 2022 03:11 AM PST My Cardview is completely responsive on Emulator but while running in phone it is going in left screen side . I used constraint layout in my whole app. I used view pager and tab layout and i am showing this layout on View Pager . I tried a lot but this layout is not responsive on any phone but on Emulator it is <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="212dp"> <androidx.cardview.widget.CardView android:id="@+id/cardView" android:layout_width="match_parent" android:layout_height="212dp" android:layout_marginStart="2dp" android:layout_marginTop="3dp" android:layout_marginEnd="2dp" app:cardBackgroundColor="#FFFFFF" app:cardCornerRadius="3dp" app:cardElevation="2dp" app:cardMaxElevation="2dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/main_image_url" android:layout_width="140dp" android:layout_height="140dp" app:layout_constraintBottom_toBottomOf="@+id/main_description" app:layout_constraintEnd_toStartOf="@+id/main_title" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/main_title" tools:srcCompat="@tools:sample/avatars" /> <TextView android:id="@+id/main_title" android:layout_width="220dp" android:layout_height="70dp" android:layout_marginTop="16dp" android:layout_marginEnd="5dp" android:ellipsize="end" android:fontFamily="@font/fira_sans_medium" android:maxLines="3" android:padding="2dp" android:text="Title displayes here lslsll ajajja alalal aayya ahahha akakaka oaoaooas ssssjsjs sjsjjs ssjjsjsjs sjsjjsjs ssshshhs jsjsjsssssjsjsjsjsjsjsjjsjsjs" android:textColor="@color/black" android:textSize="17sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="@+id/main_description" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/main_description" android:layout_width="220dp" android:layout_height="80dp" android:layout_marginTop="10dp" android:layout_marginEnd="5dp" android:ellipsize="end" android:fontFamily="@font/fira_sans_light" android:maxLines="4" android:padding="2dp" android:text="Description jsjsjsjjsjsjsj jajajajja sosososoosos shshshshss shhshshhshs shshshhs saiiaiaaia sbsbbsbsb aoaoaoao sjsjsjs akakaDescription jsjsjsjjsjsjsj jajajajja sosososoosos shshshshss shhshshhshs shshshhs saiiaiaaia sbsbbsbsb aoaoaoao sjsjsjs akaka" android:textColor="#000000" android:textSize="14sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/main_title" /> <TextView android:id="@+id/main_source_id" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="64dp" android:fontFamily="monospace" android:text="Source_ID" android:textColor="@color/black" android:textSize="10sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/share" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/main_image_url" /> <TextView android:id="@+id/main_pubDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="32dp" android:text="Update Date" android:textColor="@color/black" android:textSize="10sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toEndOf="@+id/share" app:layout_constraintTop_toBottomOf="@+id/main_description" app:layout_constraintVertical_bias="0.409" /> <ImageView android:id="@+id/share" android:layout_width="18dp" android:layout_height="18dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/main_pubDate" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toEndOf="@+id/main_source_id" app:layout_constraintTop_toBottomOf="@+id/main_description" app:srcCompat="@drawable/share" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.cardview.widget.CardView> </androidx.constraintlayout.widget.ConstraintLayout> |
group by json array based on combine multiple keys taking too much time Posted: 27 Jan 2022 03:11 AM PST I have below json array I want to group by it based on sourceno and destno combine key. json array:- [ { "sourceno": "112", "destno": "321", "edno": "123", "eppno": "322" }, { "sourceno": "112", "destno": "321", "edno": "123", "eppno": "324" }, { "sourceno": "114", "destno": "335", "edno": "100", "eppno": "355" }, { "sourceno": "114", "destno": "335", "edno": "222", "eppno": "999" } ] Present Code:- let pobj={} let p_data=[] let count=0; for(key in eddarr) { let resultarr=eddarr[key] let pkey = eddarr[key].sourceno+'-'+eddarr[key].destno; let obj = {}; let isNew = true; if(pdata.length > 0){ for(let j=0;j<pdata.length;j++){ if(pdata[j].hasOwnProperty(pkey)){ pdata[j][pkey][pdata[j][pkey].length] = resultarr; isNew = false; break; } } } if(isNew){ obj[pkey] = new Array(); obj[pkey][0] = resultarr; pdata.push(obj); } console.log(pdata) Above code is working fine and i am getting below result but its running very slow its creating below result for 37K records after 15 min. How can i optimise this code or any other logic need to build. I want to process 15 lac records but loop is taking too much time.thanks in advance Final result after processing should be like this:- [ { "112-321": [ { "edno": "123", "eppno": "322" }, { "edno": "123", "eppno": "324" } ] }, { "114-335": [ { "edno": "100", "eppno": "355" }, { "edno": "222", "eppno": "999" } ] } ] |
primeng v11.2.0: p-columnFilter not showing Posted: 27 Jan 2022 03:10 AM PST Dear all I am using the p-table component from primeNG library: the main filter (highlighted input box) is working but when I click on the funnel next to the 'Sample' nothing happens and no error is showing in the console. I am expecting something similar to the following: Here is my code: <p-table #dt1 id="graphData" [value]="graphData" dataKey="sample" [rows]="6" [showCurrentPageReport]="true" [rowsPerPageOptions]="[6,10,25,50]" [loading]="loading" styleClass="p-datatable-gridlines" [paginator]="true" currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [globalFilterFields]="['sample','tyre_pressure','speed','power']"> <ng-template pTemplate="caption"> <div class="flex"> <button pButton label="Clear" class="p-button-outlined" icon="pi pi-filter-slash" (click)="clear(dt1)"></button> <span class="p-input-icon-left ml-auto"> <i class="pi pi-search"></i> <input #filterName pInputText type="text" (input)="dt1.filterGlobal($event.target.value, 'contains')" placeholder="Search keyword" /> </span> </div> </ng-template> <ng-template pTemplate="header"> <tr> <th> <div class="flex justify-content-center align-items-center"> Sample <p-columnFilter type="text" field="graphData.sample" display="menu"> </p-columnFilter> </div> </th> <th> <div class="flex justify-content-center align-items-center"> Tyre Pressure <p-columnFilter type="number" field="tyre_pressure" display="menu"> </p-columnFilter> </div> </th> The text filter in p-columFilter is not showing when I press the funnel button: <th> <div class="flex justify-content-center align-items-center"> Sample <p-columnFilter type="text" field="graphData.sample" display="menu"> </p-columnFilter> </div> </th> What am i missing? |
skip the line in json generated through php Posted: 27 Jan 2022 03:10 AM PST Hello I am currently working on a project with file generation with Json it works fine. But I'm facing a problem it mounts the Json in a single line as shown in the image. I would like it to be one below the other as in the following example I tried to use \n but I didn't have a positive result it didn't work my code below is this header('Content-disposition: attachment; filename=DadosKDL.json'); header('Content-type: application/json'); $query ='SELECT * from ite'; $result = mysqli_query($banco, $query); if (!$result) { echo("Error description: " . mysqli_error($banco)); } $i=0; while ($row = mysqli_fetch_array($result)){ $nserlum=$row['nserlum']; $nsercon=$row['nsercon']; $hora=$row['hora']; $posts[] = array('ITEM 1 '=> $nserlum, 'ITEM 2 '=> $nsercon, 'ITEM 3'=> $hora); } $fp = fopen( 'php://output', 'w'); fwrite($fp, json_encode($posts)); fclose($fp); mysqli_close($banco); |
Progress Bar with data Posted: 27 Jan 2022 03:10 AM PST I was looking to code a progress bar which is linked with data. For example if a student answers a certain amount of questions the progress bar goes up. How would I go about this? I can code the progress bar. I don't know what to use for the data and how to link it. |
xorriso fails extracting iso from curl through pipe Posted: 27 Jan 2022 03:10 AM PST I have an .iso that should be downloaded and "extracted" to a directory. I figured I could do this same as tar using stdin or bash process substitution to extract while downloading, but I'm getting errors that the file is empty. Running the curl command standalone downloads the .iso as expected. $ osirrox -drive-class clear_list caution -indev <( curl --fail --header "X-JFrog-Art-Api: $(cat /run/secrets/ARTIFACTORY_API_KEY)" https://artifactory.corp.int/application.iso ) -extract / application -file_name_limit 255 > #10 0.331 xorriso 1.4.8 : RockRidge filesystem manipulator, libburnia project. > #10 0.331 > #10 0.333 Drive current: -indev '/dev/fd/63' > #10 0.333 Media current: stdio file, sequential > #10 0.333 Media status : is blank > #10 0.333 Media summary: 0 sessions, 0 data blocks, 0 data, 1024g free Not sure whether it's curl or xorriso giving me a hard time. Possibly related; I cannot make it work with 7z either (process substitution or -si ). Not as interested in a 7z solution since it among other things drops execute permissions, but the info might be useful for finding a root cause. |
AlertDialog with EditText and Three buttons Posted: 27 Jan 2022 03:10 AM PST So i have tis code and i'm trying to create a AlertDialog with an EditTet and Three buttons the positive one, the négative one and the neutral one , but it doesn't work and the application stops b5.setOnClickListener(new View.OnClickListener() { @SuppressLint("UseCompatLoadingForDrawables") @Override public void onClick(View view) { AlertDialog.Builder boite; boite = new AlertDialog.Builder(MainActivity.this); boite.setTitle("boite de dialogue"); boite.setIcon(getDrawable(R.drawable.warning_shield_96px)); final EditText input = new EditText(MainActivity.this); input.setInputType(InputType.TYPE_CLASS_TEXT); boite.setView(input); boite.setPositiveButton("OUI", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //whatever action } }); boite.show(); boite.setNegativeButton("NON", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //whatever action } }); boite.show(); boite.setNeutralButton("CANCEL", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { //whatever action } }); boite.show(); } }); |
Cannot get remote stream when using Kurento Utils Posted: 27 Jan 2022 03:10 AM PST I have a video-call-chat website using WebRTC. I built it with express, socket.io and kurento. Specifically, I run kurento server at port 8888: docker run -d -p 8888:8888 kurento/kurento-media-server:6.6.0 and I use Kurento Utils JS in client for: get Peer connection, transfer video streams, ICE candidates as well as handle offers, answers. I run my app on https://localhost:3000. In the client of local user, I use WebRtcPeerSendonly to send and embedded local MediaStream. And with remote users, they will receive and embedded the received MediaStream by method WebRtcPeerRecvonly. But the received MediaStream is always wrong and user can't embedded exact remote stream of the others. Can someone help in resolving this issue? Below is my code: user.rtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly( options, function (err) { if (err) { return console.error(err); } this.generateOffer(onOffer); } ); user.rtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendonly( options, function (err) { if (err) { return console.error(err); } this.generateOffer(onOffer); } ); I have took a look at Kurento Utils JS library and I find out that it has two functions to get and assign remote stream: one is getRemoteStreams() and another is setRemoteVideo(). Below is the code: if (!pc.getRemoteStreams && pc.getReceivers) { pc.getRemoteStreams = function () { var stream = new MediaStream(); pc.getReceivers().forEach(function (sender) { stream.addTrack(sender.track); }); return [stream]; }; } function setRemoteVideo() { if (remoteVideo) { remoteVideo.pause(); var stream = pc.getRemoteStreams()[0]; console.log(stream) remoteVideo.srcObject = stream; logger.debug("Remote stream:", stream); if ( typeof AdapterJS !== "undefined" && AdapterJS.webrtcDetectedBrowser === "IE" && AdapterJS.webrtcDetectedVersion >= 9 ) { remoteVideo = attachMediaStream(remoteVideo, stream); } else { remoteVideo.load(); } } } When if condition come false, it mean the default getRemoteStreams function of this library is applied, I try to console.log the remote stream in library and it always show a MediaStream with ID = "default":
MediaStream {id: 'default', active: true, onaddtrack: null, onremovetrack: null, onactive: null, …} active: true id: "default" onactive: null onaddtrack: null oninactive: null onremovetrack: null But when I remove if condition, means that the getRemoteStreams function is overridden as above. Then the log show that remote stream is a MediaStream with a specified , for example: MediaStream {id: 'a1ece389-bac6-4263-83a8-e142f7137efb', active: true, onaddtrack: null, onremovetrack: null, onactive: null, …} active: true id: "a1ece389-bac6-4263-83a8-e142f7137efb" onactive: null onaddtrack: null oninactive: null onremovetrack: null But in this case, the received ID doesn't coincide with the sended MediaStream ID. I think the reason is not server connection because when new user access this website, it create a new ID (showed in console) and it can send Media Stream to the others (but not the expected one). |
__str__ returned non-string (type Category). when I add post from admin Posted: 27 Jan 2022 03:11 AM PST After I added user and date_added in the Photo models, when I add post from admin its throws me an error saying: str returned non-string (type Category), when I click on the addpost link in the home template its throw another error: 'tuple' object has no attribute 'name'. how can I solve that ? the models.py: from django.db import models from cloudinary.models import CloudinaryField from django.contrib.auth.models import User # Create your models here. class Category(models.Model): name = models.CharField(max_length=100, null=False, blank=False) def __str__(self): return self.name class Photo(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True, blank=True) image = CloudinaryField('image') description = models.TextField(null=True) date_added = models.DateTimeField(auto_now_add=True) def __str__(self): return self.category the view.py file: def home(request): category = request.GET.get('category') if category == None: photos = Photo.objects.all() else: photos = Photo.objects.filter(category__name=category) categories = Category.objects.all() context = {'categories': categories, 'photos': photos} return render(request, 'home.html', {'categories': categories, 'photos': photos} ) def viewPhoto(request, pk): photo = Photo.objects.get(id=pk) return render(request, 'photo.html', {'phpto': photo}) class PostCreativeView(LoginRequiredMixin, CreateView): model = Photo, Category fields = ['description', 'image', 'category', 'name'] template_name = 'post_create.html' def form_valid(self, form): form.instance.user = self.request.user return super (PostCreativeView, self).form_valid(form) |
Which objects have the EventTarget interface? Posted: 27 Jan 2022 03:10 AM PST according to MDN Element, and its children, as well as Document and Window are EventTargets. What does its children mean? Since I can't add events to text nodes, right? Thanks and Greetings |
Seach and comment all matches Posted: 27 Jan 2022 03:11 AM PST Is there a way to comment all the matches when doing CTRL+F or CTRL+R? I have tried a quick fix, but this is not working properly when the line to be printed is in different lines: # print("Hello" "World") I am using Python 3.7 and PyCharm 2021.3.1 |
Is it possible to make LazyRow/LazyColumn display a certain amount of items on the screen without passing in an explicit DP width Posted: 27 Jan 2022 03:10 AM PST Is there a way to make a LazyRow/Row display for example 2 items on the screen simultaneously without measuring the screen width manually and passing the DP width to the children of the LazyRow? Current setup example: LazyRow( modifier = Modifier .fillMaxWidth() .height(200.dp) ) { item { FirstItem( modifier = Modifier.width( ScreenUtils.getScreenWidthDP(LocalContext.current) / columnCount ) ) } item { SecondItem( modifier = Modifier.width( ScreenUtils.getScreenWidthDP(LocalContext.current) / columnCount ) ) ) } } |
Why do we use square brackets inside len()? Posted: 27 Jan 2022 03:10 AM PST I am new to Python and I am trying to understand why we use the square brackets inside the len() function: def counts(txt): return len([letter for letter in txt.lower() if letter in "aeiou"]) If I remove the square brackets, I get TypeError: object of type 'generator' has no len() but I don't understand what that means. |
Why is there an unnecessary or operation when inverting bytes? Posted: 27 Jan 2022 03:11 AM PST I am really confused by this, however trivial it may be. Here's an example (which I tried on paper): uint16_t val = 32; //00000000 00100000 uint16_t swapped = val >> 8; //00100000 00000000 uint16_t swapped2 = val << 8; //00100000 00000000 uint16_t swapped3 = (val >> 8) | (val << 8); //00100000 00000000 I may be missing something... But as far as I know, they all have the same value, I was wondering maybe the operation in "swapped3" was a safeguard/good practice when doing the same for unsigned 32 bit values, but it wouldn't make sense. I've tried to search answers online, but all operations are either this or a play on it. Enlighten me, if possible, binary operations make my head spin. |
How to download data in zip using Angular with nested folders [duplicate] Posted: 27 Jan 2022 03:11 AM PST I have following json "data":[ { "Name":"Mary ", "Email":"Mary.test@yahoo.com", "Phone_No":"1234567890","Birthdate":"1983-02-04", "Photo":"data:.....", //image data url "SerialNo":1, "updatedAt":"2022-01-24 12:41:57","createdAt":"2022-01-24 12:39:52", }, { "Name":"John ", "Email":"John.test@yahoo.com", "Phone_No":"1234567890","Birthdate":"1985-02-04", "Photo":"data:.....", //image data url "SerialNo":2, "updatedAt":"2022-01-24 12:41:57","createdAt":"2022-01-24 12:39:52", } ] I want to download this data in zip folder(sample.zip) Folder structure should be like this. how to create photo folder? I am trying following code, it downloads 3 files data.xls, 1.jpeg, 2.jpeg. now i want the folder structure downloadData(data: any){ let userData: any = []; let tokenData: any = {}; for (let key in data) { if (key.toLocaleLowerCase().includes('photo') ) { const image = element.data[key]; const imageName = `${element['SerialNo']}.jpeg`; tokenData[key] = imageName; const link = document.createElement('a'); link.href = image; link.download = imageName; link.click(); } else { tokenData[key] = element.data[key]; } } userData.push(tokenData); } this.exportJsonAsExcelFile(userData, `sample`); } private exportJsonAsExcelFile(json: any[], excelFileName:string): void { const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json); const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] }; const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); this.saveAsExcelFile(excelBuffer, excelFileName); } private saveAsExcelFile(buffer: any, fileName: string): void { const data: Blob = new Blob([buffer], { type: EXCEL_TYPE }); FileSaver.saveAs(data, fileName + EXCEL_EXTENSION); } |
SQL query to return ids that only signed up but didn't take any other action Posted: 27 Jan 2022 03:11 AM PST I have an event table that looks like this. | id | event | date | |----|---------|------------| | 1 | sign up | 28/01/2022 | | 1 | log in | 29/01/2022 | | 1 | delete | 30/01/2022 | | 2 | sign up | 31/01/2022 | | 3 | log in | 01/02/2022 | | 4 | sign up | 02/02/2022 | | 4 | NULL | 03/02/2022 | I want to write a query that selects distinct ids that only signed up and did not carry out any other event. Thanks. |
Extract Title Tags BeautifulSoup Posted: 27 Jan 2022 03:11 AM PST I need help because I wanted to write a Code for finding out title tags on a website. Although I used the code from another question and applied it to this scenario, there is no title tags whenever I print 'Beschreibung' from bs4 import BeautifulSoup import requests import pandas as pd import urllib.parse webseite = 'https://www.entega.de/sitemap/' response = requests.get(webseite) response.status_code soup = BeautifulSoup (response.content, 'html.parser') result_container = soup.find_all('div', {'class':'clearfix'}) url_part_1 = 'https://www.entega.de/sitemap/' url_part_2 = [] for item in result_container: for link in item.find_all ('a', {'class':'modSitemap__lvl1Link ui-link' }): url_part_2.append (link.get ('href')) url_joined = [] for i in url_part_2: url_joined.append (urllib.parse.urljoin(url_part_1,i)) Überschrift= [] Beschreibung= [] Verlinkungen = [] for link in url_joined: response = requests.get (link) soup = BeautifulSoup (response.content, 'html.parser') Beschreibung.append(soup.find_all('a', title=True, class_='modSitemap__lvl1Link ui-link')) |
Google Analytics notification_receive Report 'not set' problem Posted: 27 Jan 2022 03:11 AM PST I am trying to report the notifications I send via Fcm using google analytics. However, most of the data appear to be not set. I can't find the reason for this. |
Windbg alias replacement broken? Simplified example Posted: 27 Jan 2022 03:11 AM PST Yesterday I asked a question about the behavior of windbg aliases (Strange behavior of windbg alias in loops) and got some helpful answers. Now I have a simplified example that shows the behavior I am seeing, without any loops. It seems like alias replacement is simply broken, and the documentation about .block {} is basically wrong. In a foo.windbg script I have the following: ;aS ${/v:foo} 1 al .block { .echo foo } I run the script with $$><foo.windbg If the alias foo is not defined before running the script (or if it is already defined to 1), this works as expected. However if I already have foo defined to a different value, e.g. 0 ;aS ${/v:foo} 0 then when I run the script foo gets set to 1 (I can see that from the al command in the script) but the command .echo foo in the script produces 0. Even the reference to foo is in a .block{}. It works if the closing curly brace in the block statement is immediately after the reference to foo ;aS ${/v:foo} 1 al .block { .echo foo} This doesn't help because it means you can't use the alias unless it happens to be at the end of a .block{} or other compound statement. I though referencing the alias with ${foo} would help but it does not. From the answers to my previous question I see that deleting (ad) the alias before setting it seems to fix the problem in some cases. Just using ad foo will error out the script if foo is not defined so I can't use it. Using ad * works but deletes all aliases including ones I have already created and want to use. I tried .if (${/d:foo}) {ad ${/v:foo}} but that gives the same behavior, where foo is replaced with the old value when used further down in the script. So I guess the work-around is to start the script with aS ${/v:foo} dummy ad ${/v:foo} which seems to work. So the basic problem is that alias replacement fails (in some cases) unless the alias name is followed by the closing curly brace of certain statements like .block. All the examples from the windbg documentation just so happen to do exactly this, and/or delete all aliases first and work around the problem that way. I know I'm beating the dead horse but does this behavior have an explanation? Am I confused? It seems simply broken and, for the way I want to use aliases, useless. Thanks, Dave |
Clone new object of old object without old reference in C# Posted: 27 Jan 2022 03:10 AM PST I have a huge object with a lot of attributes and child objects. Because of a poorly designed database which I can't control, I need to find matching objects in allCourses with the attribute CourseType = "SVYE" . For those who matches the condition, I want to change all values from "SVYE" to "SVYR" instead and add them to the original object allCourses . I realized that when you declare svCourse you still have the old references in courses which will cause all objects with the value on CourseType = "SVYR" . Instead of every match should be one with CourseType = "SVYE" and one with CourseType = "SVYR" . How could I create a copy of the matching values without having the reference to allCourses in the new var svCourses without declaring every attribute again? new Course(){ name = a.name // etc.. } My code: var svCourses = allCourses.Where(x => x.Occasions .Any(y => y.CourseType.Equals("SVYE"))) .ToList(); foreach(var svCourse in svCourses) { foreach(var o in svCourse.Occasions) { o.CourseType = "SVYR"; } allCourses.Add(svCourse); } return allCourses; |
Python pandas decrease backfill until reach a certain number based on interval Posted: 27 Jan 2022 03:11 AM PST I have the following dataframe called df, date flag1 flag2 flag3 flag4… 2020-12-31 2021-01-01 2021-01-02 1 2021-01-03 2021-01-04 2021-01-05 1 2021-01-06 1 2021-01-07 2021-01-08 2021-01-09 2021-01-10 2021-01-11 1 1 2021-01-12 I want to do a backfill when a 1 appears in any column, and fill backwards until a number appears or failing that, backfill til a set number. So let's say the set number to reduce o to is 0 and the decrement is 0.1, it should look like this, date flag1 flag2 flag3 flag4… 2020-12-31 0.5 0.8 0.4 2021-01-01 0.0 0.6 0.9 0.5 2021-01-02 0.1 0.7 1.0 0.6 2021-01-03 0.2 0.8 0.7 2021-01-04 0.3 0.9 0.8 2021-01-05 0.4 1.0 0.9 2021-01-06 0.5 1.0 2021-01-07 0.6 0.6 2021-01-08 0.7 0.7 2021-01-09 0.8 0.8 2021-01-10 0.9 0.9 2021-01-11 1.0 1.0 2021-01-12 Can this be achieved with pandas? I want to be able to set the decrement amount and the limit for example the above would be 0.1 and 0. I know that this command can increment the values backwards, df1 = df1[::-1].fillna(method='ffill') (df1 + (df1 == df1.shift()).cumsum()).sort_index() But that's not what I want. |
Flutter - How to compress image to display thumbnail? Posted: 27 Jan 2022 03:10 AM PST I am making a flutter app which loads about 700+ image from Cloud Storage through Firebase. Though, I am using pagination, the app still crashes sometimes on low end devices(does not crash on emulator). I have already compressed all my images, still sometimes it crashes. Is there a way to compress images when we load them from firestore to display only low quality thumbnails. It's a wallpaper app. So what I want to do is, display low quality images when loading all of them to reduce work load on the device and then use the original quality when setting them as wallpaper. |
Linear Dependence of Set of Vectors in numpy Posted: 27 Jan 2022 03:11 AM PST I want to check whether some vectors are dependent on each other or not by numpy, I found some good suggestions for checking linear dependency of rows of a matrix in the link below: How to find linearly independent rows from a matrix I can not understand the 'Cauchy-Schwarz inequality' method which I think is due to lack of my knowledge, however I tried the Eigenvalue method to check linear dependency among columns and here is my code: A = np.array([ [0, 1, 0, 0], [0, 0, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1] ]) lambdas, V = np.linalg.eig(A) print(lambdas) print(V) and I get: [ 1. 0. 1.61803399 -0.61803399] [[ 0. 0.70710678 0.2763932 -0.7236068 ] [ 0. 0. 0.4472136 0.4472136 ] [ 0. 0. 0.7236068 -0.2763932 ] [ 1. -0.70710678 0.4472136 0.4472136 ]] My question is how can I know that which columns of matrix A has eigen values 0? |
Extract all inherited types / base list of ClassDeclarationSyntax Posted: 27 Jan 2022 03:11 AM PST How can I extract all inherited/implemented types names list Let's say that I have this hierarchy: public interface ISomething : ISomethingElse { } public class Other<T> : SomethingOther<T>, Other2 { } public class Test<T> : Other<T>, ISomething { } and now I do have ClassDeclarationSyntax for Test How can I then extract whole hierarchy? var msWorkspace = MSBuildWorkspace.Create(); var solution = await msWorkspace.OpenSolutionAsync(pathToSln); foreach (var project in solution.Projects) { foreach (var document in project.Documents) { var semanticModel = document.GetSemanticModelAsync().Result; } } (...) var root = semanticModel.SyntaxTree.GetRoot(); // and then recurisve walk if (current is ClassDeclarationSyntax classDec) { if (classDec.BaseList != null) { if (classDec.BaseList.Types.Any(x => x.ToString().Contains("_SpecificInterface"))) { var inherited = ExtractInheritedTypes(classDec, semanticModel); } } } (...) // Here are some my messy attempts to extract it static object ExtractInheritedTypes(ClassDeclarationSyntax classDec, SemanticModel sm) { var symbols = new List<ISymbol>(); foreach (var entry in classDec.BaseList.Types) { var q = sm.Compilation.GetTypeByMetadataName(entry.Type.ToString()); var s = semanticModel.GetDeclaredSymbol(entry.Type); symbols.Add(s); } return 0; } but I only managed to find "first level" of inheritance - Other<T>, ISomething , but no "deeper" |
Minage usage in powershell Posted: 27 Jan 2022 03:11 AM PST I am trying to delete files which are too long filenames in Windows 10 but this powershell scripts delete all files even some files's modified date is newer than minage date. Could you please help me to solve that problem? $directory="C:\Users\test\Downloads\aaa" mkdir empty_dir robocopy empty_dir $directory /MINAGE:20210101 /mir rmdir empty_dir rmdir $directory |
Non-literal types and constant expressions Posted: 27 Jan 2022 03:11 AM PST struct A { ~A() {} consteval A() {} consteval auto f() {} }; int main() { A{}; //A{}.f(); //1 } https://godbolt.org/z/4KPY5P7o7 This program is accepted by ICC, GCC and Clang, but rejected by MSVC which complains that the destructor is not constexpr in the immediate function invocation. Adding the line marked //1 results in all four compilers rejecting the code. Question: In either case, are the compilers correct, and if so why? Note that the interesting part here is that A is non-literal due to the non-constexpr non-trivial destructor. Removing its declaration, all compilers accept both the variant with and without //1 . There are a few restrictions specific to non-literal types for constexpr /consteval functions and for constant expressions, but I don't think any of them should apply here. The restrictions are on return types, parameter types, types of local variable definitions, rvalue-to-lvalue conversions and modifications of objects. I think only the last one can apply here. But what exactly does modification in [expr.const]/5.16 mean and which object would be modified here? I also think MSVC's complaint is incorrect since the destruction of the object shouldn't be part of its constructor's immediate invocation. See also my earlier question inspiring this one: Consteval constructor and member function calls in constexpr functions |
Map not clickable around marker in Google Map SDK for Android Posted: 27 Jan 2022 03:11 AM PST I am building some app like image below, I want to force markers not to be clickable, but there is no setClickable(false) for Marker or MarkerOptions. Currently area around marker (see attachment) is not clickable ( click is passed to marker, not map) |
The JVM option jmxremote.local.only=true does not work properly Posted: 27 Jan 2022 03:11 AM PST I wrote a batch Java 7 application that should be controlled by a JMX client. The JMX service is up and running, and I can connect to it using jConsole from my machine. I set the option -Dcom.sun.management.jmxremote.local.only=true to avoid any incoming connection except from 127.0.0.1. But... when I tried to connect from another computer, my connection wasn't filtered out, and I was able to access to JMX remotely. Here it is java invocation: java -Dcom.sun.management.jmxremote ^ -Dcom.sun.management.jmxremote.port=7000 ^ -Dcom.sun.management.jmxremote.local.only=true ^ -Dcom.sun.management.jmxremote.authenticate=false ^ -Dcom.sun.management.jmxremote.ssl=false ^ -cp lib/*;hns-consumer.jar it.andrearota.com.Main %1 Looks like that the option haven't been considered. Any help? |
No comments:
Post a Comment