Id
int64 1.68k
75.6M
| PostTypeId
int64 1
2
| AcceptedAnswerId
int64 1.7k
75.6M
⌀ | ParentId
int64 1.68k
75.6M
⌀ | Score
int64 -60
3.16k
| ViewCount
int64 8
2.68M
⌀ | Body
stringlengths 1
41.1k
| Title
stringlengths 14
150
⌀ | ContentLicense
stringclasses 3
values | FavoriteCount
int64 0
1
⌀ | CreationDate
stringlengths 23
23
| LastActivityDate
stringlengths 23
23
| LastEditDate
stringlengths 23
23
⌀ | LastEditorUserId
int64 -1
21.3M
⌀ | OwnerUserId
int64 1
21.3M
⌀ | Tags
sequence |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
74,579,262 | 2 | null | 18,326,982 | 0 | null | This will work. You can simply use an icon or an image to trigger the calendar using onclick.
```
<form name="searchPending">
<div class="input-icon form-group">
<i class="ti-calendar" onclick="searchPending.selectDate.showPicker()"></i>
<input name="selectDate" type="date" onfocus="this.showPicker()" class="form-control m-b" placeholder="Sep 23, 2022" />
</div>
</form>
```
| null | CC BY-SA 4.0 | null | 2022-11-26T02:15:38.373 | 2022-11-26T23:01:26.643 | 2022-11-26T23:01:26.643 | 943,953 | 943,953 | null |
74,579,408 | 2 | null | 74,579,194 | 0 | null | Don't combine `await` and `then`. If you use `await`, it returns the value from the `Future` already.
So:
```
Future<bool> isRomeExiste(String userId1, String userId2) async {
var doc = await FirebaseFirestore.instance
.collection('message')
.doc("JryeL6uzGRh86RiY5SXtn58fpup1-JryeL6uzGRh86RiY5SXtn58fpup1")
.get();
bool exist = doc.exists;
return exist;
}
```
---
Note that this will still return false, as there is no document at the path `message/JryeL6uzGRh86RiY5SXtn58fpup1-JryeL6uzGRh86RiY5SXtn58fpup1` in your database. The Firebase console show the path in italics to indicate that there is no document there, but there subcollection.
If you want to be able to check whether the document exists, be sure to create it when you also create the `messages` subcollection. Alternatively, you can check whether the `messages` subcollection has any document with something like:
```
Future<bool> isRomeExiste(String userId1, String userId2) async {
var snapshot = await FirebaseFirestore.instance
.collection('message/JryeL6uzGRh86RiY5SXtn58fpup1-JryeL6uzGRh86RiY5SXtn58fpup1/messages')
.limit(1)
.get();
bool exist = snapshot.size > 0;
return exist;
}
```
| null | CC BY-SA 4.0 | null | 2022-11-26T02:55:52.010 | 2022-11-26T02:55:52.010 | null | null | 209,103 | null |
74,579,517 | 2 | null | 74,552,974 | 1 | null | I Fixed changing the JS code like these:
```
//sedegeneral.addEventListener("click", clicksede);
//function clicksede(){
sedegeneral.addEventListener("change", clicksede2);
function clicksede2(){
const sedegeneral1 = document.getElementById('sedegeneral').value;
const doctorseleccionado1 = document.getElementById('doctorseleccionado').value;
const url = base_url + 'Home/listar';
const http = new XMLHttpRequest();
http.open("POST", url, true);
http.send(new FormData(frmflt));
http.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
const ressede = JSON.parse(this.responseText);
Swal.fire(
'Filtrando Sede '+sedegeneral1+' y el doctor '+doctorseleccionado1,
//ressede.msg,
//ressede.tipo
)
calendar.removeAllEvents();
calendar.addEventSource(ressede)
}
}
sedegeneral.removeEventListener("change", clicksede2);
};
//};
```
| null | CC BY-SA 4.0 | null | 2022-11-26T03:31:39.803 | 2022-11-26T03:31:39.803 | null | null | 20,575,573 | null |
74,579,627 | 2 | null | 74,578,422 | 0 | null | I resolved this. I changed the schema to an array and sent the data as objects.
| null | CC BY-SA 4.0 | null | 2022-11-26T03:59:16.830 | 2022-11-26T03:59:16.830 | null | null | 14,903,000 | null |
74,579,721 | 2 | null | 74,579,684 | 0 | null | As esqew said, `isoparse` doesn't take a `sep` argument. You should loop over the dates and parse them individually, like so:
```
for i in historialSKIN["data"]:
for datestr in i['shopHistory']:
fecha = isoparse(datestr).timestamp()
print(fecha)
```
| null | CC BY-SA 4.0 | null | 2022-11-26T04:27:32.567 | 2022-11-26T04:27:32.567 | null | null | 11,542,834 | null |
74,579,926 | 2 | null | 30,766,755 | 0 | null | Android N does provide a variant as `setProgress(newProgress, true)` which support animating the progress .
It will require a version check, though there is another method which you can directly use `setProgressCompat(progress, true)` regardless of version.
```
progressBar.setProgressCompat(progress, true)
```
| null | CC BY-SA 4.0 | null | 2022-11-26T05:22:07.823 | 2022-11-26T05:22:07.823 | null | null | 4,168,607 | null |
74,580,054 | 2 | null | 68,398,379 | 2 | null | You have to add the `textDecoration='none'` prop to your link component.
Example:-
```
<LinkBox as={Tr}>
<LinkOverlay
href="https://www.google.com"
textDecoration='none'
>
inches
</LinkOverlay>
<Td>millimetres (mm)</Td>
<Td isNumeric>25.4</Td>
</LinkBox>
```
| null | CC BY-SA 4.0 | null | 2022-11-26T05:54:19.943 | 2022-11-26T05:54:19.943 | null | null | 19,968,313 | null |
74,580,209 | 2 | null | 74,580,125 | 1 | null | Your variable "fecha" must be array or string to contain all your dates.
Here's the code, it should work. I think I've shown you the problem and then you'll figure it out for yourself.
```
@bot.command()
async def skin(ctx):
url = requests.get("https://fortnite-api.com/v2/cosmetics/br/search/all?language=es&name=palito%20de%20pescado%20de%20gominola&searchLanguage=es")
historialSKIN= url.json()
fecha = ""
for i in historialSKIN["data"]:
for datestr in i['shopHistory']:
fecha += str(isoparse(datestr).timestamp()) +"\n"
embed=discord.Embed(title="Titulo", description=fecha)
embed.add_field(name="Skin", value="skin", inline=False)
await ctx.send(embed=embed)
```
| null | CC BY-SA 4.0 | null | 2022-11-26T06:33:31.407 | 2022-11-26T06:33:31.407 | null | null | 20,250,545 | null |
74,580,369 | 2 | null | 74,580,257 | 0 | null | The space is related to this css code:
```
.nav-links,
li,
a {
display: flex;
font-size: 16px;
text-decoration: none;
margin: 10px;
font-weight: 700;
color: black;
}
```
change margin.
| null | CC BY-SA 4.0 | null | 2022-11-26T07:09:17.013 | 2022-11-26T07:09:17.013 | null | null | 5,876,267 | null |
74,580,455 | 2 | null | 27,788,530 | 0 | null | If you are using `SwiftUI`. The above appearance technique won't work. Use `.tint` modifier on your `TabView`.
```
TabView(
...
)
.tint(Color.red)
```
Note that the API is `.accentColor` on older SwiftUI versions
| null | CC BY-SA 4.0 | null | 2022-11-26T07:28:14.340 | 2022-11-26T07:28:14.340 | null | null | 1,085,698 | null |
74,580,972 | 2 | null | 74,580,867 | 1 | null | There is a `onValue()` function in the new Modular SDK to listen for updates at the database reference. Try refactoring the code like this:
```
import { getDatabase, ref, onValue} from "firebase/database";
const reference = ref(db, 'room/' + 'new');
onValue(reference, (snapshot) => {
const data = snapshot.val();
console.log(data)
});
```
Checkout the [documentation](https://firebase.google.com/docs/database/web/read-and-write#web-version-9_2) for more information.
| null | CC BY-SA 4.0 | null | 2022-11-26T09:14:52.340 | 2022-11-26T09:14:52.340 | null | null | 13,130,697 | null |
74,581,252 | 2 | null | 43,093,400 | 1 | null | If anyone still is experiencing the issue, downgrading to opencv to 4.5.5.62 helped my case.
| null | CC BY-SA 4.0 | null | 2022-11-26T10:06:52.443 | 2022-11-26T10:06:52.443 | null | null | 12,244,825 | null |
74,581,235 | 2 | null | 9,581,592 | 0 | null | DYNAMIC IMAGE RESIZING SCRIPT - V2
The following script will take an existing JPG image, and resize it
using set options defined in your .htaccess file (while also providing
a nice clean URL to use when referencing the images)
Images will be cached, to reduce overhead, and will be updated only if
the image is newer than it's cached version.
The original script is from Timothy Crowe's 'veryraw' website, with
caching additions added by Trent Davies:
[http://veryraw.com/history/2005/03/image-resizing-with-php/](http://veryraw.com/history/2005/03/image-resizing-with-php/) <Not Work>
Further modifications to include antialiasing, sharpening, gif & png
support, plus folder structues for image paths, added by Mike Harding
[http://sneak.co.nz](http://sneak.co.nz) <Not Work>
For instructions on use, head to [http://sneak.co.nz](http://sneak.co.nz) <Not Work>
```
<?php
// max_width and image variables are sent by htaccess
$max_height = 1000;
$image = $_GET["imgfile"];
$max_width = $_GET["max_width"];
if (strrchr($image, '/')) {
$filename = substr(strrchr($image, '/'), 1); // remove folder references
} else {
$filename = $image;
}
$size = getimagesize($image);
$width = $size[0];
$height = $size[1];
// get the ratio needed
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
// if image already meets criteria, load current values in
// if not, use ratios to load new size info
if (($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
} else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
} else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
/* Caching additions by Trent Davies */
// first check cache
// cache must be world-readable
$resized = 'cache/'.$tn_width.'x'.$tn_height.'-'.$filename;
$imageModified = @filemtime($image);
$thumbModified = @filemtime($resized);
header("Content-type: image/jpeg");
// if thumbnail is newer than image then output cached thumbnail and exit
if($imageModified<$thumbModified) {
header("Last-Modified: ".gmdate("D, d M Y H:i:s",$thumbModified)." GMT");
readfile($resized);
exit;
}
// read image
$ext = substr(strrchr($image, '.'), 1); // get the file extension
switch ($ext) {
case 'jpg': // jpg
$src = imagecreatefromjpeg($image) or notfound();
break;
case 'png': // png
$src = imagecreatefrompng($image) or notfound();
break;
case 'gif': // gif
$src = imagecreatefromgif($image) or notfound();
break;
default:
notfound();
}
// set up canvas
$dst = imagecreatetruecolor($tn_width,$tn_height);
imageantialias ($dst, true);
// copy resized image to new canvas
imagecopyresampled ($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
/* Sharpening addition by Mike Harding */
// sharpen the image (only available in PHP5.1)
if (function_exists("imageconvolution")) {
$matrix = array( array( -1, -1, -1 ),
array( -1, 32, -1 ),
array( -1, -1, -1 ) );
$divisor = 24;
$offset = 0;
imageconvolution($dst, $matrix, $divisor, $offset);
}
// send the header and new image
imagejpeg($dst, null, -1);
imagejpeg($dst, $resized, -1); // write the thumbnail to cache as well...
// clear out the resources
imagedestroy($src);
imagedestroy($dst);
?>
```
| null | CC BY-SA 4.0 | null | 2022-11-26T10:04:00.953 | 2023-02-26T14:58:48.600 | 2023-02-26T14:58:48.600 | 13,302 | 14,585,422 | null |
74,581,442 | 2 | null | 26,570,194 | 0 | null | Make sure to add both with and without trailing '/' as redirect url.
```
http://localhost:8000/oauth/complete/linkedin-oauth2
http://localhost:8000/oauth/complete/linkedin-oauth2/
```
| null | CC BY-SA 4.0 | null | 2022-11-26T10:37:26.363 | 2022-11-26T10:37:26.363 | null | null | 12,754,117 | null |
74,581,644 | 2 | null | 74,581,611 | 0 | null | The pointer `p1` is declared like
```
int (*p1)[10];
```
In this assignment statement
```
p1=Arr1;
```
the pointer is assigned with an expression of the type `int *` due to the implicit conversion of the array designator to pointer to its first element of the type `int *`.
The pointer types of the operands are not compatible. So the compiler should issue a message.
You could either write
```
int (*p1)[10];
//...
p1 = &Arr1;
printf("1D Array is: \n");
for(i=0;i<n1;i++)
{
printf("Arr[%d] is %d\t", i, ( *p1 )[i] );
printf("\nAddress of %d th array is %p\n", i,( void * ) ( *p1 + i ) );
}
```
The expression with the subscript operator
```
( *p1 )[i]
```
is equivalent to
```
*( *p1 + i )
```
Or you could write
```
int *p1;
//...
p1 = Arr1;
printf("1D Array is: \n");
for(i=0;i<n1;i++)
{
printf("Arr[%d] is %d\t", i, p1[i]);
printf("\nAddress of %d th array is %p\n", i,( void * ) ( p1 + i));
}
```
I suppose that in the second call of `printf` you want to output the address of each element of the array..
| null | CC BY-SA 4.0 | null | 2022-11-26T11:11:56.097 | 2022-11-26T11:24:07.983 | 2022-11-26T11:24:07.983 | 2,877,241 | 2,877,241 | null |
74,581,653 | 2 | null | 74,577,546 | 0 | null |
# Introduction
Oracle has a helpful tutorial, [Creating a GUI With Swing](https://docs.oracle.com/javase/tutorial/uiswing/index.html). Skip the Learning Swing with the NetBeans IDE section.
I went ahead and created the following GUI. I didn't worry about making it pretty. I'll leave that as an exercise for you.
[](https://i.stack.imgur.com/fIgg0.png)
Here's the same GUI scrolled down a page.
[](https://i.stack.imgur.com/lUaCD.png)
# Explanation
The hardest part of coding this was creating the application model. Most of the code is devoted to creating the application model. Once I had the application model done, coding the GUI was straightforward. Using the model-view-controller (MVC) pattern makes creating a GUI so much easier.
## Model
The application model consists of three classes. `ExerciseModel` is the main plain Java getter/setter model class. It holds a `java.util.List` of `Exercise` instances and a `List` of `ExerciseType` instances.
`Exercise` is a plain Java getter/setter class that holds the results of one set of one exercise. I based this class on your original table image.
`ExerciseType` is a plain Java getter/setter class that holds a type of exercise.
## View
All Swing applications must start with a call to the `SwingUtilities` `invokeLater` method. This method ensures that the Swing components are created and executed on the [Event Dispatch Thread](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html).
I created a `JTablePanel` class to create the `JTable` `JPanel`. I made it a class because I was going to need as many instances of the class as there were exercise types.
The rest of the view is a straightforward creation of the `JFrame` and `JPanels`.
There are no controller classes in this example.
# Code
Here's the complete runnable code. I made all the additional classes inner classes so I could post the code as one block.
```
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
public class ExerciseGUI implements Runnable {
public static void main(String[] args) {
SwingUtilities.invokeLater(new ExerciseGUI());
}
private final ExerciseModel model;
public ExerciseGUI() {
this.model = new ExerciseModel();
}
@Override
public void run() {
JFrame frame = new JFrame("Exercise GUI");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(createMainPanel(), BorderLayout.CENTER);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
private JScrollPane createMainPanel() {
JPanel panel = new JPanel(new GridLayout(0, 1, 5, 5));
panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
Dimension tablePanelDimension = new Dimension(0, 0);
List<ExerciseType> exerciseTypes = model.getExerciseTypes();
for (ExerciseType exerciseType : exerciseTypes) {
JPanel tablePanel = new JTablePanel(model, exerciseType).getPanel();
tablePanelDimension = tablePanel.getPreferredSize();
panel.add(tablePanel);
}
JScrollPane scrollPane = new JScrollPane(panel);
scrollPane.setPreferredSize(new Dimension(tablePanelDimension.width + 50,
tablePanelDimension.height));
return scrollPane;
}
public class JTablePanel {
private final ExerciseModel model;
private final ExerciseType exerciseType;
private final JPanel panel;
public JTablePanel(ExerciseModel model, ExerciseType exerciseType) {
this.model = model;
this.exerciseType = exerciseType;
this.panel = createJTablePanel();
}
private JPanel createJTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 30, 5));
JLabel exerciseLabel = new JLabel(exerciseType.getExercise());
titlePanel.add(exerciseLabel);
JLabel bodyAreaLabel = new JLabel(exerciseType.getBodyArea());
titlePanel.add(bodyAreaLabel);
panel.add(titlePanel, BorderLayout.NORTH);
JTable table = new JTable(createTableModel());
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane, BorderLayout.CENTER);
return panel;
}
private DefaultTableModel createTableModel() {
DefaultTableModel tableModel = new DefaultTableModel();
tableModel.addColumn("Set");
tableModel.addColumn("Weight");
tableModel.addColumn("Reps");
for (Exercise exercise : model.getExercises()) {
if (exercise.getExercise().equals(exerciseType.getExercise())) {
Object[] rowData = new Object[3];
rowData[0] = exercise.getSet();
rowData[1] = exercise.getWeight();
rowData[2] = exercise.getReps();
tableModel.addRow(rowData);
}
}
return tableModel;
}
public JPanel getPanel() {
return panel;
}
}
public class ExerciseModel {
private final List<Exercise> exercises;
private final List<ExerciseType> exerciseTypes;
public ExerciseModel() {
this.exercises = createExercise();
this.exerciseTypes = createExerciseTypes(exercises);
}
private List<Exercise> createExercise() {
List<Exercise> exercises = new ArrayList<>();
exercises.add(new Exercise("Chest Press", "Chest", 1, 10, 12));
exercises.add(new Exercise("Chest Press", "Chest", 2, 10, 12));
exercises.add(new Exercise("Chest Press", "Chest", 3, 10, 12));
exercises.add(new Exercise("Chest Press", "Chest", 4, 10, 12));
exercises.add(new Exercise("Chest Press", "Chest", 5, 10, 12));
exercises.add(new Exercise("Deadlift", "Back", 1, 10, 70));
exercises.add(new Exercise("Deadlift", "Back", 2, 10, 70));
exercises.add(new Exercise("Deadlift", "Back", 3, 10, 70));
exercises.add(new Exercise("Deadlift", "Back", 4, 10, 70));
exercises.add(new Exercise("Deadlift", "Back", 5, 10, 70));
exercises.add(new Exercise("Kickbacks", "Tricept", 1, 10, 12));
exercises.add(new Exercise("Kickbacks", "Tricept", 2, 10, 12));
exercises.add(new Exercise("Kickbacks", "Tricept", 3, 10, 12));
exercises.add(new Exercise("Kickbacks", "Tricept", 4, 10, 12));
exercises.add(new Exercise("Kickbacks", "Tricept", 5, 10, 12));
return exercises;
}
private List<ExerciseType> createExerciseTypes(
List<Exercise> exercises) {
List<ExerciseType> exerciseTypes = new ArrayList<>();
String previousExercise = "", previousBodyArea;
for (Exercise exercise : exercises) {
if (!previousExercise.equals(exercise.getExercise())) {
previousExercise = exercise.getExercise();
previousBodyArea = exercise.getBodyArea();
exerciseTypes.add(new ExerciseType(previousExercise,
previousBodyArea));
}
}
return exerciseTypes;
}
public List<Exercise> getExercises() {
return exercises;
}
public List<ExerciseType> getExerciseTypes() {
return exerciseTypes;
}
}
public class Exercise {
private final int set, weight, reps;
private final String exercise, bodyArea;
public Exercise(String exercise, String bodyArea, int set, int reps,
int weight) {
this.exercise = exercise;
this.bodyArea = bodyArea;
this.set = set;
this.reps = reps;
this.weight = weight;
}
public int getSet() {
return set;
}
public int getWeight() {
return weight;
}
public int getReps() {
return reps;
}
public String getExercise() {
return exercise;
}
public String getBodyArea() {
return bodyArea;
}
}
public class ExerciseType {
private final String exercise, bodyArea;
public ExerciseType(String exercise, String bodyArea) {
this.exercise = exercise;
this.bodyArea = bodyArea;
}
public String getExercise() {
return exercise;
}
public String getBodyArea() {
return bodyArea;
}
}
}
```
| null | CC BY-SA 4.0 | null | 2022-11-26T11:13:19.477 | 2022-11-26T11:13:19.477 | null | null | 300,257 | null |
74,581,979 | 2 | null | 74,573,119 | 1 | null | Try to set `bg` variable as `''` before saving. But wait for canvas to be drawn again by `draw` function at least one time, and then call `saveCanvas`. you can bring back the bg after exporting the canvas.
```
function keyPressed() {
//if the key is a s
if (key == "s") {
//save out to a file
bg = "";
setTimeout(() => {
saveCanvas(canvas, "c", "png");
bg = loadImage("images/grid.png");
}, 1000);
}
}
```
| null | CC BY-SA 4.0 | null | 2022-11-26T11:59:49.227 | 2022-11-28T07:51:09.530 | 2022-11-28T07:51:09.530 | 1,213,181 | 1,213,181 | null |
74,582,104 | 2 | null | 67,320,990 | 0 | null | You have to do like this
```
OutlinedTextField(
...
colors = TextFieldDefaults.textFieldColors(
backgroundColor =Color.White
)
)
```
in order to set background Outline textfield
| null | CC BY-SA 4.0 | null | 2022-11-26T12:19:38.967 | 2022-11-29T20:47:44.933 | 2022-11-29T20:47:44.933 | 4,558,483 | 18,922,055 | null |
74,582,439 | 2 | null | 74,582,203 | 0 | null | This reshaping should really be done in PQ but if you insist on DAX, here you go.
```
Table =
VAR a = ADDCOLUMNS(
SUMMARIZE(Orange, Orange[Sum Value (Agg.)]),
"Item Name",
"Orange"
)
VAR b = ADDCOLUMNS(
SUMMARIZE(Apple, Apple[Sum Value (Agg.)]),
"Item Name",
"Apple"
)
RETURN UNION(a,b)
```
[](https://i.stack.imgur.com/y0MAY.png)
| null | CC BY-SA 4.0 | null | 2022-11-26T13:09:12.480 | 2022-11-26T13:09:12.480 | null | null | 18,345,037 | null |
74,582,454 | 2 | null | 74,582,277 | -1 | null | Probably your model is over-fitting the data:
[https://www.ibm.com/cloud/learn/overfitting#:~:text=Overfitting%20is%20a%20concept%20in,unseen%20data%2C%20defeating%20its%20purpose](https://www.ibm.com/cloud/learn/overfitting#:%7E:text=Overfitting%20is%20a%20concept%20in,unseen%20data%2C%20defeating%20its%20purpose).
A clear sign of over-fitting is when the is very low, but the are large.
Why does this happen? Well, neural networks have so many degrees-of-freedom that in some cases, they "memorize" the training data on a point-by-point basis, but they do not build internal rules to classify the data in a physical manner.
The best way to overcome this is to reduce the size of the neural network, to avoid having too many redundant degrees-of-freedom that contribute to over-fitting, or to introduce
[https://towardsdatascience.com/l1-and-l2-regularization-methods-ce25e7fc831c?gi=519207f1e90d](https://towardsdatascience.com/l1-and-l2-regularization-methods-ce25e7fc831c?gi=519207f1e90d)
Also, if you have any hints about a numerical or physical framework that is well-suited for your problem (for example, a special transformation for your input data), you should also consider adding it to the neural network manually. (This is recommeded in most PhD-level courses about machine learning).
| null | CC BY-SA 4.0 | null | 2022-11-26T13:11:13.230 | 2022-11-26T14:11:11.497 | 2022-11-26T14:11:11.497 | 874,188 | 4,667,669 | null |
74,582,571 | 2 | null | 27,753,344 | 0 | null | The answer is just for future visitors, since the question was asked long day ago. At first, I will just redirect you to my [GitHub page](https://github.com/b-Istiak-s/RetrofitRecyclerView/tree/master/app/src/main/java/com/istiak/getdatabyretrofit) where I used RecyclerView to show data and Retrofit to call data. I used [Volley](https://github.com/b-Istiak-s/RecyclerViewInMysqlDatabase/blob/master/app/src/main/java/com/istiak/recyclerviewinmysqldatabase/MainActivity.java) also. Finally, let me show simple way to load data to recyclerview.
You need an extra class call it CustomAdapter.
```
public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.MyViewHolder> {
Context context;
private String countryList[];
private int imgList[];
//constructor
public CustomAdapter(Context context, String countryList[],int imgList[]) {
this.context = context;
this.countryList = countryList;
this.imgList=imgList;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// inflate the item Layout
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.items, parent, false);
// set the view's size, margins, paddings and layout parameters
MyViewHolder vh = new MyViewHolder(view); // pass the view to View Holder
return vh;
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder myHolder, final int position) {
myHolder.txtName.setText(countryList[position]);
myHolder.imgCountry.setImageResource(imgList[position]);
// implement setOnClickListener event on item view.
myHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// display a toast with person name on item click
Toast.makeText(context, countryList[position], Toast.LENGTH_SHORT).show();
}
});
}
@Override
public int getItemCount() {
return countryList.length;
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView txtName;
ImageView imgCountry;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
// get the reference of item view's
txtName = itemView.findViewById(R.id.txt_name);
imgCountry = itemView.findViewById(R.id.img_flag);
}
}
}
```
And in the MainActivity, you have declare a LayoutManager for RecyclerView and have to call CustomAdapter to load data in RecyclerView.
```
String countryList[]={"Bangladesh","India","China","Australia","America","New Zealand","Portugal"};
int imgList[]={R.drawable.bd,R.drawable.india,R.drawable.china,R.drawable.australia,R.drawable.america,R.drawable.new_zealand,R.drawable.portugle};
RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get the reference of RecyclerView
recyclerView = findViewById(R.id.recycler_view);
// set a LinearLayoutManager with default vertical orientation
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
// set a LinearLayoutManager with default Horizontal orientation
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext(),LinearLayoutManager.HORIZONTAL,false);
recyclerView.setLayoutManager(linearLayoutManager);
// call the constructor of CustomAdapter to send the reference and data to Adapter
CustomAdapter customAdapter = new CustomAdapter(MainActivity.this,countryList, imgList);
recyclerView.setAdapter(customAdapter); // set the Adapter to RecyclerView
}
```
activity_main.xml :
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
```
items.xml
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/img_flag"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="5dp"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="10dp"
android:text="TextView"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
```
Here's the [github repository](https://github.com/b-Istiak-s/RecyclerView). If you are calling data from server then visit my Volley repo.
| null | CC BY-SA 4.0 | null | 2022-11-26T13:25:39.487 | 2022-11-26T13:25:39.487 | null | null | 16,241,416 | null |
74,582,814 | 2 | null | 72,809,319 | 0 | null | For anyone else that gets this issue. What happens is that you have a web site that is not even a web project in the VS sense and you open it from VS 2022. VS creates an empty web.config file on the fly and because it is empty, you see the error above. To fix this you should open the web.config in a text editor and just add an empty configuration element:
```
<configuration></configuration>
```
Save the web.config, and in VS, right-click the web site root and do 'Reload project'. That fixed it for me.
| null | CC BY-SA 4.0 | null | 2022-11-26T14:00:57.583 | 2022-11-26T14:00:57.583 | null | null | 81,317 | null |
74,582,897 | 2 | null | 28,385,172 | 0 | null | go to Build-> Clean Project
| null | CC BY-SA 4.0 | null | 2022-11-26T14:13:54.270 | 2022-11-26T14:13:54.270 | null | null | 20,406,746 | null |
74,582,898 | 2 | null | 69,543,665 | 0 | null | This debugging error might happen when you pass a smart pointer (CComPtr) to COM like so:
```
CComPtr<IUIAutomationElement> root, navigation, editbox;
CComPtr<IUIAutomationCondition> c1, c2;
// Find root from hwnd handle
if (FAILED(uia->ElementFromHandle(hwnd, &root))) // Here, we pass an IUIAutomationElement as input.
cout << "Something Error." << endl;
```
When you pass a CComPtr as an input, you must release that smart pointer before using it again like so:
```
root.Release();
```
Not only for that smart pointer, but for any smart pointer you pass as an input you should release it before using again.
See this MSDN link: [Debug Assertion Error when debugging CComPtr](https://social.msdn.microsoft.com/Forums/vstudio/en-US/da2af9b8-9cfa-47e8-ae51-8867ee164993/debug-assertion-error-when-debugging-a-ccomptr-no-clue-as-to-why-it-gives-me-that?forum=vcgeneral)
Learn more about CComPtr and smart pointers here: [COM Coding Practices](https://learn.microsoft.com/en-us/windows/win32/learnwin32/com-coding-practices)
| null | CC BY-SA 4.0 | null | 2022-11-26T14:13:59.857 | 2022-11-26T14:13:59.857 | null | null | 16,216,985 | null |
74,582,915 | 2 | null | 74,582,868 | 1 | null | How about changing your strategy and doing it like this:
```
morning_list= []
midday_list= []
night_list= []
time_dict = dict()
with open("stats.csv", "r") as data_file:
headers = data_file.readline()
for line in data_file:
Time, VS = line.split(",")
if Time == "morning":
morning_list.append(int(VS))
elif Time == "midday":
midday_list.append(int(VS))
elif Time == "night":
night_list.append(int(VS))
time_dict["morning"] = morning_list
time_dict["midday"] = midday_list
time_dict["night"] = night_list
```
| null | CC BY-SA 4.0 | null | 2022-11-26T14:16:33.547 | 2022-11-26T17:48:10.157 | 2022-11-26T17:48:10.157 | 17,580,723 | 17,580,723 | null |
74,583,010 | 2 | null | 74,582,868 | 1 | null | I would do it this way:
```
import csv
with open(fn) as csv_in:
reader=csv.reader(csv_in)
header=next(reader)
data={}
for t,vs in reader:
data.setdefault(t, []).append(int(vs))
```
---
From comment "I can't use imports":
```
with open(fn) as csv_in:
header=next(csv_in)
data={}
for t,vs in (line.split(',') for line in csv_in):
data.setdefault(t, []).append(int(vs))
```
From comment "The data is in the eighth column":
With a slight modification (and assuming Python 3) you can set `*vs` so that `vs` accepts a variable number in the expansion:
```
with open(fn) as csv_in:
header=next(csv_in)
data={}
for t,*vs in (line.split(',') for line in csv_in):
data.setdefault(t, []).append(int(vs[7]))
```
Given this file:
```
Time,VS
morning,1,2,3,4,5,6,7,80
morning,1,2,3,4,5,6,7,81
midday,1,2,3,4,5,6,7,90
midday,1,2,3,4,5,6,7,91
night,1,2,3,4,5,6,7,100
night,1,2,3,4,5,6,7,101
```
Prints:
```
>>> data
{'morning': [80, 81], 'midday': [90, 91], 'night': [100, 101]}
```
| null | CC BY-SA 4.0 | null | 2022-11-26T14:29:30.680 | 2022-11-26T14:51:45.303 | 2022-11-26T14:51:45.303 | 298,607 | 298,607 | null |
74,583,094 | 2 | null | 44,640,911 | 0 | null | Worked for me with
font = cv2.FONT_HERSHEY_SIMPLEX
as the best answer suggested.
| null | CC BY-SA 4.0 | null | 2022-11-26T14:41:16.717 | 2022-11-26T14:41:16.717 | null | null | 7,127,756 | null |
74,583,583 | 2 | null | 74,583,363 | 1 | null | In your example the process might get stuck as you are not reading it's stdout and stderr streams. From the [Process documentation](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Process.html):
So essentially you are just asking how to execute a process from Java. It is irrelevant that to the user your program would display a terminal-like UI. Knowing this we could rephrase your question and find answers like
- [Starting a process in Java?](https://stackoverflow.com/questions/3774432/starting-a-process-in-java)- [Java Execute a bash script using Java process builder](https://stackoverflow.com/questions/24814966/java-execute-a-bash-script-using-java-process-builder)- [Execute process from Java irrespective of underlying OS](https://stackoverflow.com/questions/18655538/execute-process-from-java-irrespective-of-underlying-os)- [Java ProcessBuilder - get Output immediately](https://stackoverflow.com/questions/45050390/java-processbuilder-get-output-immediately)- [https://alvinalexander.com/java/java-exec-processbuilder-process-1/](https://alvinalexander.com/java/java-exec-processbuilder-process-1/)
| null | CC BY-SA 4.0 | null | 2022-11-26T15:51:54.107 | 2022-11-26T15:57:15.823 | 2022-11-26T15:57:15.823 | 4,222,206 | 4,222,206 | null |
74,583,853 | 2 | null | 58,052,323 | 0 | null | The problem is that you put the label into the parent window, and not into the ttk frame. This is why the background color is different. You should set `self`as the parent for the label.
```
ttk.Label(self, text="Youtube Url").pack(side='top', anchor='w', **paddings)
```
| null | CC BY-SA 4.0 | null | 2022-11-26T16:28:45.063 | 2022-11-26T16:28:45.063 | null | null | 15,488,879 | null |
74,583,945 | 2 | null | 74,561,138 | 0 | null | If you just remove `knit: pagedown::chrome_print` the document will render to HTML just fine, Then from here, you can `"print to PDF"` from the browser to get both an HTML and a PDF doc of the output
```
---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
number_sections: FALSE
---
```
I think the issue might be your are specifying 2 different output formats, and Rmarkdown is taking a long time to render these
There is a similar issue discussed [here](https://github.com/rstudio/pagedown/issues/157) the advice was to increase the `timeout` value, as it's default is 30 seconds until the process is fails out. and another similar issue [here](https://community.rstudio.com/t/not-able-to-produce-paged-pdf-document-when-trying-to-render-html-paged-rmarkdown-document-using-parameters/80677)... but to be honest, I was not able to correct apply the `timeout` argument in `chrome_print`
[](https://i.stack.imgur.com/r7HWS.png)
| null | CC BY-SA 4.0 | null | 2022-11-26T16:42:21.447 | 2022-11-26T16:42:21.447 | null | null | 7,401,037 | null |
74,584,109 | 2 | null | 74,582,936 | 3 | null | You could try this little function which should work irrespective of the starting colour.
```
de_alpha <- function(col) {
col <- col2rgb(col, alpha = TRUE)
alpha <- col[4,]
col <- col[1:3,]
whiteness <- (255 - alpha)/255
do.call(rgb, as.list((col + (255 - col) * whiteness)/255))
}
```
This works on green giving the same result:
```
transparent_green <- scales::alpha("green", 0.3)
nontransparent_green <- de_alpha(transparent_green)
scales::show_col(c(transparent_green, nontransparent_green))
```

But also works on your grey example:
```
transparent_grey <- scales::alpha("grey10", 0.3)
nontransparent_grey <- de_alpha(transparent_grey)
scales::show_col(c(transparent_grey, nontransparent_grey))
```

[reprex v2.0.2](https://reprex.tidyverse.org)
| null | CC BY-SA 4.0 | null | 2022-11-26T17:04:14.130 | 2022-11-26T17:04:14.130 | null | null | 12,500,315 | null |
74,584,363 | 2 | null | 27,997,485 | 0 | null | I had the same problem, but in MacOS using NSOpenPanel. My problem was a timer used for TCP keep-alive which would not fire, and I would lose connection with my devices if the panel was open too long. My app would reconnect once I closed the panel, but was now in the wrong state. Just adding the code as recommended above fixed the problem.
```
RunLoop.main.add(timer, forMode: .common)
```
| null | CC BY-SA 4.0 | null | 2022-11-26T17:40:11.123 | 2022-11-26T17:40:11.123 | null | null | 2,741,483 | null |
74,584,659 | 2 | null | 74,583,967 | 1 | null | If its specifically for the select tag
add this CSS
```
.form-select.is-valid:not([multiple]):not([size]), .form-select.is-valid:not([multiple])[size="1"], .was-validated .form-select:valid:not([multiple]):not([size]), .was-validated .form-select:valid:not([multiple])[size="1"] {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}
```
| null | CC BY-SA 4.0 | null | 2022-11-26T18:27:54.157 | 2022-11-26T18:27:54.157 | null | null | 9,677,279 | null |
74,584,747 | 2 | null | 74,584,600 | 1 | null | You need to run php on a local server. PHP cannot be run anywhere on your document. You need to install xampp or apache.
| null | CC BY-SA 4.0 | null | 2022-11-26T18:42:57.150 | 2022-11-26T18:42:57.150 | null | null | 1,131,888 | null |
74,584,943 | 2 | null | 74,584,147 | 0 | null | You have a typo: "Ligth" should be "Light".
| null | CC BY-SA 4.0 | null | 2022-11-26T19:14:50.927 | 2022-11-26T19:14:50.927 | null | null | 2,060,725 | null |
74,585,303 | 2 | null | 71,564,028 | 2 | null | I updated mui's packages, using:
`yarn upgrade @mui/icons-material @mui/material @mui/styles --latest` since I was using material-table 2.0.2.
then don't froget to wrap the table with the ThemeProvider: ( THANKS @nikried FOR your answer, it was very helpful! )
```
import * as React from 'react';
import MaterialTable from 'material-table';
import { ThemeProvider, createTheme } from '@mui/material';
export function SimpleExample () {
const defaultMaterialTheme = createTheme();
return(
<div style={{ width: '100%', height: '100%' }}>
<ThemeProvider theme={defaultMaterialTheme}>
<MaterialTable
columns={columns}
data={data}
/>
</ThemeProvider>
</div>
);
}
}
```
if you have other problems, don't forget to check the peerDependencies of material-table inside node_modules, and try to use the same package's version montioned to avoid all the possible conflicts.
| null | CC BY-SA 4.0 | null | 2022-11-26T20:13:49.980 | 2022-11-26T20:13:49.980 | null | null | 13,357,753 | null |
74,585,425 | 2 | null | 74,585,281 | 1 | null | You are overthinking some parts of your program.
The `recursive_circles()` function only needs to draw its own circle, move to other relative positions and call `recursive_circles()` to draw all the other circles down from there,
Also the radius should be halved in size on forward calls.
```
import turtle
def centered_circle(circle_radius, turtle):
turtle.penup()
turtle.forward(circle_radius)
turtle.left(90)
turtle.pendown()
turtle.circle(circle_radius)
turtle.penup()
turtle.right(90)
turtle.backward(circle_radius)
turtle.penup()
def recursive_circles(circle_radius, turtle):
if circle_radius > 2:
centered_circle(circle_radius, turtle)
turtle.left(90)
turtle.forward(circle_radius * 1.5)
recursive_circles(circle_radius * 0.5, turtle) #Recursive call
turtle.backward(circle_radius * 1.5)
turtle.right(180)
turtle.forward(circle_radius * 1.5)
recursive_circles(circle_radius * 0.5, turtle) #Recursive call
turtle.backward(circle_radius * 1.5)
turtle.left(90)
turtle.forward(circle_radius * 1.5)
recursive_circles(circle_radius * 0.5, turtle) #Recursive call
turtle.backward(circle_radius * 1.5)
def main():
# Set up the turtle and window
recursive_turtle = turtle.Turtle()
recursive_turtle.speed(0)
recursive_turtle.hideturtle()
myWin = turtle.Screen()
# Draw the circles
recursive_turtle.penup()
recursive_turtle.goto(0, 100)
recursive_turtle.setheading(90)
recursive_circles(50, recursive_turtle)
myWin.exitonclick()
if __name__ == "__main__":
main()
```
| null | CC BY-SA 4.0 | null | 2022-11-26T20:33:09.163 | 2022-11-26T20:33:09.163 | null | null | 4,834 | null |
74,585,467 | 2 | null | 74,583,489 | 1 | null | You can make this work with a little VBA;
Setup the sheet like below with a cell (in green) in which to select a student name from a drop down (data validation) and a button to click to implement the filtering
[](https://i.stack.imgur.com/UXmq9.png)
Then name the button as GoButn and add the code below to the Sheet
```
Private Sub GoButn_Click()
Dim SrchFor As String
ActiveSheet.AutoFilter.ShowAllData
SrchFor = "*" & Trim(Range("G2").Text) & "*"
ActiveSheet.Range("MissingPPL").AutoFilter Field:=5, Criteria1:=SrchFor, Operator:=xlAnd
End Sub
```
In the above code the Green cell is "G2" and the Table has been named "MissingPPL"
Example below of selecting Jill and clicking Go
[](https://i.stack.imgur.com/vXwwH.png)
Hope this helps
| null | CC BY-SA 4.0 | null | 2022-11-26T20:44:44.930 | 2022-11-26T20:51:32.790 | 2022-11-26T20:51:32.790 | 1,302,114 | 1,302,114 | null |
74,585,553 | 2 | null | 60,160,453 | 0 | null | For Mac users do these steps:
Actually the issue is all because you have .git folder in your main root, so to solve this issue do these steps:
1-Open your terminal and go to your main computer root.
2-Write this >> git ls -a to find all hidden files and folders, .git will be one of them.
3-Then write this rm -rf .git to remove .git folder. Dont worry it will not ruin anything.
4-Now reopen your current project you see your source control on Visual Studio is clean.
DONE
| null | CC BY-SA 4.0 | null | 2022-11-26T21:00:30.053 | 2022-11-26T21:06:02.330 | 2022-11-26T21:06:02.330 | 16,957,724 | 16,957,724 | null |
74,585,737 | 2 | null | 74,585,668 | 0 | null | From the PHP manua:
> When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
[https://www.php.net/manual/function.mail.php](https://www.php.net/manual/function.mail.php)
| null | CC BY-SA 4.0 | null | 2022-11-26T21:35:18.230 | 2022-11-26T21:35:18.230 | null | null | 17,637,456 | null |
74,585,789 | 2 | null | 74,585,759 | 1 | null | Try something like this:
```
def main():
with open('Bayofagbenro.txt', 'w') as f:
f.write('Modupeola\n')
f.write('Ayobami\n')
f.write('AKintola\n')
f.write('Omonike\n')
f.write('Fehintoluwa\n')
f.write('Modupeola is 44yrs, Ayobami is 42 years, AKintola is 38 years, omonike is 36 years while fehintoluwa is 30 years')
```
| null | CC BY-SA 4.0 | null | 2022-11-26T21:41:58.823 | 2022-11-26T21:41:58.823 | null | null | 16,024,450 | null |
74,585,948 | 2 | null | 74,585,793 | 0 | null | In the inner query count the number of travels for each user using `group by`, after that you can do the final aggregations.
```
select
avg(cnt) as average,
max(cnt) as maximum,
sum(cnt) as total
from (
select
USER_ID,
count(TRAVEL_ID) as cnt
from TRAVELS
group by
USER_ID
) as a
```
| null | CC BY-SA 4.0 | null | 2022-11-26T22:10:00.170 | 2022-11-26T22:10:00.170 | null | null | 12,348,098 | null |
74,585,955 | 2 | null | 74,585,652 | 1 | null | This can be done with grid layout. If you don’t know about it, here is the link I used to learn grid layout in css:
[https://cssgridgarden.com/](https://cssgridgarden.com/)
| null | CC BY-SA 4.0 | null | 2022-11-26T22:11:42.420 | 2022-11-26T22:11:42.420 | null | null | 13,970,434 | null |
74,586,079 | 2 | null | 74,585,652 | 1 | null | Here a simple example
```
#container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows:auto;
height: 600px;
width: 300px;
border-radius: 35px;
background-color: red;
}
.photo {
width: 100%;
height: 100%;
background-color: blue;
border-radius: 10px;
border: 2.5px solid white;
}
.photo.big {
grid-column-start:2;
grid-column-end: span 2;
grid-row-start:2;
grid-row-end: span 2;
background-color: green;
border-radius: 10px;
border: 2.5px solid white;
}
```
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Document</title>
</head>
<body>
<div id="container">
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo big"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
</div>
</body>
</html>
```
| null | CC BY-SA 4.0 | null | 2022-11-26T22:34:06.107 | 2022-11-26T22:34:06.107 | null | null | 13,258,195 | null |
74,586,152 | 2 | null | 74,585,842 | 0 | null | I think you should use a subplots: Check this link, and see the examples.
[Subplots](https://plotly.com/python/subplots/)
| null | CC BY-SA 4.0 | null | 2022-11-26T22:45:28.670 | 2022-11-26T22:45:28.670 | null | null | 13,954,475 | null |
74,586,350 | 2 | null | 13,931,049 | 1 | null | You need to go from "data view" on the bottom tab to "variable view". Then you will look up and change the "type" from "string" to "numeric".
| null | CC BY-SA 4.0 | null | 2022-11-26T23:21:06.737 | 2022-11-26T23:21:06.737 | null | null | 20,610,178 | null |
74,586,548 | 2 | null | 74,586,523 | 2 | null | ```
(p1a | (p2 / p3)) + plot_layout(guides = 'collect')
```
[](https://i.stack.imgur.com/tCyZJ.png)
Without the parentheses, the plot_layout() will only relate to the immediately preceding term, `(p2 / p3)`. From the documentation for `plot_layout()`:
> If you are nesting grids, the layout is scoped to the current nesting
level.
I think in this case "the current nesting level" will be the most recent term.
| null | CC BY-SA 4.0 | null | 2022-11-27T00:09:44.400 | 2022-11-27T00:09:44.400 | null | null | 6,851,825 | null |
74,586,686 | 2 | null | 74,586,467 | 0 | null | You can use `moviepy.video.fx.all.crop`. Documentation are [here](https://zulko.github.io/moviepy/ref/videofx/moviepy.video.fx.all.crop.html). For example,
```
import moviepy.editor as mpy
from moviepy.video.fx.all import crop
clip = mpy.VideoFileClip("path/to/video.mp4")
(w, h) = clip.size
crop_width = h * 9/16
# x1,y1 is the top left corner, and x2, y2 is the lower right corner of the cropped area.
x1, x2 = (w - crop_width)//2, (w+crop_width)//2
y1, y2 = 0, h
cropped_clip = crop(clip, x1=x1, y1=y1, x2=x2, y2=y2)
# or you can specify center point and cropped width/height
# cropped_clip = crop(clip, width=crop_width, height=h, x_center=w/2, y_center=h/2)
cropped_clip.write_videofile('path/to/cropped/video.mp4')
```
The code is not tested. If there is any further question, please let me know.
| null | CC BY-SA 4.0 | null | 2022-11-27T00:45:20.743 | 2022-11-27T00:45:20.743 | null | null | 20,566,440 | null |
74,587,158 | 2 | null | 74,585,842 | 1 | null | The only functions to adjust the spacing of bars in plotly are the spacing of bars and the type of spacing within a group. So you can force spacing by inserting a null-valued graph in between.
```
fig.update_layout(barmode='group', bargroupgap=0.2)
```
[](https://i.stack.imgur.com/x4Ekq.png)
```
fig = go.Figure()
fig.add_trace(go.Bar(
x = names,
y = values1,
legendgroup="group",
legendgrouptitle_text="method one",
name="first"
))
fig.add_trace(go.Bar(
x=names,
y=values2,
legendgroup="group",
name="second"
))
# add bar plot(null data)
fig.add_trace(go.Bar(
x=names,
y=np.full((1,51),np.NaN),
showlegend=False,
))
fig.add_trace(go.Bar(
x=names,
y=values3,
legendgroup="group2",
legendgrouptitle_text="method two",
name="first"
))
fig.add_trace(go.Bar(
x=names,
y=values4,
legendgroup="group2",
name="second"
))
fig.update_layout(barmode='group')#, bargroupgap=0.2
fig.update_traces(texttemplate='%{y:.2}', textposition='inside')
fig.show()
```
[](https://i.stack.imgur.com/wNwoB.png)
| null | CC BY-SA 4.0 | null | 2022-11-27T02:53:15.097 | 2022-11-27T02:53:15.097 | null | null | 13,107,804 | null |
74,587,332 | 2 | null | 74,587,297 | 3 | null | ```
library(dplyr)
df %>%
group_by(col2) %>%
mutate(rem_val = 40 - cumsum(lag(col1, default = 0))) %>%
ungroup()
```
| null | CC BY-SA 4.0 | null | 2022-11-27T03:42:21.627 | 2022-11-27T03:42:21.627 | null | null | 6,851,825 | null |
74,587,381 | 2 | null | 74,587,297 | 0 | null | Here is another option.
```
library(tidyverse)
df |>
group_by(col2) |>
mutate(rem_val = Reduce("-", head(col1, n()-1), accumulate = TRUE, init = 40))
#> # A tibble: 14 x 3
#> # Groups: col2 [4]
#> col1 col2 rem_val
#> <dbl> <dbl> <dbl>
#> 1 2 1 40
#> 2 3 1 38
#> 3 6 1 35
#> 4 1 1 29
#> 5 8 2 40
#> 6 4 2 32
#> 7 8 2 28
#> 8 2 3 40
#> 9 4 3 38
#> 10 5 3 34
#> 11 7 3 29
#> 12 4 4 40
#> 13 2 4 36
#> 14 7 4 34
```
| null | CC BY-SA 4.0 | null | 2022-11-27T03:54:16.220 | 2022-11-27T03:54:16.220 | null | null | 9,778,513 | null |
74,587,487 | 2 | null | 16,875,466 | 0 | null | Another belated idea, it may help in cases where gaps aren't too big:
If the total width of the gaps between images doesn't exceed one image width you can use
```
background-repeat: space;
```
[background-repeat on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat#repeat-style)
| null | CC BY-SA 4.0 | null | 2022-11-27T04:24:42.367 | 2022-11-27T04:24:42.367 | null | null | 107,300 | null |
74,587,545 | 2 | null | 74,587,419 | 0 | null | This is JSDocs and is coming from the `node_modules/@nestjs/common/decorators/core/controller.decorator.d.ts`
If you Ctrl + Click on `@Controller` (Go to Definition) you should get:
```
/**
* Decorator that marks a class as a Nest controller that can receive inbound
* requests and produce responses.
*
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
* It defines a class that provides the context for one or more related route
* handlers that correspond to HTTP request methods and associated routes
* for example `GET /api/profile`, `POST /users/resume`.
*
* A Microservice Controller responds to requests as well as events, running over
* a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
* It defines a class that provides a context for one or more message or event
* handlers.
*
* @see [Controllers](https://docs.nestjs.com/controllers)
* @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
*
* @publicApi
*/
export declare function Controller(): ClassDecorator;
```
This means that you have `@nestjs/common` package installed in your local repository.
| null | CC BY-SA 4.0 | null | 2022-11-27T04:40:10.727 | 2022-11-27T04:40:10.727 | null | null | 9,486,457 | null |
74,588,019 | 2 | null | 65,503,907 | 0 | null | I've been in situations where I've tried to specify the python version when creating the environment for conda.
```
conda env create -f environment.yml python={version}
```
It would usually install the latest version and ignore my command.
[](https://i.stack.imgur.com/pxz0Q.png)
To resolve this I activate my environment:
`conda activate ${env}`
Then I install the right version:
`conda install python=3.9.12 -y`
The key or big take away that I gathered is in the VSCode UI it gives me the option to select my kernel environment & it also gives me the path to that environment. When I went in to that directory the python version was not there. So...install it, reboot VScode.
| null | CC BY-SA 4.0 | null | 2022-11-27T06:34:42.793 | 2022-11-27T06:34:42.793 | null | null | 3,738,936 | null |
74,588,401 | 2 | null | 74,586,362 | 1 | null | In 2D You just displace the cuts in perpendicular direction to the cut line. If your cut line endpoints are: `p0(x0,y0),p1(x1,y1)` then the line direction is:
```
dp = p1-p0 = (x1-x0,y1-y0)
```
make it unit:
```
dp /= sqrt((dp.x*dp.x)+(dp.y*dp.y)
```
make it equal to half of the gap between cuts:
```
dp *= 0.5*gap
```
now tere are two perpendicular directions:
```
d0 = (-dp.y,+dp.x)
d1 = (+dp.y,-dp.x)
```
so now just add `d0` to all vertexes of one cut, and `d1` to the other one. Which use for which is simply you take point that does not lie on the cutting line (for example avg point of your cut) `p` and compute (only once for polygon cut):
```
t = dot(p-p0,d0) = ((p.x-x0)*d0.x)+((p.y-y0)*d0.y)
```
if `(t>0)` use `d0`, if `(t<0)` use `d1` and if `(t==0)` you chose wrong point `p` as it lies on cutting line.
| null | CC BY-SA 4.0 | null | 2022-11-27T07:56:15.817 | 2022-11-27T07:56:15.817 | null | null | 2,521,214 | null |
74,588,767 | 2 | null | 74,588,655 | 0 | null | You need to use DIR, also you have only one level "../"
```
include __DIR__ . '/../db/db_connection.php';
```
But it`s better to use for config files
| null | CC BY-SA 4.0 | null | 2022-11-27T09:08:41.693 | 2022-11-27T09:08:41.693 | null | null | 4,546,382 | null |
74,588,803 | 2 | null | 74,588,655 | 0 | null | You may check you file location first, `include()` and its relatives take filesystem paths, not web paths relative to the document root.
To get the parent directory `use ../`
```
include('../db/db_connection.php');
include('../../db/db_connection.php');
```
| null | CC BY-SA 4.0 | null | 2022-11-27T09:15:21.570 | 2022-11-27T09:16:00.730 | 2022-11-27T09:16:00.730 | 8,521,049 | 8,521,049 | null |
74,588,847 | 2 | null | 74,588,534 | 0 | null | The best way to send/store data in real-time database is to create an object of
Hashmap. Below is the code to achieve this objective
```
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
HashMap<String, Object> data = new HashMap<>();
data.put("Actual amount", Your actual amount);
data.put("Current reading", Your current reading);
data.put("Employee", Employee name);
databaseReference.child("The child name")
.updateChildren(data)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
Log.d("TAG", "Data added successfully");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d("TAG", "Failed " + e.getMessage());
}
});
```
| null | CC BY-SA 4.0 | null | 2022-11-27T09:23:11.993 | 2022-11-27T15:30:12.397 | 2022-11-27T15:30:12.397 | 209,103 | 17,983,433 | null |
74,588,951 | 2 | null | 74,588,908 | 0 | null | You can set your color to the `menuBackgroundColor` property of the ZoomDrawer class as:
```
ZoomDrawer(menuBackgroundColor: <your color>);
```
:
```
ZoomDrawer(menuBackgroundColor: Colors.red);
```
| null | CC BY-SA 4.0 | null | 2022-11-27T09:43:02.270 | 2022-11-27T09:43:02.270 | null | null | 5,882,307 | null |
74,588,984 | 2 | null | 74,588,319 | 1 | null | First I generated some random reproducible data. You could directly generate dates in your `ts` with `as.Date`. After that you need to convert the time series to a date format. To show the axis with month/weeks dates, you can use `scale_x_date` with `date_labels` form week and month. Here is a reproducible example:
```
library(ggplot2)
# Generate random reproducible data
set.seed(1)
DUMMYDATA <- cumsum(rnorm(10000))
TS1<-ts(DUMMYDATA, frequency = 52, start = as.Date('2015-02-01'), end = as.Date('2016-09-01'))
# Convert to dataframe
data = data.frame(y=as.matrix(TS1), date=time(TS1))
# convert date to date format
data$date <- as.Date(as.numeric(time(data$date)), origin = "1970-01-01")
ggplot(data, aes(x = date, y = y)) +
geom_line() +
scale_x_date(date_labels = "%b-%W",
date_breaks = '1 week') +
guides(x = guide_axis(angle = 90)) +
theme_bw()
```

[reprex v2.0.2](https://reprex.tidyverse.org)
If you don't want to show each week, you can change `date_breaks` to months like this:
```
library(ggplot2)
ggplot(data, aes(x = date, y = y)) +
geom_line() +
scale_x_date(date_labels = "%b-%W",
date_breaks = '1 month') +
guides(x = guide_axis(angle = 90)) +
theme_bw()
```

[reprex v2.0.2](https://reprex.tidyverse.org)
| null | CC BY-SA 4.0 | null | 2022-11-27T09:48:15.100 | 2022-11-27T09:48:15.100 | null | null | 14,282,714 | null |
74,589,250 | 2 | null | 51,508,415 | 0 | null | What worked for me was following all these instructions ([https://www.listendata.com/2019/06/create-infographics-with-r.html](https://www.listendata.com/2019/06/create-infographics-with-r.html)) BUT installing the FontAwesome package 4.7 that you can download here ([https://fontawesome.com/versions](https://fontawesome.com/versions)). Otherwise I think it seems newer packages have a different font/family name (Free Reegular version whatever) that waffle can not read.
I would say main points are:
- - [https://stackoverflow.com/a/70386036/4438465](https://stackoverflow.com/a/70386036/4438465)-
| null | CC BY-SA 4.0 | null | 2022-11-27T10:33:53.360 | 2022-11-27T10:33:53.360 | null | null | 4,438,465 | null |
74,589,262 | 2 | null | 72,532,485 | 0 | null | My error was after a failed previous install with WSL... so same on windows, only:
```
cd /home
sudo rm -rf homebrew/
```
| null | CC BY-SA 4.0 | null | 2022-11-27T10:35:32.487 | 2022-11-27T10:35:32.487 | null | null | 12,131,466 | null |
74,589,266 | 2 | null | 74,565,247 | -1 | null | you can use video of this progress bar loading using MediaPlayer library in swift and i sure it will work :)
| null | CC BY-SA 4.0 | null | 2022-11-27T10:36:16.830 | 2022-11-27T10:36:16.830 | null | null | 20,613,515 | null |
74,589,268 | 2 | null | 74,580,643 | 0 | null | u can easily add
```
.setSmallIcon(android.R.color.transparent)
```
or create custom notification, check this doc out:
[https://developer.android.com/develop/ui/views/notifications/custom-notification](https://developer.android.com/develop/ui/views/notifications/custom-notification)
also this is an article about custom notification:
[https://medium.com/hootsuite-engineering/custom-notifications-for-android-ac10ca67a08c](https://medium.com/hootsuite-engineering/custom-notifications-for-android-ac10ca67a08c)
| null | CC BY-SA 4.0 | null | 2022-11-27T10:36:31.443 | 2022-11-27T10:36:31.443 | null | null | 7,593,474 | null |
74,589,476 | 2 | null | 74,588,319 | 1 | null | One way to do this is to use a `tsibble` object rather than a `ts` object. Here is an example:
```
library(ggplot2)
library(tsibble)
library(lubridate)
library(feasts)
set.seed(1)
df <- tsibble(
Week = yearweek(seq(as.Date("2015-01-01"), length=300, by="7 days")),
TS1 = cumsum(rnorm(300))
)
#> Using `Week` as index variable.
df |> autoplot(TS1) +
scale_x_yearweek(date_breaks = '1 year')
```

[reprex v2.0.2](https://reprex.tidyverse.org)
It appears that you are using the `forecast` package to create forecasts from `ts` objects. The equivalent functionality is provided in the `fable` package to create forecasts from `tsibble` objects. See [my book](https://OTexts.com/fpp3) for lots of examples, including using weekly data.
| null | CC BY-SA 4.0 | null | 2022-11-27T11:04:35.730 | 2022-11-27T11:04:35.730 | null | null | 144,157 | null |
74,589,600 | 2 | null | 74,589,140 | 1 | null | This should work. I just removed the .join() function and created the appending with a loop instead.
```
@bot.command()
async def habbo(ctx):
response = requests.get("https://images.habbo.com/habbo-web-leaderboards/hhes/visited-rooms/daily/latest.json")
data = response.json()
count = 0
content = ""
for item in data:
count = count + 1
item = item["name"]
content = content + f"\n{count} - {item}\n"
embed = discord.Embed(title=f"", description=f"{content}", color=discord.Colour.random())
await ctx.send(embed=embed)
```
| null | CC BY-SA 4.0 | null | 2022-11-27T11:23:51.460 | 2022-11-27T11:23:51.460 | null | null | 15,869,190 | null |
74,590,079 | 2 | null | 67,466,745 | 0 | null | Use this in settings.json when using c++
".cpp":"echo -e",
| null | CC BY-SA 4.0 | null | 2022-11-27T12:39:41.413 | 2022-11-27T12:44:54.680 | 2022-11-27T12:44:54.680 | 20,614,409 | 20,614,409 | null |
74,590,139 | 2 | null | 74,588,534 | 0 | null | The add data to the Realtime Database you need to use [setValue()](https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference#setValue(java.lang.Object)) method. In code
```
DatabaseReference pay_details = database.getReference("pay/0/0/");
HashMap<String, Object> map = new HashMap<>();
map.put("fieldName", "fieldValue");
pay_details.setValue(map).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Data added successfully.");
} else {
Log.d(TAG, task.getException().getMessage()); //Never ignore potential errors!
}
}
});
```
If you want to add multiple children, then you can also use [push()](https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference#push()).
| null | CC BY-SA 4.0 | null | 2022-11-27T12:47:21.553 | 2022-11-27T12:47:21.553 | null | null | 5,246,885 | null |
74,590,183 | 2 | null | 74,590,059 | 0 | null | You want to concat the output of the models, that is `base_model1.output` and `base_model2.output`. They differ in the shape, so you have to flatten them before concatenating:
```
output = Concatenate()([Flatten()(base_model1.output), Flatten()(base_model2.output)])
output = Dropout(0.8)(output)
output = Dense(1, activation='sigmoid')(output)
combine = Model(inputs = input, outputs = output)
```
| null | CC BY-SA 4.0 | null | 2022-11-27T12:52:43.630 | 2022-11-27T12:52:43.630 | null | null | 7,246,805 | null |
74,590,469 | 2 | null | 67,491,546 | 0 | null | Actually quite a simple way of adding spam
```
import asyncio
@bot.command(name='spam', help= "Spam to your heart's delight")
async def spam(ctx, thing, amount):
count = 0
while count < int(amount):
await ctx.send(thing)
count += 1
if count < amount:
await asyncio.sleep(1)
```
| null | CC BY-SA 4.0 | null | 2022-11-27T13:35:41.497 | 2022-11-27T13:35:41.497 | null | null | 20,614,593 | null |
74,591,143 | 2 | null | 74,590,876 | 0 | null | In your case the isssue is:
> .
Required: `androidx.appcompat.widget.Toolbar?`
Found: `android.widget.Toolbar`
Check your import. You have to use `androidx.appcompat.widget`.
```
//import android.widget.Toolbar
import androidx.appcompat.widget.Toolbar
```
| null | CC BY-SA 4.0 | null | 2022-11-27T15:10:45.203 | 2022-11-27T15:10:45.203 | null | null | 2,016,562 | null |
74,591,232 | 2 | null | 74,590,458 | 0 | null | To read and log all nodes under `Sensor MQ7`, you can do:
```
const reference = admin.database().ref("Sensor MQ7");
const snapshot = await reference.get();
snapshot.forEach((childSnapshot) => {
console.log(childSnapshot.child("MQ7").val());
});
```
In here:
- `snapshot``Sensor MQ7`- `snapshot.forEach()`- `child("MQ7")`- `.val()`
| null | CC BY-SA 4.0 | null | 2022-11-27T15:21:34.903 | 2022-11-27T15:21:34.903 | null | null | 209,103 | null |
74,591,348 | 2 | null | 71,334,309 | 0 | null | Ran into the same problem. I was able to fix it by passing in render_mode="human". For example
```
env = gym.make("FrozenLake-v1", map_name="8x8", render_mode="human")
```
This worked on my own custom maps in addition to the built in ones.
| null | CC BY-SA 4.0 | null | 2022-11-27T15:35:06.390 | 2022-11-27T15:35:06.390 | null | null | 5,377,933 | null |
74,591,593 | 2 | null | 74,591,257 | 0 | null | Because, you are adding additional fields to the default user model. First you have to
-Create a Custom User Model by using AbstractUser
Then
-Create a Custom Form for UserCreationForm
You can search google for:
Extend-existing-user-model-in-django
| null | CC BY-SA 4.0 | null | 2022-11-27T16:04:41.233 | 2022-11-27T16:04:41.233 | null | null | 8,944,675 | null |
74,591,638 | 2 | null | 74,589,749 | 0 | null | It is because there is no variable referencing the instance of `Botoes()`, so it will be garbage collected (so as the image inside it).
Just use a variable to store the instance of `Botoes()`:
```
class Janela(Images):
def __init__(self) -> None:
self.images_base64()
self.tamJanela()
def tamJanela(self):
self.janela_doMenu = tk.Tk()
janela = self.janela_doMenu
# janela.state('zoomed')
janela.title('Disk Gás Gonçalves')
janela.configure(background=preto_claro)
janela.geometry("%dx%d" % (janela.winfo_screenwidth(), janela.winfo_screenheight()))
# Here the code works ###############################################################
self.img_icoName = tk.PhotoImage(data=base64.b64decode(self.editUser))
self.rotulo_nome2 = tk.Button(master=janela, image=self.img_icoName, activebackground='#00FA9A', bg='#4F4F4F',
highlightbackground='#4F4F4F', highlightcolor='#4F4F4F')
self.rotulo_nome2.grid(row=0, column=0)
# need a variable to store the instance of Botoes
# to avoid garbage collection
botoes = Botoes(janela)
janela.minsize(1200, 640)
janela.mainloop()
```
Result:
[](https://i.stack.imgur.com/TG8Jj.png)
| null | CC BY-SA 4.0 | null | 2022-11-27T16:10:32.017 | 2022-11-27T16:10:32.017 | null | null | 5,317,403 | null |
74,592,081 | 2 | null | 74,592,008 | 1 | null |
### EDIT
You have an object at the end in your `this.parkingPlaces` as shown by your `console.log`.
You need the following to access the actual data (as an iterable array).
```
async fetch() {
const response = await fetch('http://localhost:8000/api/parkingPlace')
const json = await response.json()
this.parkingPlaces = json.data
console.log(this.parkingPlaces)
}
```
PS: I also recommend that you use [this.$axios.$get shortcuts](https://axios.nuxtjs.org/usage#-shortcuts) as [showcased here](https://stackoverflow.com/a/74329715/8816585).
---
What is `getData`? Put that function into a `methods` in your `export default {` rather.
Then, use `asyncData()` or `fetch()` hook to fetch the data properly in a Nuxt way, you can call `this.getData` inside of any of them.
Apply a conditional in your `template` so that you have a fallback in your template (only needed for `fetch()`'s lifecycle hook). `asyncData` is indeed render-blocking.
It can be `v-if="parkingPlaces.length"`, no need for more.
But [don't stack both](https://vuejs.org/style-guide/rules-essential.html#avoid-v-if-with-v-for) at the same time. ESlint can warn you about that.
Here is [an example](https://stackoverflow.com/a/67490633/8816585), there we're using `$fetchState.pending` to wait until we have our data before iterating over the array. Without that conditional, the template will iterate on something empty and throw the error that you do have.
Indeed, the `template` section is not clever enough to understand that the data may be async. Hence it is run into a `sync` approach. Using a conditional is enough to make it aware of the possibility of something being empty (because not fully async fetched).
---
More info on how to fetch data in Nuxt available here: [https://nuxtjs.org/docs/features/data-fetching#the-fetch-hook](https://nuxtjs.org/docs/features/data-fetching#the-fetch-hook)
| null | CC BY-SA 4.0 | null | 2022-11-27T17:07:44.440 | 2022-11-27T18:11:04.677 | 2022-11-27T18:11:04.677 | 8,816,585 | 8,816,585 | null |
74,592,362 | 2 | null | 18,980,276 | 0 | null | Although this is an old question the behaviour still exists in latest Android studio (Nov 20220) so an update here:
- - - -
It would obviously be nicer if the instructions in Studio could be updated to include notes on this in the update panel as it's clearly still confusing.
It would probably be a good idea to back up your machine before doing to upgrade, just to be safe.
| null | CC BY-SA 4.0 | null | 2022-11-27T17:43:16.897 | 2022-11-27T17:43:16.897 | null | null | 334,402 | null |
74,592,593 | 2 | null | 74,592,553 | 1 | null | [document.getElementsByClassName](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName) returns an [HTMLCollection](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) that can be iterated and accessed like an array. If you want to return the `.innerHTML` of the first element, then you can just do this:
```
const collection = document.getElementsByClassName('example');
console.log(collection[0].innerHTML)
```
```
<span class="example">Text</span>
```
However, multiple elements may have the same class name, so if you want to print the `.innerHTML` of all elements with the class, you can use a for-loop:
```
const collection = document.getElementsByClassName('example');
for (const el of collection) {
console.log(el.innerHTML)
}
```
```
<span class="example">Text 1</span>
<span class="example">Text 2</span>
<span class="example">Text 3</span>
```
| null | CC BY-SA 4.0 | null | 2022-11-27T18:14:40.817 | 2022-11-27T18:14:40.817 | null | null | 13,376,511 | null |
74,593,083 | 2 | null | 74,592,972 | 0 | null | I think something like this should do the trick.
```
.card {
background-color: lightgreen;
height: 140px;
width: 80px;
border-radius: 100px 100px 30px 30px / 60px 60px 30px 30px
}
```
```
<div class="card"></div>
```
You can read more about the [border-radius on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius)
| null | CC BY-SA 4.0 | null | 2022-11-27T19:18:00.067 | 2022-11-27T19:18:00.067 | null | null | 5,509,709 | null |
74,593,184 | 2 | null | 74,592,995 | 2 | null | Don't search the pgadmin4 documentation, but look at the SQL tab of the dialog to see the generated SQL commands. Then refer to the [official postgres documentation on CREATE FUNCTION](https://www.postgresql.org/docs/current/sql-createfunction.html), it mentions `internal` as one of the possible languages.
Admittedly, that still doesn't tell you a lot, but when searching the docs for "internal function" you'll find [chapter 38](https://www.postgresql.org/docs/current/extend.html) about extending the PostgreSQL SQL query language. In particular, it talks about [internal functions](https://www.postgresql.org/docs/current/xfunc-internal.html):
> Internal functions are functions written in C that have been statically linked into the PostgreSQL server. The “body” of the function definition specifies the C-language name of the function, which need not be the same as the name being declared for SQL use.
| null | CC BY-SA 4.0 | null | 2022-11-27T19:32:10.090 | 2022-11-27T19:32:10.090 | null | null | 1,048,572 | null |
74,593,455 | 2 | null | 74,593,360 | 1 | null | Seems that your Job run a with a component which will be installed automatically (Maybe Java).
And your Jenkins instance could not download the artifact. I would check the tools configuration and Job configuration.
For more help show us more information.
| null | CC BY-SA 4.0 | null | 2022-11-27T20:08:47.100 | 2022-11-27T20:08:47.100 | null | null | 1,504,041 | null |
74,593,469 | 2 | null | 16,784,052 | 0 | null | [https://github.com/jupierce/aws-s3-web-browser-file-listing](https://github.com/jupierce/aws-s3-web-browser-file-listing) is a solution I developed for this use case. It leverages AWS CloudFront and Lambda@Edge functions to dynamically render and deliver file listings to a client's browser.
To use it, a simple CloudFormation template will create an S3 bucket and have your file server interface up and running in just a few minutes.
There are many viable alternatives, as already suggested by other posters, but I believe this approach has a unique range of benefits:
- - - - - - - - - - -
| null | CC BY-SA 4.0 | null | 2022-11-27T20:10:25.530 | 2022-11-27T20:10:25.530 | null | null | 6,431,503 | null |
74,593,878 | 2 | null | 74,587,775 | 0 | null | Each version of Python comes with corresponding versions of the Python-coded tkinter and C-coded _tkinter modules. (Tkinter imports _tkinter.) One cannot upgrade tkinter except by upgrading Python.
That said, the tkinter that comes with current versions of Python (3.10+) potentially display all unicode characters. What are you using? The following is from IDLE's settings dialog font sample on Windows with SourceCodePro font.
```
<ASCII/Latin1>
AaBbCcDdEeFfGgHhIiJj
1234567890#:+=(){}[]
¢£¥§©«®¶½ĞÀÁÂÃÄÅÇÐØß
<IPA,Greek,Cyrillic>
ɐɕɘɞɟɤɫɮɰɷɻʁʃʆʎʞʢʫʭʯ
ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκ
БбДдЖжПпФфЧчЪъЭэѠѤѬӜ
<Hebrew, Arabic>
אבגדהוזחטיךכלםמןנסעף
ابجدهوزحطي٠١٢٣٤٥٦٧٨٩
<Devanagari, Tamil>
०१२३४५६७८९अआइईउऊएऐओऔ
௦௧௨௩௪௫௬௭௮௯அஇஉஎ
<East Asian>
〇一二三四五六七八九
汉字漢字人木火土金水
가냐더려모뵤수유즈치
あいうえおアイウエオ
```
If characters do not display, the issue is with the OS and font. Characters not in the Basic Multilingual Plane do, however, interfere with editing. Everything you see above in the BMP and the same will be true of most anything that people want to insert into a text translator.
Post the minimum amount of code needed to illustrate your problem: just one text-display widget and code to insert text that results in '?'s.
| null | CC BY-SA 4.0 | null | 2022-11-27T21:20:13.087 | 2022-11-27T21:20:13.087 | null | null | 722,804 | null |
74,593,884 | 2 | null | 74,593,768 | 1 | null | In order for the compiler to keep track of the string [literal types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types) corresponding to valid edge ids, we will need to make `Package` [generic](https://www.typescriptlang.org/docs/handbook/2/generics.html) in the [union](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types) of those types, and all the types and interfaces that hold such ids should be generic as well.
Something like this:
```
interface IEdge<K extends string = string> {
id: K
}
interface IModule<K extends string = string> {
id: string
data: {
inputEdges: readonly IEdge<K>[]
}
}
```
Here I've added the generic type parameter `K` to both `IEdge` and `IModule`. If you don't specify them they will [default](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#generic-parameter-defaults) to `string` like your version. Also, when you create `sampleModule` the compiler will infer just `string` for those ids unless you give it a hint that it should pay closer attention, such as with a [const assertion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions):
```
const sampleModule = {
id: "sampleModule",
data: {
inputEdges: [
{
id: "sampleEdge"
},
{
id: "anotherEdge"
}
]
}
} as const;
```
That `as const` causes the compiler to infer `sampleModule` as this type:
```
/* const sampleModule: {
readonly id: "sampleModule";
readonly data: {
readonly inputEdges: readonly [{
readonly id: "sampleEdge";
}, {
readonly id: "anotherEdge";
}];
};
} */
```
So now the compiler definitely knows that `"sampleEdge"` and `"anotherEdge"` are valid edge ids. Also note that `inputEdges` has been inferred as a [readonly array type](https://www.typescriptlang.org/docs/handbook/2/objects.html#the-readonlyarray-type), which is technically wider than a read-write array. That's why I widened the type in `IModule<K>` to `readonly IEdge<K>[]`. That probably won't matter unless you need to start modifying that array after the fact (but I hope you don't, since that could change which edge ids are valid).
---
To make this easy, I'm going to replace your `init()` method with a constructor argument. That way, the type of your package instance can know about the edge ids from the moment it's created. Otherwise we'd have to try to narrow the type when you call `init()`, which is hard to do properly. You can technically do it by making `init()` an [assertion method](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions), but it's not fun. Unless someone needs to have a package instance sit around before it's initialized, we should have the initialization done in the constructor, which is more conventional anyway.
Here it is:
```
class Package<K extends string> {
constructor(public module: IModule<K>) { }
recieveOnEdge(
edgeId: K,
callback: any
) {
console.log(edgeId, callback)
}
}
```
So you can see that `receiveOnEdge()` only takes an `edgeId` of type `K`. Let's test it out:
```
const packageInstance = new Package(sampleModule);
// const packageInstance: Package<"sampleEdge" | "anotherEdge">
```
So the compiler infers that `packageInstance` is of type `Package<"sampleEdge" | "anotherEdge">`, leading to the behavior you wanted with `receiveOnEdge()`:
```
packageInstance.recieveOnEdge("sampleEdge", "doesNotMatter"); // okay
packageInstance.recieveOnEdge("badEdge", "doesNotMatter"); // error
```
[Playground link to code](https://www.typescriptlang.org/play?ts=4.9.3&ssl=27&ssc=28&pln=26&pc=21#code/JYOwLgpgTgZghgYwgAgJIFEAmBzCAeAaWQgA9IRMBnZSsKUbZAXhroYD5kBvAKAEhgmAFzICPAL48eoSLEQpUAWQD2mAK4AbfEVLkqreiEYtah7J14DhBhv0xwwcEZYEgADmrBZclEVAhwmMogGgCeaN7a7ADaALr8kpIIwbQ0cAC2bloq6lrM3PyCIgBElBlZEDmaEMUANHYOTgV8rh5eOBC+yNH8LS4tRcil5VqRxb184vUtfP1WJXAgymAAFtBjE5It8ZMSyHDUySC0PAD0AFTIR6llmdmq1c48yC-I-oHBYciDw3eVD1pigBuZ6vd5BELheyOJ6vOFvAIQr6gNqRLrgz7haK8eG4hEfSHfay-CpjEF45BTAoUuEYwk-RbLNZQMmg3HiWLk17iEHiZDnU5SBAaA7UAAKiAA1nBcIRiGQIBRqKYOM1rnQ1AgwMooAAKDwAIw0wAQyHSAIgIiUFsI7AAlNxKfx-AhgBAAG4QADyIEiut6EA6qGsBGmfAQcA0GgNUpEi1C-AdLmuyi0ADoNMpsLrA7hg7UrpHo1K7QkJEKUmBkG4pTKIKhjo4QEh8iAIAB3ZAShDS3C624VKpaO0g06nK6V6u1vONxZIETd3v4EmjDrFZAAHyGjNW6zX7CkNZ7dYbtDnEDTLrdnp9fpXEDGBeKQU6ADllooHLJiiPkGPkMo0oJkeS6nk2SCXhAroet6vodLqxQxpgj5DC+lDvmAn5gN+v7-tAUA6jwQA)
| null | CC BY-SA 4.0 | null | 2022-11-27T21:21:11.287 | 2022-11-27T21:55:33.537 | 2022-11-27T21:55:33.537 | 2,887,218 | 2,887,218 | null |
74,594,087 | 2 | null | 56,497,119 | 0 | null | You have two options to sort out the situation in your case.
### 1. Change the memory allocaction from node.
You can achieve this by doing so: run the command
`node index.js --max-old-space-size=8000`. This settings may not be persitent and you would wanna use a much more long term approach, which is of course the second option.
### 2. Change your swap space allocation.
Just like the article shared by @Jesse in the previous answer, you can follow that guide to change your swap space settings. it works like a charm.
| null | CC BY-SA 4.0 | null | 2022-11-27T21:57:06.103 | 2022-11-27T21:57:06.103 | null | null | 7,982,806 | null |
74,594,166 | 2 | null | 31,228,534 | 0 | null | If anyone is still having this issue, check to see you don't have any unspecified `:first-letter`
| null | CC BY-SA 4.0 | null | 2022-11-27T22:09:03.087 | 2022-11-27T22:09:03.087 | null | null | 20,147,305 | null |
74,594,576 | 2 | null | 74,594,520 | 1 | null | Your for loops end with a semicolon, which ends the loop. The following code blocks are not treated as part of the loop body because of that. Additionally as aybe mentioned you use i for both loops which will update the same variable.
EDIT: As mentioned below you also shouldn't redeclare the variable C as it won't update the variable C at the top, same reason as to why you don't want to use i for both loops.
EDIT: Code below still has redeclared variables, check author's answer for updated code.
I suggest changing it to this:
```
int qny = 4;
int ADD = 1;
int B = 1;
string C = " ";
for (int i = 0; i < qny; i++)
{
int R = qny + ADD;
for (int j = 0; j < R; j++)
{
C = string.Join(C, B);
}
int qny = qny - 1;
int B = B + 1;
}
Console.WriteLine(C);
```
To avoid such errors in the future I would recommend checking out some tutorials on the basics of C#. I wish you good luck on your coding journey!
| null | CC BY-SA 4.0 | null | 2022-11-27T23:22:26.653 | 2022-11-28T00:04:02.220 | 2022-11-28T00:04:02.220 | 20,614,914 | 20,614,914 | null |
74,594,735 | 2 | null | 74,594,520 | 0 | null | Thanks to the people that helped me. As someone suggested, I’ll check out some tutorials. The final code looks like this:
```
int qny = 4;
int ADD = 1;
int B = 1;
string C = " ";
for (int i = 0; i < qny; i++)
{
int R = qny + ADD;
for (int j = 0; j < R; j++)
{
C = string.Join(C, B);
}
qny = qny - 1;
B = B + 1;
}
Console.WriteLine(C);
```
| null | CC BY-SA 4.0 | null | 2022-11-27T23:59:10.233 | 2022-11-30T00:59:41.743 | 2022-11-30T00:59:41.743 | 3,025,856 | 20,618,074 | null |
74,595,191 | 2 | null | 74,592,493 | 0 | null | The code is not clear and complete. However, I presume that you have defined onclick events for both `<tr>` and `<td>` tags and when you click the `<td>`, it also triggers the `<tr>` event. To prevent this, add this code at the end of your `<td>` event handler.
```
event.stopPropagation();
```
| null | CC BY-SA 4.0 | null | 2022-11-28T01:47:33.700 | 2022-11-28T01:47:33.700 | null | null | 6,544,200 | null |
74,595,194 | 2 | null | 74,595,103 | 0 | null | try this:
change this
```
tileColor: isSelected ? Colors.green : Colors.red,
```
to this:
```
tileColor: item.isExpanded ? Colors.green : Colors.red,
```
you have to use bool condition from parent panel
[](https://i.stack.imgur.com/axEqM.png)
| null | CC BY-SA 4.0 | null | 2022-11-28T01:48:18.193 | 2022-11-28T01:48:18.193 | null | null | 12,838,877 | null |
74,595,364 | 2 | null | 70,009,665 | 0 | null | With me I'm just go to C:\Users<USER>\AppData\Roaming\MySQL\Workbench\modules and then delete the .py file you install, then open the Workbench again
| null | CC BY-SA 4.0 | null | 2022-11-28T02:23:35.357 | 2022-11-28T02:23:35.357 | null | null | 15,935,134 | null |
74,595,524 | 2 | null | 74,595,418 | 1 | null | You could simply wrap both headers in a `block` element (`div`s are `display: block;` by default):
```
.card {
display: flex;
width: 344px;
flex-wrap: wrap;
}
.card:hover {
box-shadow: 0px 2px 4px rgba(0, 0, 0, .3);
}
.desert {
height: 194px;
width: 100%;
}
.avatar {
border-radius: 50%;
height: 40px;
width: 40px;
align-items: center;
padding: 10px;
}
p {
padding: 16px;
font-size: 11px;
}
h1 {
color: #000;
font-size: 22px;
}
h3,
p {
color: #232f32;
}
h1,
h3 {
/* headers have a large margin by default */
margin: 0;
}
/* if you need the wrapper to be a flexbox
.wrapper {
display: flex;
flex-direction: column;
}
*/
```
```
<div class="card">
<img class="desert" src="./images/desert.jpg" alt="a desert">
<img class="avatar" src="./images/person-avatar.jpg" alt="an avatar">
<div class="wrapper">
<h1>Title goes here</h1>
<h3>Secondary text</h3>
</div>
<p>Greyhound divisively hello coldly wonderfully marginally far upon excluding.</p>
</div>
```
If you need the wrapper to be a flexbox, you could simply assign the div a property of `flex-direction: column;`
| null | CC BY-SA 4.0 | null | 2022-11-28T02:54:16.137 | 2022-11-28T02:54:16.137 | null | null | 17,186,475 | null |
74,595,585 | 2 | null | 74,595,418 | 1 | null | Wrap what you want vertically in a div. By default it will stack vertically.
```
<div class="card">
<img class="desert" src="./images/desert.jpg" alt="a desert">
<img class="avatar" src="./images/person-avatar.jpg" alt="an avatar">
<div style="margin-top: 10px;">
<h1>Title goes here</h1>
<h3>Secondary text</h3>
</div>
<p>Greyhound divisively hello coldly wonderfully marginally far
upon excluding.</p>
</div>
```
Remove default margins:
```
h1,
h3 {
margin: 0;
}
```
| null | CC BY-SA 4.0 | null | 2022-11-28T03:06:26.977 | 2022-11-28T03:13:23.370 | 2022-11-28T03:13:23.370 | 20,421,592 | 20,421,592 | null |
74,595,812 | 2 | null | 74,595,103 | 0 | null | No matter which tile you click, the `isSelected` will be changed, and every tile will recognize the change since the `isSelected` condition determines which color you would like to display.
So, You have to change the type of your `isSelected` from `bool` to `String`
, which when you tap it, you can set the `isSelected` to the label, in this way, flutter will know which tile you want to change.
```
String selected = '';
```
in your tile property
```
tileColor: selected == items[index].header ? Colors.green : Colors.red,
onTap: () => setState(() => selected = items[index].header),
```
However, for the best practice, either you can set a new field `id` for the Item class, or you can use `asMap()` to declare the indexes. Because sometimes, the headers could be same.
| null | CC BY-SA 4.0 | null | 2022-11-28T03:54:15.803 | 2022-11-28T03:54:15.803 | null | null | 7,596,415 | null |
74,596,058 | 2 | null | 69,265,941 | 0 | null | I encountered this error when creating a new ASP.NET core web api project, but forgot to check "Use controllers (uncheck to use minimal APIs)" in Visual Studio. Recreating the project with that box checked solved the issue for me.
| null | CC BY-SA 4.0 | null | 2022-11-28T04:40:18.623 | 2022-11-28T04:40:18.623 | null | null | 244,105 | null |
74,596,266 | 2 | null | 74,595,918 | 1 | null | simply do that this way :
there is no need to delete (or create) anything, just re-affect option to it new select parent.
```
const myForm = document.querySelector('#my-form');
myForm.onsubmit = e => e.preventDefault(); // disable submit on testing implemention
myForm.onclick = ({target : btn}) =>
{
if (!btn.matches('button[data-mov]')) return
let sel_out = (btn.dataset.mov === 'add') ? myForm.framework : myForm.list;
let sel_in = (btn.dataset.mov === 'del') ? myForm.framework : myForm.list;
;
if (sel_out.selectedOptions.length===0) alert('no option selected...!');
[...sel_out.selectedOptions].forEach( opt => sel_in.add( opt ));
}
```
```
body {
font-family : Arial, Helvetica, sans-serif;
font-size : 16px;
}
#my-form label {
display : inline-block;
vertical-align : middle;
}
#my-form select {
display : block;
width : 6rem;
height : 20rem;
font-size : 1.2rem;
text-align: center;
}
button {
display: block;
}
```
```
<form id="my-form">
<label>
Framework:
<select name="framework" multiple>
<option value="1A">1A</option>
<option value="1B">1B</option>
<option value="1C">1C</option>
<option value="2A">2A</option>
<option value="2B">2B</option>
<option value="2C">2C</option>
<option value="3A">3A</option>
<option value="3B">3B</option>
<option value="3C">3C</option>
<option value="3D">3D</option>
</select>
</label>
<label>
<button data-mov="add"> >>> </button>
<button data-mov="del"> <<< </button>
</label>
<label>
List:
<select name="list" multiple></select>
</label>
</form>
```
| null | CC BY-SA 4.0 | null | 2022-11-28T05:13:40.940 | 2022-11-28T05:23:00.040 | 2022-11-28T05:23:00.040 | 10,669,010 | 10,669,010 | null |
74,596,453 | 2 | null | 74,595,866 | 0 | null | Set a breakpoint and step through the code. When you get to the `if/else` conditions, is `place.sprite == null` actually `true`? I don't know Unity, but it seems to me this would only be `true` the first time the method is called. After that, it's set to `X.sprite` or `O.sprite`, so subsequent calls would have no affect since the conditions would evaluate to `false`.
If this is the case, then removing the `null` check should resolve the issue:
```
public void ChangeMove()
{
if (changeMove) place.sprite = O.sprite;
else place.sprite = X.sprite;
changeMove = !changeMove;
}
```
You may even be able to get rid of the `changeMove` variable and just examine the value of `place.sprite`:
```
public void ChangeMove()
{
if (place.sprite == O.sprite) place.sprite = X.sprite;
else place.sprite = O.sprite;
}
```
| null | CC BY-SA 4.0 | null | 2022-11-28T05:46:45.513 | 2022-11-28T05:52:05.517 | 2022-11-28T05:52:05.517 | 2,052,655 | 2,052,655 | null |
74,596,471 | 2 | null | 74,596,102 | 0 | null | Could this help you?
```
import pandas as pd
from collections import OrderedDict
df['event'] = df['event'].str.replace('amp;', '')
df = df.groupby('date')['event'].apply(lambda x: ' '.join(x)).reset_index()
df['event'] = df['event'].str.split().apply(lambda x: OrderedDict.fromkeys(x).keys()).str.join(' ')
```
| null | CC BY-SA 4.0 | null | 2022-11-28T05:49:22.130 | 2022-11-28T05:49:22.130 | null | null | 19,941,536 | null |
74,596,556 | 2 | null | 74,596,303 | 3 | null | The table cannot be easily parsed with `read_html` because of its unorthodox use of `<thead>` attribute. You can try luck with `BeautifulSoup`:
```
import bs4
import urllib.request
soup = bs4.BeautifulSoup(urllib.request.urlopen(url))
data = [["".join(cell.strings).strip()
for cell in row.find_all(['td', 'th'])]
for row in soup.find_all('table')[0].find_all('tr')]
table = pd.DataFrame(data[1:])\
.rename(columns=dict(enumerate(data[0])))\
.dropna(how='all')
```
| null | CC BY-SA 4.0 | null | 2022-11-28T06:00:20.343 | 2022-11-28T22:33:10.607 | 2022-11-28T22:33:10.607 | 4,492,932 | 4,492,932 | null |
74,597,153 | 2 | null | 74,596,303 | 1 | null | So I took a look at the link and the table you're trying to get.
The problem with the table in the link is that it contains multiple headers so the .read_html(URL) function, gets all of them and sets those as your
header:
[](https://i.stack.imgur.com/yAT71.png)
so instead of using pandas to read the HTML I used
beautiful soup for what you're trying to accomplish.
With beautiful and urllib.requests I got the HTML from the URL and extracted the HTML with the table class name
```
url = "https://www.environment.nsw.gov.au/topics/animals-and-plants/threatened-species/programs-legislation-and-framework/nsw-koala-strategy/local-government-resources-for-koala-conservation/north-coast-koala-management-area#:~:text=The%20North%20Coast%20Koala%20Management,Valley%2C%20Clarence%20Valley%20and%20Taree."
#load html with urllib
html = urllib.request.urlopen(url)
soup = BeautifulSoup(html.read(), 'lxml')
#get the table you're trying to get based
#on html elements
htmltable = soup.find('table', { 'class' : 'table-striped' })
```
Then using [a function I found](https://stackoverflow.com/a/58274853/6297478) to make a list from tables extract from beautiful soup, I modified the function to get your values in a shape that would be easy to load into a dataframe and would also be easy to call depending on what you want:
[{"common name" : value, "Species name": value, "type": value}...{}]
```
def tableDataText(table):
"""Parses a html segment started with tag <table> followed
by multiple <tr> (table rows) and inner <td> (table data) tags.
It returns a list of rows with inner columns.
Accepts only one <th> (table header/data) in the first row.
"""
def rowgetDataText(tr, coltag='td'): # td (data) or th (header)
return [td.get_text(strip=True) for td in tr.find_all(coltag)]
rows = []
trs = table.find_all('tr')
headerow = rowgetDataText(trs[0], 'th')
if headerow: # if there is a header row include first
trs = trs[1:]
for tr in trs: # for every table row
#this part is modified
#basically we'll get the type of
#used based of the second table header
#in your url table html
if(rowgetDataText(tr, 'th')):
last_head = rowgetDataText(tr, 'th')
#we'll add to the list a dict
#that contains "common name", "species name", "type" (use type)
if(rowgetDataText(tr, 'td')):
row = rowgetDataText(tr, 'td')
rows.append({headerow[0]: row[0], headerow[1]: row[1], 'type': last_head[0]})
return rows
```
then when we convert the results of that function using
the table content we extracted with beautiful soup we get this:
[](https://i.stack.imgur.com/ehWDm.png)
Then you can easily reference the type of use and each value common/species name.
Here is the full code:
```
import pandas as pd
from bs4 import BeautifulSoup
import urllib.request
url = "https://www.environment.nsw.gov.au/topics/animals-and-plants/threatened-species/programs-legislation-and-framework/nsw-koala-strategy/local-government-resources-for-koala-conservation/north-coast-koala-management-area#:~:text=The%20North%20Coast%20Koala%20Management,Valley%2C%20Clarence%20Valley%20and%20Taree."
#load html with urllib
html = urllib.request.urlopen(url)
soup = BeautifulSoup(html.read(), 'lxml')
#get the table you're trying to get based
#on html elements
htmltable = soup.find('table', { 'class' : 'table-striped' })
#modified function taken from: https://stackoverflow.com/a/58274853/6297478
#to fit your data shape in a way that
#you can use.
def tableDataText(table):
"""Parses a html segment started with tag <table> followed
by multiple <tr> (table rows) and inner <td> (table data) tags.
It returns a list of rows with inner columns.
Accepts only one <th> (table header/data) in the first row.
"""
def rowgetDataText(tr, coltag='td'): # td (data) or th (header)
return [td.get_text(strip=True) for td in tr.find_all(coltag)]
rows = []
trs = table.find_all('tr')
headerow = rowgetDataText(trs[0], 'th')
if headerow: # if there is a header row include first
trs = trs[1:]
for tr in trs: # for every table row
#this part is modified
#basically we'll get the type of
#used based of the second table header
#in your url table html
if(rowgetDataText(tr, 'th')):
last_head = rowgetDataText(tr, 'th')
#we'll add to the list a dict
#that contains "common name", "species name", "type" (use type)
if(rowgetDataText(tr, 'td')):
row = rowgetDataText(tr, 'td')
rows.append({headerow[0]: row[0], headerow[1]: row[1], 'type': last_head[0]})
return rows
#we store our results from the function in list_table
list_table = tableDataText(htmltable)
#turn our table into a DataFrame
dftable = pd.DataFrame(list_table)
dftable
```
I left some comments for you in the code to help you out.
I hope this helps!
| null | CC BY-SA 4.0 | null | 2022-11-28T07:13:37.263 | 2022-11-28T07:13:37.263 | null | null | 6,297,478 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.