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,941,689 | 2 | null | 74,941,519 | 0 | null | Using [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) is your go-to here. Thanks to it, you will be able to set various behavior, fetch content and allow for interactivity regarding the other "date cells".
The [useIntersectionObserver composable](https://vueuse.org/core/useintersectionobserver/#useintersectionobserver) is a good candidate for such a purpose.
---
Only displaying what is currently visible can also be helpful, so that you don't have too much content in the DOM. This [may help](https://github.com/Akryum/vue-virtual-scroller) but can also be done yourself (check the source code there).
---
I'm not sure why your list needs to be re-rendered but maybe consider not nuking the whole thing and applying some modifications at the given locations.
Or use a [memoization approach](https://vueuse.org/core/usememoize/#usememoize), depending on what you need to memorize it may be quite quick to implement yourself.
With the given approaches listed above, you may not even need to remove dates from your list, just hide (CSS) or let it off the screen. Aka rather than having `let datelist = [yesterday, today, tomorrow]`, consider having `let datelist = [..., x , y, today, z, a, b, ...]` each time you reach a boundary.
---
TLDR: for your constraints, you can pick only 2 from the 3.
| null | CC BY-SA 4.0 | null | 2022-12-28T14:51:22.470 | 2022-12-28T14:51:22.470 | null | null | 8,816,585 | null |
74,941,817 | 2 | null | 74,937,810 | 0 | null | you should do it like this
```
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
root.geometry("1000x700")
root.minsize(1000, 700)
root.maxsize(1000, 700)
my_image = ImageTk.PhotoImage(Image.open("image_processing20200410-19194-aihwb4.png"))
bg_img = Label(image=my_image, compound=CENTER)
bg_img.pack(expand=1, fill=BOTH)
```
you should first put the image in a variable then pass it in
| null | CC BY-SA 4.0 | null | 2022-12-28T15:03:04.597 | 2022-12-28T15:03:04.597 | null | null | 20,860,514 | null |
74,941,896 | 2 | null | 35,508,711 | 0 | null | I post here the working code of the proposed solution by [ekhumoro](https://stackoverflow.com/users/984421/ekhumoro) for and . Before running be sure to have image.jpg in the directory.
```
from PyQt6 import QtCore, QtGui, QtWidgets
class PhotoViewer(QtWidgets.QGraphicsView):
photoClicked = QtCore.pyqtSignal(QtCore.QPointF)
def __init__(self, parent):
super(PhotoViewer, self).__init__(parent)
self._zoom = 0
self._empty = True
self._scene = QtWidgets.QGraphicsScene(self)
self._photo = QtWidgets.QGraphicsPixmapItem()
self._scene.addItem(self._photo)
self.setScene(self._scene)
self.setTransformationAnchor(QtWidgets.QGraphicsView.ViewportAnchor.AnchorUnderMouse)
self.setResizeAnchor(QtWidgets.QGraphicsView.ViewportAnchor.AnchorUnderMouse)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(30, 30, 30)))
self.setFrameShape(QtWidgets.QFrame.Shape.NoFrame)
def hasPhoto(self):
return not self._empty
def fitInView(self, scale=True):
rect = QtCore.QRectF(self._photo.pixmap().rect())
if not rect.isNull():
self.setSceneRect(rect)
if self.hasPhoto():
unity = self.transform().mapRect(QtCore.QRectF(0, 0, 1, 1))
self.scale(1 / unity.width(), 1 / unity.height())
viewrect = self.viewport().rect()
scenerect = self.transform().mapRect(rect)
factor = min(viewrect.width() / scenerect.width(),
viewrect.height() / scenerect.height())
self.scale(factor, factor)
self._zoom = 0
def setPhoto(self, pixmap=None):
self._zoom = 0
if pixmap and not pixmap.isNull():
self._empty = False
self.setDragMode(QtWidgets.QGraphicsView.DragMode.ScrollHandDrag)
self._photo.setPixmap(pixmap)
else:
self._empty = True
self.setDragMode(QtWidgets.QGraphicsView.DragMode.NoDrag)
self._photo.setPixmap(QtGui.QPixmap())
self.fitInView()
def wheelEvent(self, event):
if self.hasPhoto():
if event.angleDelta().y() > 0:
factor = 1.25
self._zoom += 1
else:
factor = 0.8
self._zoom -= 1
if self._zoom > 0:
self.scale(factor, factor)
elif self._zoom == 0:
self.fitInView()
else:
self._zoom = 0
def toggleDragMode(self):
if self.dragMode() == QtWidgets.QGraphicsView.DragMode.ScrollHandDrag:
self.setDragMode(QtWidgets.QGraphicsView.DragMode.NoDrag)
elif not self._photo.pixmap().isNull():
self.setDragMode(QtWidgets.QGraphicsView.DragMode.ScrollHandDrag)
def mousePressEvent(self, event):
if self._photo.isUnderMouse():
self.photoClicked.emit(self.mapToScene(event.position().toPoint()))
super(PhotoViewer, self).mousePressEvent(event)
class Window(QtWidgets.QWidget):
def __init__(self):
super(Window, self).__init__()
self.viewer = PhotoViewer(self)
# 'Load image' button
self.btnLoad = QtWidgets.QToolButton(self)
self.btnLoad.setText('Load image')
self.btnLoad.clicked.connect(self.loadImage)
# Button to change from drag/pan to getting pixel info
self.btnPixInfo = QtWidgets.QToolButton(self)
self.btnPixInfo.setText('Enter pixel info mode')
self.btnPixInfo.clicked.connect(self.pixInfo)
self.editPixInfo = QtWidgets.QLineEdit(self)
self.editPixInfo.setReadOnly(True)
self.viewer.photoClicked.connect(self.photoClicked)
# Arrange layout
VBlayout = QtWidgets.QVBoxLayout(self)
VBlayout.addWidget(self.viewer)
HBlayout = QtWidgets.QHBoxLayout()
HBlayout.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft)
HBlayout.addWidget(self.btnLoad)
HBlayout.addWidget(self.btnPixInfo)
HBlayout.addWidget(self.editPixInfo)
VBlayout.addLayout(HBlayout)
def loadImage(self):
self.viewer.setPhoto(QtGui.QPixmap('image.jpg'))
def pixInfo(self):
self.viewer.toggleDragMode()
def photoClicked(self, posi):
if self.viewer.dragMode() == QtWidgets.QGraphicsView.DragMode.NoDrag:
self.editPixInfo.setText('{0:04.0f}, {0:04.0f}'.format(posi.x(), posi.y()))
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
window = Window()
window.setGeometry(500, 300, 800, 600)
window.show()
sys.exit(app.exec())
```
| null | CC BY-SA 4.0 | null | 2022-12-28T15:11:34.997 | 2022-12-28T15:11:34.997 | null | null | 19,135,499 | null |
74,942,024 | 2 | null | 74,935,997 | 1 | null | You can use either of the following options:
- [Pygubu designer](https://github.com/alejandroautalan/pygubu-designer)[pygubu](https://github.com/alejandroautalan/pygubu)- [Qt designer](https://build-system.fman.io/qt-designer-download)[PyQt](https://riverbankcomputing.com/software/pyqt/intro)- [IronPython](https://ironpython.net/)
Here is an example of using IronPython in a C# Windows Forms app:
1. Create a Windows Forms application.
2. Install IronPython nuget package.
3. Add using IronPython.Hosting; statement to the using statements.
4. Drop a TextBox on the form (textBox1)
5. Drop a Button on the form (button1)
6. Double click on button and add the following code for the click handler: private void button1_Click(object sender, EventArgs e)
{
var engine = Python.CreateEngine();
var scope = engine.CreateScope();
//You can also load script from file
var source = engine.CreateScriptSourceFromString(
"def hello(name):" + "\n" +
" result = 'Hello, {}!'.format(name)" + "\n" +
" return(result)",
Microsoft.Scripting.SourceCodeKind.Statements);
var compiled = source.Compile();
compiled.Execute(scope);
dynamic hello = scope.GetVariable("hello");
var result = hello(textBox1.Text);
MessageBox.Show((string)result);
}
7. Press F5 to Run the application, enter a text, and click on the button. The function will run and you will see a message box saying hello.
You can download or clone the example:
- [Zip](https://github.com/r-aghaei/WinFormsIronPythonExample/archive/refs/heads/master.zip)- [r-aghaei/WinFormsIronPythonExample](https://github.com/r-aghaei/WinFormsIronPythonExample)
| null | CC BY-SA 4.0 | null | 2022-12-28T15:24:50.847 | 2022-12-28T22:29:38.270 | 2022-12-28T22:29:38.270 | 3,110,834 | 3,110,834 | null |
74,942,117 | 2 | null | 64,757,756 | 0 | null | If you are using some script to add or modify data, then you should just skip the variable on the script (e.g. does not write then on the insert statement), but on doing so you should modify your csv to delete the insert column(the data, if any, and the separator, usually a comma) since the number of variables are now different.
Looking at your print I suppose you are using pgadmin or some simmilar GUI, on the case of pgadmin if you click on the column and select the import\export data... option, you will open a windows where you should select "import" and then, on the upper windows menu, click on "columns" and exclude the "ID" or any other auto-increment, this slution also needs you to remove the csv column as well.
| null | CC BY-SA 4.0 | null | 2022-12-28T15:34:49.913 | 2022-12-28T15:34:49.913 | null | null | 20,880,619 | null |
74,942,143 | 2 | null | 74,935,168 | 0 | null | The problem was String named `adress` in `Office` constructor.
Key from is named `address`.
So it was returning `null`, because there's no key named `adress`
```
class Office {
String? name;
String? adress;
String? image;
Office({
required this.name,
required this.adress, // <-- "adress" instead of "address
required this.image,
});
factory Office.fromJson(Map<String, dynamic> json) {
return Office(
name: json['name'] as String,
adress: json['adress'] as String, // <-- "adress" instead of "address
image: json['image'] as String);
}
}
```
| null | CC BY-SA 4.0 | null | 2022-12-28T15:36:45.860 | 2022-12-29T13:18:08.933 | 2022-12-29T13:18:08.933 | 8,402,500 | 19,272,770 | null |
74,942,172 | 2 | null | 29,811,134 | 0 | null | Include your files in the project`s resources folder by right-clicking on your project name>>properties>>Recources>>select audio>>drag your .wav file.
Then you can play the file from Memory Stream:
```
public void Play()
{
SoundPlayer player = new SoundPlayer();
player.Stream = YOUR_PROJECT_NAME.Properties.Resources.YOUR_FILE_NAME;
player.Play();
}
```
Solution taken from : [Please be sure a sound file exists at the specified location](https://stackoverflow.com/questions/72439532/please-be-sure-a-sound-file-exists-at-the-specified-location)
| null | CC BY-SA 4.0 | null | 2022-12-28T15:39:21.470 | 2022-12-28T15:39:21.470 | null | null | 16,749,283 | null |
74,942,206 | 2 | null | 22,916,591 | 0 | null | If you get such an error without changing any settings of wampserver, just downgrade the php version, then select the version you are using again and it will be fixed.
System tray - Wampserver PHP -> PHP version - 7.4.26 change 7.3.33
Restart all service
Again
System tray - Wampserver PHP -> PHP version - 7.3.33 change 7.4.26
fixed
| null | CC BY-SA 4.0 | null | 2022-12-28T15:42:52.167 | 2022-12-28T15:42:52.167 | null | null | 4,763,357 | null |
74,942,250 | 2 | null | 74,941,945 | 1 | null | You can achieve this by following these steps:
- `id``div`- `onclick``img`- `event`- `div``event.target.parentNode``display``none``remove()`
Hope this helps.
| null | CC BY-SA 4.0 | null | 2022-12-28T15:47:14.610 | 2022-12-28T15:51:28.757 | 2022-12-28T15:51:28.757 | 13,504,876 | 13,504,876 | null |
74,942,289 | 2 | null | 74,941,945 | 1 | null | Can try something like this (you can merge the JS in the onclick with your delete image):
```
<div class="chassi">
Test
<button onClick="this.parentNode.parentNode.removeChild(this.parentNode);">Delete me</button>
</div>
<div class="chassi">
Test
<button onClick="this.parentNode.parentNode.removeChild(this.parentNode);">Delete me</button>
</div>
```
| null | CC BY-SA 4.0 | null | 2022-12-28T15:51:50.673 | 2022-12-28T15:51:50.673 | null | null | 13,880,122 | null |
74,942,358 | 2 | null | 74,941,945 | 2 | null | just remove the parent
```
<img onclick="remove(this.parentNode);" />
```
or if you have multi parent
```
<img onclick="remove(this.parentNode.parentNode);" />
```
| null | CC BY-SA 4.0 | null | 2022-12-28T15:58:22.113 | 2022-12-28T15:58:22.113 | null | null | 520,848 | null |
74,942,386 | 2 | null | 10,795,078 | 0 | null | In Kotlin you can use this code:
```
val dialog = Dialog(context)
dialog.window?.decorView?.background = null
```
| null | CC BY-SA 4.0 | null | 2022-12-28T16:02:10.763 | 2022-12-31T14:33:22.020 | 2022-12-31T14:33:22.020 | 7,699,617 | 20,593,361 | null |
74,942,431 | 2 | null | 74,930,784 | 1 | null | I've been trying to solve this issue myself for some time, and It seems the only way to automate disabling the script icon gizmo is by disabling the icon gizmos of your specific `MonoBehaviour` through reflection.
Here's where I found my solution. The last answer by Acegikmo gives a concise method that solves the issue perfectly.
[https://answers.unity.com/questions/851470/how-to-hide-gizmos-by-script.html](https://answers.unity.com/questions/851470/how-to-hide-gizmos-by-script.html)
```
static MethodInfo setIconEnabled;
static MethodInfo SetIconEnabled => setIconEnabled = setIconEnabled ??
Assembly.GetAssembly( typeof(Editor) )
?.GetType( "UnityEditor.AnnotationUtility" )
?.GetMethod( "SetIconEnabled", BindingFlags.Static | BindingFlags.NonPublic );
public static void SetGizmoIconEnabled( Type type, bool on ) {
if( SetIconEnabled == null ) return;
const int MONO_BEHAVIOR_CLASS_ID = 114; // https://docs.unity3d.com/Manual/ClassIDReference.html
SetIconEnabled.Invoke( null, new object[] { MONO_BEHAVIOR_CLASS_ID, type.Name, on ? 1 : 0 } );
}
```
You just need to call the method `SetGizmoIconEnabled` from anywhere for the Type of your `MonoBehaviour` and it should work.
---
The alternative is to manually find the Gizmo dropdown menu in the Scene view and disable the script Gizmo from there:
[](https://i.stack.imgur.com/QtP3N.png)
| null | CC BY-SA 4.0 | null | 2022-12-28T16:06:08.887 | 2022-12-29T12:49:44.167 | 2022-12-29T12:49:44.167 | 3,987,342 | 3,987,342 | null |
74,942,550 | 2 | null | 7,558,497 | 2 | null | In idea 2022 for MAC it is located under ~/Library/Application Support/JetBrains/IntelliJIdea2022.3/options
| null | CC BY-SA 4.0 | null | 2022-12-28T16:17:40.150 | 2022-12-28T16:17:40.150 | null | null | 5,732,661 | null |
74,942,620 | 2 | null | 74,369,892 | 3 | null | The Flutter will always render the children of the Stack in order, what means that the last widget of the Stack will be in front of every other widget, and that is why the purple side (the last child of the Stack) is always visible regardless of the movement you do.
To simulate a cube you will have to change the order of the cube's sides accordingly to the rotation of the cube. To change the order, you will have to store all the sides in an array and pass this array as the argument of the Stack:
```
class _CubeState extends State<Cube> {
List<Widget> sides = [];
final side1 = Transform(
key: const ValueKey("side1"), // you must use a key to allow flutter to know that a widget changed its order
transform: Matrix4.identity()..translate(0.0, 0.0, -100),
alignment: Alignment.center,
child: Container(
color: Colors.amber,
child: const FlutterLogo(size: 200),
),
);
//... the other sides follow the same logic of the side1
@override
void initState() {
super.initState();
sides = [side1, side2, side3, side4];
}
void update(Offset value) {
setState(() {
// I recommend to normalize the offset to be always between [0, 360)
offset = Offset((offset.dx + value.dx) % 360, (offset.dy + value.dy) % 360);
sides = [side1, side3, ...] // change the order of the sides here accordingly with the new offset value. This is the hardest part. For a cube where you want to render all the 6 sides, you will have to perform a lot of calculations to know which side is in front of which.
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
// The rendered cube is inside the `Center` widget below
Center(
child: Transform(
key: const ValueKey('cube'),
transform: Matrix4.identity()
..rotateX(-offset.dy * pi / 180)
..rotateY(-offset.dx * pi / 180),
alignment: Alignment.center,
child: Stack(
children: sides,
),
),
),
// The gesture recognizer that will receive the movement of the mouse is inside the `Positioned.fill`
Positioned.fill(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: GestureDetector(
onPanUpdate: (details) {
update(details.delta);
},
child: Container(color: Colors.transparent),
),
),
Text('x: ${offset.dx} y: ${offset.dy}')
],
),
),
],
),
);
}
```
Note that you need to pass an unique key to every widget in the Stack to make it possible to Flutter identify uniquely every widget (you can see more about Keys in [https://www.youtube.com/watch?v=kn0EOS-ZiIc](https://www.youtube.com/watch?v=kn0EOS-ZiIc)).
I made a simple example below with a cube of 4 sides. To do the same in a cube of 6 sides will require more math, but I think I gave you enough knowledge to you figure it out that by yourself.
[https://dartpad.dev/?id=3698b3013fe7189d3c3c063d088cf69a](https://dartpad.dev/?id=3698b3013fe7189d3c3c063d088cf69a)
### How to capture the mouse movement independently of how the cube is rotated/transformed.
If the `GestureRecognizer` has the transformed cube as its child, the movement of the mouse will capture the original cube's side that was being show at the beggining (the blue side in my example), thus depending on how the cube is rotated, if the blue side is not visible anymore, the mouse will not be captured anymore. To solve that we have to split the mouse capture logic of the cube's rendering.
There are many possible ways, one of those is to render a `Stack` (to make one child be in front of another child, creating multiple layers). The underlayer will be used to render the cube and the overlayer will be used to capture the mouse movement (this layer needs to be transparent to don't affect the visualization of the cube).
I did that with the cobe below:
```
Stack(
children: [
Center( // This is the underlayer that renders the cube. It will be always in the center of the screen.
child: Transform(
key: const ValueKey('cube'),
transform: Matrix4.identity()
..rotateX(-offset.dy * pi / 180)
..rotateY(-offset.dx * pi / 180),
alignment: Alignment.center,
child: Stack(
children: sides,
),
),
),
Positioned.fill( // This is the overlayer that receives the mouse/finger movement. It has to be a `Positioned.fill` if you want that all the available space can be used to rotate the cube.
child: GestureDetector(
onPanUpdate: (details) {
update(details.delta);
},
child: Container(color: Colors.transparent), // We need any widget that actually renders pixels on the screen and that can have a size. If not, the `GestureRecognizer` would have size zero and would not work. The colors is transparent to allow the cube (that it is in the underlayer) to be visible.
),
),
],
)
```
| null | CC BY-SA 4.0 | null | 2022-12-28T16:24:04.340 | 2023-01-08T20:58:58.010 | 2023-01-08T20:58:58.010 | 5,673,445 | 5,673,445 | null |
74,942,674 | 2 | null | 74,942,604 | 4 | null | You could use `geom_errorbar` where the ymin and ymax are the same values like this:
```
library(ggplot2)
ggplot(aes(x = Factor, y = Percent), data = Tbl) +
geom_bar(position = "stack", stat = "identity", fill = "blue") +
ylim(0,100) +
geom_errorbar(aes(x = Factor, ymin = Percent, ymax = Percent), data = Tbl2,
stat = "identity", color = "black") +
theme_bw()
```

[reprex v2.0.2](https://reprex.tidyverse.org)
| null | CC BY-SA 4.0 | null | 2022-12-28T16:29:37.990 | 2022-12-28T16:29:37.990 | null | null | 14,282,714 | null |
74,942,716 | 2 | null | 74,942,604 | 3 | null | Another option is `geom_point` with `shape = 95` (line) and the size adjusted to suit:
```
library(tidyverse)
Tbl = data.frame(Factor = c("a","b","c","d"),
Percent = c(43,77,37,55))
Tbl2 = data.frame(Factor = c("a","b","c","d"),
Percent = c(58,68,47,63))
ggplot(aes(x = Factor, y = Percent), data = Tbl) +
geom_bar(position = "stack", stat = "identity", fill = "blue") +
ylim(0,100) +
geom_point(aes(x = Factor, y = Percent), data = Tbl2,
position = "stack", stat = "identity", color = "black", shape = 95, size = 30) +
theme_bw()
```

[reprex v2.0.2](https://reprex.tidyverse.org)
| null | CC BY-SA 4.0 | null | 2022-12-28T16:32:59.307 | 2022-12-28T16:32:59.307 | null | null | 7,327,058 | null |
74,942,856 | 2 | null | 26,187,813 | 0 | null | For what it's worth after eight years, I had a similar problem where Chrome would not load some images even though they were definitely available, ready, and waiting.
My solution was to close the browser, flushing cookies, history, and all the other internal cruft which had built up over time (using the "Close All & Clean" extension).
Restarting the browser and reloading the page, everything was there, all tickety-boo.
I have no useful theories on why this might've worked but as they say "works for me." Your mileage may vary.
| null | CC BY-SA 4.0 | null | 2022-12-28T16:45:50.200 | 2022-12-28T16:45:50.200 | null | null | 14,311,802 | null |
74,942,907 | 2 | null | 74,369,892 | 2 | null | You can try the below code. :)
[](https://i.stack.imgur.com/Lyiq5.gif)
```
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(
const MaterialApp(
home: Scaffold(
body: CreateApp(),
),
),
);
num map(num value,
[num iStart = 0, num iEnd = pi * 2, num oStart = 0, num oEnd = 1.0]) =>
((oEnd - oStart) / (iEnd - iStart)) * (value - iStart) + oStart;
class CreateApp extends StatefulWidget {
const CreateApp({super.key});
@override
CreateAppState createState() => CreateAppState();
}
class CreateAppState extends State<CreateApp> {
final List<Widget> _list = <Widget>[];
final double _size = 140.0;
double _x = pi * 0.25, _y = pi * 0.25;
late Timer _timer;
int get size => _list.length;
@override
Widget build(BuildContext context) {
return Stack(children: <Widget>[
// Rainbow
LayoutBuilder(
builder: (_, BoxConstraints c) => Stack(
children: _list.map((Widget w) {
final num i = map(size - _list.indexOf(w), 0, 150);
return Positioned(
top: (c.maxHeight / 2 - _size / 2) + i * c.maxHeight * 0.9,
left: (c.maxWidth / 2 - _size / 2) - i * c.maxWidth * 0.9,
child: Transform.scale(scale: i * 1.5 + 1.0, child: w));
}).toList())),
// Cube
GestureDetector(
onDoubleTap: _start,
onPanUpdate: (DragUpdateDetails u) => setState(() {
_x = (_x + -u.delta.dy / 150) % (pi * 2);
_y = (_y + -u.delta.dx / 150) % (pi * 2);
}),
child: Container(
color: Colors.transparent,
child: Cube(
color: Colors.grey.shade200, x: _x, y: _y, size: _size))),
]);
}
@override
void dispose() {
_timer.cancel();
super.dispose();
}
void _start() {
if (_timer.isActive) {
return;
}
_timer = Timer.periodic(const Duration(milliseconds: 48), (_) => _add());
}
void _add() {
if (size > 150) {
_list.removeRange(0, Colors.accents.length * 4);
} // Expensive, remove more at once
setState(() => _list.add(Cube(
x: _x,
y: _y,
color: Colors.accents[_timer.tick % Colors.accents.length]
.withOpacity(0.2),
rainbow: true,
size: _size)));
}
}
class Cube extends StatelessWidget {
const Cube(
{super.key,
required this.x,
required this.y,
required this.color,
required this.size,
this.rainbow = false});
static const double _shadow = 0.2, _halfPi = pi / 2, _oneHalfPi = pi + pi / 2;
final double x, y, size;
final Color color;
final bool rainbow;
double get _sum => (y + (x > pi ? pi : 0.0)).abs() % (pi * 2);
@override
Widget build(BuildContext context) {
final bool topBottom = x < _halfPi || x > _oneHalfPi;
final bool northSouth = _sum < _halfPi || _sum > _oneHalfPi;
final bool eastWest = _sum < pi;
return Stack(children: <Widget>[
_side(
zRot: y,
xRot: -x,
shadow: _getShadow(x).toDouble(),
moveZ: topBottom),
_side(
yRot: y,
xRot: _halfPi - x,
shadow: _getShadow(_sum).toDouble(),
moveZ: northSouth),
_side(
yRot: -_halfPi + y,
xRot: _halfPi - x,
shadow: _shadow - _getShadow(_sum),
moveZ: eastWest)
]);
}
num _getShadow(double r) {
if (r < _halfPi) {
return map(r, 0, _halfPi, 0, _shadow);
} else if (r > _oneHalfPi) {
return _shadow - map(r, _oneHalfPi, pi * 2, 0, _shadow);
} else if (r < pi) {
return _shadow - map(r, _halfPi, pi, 0, _shadow);
}
return map(r, pi, _oneHalfPi, 0, _shadow);
}
Widget _side(
{bool moveZ = true,
double xRot = 0.0,
double yRot = 0.0,
double zRot = 0.0,
double shadow = 0.0}) {
return Transform(
alignment: Alignment.center,
transform: Matrix4.identity()
..rotateX(xRot)
..rotateY(yRot)
..rotateZ(zRot)
..translate(0.0, 0.0, moveZ ? -size / 2 : size / 2),
child: Container(
alignment: Alignment.center,
child: Container(
constraints: BoxConstraints.expand(width: size, height: size),
color: color,
foregroundDecoration: BoxDecoration(
color: Colors.black.withOpacity(rainbow ? 0.0 : shadow),
border: Border.all(
width: 0.8,
color: rainbow ? color.withOpacity(0.3) : Colors.black26,
),
),
child: const FlutterLogo(
size: 200,
),
),
),
);
}
}
```
| null | CC BY-SA 4.0 | null | 2022-12-28T16:50:45.903 | 2022-12-28T16:50:45.903 | null | null | 18,040,554 | null |
74,942,989 | 2 | null | 74,942,604 | 2 | null | Here is one more using `geom_segment()`. Some would say to fancy, but anyway:
For this we have to extend `Tbl2`:
```
library(ggplot2)
library(dplyr)
ggplot(aes(x = Factor, y = Percent), data = Tbl) +
geom_bar(position = "stack", stat = "identity", fill = "blue") +
ylim(0,100) +
geom_segment(data = Tbl2 %>%
mutate(x = c(0.55, 1.55, 2.55, 3.55),
xend = x+0.9), aes(x=x,xend=xend, y = Percent, yend=Percent), size=2)+
theme_bw()
```
[](https://i.stack.imgur.com/5I1Mg.png)
| null | CC BY-SA 4.0 | null | 2022-12-28T17:00:22.090 | 2022-12-28T17:00:22.090 | null | null | 13,321,647 | null |
74,943,040 | 2 | null | 74,942,744 | 0 | null | So you are using the Field Calculator to compute the values for Column C from the values of Column A and Column B.
Note that QGIS Feature attributes have types they could be either integer, float, or text. Assuming your Column A and Column B are integers, then Column C would also be an integer column, therefore the value `'???'` would not be acceptable as this cannot be converted to an integer value.
One common approach to this is to reserve a specific value from the integer range as an additional INVALID DATA value. For instance if all your valid values are positive you could use `-1` as your INVALID DATA value.
Then your code could look like this:
```
if( ("PUNTS INICIALS ed50_EQM1 C d" is NULL) or ("PUNTS FINALS ed50_EQM1 C d" is NULL),
coalesce("PUNTS INICIALS ed50_EQM1 C d","PUNTS FINALS ed50_EQM1 C d"),
if("PUNTS INICIALS ed50_EQM1 C d"="PUNTS FINALS ed50_EQM1 C d","PUNTS INICIALS ed50_EQM1 C d",-1))
```
Note that `coalesce()` can be used to handle the case when one of the values is NULL.
| null | CC BY-SA 4.0 | null | 2022-12-28T17:05:44.073 | 2022-12-28T17:05:44.073 | null | null | 1,328,439 | null |
74,943,288 | 2 | null | 4,553,073 | 0 | null | After poking around a lot I managed to hide this extra column just by setting negative margin in a few places. It's quite hacky but it works:
```
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Margin" Value="0,0,-7,1"/>
</Style>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Margin" Value="0,0,-2,0"/>
</Style>
```
And perhaps add
```
<Trigger Property="Role" Value="Padding">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
```
in the GridViewColumnHeader style, as well.
First one can be set as negative as you like, it seems; it caps when it can't reduce anymore. Doing so will still leave a wee 2px gap on the right side of the headers, which the 2nd Style fixes.
Alas, the -2 margin applies to all GridViewColumnHeaders (and the Style Trigger method doesn't seem to work), so it can mess with inner borders and content alignment a bit, but if that's tolerable this works fine.
EDIT: Actually yeah scratch the -2 margin, it has too many negative side effects.
Inside `<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">` you'll find a `<GridViewHeaderRowPresenter>`; set its Margin equal to `"0,0,-2,0"` and you'll get the same effect without the drawbacks.
| null | CC BY-SA 4.0 | null | 2022-12-28T17:32:40.140 | 2023-01-04T19:15:56.807 | 2023-01-04T19:15:56.807 | 2,852,832 | 2,852,832 | null |
74,943,583 | 2 | null | 73,569,416 | 1 | null | You have to make sure that each of your menu commands have actions associated with them; otherwise, at run time, that exception is thrown.
So, after clicking on a menu command, go to the Connections Inspector and wire up an action to your code:
[](https://i.stack.imgur.com/MaxAF.png)
| null | CC BY-SA 4.0 | null | 2022-12-28T18:06:16.040 | 2022-12-30T06:01:59.547 | 2022-12-30T06:01:59.547 | 10,871,073 | 4,424,544 | null |
74,943,877 | 2 | null | 74,888,871 | 3 | null | I finally figured out the problem. This was silly oversight on my part. My code was using the result of the to add the new message to the list which updated the sending device to see the new message.
The correct way is to use with the exact same value that the api method replies to. In my case, each chat session is represented by a Guid and the API responsed to that Guid. However, the client was listening using
when it needs to be .
Below are my code changes. Notice, the result of invoke is irrevelant now, so using send or invoke would work.
```
this.connection.on(this.state.sessionItem.sessionId.toString(), (msg) => {
this.addNewMessageToState(msg);
});
sendMessage(){
this.connection.invoke("SendMessage",
{
sessionId: this.state.sessionItem.sessionId,
senderUserId: this.state.user.id,
message: this.state.newMessage
}).catch((error) => console.log('connection invoke error', error));
}
```
| null | CC BY-SA 4.0 | null | 2022-12-28T18:41:09.290 | 2022-12-28T18:41:09.290 | null | null | 19,256,909 | null |
74,943,940 | 2 | null | 56,764,684 | 0 | null | u fire the event only at the end.
if u slide back it wouldn't transform slides back to initialtion-part.
change it to mySwiper.on('progress', ...
```
swiper.on('progress', function(){
setTimeout(() => {
if (swiper.activeIndex == 0) {
$(".swiper-slide").css('transform', 'translate3d(125px, 0px, 0px)');
}
if (swiper.activeIndex == swiper.slides.length - 1) {
var translate_last = swiper.snapGrid[swiper.activeIndex] + swiper.snapGrid[0] + 10;
var translate_style = 'translate3d(-' + translate_last + 'px, 0px, 0px)';
$(".swiper-slide").css('transform', translate_style);
}
}, 10);
swiper.on('reachEnd', function(){
$(".swiper-slide").css('transform', 'translate3d(0px, 0px, 0px)');
});
});
```
| null | CC BY-SA 4.0 | null | 2022-12-28T18:50:14.497 | 2022-12-28T18:50:14.497 | null | null | 8,153,947 | null |
74,944,006 | 2 | null | 74,931,349 | 0 | null | The issue is not with Telerik.
The statement:
```
nameof(MiddlewareModel.Active ? "Active" : "Disable")
```
will give the same error in any context.
If you have an instance of Middleware class to work with then you'd use:
```
middlewareInstance.Active ? "Active" : "Disable"
```
to create the text `Active` or `Disable` based on the boolean value of Active property on middlewareInstance
| null | CC BY-SA 4.0 | null | 2022-12-28T18:57:08.640 | 2022-12-28T18:57:08.640 | null | null | 2,936,204 | null |
74,944,083 | 2 | null | 74,942,974 | 1 | null | The tilde (~) is interpreted by Asp.Net component, but as this is a native html img element, just remove the tilde and leading slash:
```
<img src = "images/Loading.gif" alt ="Loading" />
```
| null | CC BY-SA 4.0 | null | 2022-12-28T19:06:12.287 | 2022-12-28T19:06:12.287 | null | null | 2,936,204 | null |
74,944,334 | 2 | null | 74,944,270 | 0 | null | Sure - just put the part that needs encoding in a separate variable and use the [WebUtility.HtmlEncode](https://learn.microsoft.com/en-us/dotnet/api/system.net.webutility.htmlencode?view=net-7.0) method (found in `System.Net`):
```
string bad_xml = "Tes <> & \"' characters ";
bad_xml = WebUtility.HtmlEncode(bad_xml);
string xml = "<Models><Model ModelId=\"124\" ModelNameWithSpecialCHars=\"" + bad_xml + "\"/Model></Models>"
```
although you might find it cleaner to add elements and attributes using the `XmlDocument` class since you want to have an `XmlDocument` in the end anyway, and it will encode text for you into valid XML, which has slightly different escaping requirements (although for your test string they are equivalent).
| null | CC BY-SA 4.0 | null | 2022-12-28T19:37:27.817 | 2022-12-28T19:37:27.817 | null | null | 1,081,897 | null |
74,944,388 | 2 | null | 74,942,905 | 0 | null | You can use [array_agg()](https://www.postgresql.org/docs/current/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE) to collect all `"FECHA"` [ordered](https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-AGGREGATES) per `"ID"` in a [with common table expression](https://www.postgresql.org/docs/current/queries-with.html), then access them by their index. In case some of your `"ID"`s don't have 4 `"FECHA"`s to their name, you can use [array_upper()](https://www.postgresql.org/docs/current/functions-array.html#id-1.5.8.25.6.2.2.14.1.1.1) to get the index of the last element:
```
with cte as
( select
x."ID",
array_agg(x."FECHA" order by x."FECHA") as all_fecha_per_id
from sirha7.v_marcaciones x
WHERE x."CEDULA" = '0401219282' AND CAST(x."FECHA" AS date) = '2022-12-27'
GROUP BY x."ID", DATE_TRUNC ('day', x."FECHA") )
select
y."ID",
all_fecha_per_id[array_lower(all_fecha_per_id,1)] as "1pos",
all_fecha_per_id[1] as "1pos",
all_fecha_per_id[2] as "2pos",
all_fecha_per_id[3] as "3pos",
all_fecha_per_id[4] as "4pos",
all_fecha_per_id[array_upper(all_fecha_per_id,1)] as "4pos"
from cte as y
ORDER BY 2 DESC;
```
[Online demo](https://dbfiddle.uk/vACRmdKB)
| null | CC BY-SA 4.0 | null | 2022-12-28T19:43:49.877 | 2022-12-28T19:43:49.877 | null | null | 5,298,879 | null |
74,944,849 | 2 | null | 74,944,470 | 1 | null | You can use the `IconToggleButton` without using drawable resources.
Just use the `clip` and `border` modifier to achieve the shape:
```
var checked by remember { mutableStateOf(false) }
val tint by animateColorAsState(if (checked) Teal200 else Black)
val textColor = if (checked) White else Teal200
IconToggleButton(
checked = checked,
onCheckedChange = { checked = it },
modifier = Modifier
.clip(CircleShape)
.border(1.dp, Teal200, CircleShape)
.background(tint)
) {
Text("M", color = textColor)
}
```
[](https://i.stack.imgur.com/b7puu.png)
| null | CC BY-SA 4.0 | null | 2022-12-28T20:46:56.510 | 2022-12-28T20:46:56.510 | null | null | 2,016,562 | null |
74,945,334 | 2 | null | 74,939,991 | 0 | null | `classification_report` has an `output_dict` parameter that causes the function to return a dictionary instead of a string.
If you have a threshold (e.g. `0.7`) for f1-scores, you can iterate over the results and select the labels with values higher than the threshold:
```
from sklearn.metrics import classification_report
y_true = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3]
y_pred = [0, 1, 2, 0, 0, 1, 4, 3, 1, 1, 2, 2, 2, 3, 2, 1, 3, 3, 3]
labels = [0, 1, 2, 3]
cr = classification_report(y_true, y_pred, output_dict=True)
for l in labels:
if (f1_score := cr[str(l)]["f1-score"]) > 0.7:
print(f"Label {l}, f1-score: {f1_score:.3f}")
```
Output:
```
Label 0, f1-score: 0.750
Label 2, f1-score: 0.800
```
| null | CC BY-SA 4.0 | null | 2022-12-28T21:52:52.223 | 2022-12-28T21:52:52.223 | null | null | 12,439,119 | null |
74,945,341 | 2 | null | 74,944,882 | 0 | null | Declare your `int` property which is mapped to database number field as nullable with `int?`.
| null | CC BY-SA 4.0 | null | 2022-12-28T21:54:12.857 | 2022-12-28T21:54:12.857 | null | null | 5,607,537 | null |
74,945,921 | 2 | null | 73,312,653 | 0 | null | You might have put the `it()` `describe()` statements in the wrong place. Try creating the most simple test file possible or better still use an example test that cypress provides strip it down and continue to test it until it is barebones.
| null | CC BY-SA 4.0 | null | 2022-12-28T23:32:18.063 | 2023-01-01T10:41:22.247 | 2023-01-01T10:41:22.247 | 14,267,427 | 10,520,072 | null |
74,945,949 | 2 | null | 74,945,922 | 3 | null | Your input values have more digits of precision than JS floats can hold, so the last digit is being rounded to the nearest binary value. This causes the first one to be read as `2.5`, and `Math.round()` rounds this to 3.
You can see this by printing the values of `result` before rounding.
```
let result;
result = 2.4999999999999998;
console.log(result, Math.round(result));
result = 2.4999999999999997;
console.log(result, Math.round(result));
```
| null | CC BY-SA 4.0 | null | 2022-12-28T23:37:38.150 | 2022-12-28T23:37:38.150 | null | null | 1,491,895 | null |
74,945,955 | 2 | null | 74,945,922 | 1 | null | That extra 1 at the end of `2.4999999999999998` results in it being too close to 2.5 for JavaScript to recognize a difference.
```
const withEight = 2.4999999999999998;
console.log(2.4999999999999998 === 2.5)
```
So `Math.round(2.4999999999999998)` is the same as `Math.round(2.5)`.
And, as [the specification requires](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-math.round) that, when a number is rounded that is exactly between two integers, the higher integer is preferred.
>
1. Return the integral Number closest to n, preferring the Number closer to +∞ in the case of a tie.
So 3 is the result.
| null | CC BY-SA 4.0 | null | 2022-12-28T23:38:27.187 | 2022-12-28T23:38:27.187 | null | null | 9,515,207 | null |
74,946,173 | 2 | null | 11,291,727 | 0 | null | That worked for me:
1. Project->Java Build Path->Libraries->JRE version
2. Project->Java Compiler-> Compiler Compliance Level
3. Project->Project Facets->Java->Version
4. If you using Maven edit in pom.xml <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
| null | CC BY-SA 4.0 | null | 2022-12-29T00:25:01.100 | 2022-12-29T00:25:01.100 | null | null | 12,596,334 | null |
74,946,322 | 2 | null | 74,882,674 | 0 | null | Try adding this to your command.
```
-sws_flags +accurate_rnd+bitexact+full_chroma_int
```
| null | CC BY-SA 4.0 | null | 2022-12-29T00:57:03.990 | 2022-12-29T00:57:03.990 | null | null | 4,628,911 | null |
74,946,410 | 2 | null | 60,370,144 | 0 | null | You can find the answer here.
I have created graphical effects and animation that can be applied to any PyQt / PySide widget to display blurred content under widget. Also you can add many translucent backgrounds to widget (color or gradient)
Shine animation can be adjusted in angle, color, width and duration.
Move animation can be adjusted in offset and duration.
This effect only works with child widgets. If it is applied to the main widget, then it will not work. [https://github.com/GvozdevLeonid/BackDrop-in-PyQt-PySide](https://github.com/GvozdevLeonid/BackDrop-in-PyQt-PySide)
| null | CC BY-SA 4.0 | null | 2022-12-29T01:19:46.020 | 2022-12-29T01:19:46.020 | null | null | 15,261,286 | null |
74,946,432 | 2 | null | 74,930,526 | 0 | null | The root cause is the incorrect model view GUID (saying `APS_MODEL_VIEW`) at [https://github.com/autodesk-platform-services/aps-iot-extensions-demo/blob/master/public/config.js#L2](https://github.com/autodesk-platform-services/aps-iot-extensions-demo/blob/master/public/config.js#L2)
After changing the URN, the `APS_MODEL_VIEW` must be changed together since the GUID specified in the [config.js](https://github.com/autodesk-platform-services/aps-iot-extensions-demo/blob/master/public/config.js#L2) is the master view's GUID. The master view is generated by Model Derivative service automatically, so its GUID is not persistent like other Revit views inside the RVT file.
| null | CC BY-SA 4.0 | null | 2022-12-29T01:23:56.477 | 2022-12-29T01:23:56.477 | null | null | 7,745,569 | null |
74,946,673 | 2 | null | 20,427,210 | 0 | null | I think the issue is that MyBatis can't find the XML mapper configuration file. In my project using `Spring Boot` with `MyBatis-3`, I configured the mapper location in the `application.properties` as shown below:
```
mybatis.mapper-locations=classpath:mappers/*.xml
```
If you're using `application.yml` instead of `.properties`:
```
mybatis:
mapper-locations: "classpath:mappers/*.xml"
```
| null | CC BY-SA 4.0 | null | 2022-12-29T02:19:03.867 | 2023-01-09T11:03:35.763 | 2023-01-09T11:03:35.763 | 5,151,202 | 2,447,324 | null |
74,946,685 | 2 | null | 74,946,658 | 0 | null | Here is an example of how you can do this in ECharts:
```
dataZoom: [{
type: 'inside',
start: 50,
end: 100,
xAxisIndex: [0],
filterMode: 'empty'
}, {
type: 'slider',
start: 50,
end: 100,
xAxisIndex: [0],
filterMode: 'empty',
bottom: 0,
height: 20,
handleIcon: 'M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '120%',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
}
}],
```
| null | CC BY-SA 4.0 | null | 2022-12-29T02:21:44.683 | 2022-12-29T10:21:19.213 | 2022-12-29T10:21:19.213 | 15,319,747 | 20,594,416 | null |
74,947,209 | 2 | null | 74,946,942 | 1 | null | ```
<!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">
<title>sweetalert2 example</title>
</head>
<body>
<script>
window.onload = function() {
Swal.fire({
title: 'Good job!',
text: 'You clicked the button!',
type: 'success',
});
}
</script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
</body>
</html>
```
Link it to this URL instead [https://cdn.jsdelivr.net/npm/sweetalert2@11](https://cdn.jsdelivr.net/npm/sweetalert2@11)
```
// @require https://cdn.jsdelivr.net/npm/sweetalert2@11
```
As [double-beep](https://stackoverflow.com/users/10607772/double-beep) has mentioned [previously](https://stackoverflow.com/a/74958708) you need to:
> by adding `// @unwrap` to the headers
and leave it empty.
```
// @unwrap
```
Then call your modal like this:
```
/* global Swal */
window.onload = function() {
Swal.fire({
title: 'Good job!',
text: 'You clicked the button!',
type: 'success',
});
}
```
I hope this helps!
| null | CC BY-SA 4.0 | null | 2022-12-29T04:20:45.770 | 2023-02-16T22:11:52.303 | 2023-02-16T22:11:52.303 | 4,108,803 | 16,550,668 | null |
74,947,803 | 2 | null | 74,947,740 | 0 | null | Try this in Scaffold
```
return Scaffold(
body: screens.elementAt(currentIndex),
bottomNavigationBar: BottomNavyBar(
```
Remove bottomNavigationBar: const navBar() from homepage
Call navBar class in home of main.dart file as below
```
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
home: navBar(), <------ here
);
}
}
```
| null | CC BY-SA 4.0 | null | 2022-12-29T06:06:07.293 | 2022-12-29T06:20:40.987 | 2022-12-29T06:20:40.987 | 20,774,099 | 20,774,099 | null |
74,948,049 | 2 | null | 74,947,966 | 0 | null | You should read this [docs](https://reactjs.org/docs/composition-vs-inheritance.html), all you need here is `children` props
| null | CC BY-SA 4.0 | null | 2022-12-29T06:45:04.340 | 2022-12-29T06:45:04.340 | null | null | 19,296,546 | null |
74,948,066 | 2 | null | 74,947,966 | 0 | null | The word will not be displayed because you are calling the custom component in the project template with no props name which you want to display. In your code if you render the component the name will displayed only.
use this in the project template and pass the props to the childrenanme
```
<div className="projects">
{props.childrenanme}
</div>
```
| null | CC BY-SA 4.0 | null | 2022-12-29T06:48:17.547 | 2022-12-29T06:48:17.547 | null | null | 18,512,567 | null |
74,948,098 | 2 | null | 74,947,740 | 1 | null | In your homePage(), remove list of pages, currentIndex and bottom navBar.
Your homePage() should look like this:
```
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
var webb = '';
String webOccupancy = '';
String greyOccupancy = '';
String vannierOccupancy = '';
String libTime = '';
String webLevel = '';
String greyLevel = '';
String vannierLevel = '';
class _HomePageState extends State<HomePage> {
bool isLoading = true;
@override
void initState() {
super.initState();
_fetchWebOccupancy();
_fetchVannierOccupancy();
_fetchGreyOccupancy();
_fetchLibTime();
}
Future<void> _fetchLibTime() async {
if (libTime == '') {
String? libraryTime = await getDataAPI_time().getPosts();
setState(() {
libTime = libraryTime.toString();
});
}
}
Future<void> _fetchWebOccupancy() async {
if (webOccupancy == '') {
String? occupancy = await getDataAPI().getPosts();
setState(() {
webOccupancy = occupancy!.substring(0, occupancy.length - 5);
if (webOccupancy == '' || int.parse(webOccupancy) < 0) {
webOccupancy = '0';
}
if (int.parse(webOccupancy) > 100) {
webLevel = 'High';
} else if (int.parse(webOccupancy) > 75 &&
int.parse(webOccupancy) < 100) {
webLevel = 'Medium';
} else {
webLevel = 'Low';
}
isLoading = false;
});
}
}
Future<void> _fetchGreyOccupancy() async {
if (greyOccupancy == '') {
String? occupancy = await getDataAPI_G().getPosts();
setState(() {
greyOccupancy = occupancy!.substring(0, occupancy.length - 5);
if (greyOccupancy == '' || int.parse(greyOccupancy) < 0) {
greyOccupancy = '0';
}
if (int.parse(greyOccupancy) > 100) {
greyLevel = 'High';
} else if (int.parse(greyOccupancy) > 50 &&
int.parse(greyOccupancy) < 100) {
greyLevel = 'Medium';
} else {
greyLevel = 'Low';
}
isLoading = false;
});
}
}
Future<void> _fetchVannierOccupancy() async {
if (vannierOccupancy == '') {
String? occupancy = await getDataAPI_V().getPosts();
setState(() {
vannierOccupancy = occupancy!.substring(0, occupancy.length - 5);
if (vannierOccupancy == '' || int.parse(vannierOccupancy) < 0) {
vannierOccupancy = '0';
}
if (int.parse(vannierOccupancy) > 100) {
vannierLevel = 'High';
} else if (int.parse(vannierOccupancy) > 50 &&
int.parse(vannierOccupancy) < 100) {
vannierLevel = 'Medium';
} else {
vannierLevel = 'Low';
}
isLoading = false;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
// elevation: 15,
// leading: IconButton(
// icon: const Icon(Icons.menu),
// onPressed: () {},
// ),
title: const Text('xConcordia'),
flexibleSpace: Container(
decoration: const BoxDecoration(
boxShadow: [
BoxShadow(
color: Color.fromARGB(223, 57, 25, 163),
offset: Offset(0, 0),
blurRadius: 20,
),
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.blue, Colors.purple],
),
),
),
),
body: isLoading
? const Center(
child: LinearProgressIndicator(
color: Color.fromARGB(162, 114, 68, 251),
))
: Container(
margin: const EdgeInsets.only(top: 20),
child: Column(
children: [
// ignore: prefer_const_constructors
LibraryStatsHeader(), //LibraryStatsHeader widget is in a file called libraryStatsHeader
const Padding(padding: EdgeInsets.all(10)),
libCards(), //libCards widget is in a file called libraryCards
const categoryPicker(), //category picker
],
),
),
);
}
}
```
Do not add bottomNavigation to the list of pages like homePage(), secondRoute(), etc.
| null | CC BY-SA 4.0 | null | 2022-12-29T06:52:50.723 | 2022-12-29T06:52:50.723 | null | null | 6,067,774 | null |
74,948,304 | 2 | null | 74,947,673 | 0 | null | [This](https://stackoverflow.com/questions/46953967/multilabel-indicator-is-not-supported-for-confusion-matrix) thread has the information for your matrix error.
As for the accuracy, you can first play around with your arguments and change the weights type or the number of neighbours. You can also try other techniques, I generally prefer to use svm. Also, not every data is predictable, so you might also be interested in checking that for your data by running a chi-squared analysis or other [feature selection techniques](https://towardsdatascience.com/how-to-find-the-best-predictors-for-ml-algorithms-4b28a71a8a80)
| null | CC BY-SA 4.0 | null | 2022-12-29T07:23:40.173 | 2022-12-29T07:23:40.173 | null | null | 20,878,623 | null |
74,948,347 | 2 | null | 16,235,706 | 0 | null | One should not configure the `goto_definition` shortcut -- you would also need a shortcut to go back(and forth) after you jump to the definition.
Hence, consider configuring shortcuts: `goto_definition`, `jump_back`, and `jump_forward` as follows in your config file :
```
// go to the definition
{ "keys": ["ctrl+i"], "command": "goto_definition" },
// go back to the previous location
{ "keys": ["ctrl+h"], "command": "jump_back" },
// go to the next location
{ "keys": ["ctrl+l"], "command": "jump_forward" },
```
I find these three commands especially useful while trying to read code quickly.
| null | CC BY-SA 4.0 | null | 2022-12-29T07:29:32.477 | 2022-12-29T07:36:35.297 | 2022-12-29T07:36:35.297 | 3,646,014 | 3,646,014 | null |
74,948,401 | 2 | null | 74,947,966 | 0 | null | To Answer your Question:
> In JSX expressions that contain both an opening tag and a closing tag,
the content between those tags is passed as a special prop [React Documentation](https://reactjs.org/docs/jsx-in-depth.html#children-in-jsx).
And to use these special props you have to use `{props.children}`.
In your example, you have passed the content b/w opening and closing tag of a custom component but forgot to use it.
In projectTemplate component use the children that you have passed while invoking the component, like this:
```
<div className="projects">
{props.childrenanme}
</div>
```
| null | CC BY-SA 4.0 | null | 2022-12-29T07:35:01.647 | 2022-12-29T07:35:01.647 | null | null | 8,627,333 | null |
74,948,499 | 2 | null | 69,659,431 | 0 | null | I hope that's useful for you
```
import pandas as pd
df = pd.read_csv("combined.csv")
df[["Date", "Time"]] = df["dates"].str.split(" ", expand=True)
```
| null | CC BY-SA 4.0 | null | 2022-12-29T07:47:20.583 | 2022-12-29T07:48:07.500 | 2022-12-29T07:48:07.500 | 20,588,255 | 20,588,255 | null |
74,948,631 | 2 | null | 74,879,489 | 0 | null | i solved it for anyone who will meet it in future
i devied it to weeks and did the action on small group of dates and it worked !
thanx
| null | CC BY-SA 4.0 | null | 2022-12-29T08:05:57.057 | 2022-12-29T08:05:57.057 | null | null | 15,606,982 | null |
74,948,673 | 2 | null | 74,944,999 | 1 | null | Could it be a property of the chosen projection? You can see it happening when adding the transformation by inspecting the `ax._position`, `ax._originalPosition` attributes:
```
Bbox([[0.015576512213622107, 0.0], [0.9844234877863779, 1.0]])
Bbox([[0.0, 0.0], [1.0, 1.0]])
```
You can add `ax.set_adjustable('datalim')` to make it change the limits, instead of the box (of the axes) to fill the given extent. Note how this slightly changes the `ax.get_xlim()` & `ax.get_ylim()`, so make sure that's acceptable for your application.
I personally often explicitly add the dpi and bbox when saving, to make sure the output has the intended dimensions, see the example below.
When I use a different projection, I can get it to work straightaway, the code below produces a clean 500x500px image with only the axes visible in the output, not the red figure. So perhaps it's a property of the PlateCarree projection?
```
map_proj = ccrs.Mercator()
fig, ax = plt.subplots(
figsize=(5, 5), dpi=100, facecolor="r",
subplot_kw={'projection': map_proj},
)
fig.subplots_adjust(left=0.0, bottom=0.0, right=1.0, top=1.0)
ax.set_extent([-10000000, 10000000, -10000000, 10000000], crs=map_proj)
ax.coastlines()
fig.savefig('Test.png', bbox_inches=0, dpi=100)
```
| null | CC BY-SA 4.0 | null | 2022-12-29T08:10:21.830 | 2022-12-29T08:10:21.830 | null | null | 1,755,432 | null |
74,948,765 | 2 | null | 61,594,595 | 0 | null | I have resolved this,
Actually, i set another layout for this activity in setcontentView,
When I set the original layout it worked.
| null | CC BY-SA 4.0 | null | 2022-12-29T08:21:40.163 | 2022-12-29T08:21:40.163 | null | null | 13,644,300 | null |
74,948,938 | 2 | null | 74,791,058 | 2 | null | When you create the tailwindcss, Ensure that the content array is not empty, do add the following:
```
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx}',
],
theme: {
extend: {},
},
plugins: [],
}
```
| null | CC BY-SA 4.0 | null | 2022-12-29T08:43:42.510 | 2022-12-29T08:43:42.510 | null | null | 20,885,533 | null |
74,949,346 | 2 | null | 74,949,294 | 0 | null | No, There is no option available at the moment for disabling this feature only for literals. Inlay Type Hints with plylance is recently released and it only provides [following two types](https://devblogs.microsoft.com/python/python-in-visual-studio-code-july-2022-release/#inlay-type-hints).
> In this release, we have added when using
Pylance: for variable types and for return types.Return type inlay hints show the return types of functions that don’t
have an explicit annotation. To enable it, you can set
“`python.analysis.inlayHints.functionReturnTypes`”: true to your user
settings (Preferences: Open Settings (JSON) command).Similarly, variable type inlay hints show the types of variables that
don’t have explicit type annotations. You can enable it by setting
“`python.analysis.inlayHints.variableTypes”: true`.
May be you can submit a feature request/issue [here](https://github.com/microsoft/pylance-release)
| null | CC BY-SA 4.0 | null | 2022-12-29T09:26:16.807 | 2022-12-29T09:26:16.807 | null | null | 6,699,447 | null |
74,949,844 | 2 | null | 74,947,649 | 0 | null | Firebase apps will automatically [log the class name](https://firebase.google.com/docs/analytics/screenviews) of the UIViewController or Activity that is currently in focus. You might have set an Activity or the UIViewController with "/home". Where for "All Screen-Home", you're [manually logging](https://firebase.google.com/docs/analytics/screenviews#manually_track_screens) it in your app.
On the other hand, you will get a (not set) value in screen reporting if you are passing the screen name when the activity/fragment is not in a proper state or when you try to set the screen name before an Activity is presented. As such, (not set) is a placeholder that Google Analytics uses when it matches this scenario.
| null | CC BY-SA 4.0 | null | 2022-12-29T10:19:10.637 | 2022-12-29T10:19:10.637 | null | null | 20,393,543 | null |
74,949,982 | 2 | null | 74,949,606 | 0 | null | Consider the following dataset
[](https://i.stack.imgur.com/mYVOZm.png)
. But this won't replace any other string e.g. X0 contains value oth.
```
df.apply(lambda s: s.replace({s.name: np.nan}))
```
[](https://i.stack.imgur.com/zFdA1m.png)
```
df.apply(lambda s: pd.to_numeric(s, errors='coerce'))
```
[](https://i.stack.imgur.com/GKaZBm.png)
```
COLS = ['X0', 'X2']
df.apply(lambda s: pd.to_numeric(s, errors='coerce') if s.name in COLS else s)
```
[](https://i.stack.imgur.com/icB8km.png)
I have used pandas apply function but same result can be achieved with for loop
| null | CC BY-SA 4.0 | null | 2022-12-29T10:32:18.737 | 2022-12-29T10:32:18.737 | null | null | 5,828,964 | null |
74,950,585 | 2 | null | 74,948,436 | 0 | null | Maybe is hidden on your mac, for remove this file close your vscode and terminate all terminals then go to the project folder then remove ._. file, if it does not work restart your system and go there (Don't open your vscode ) and remove it.
| null | CC BY-SA 4.0 | null | 2022-12-29T11:32:52.880 | 2022-12-29T11:32:52.880 | null | null | 7,081,144 | null |
74,950,647 | 2 | null | 74,950,464 | 0 | null | You miss adding the Request class as an argument into your method. Your method should look like this:
```
public function register(Request $request)
{
//after validation
$data = $request->validated();
}
```
Dont forget to add `use Illuminate\Http\Request;` in your use statement.
| null | CC BY-SA 4.0 | null | 2022-12-29T11:39:13.813 | 2022-12-29T11:39:13.813 | null | null | 10,302,063 | null |
74,950,697 | 2 | null | 50,523,233 | 0 | null | I have resolved my issue by doing this in android/app/build.gradle
> implementation 'com.facebook.fresco:animated-gif:2.6.0'
| null | CC BY-SA 4.0 | null | 2022-12-29T11:44:48.520 | 2022-12-29T11:44:48.520 | null | null | 15,978,267 | null |
74,950,852 | 2 | null | 74,948,256 | 0 | null | I solved this problem.
```
const ActivitySchema = yup.object().shape({
Activity: yup.lazy((value) => {
if (value) {
const ValidationObject = {
ActivityName: yup.string().required(''),
Answers: yup.lazy((val) => {
if (val) {
const ValidObject = {
LanguageName: yup.string().required(''),
Answer: yup.string().required('').max(maxChar, ''),
}
const NewEnt = Object.entries(val)?.reduce((acc, [key, value]) => ({
...acc,
[key]: yup.object().shape(ValidObject)
}), {})
return yup.object().shape(NewEnt)
}
return yup.mixed('').notRequired('')
})
}
const NewEntries = Object.entries(value)?.reduce((acc, [key, value]) => ({
...acc,
[key]: yup.object().shape(ValidationObject)
}), {})
return yup.object().shape(NewEntries)
}
return yup.mixed('').notRequired('')
}
),
ActivityFiles: yup.array().min(1, ''),
})
```
| null | CC BY-SA 4.0 | null | 2022-12-29T12:00:06.257 | 2022-12-29T12:00:06.257 | null | null | 20,884,951 | null |
74,950,883 | 2 | null | 74,898,013 | 0 | null | Try Check the first checkbox .
[](https://i.stack.imgur.com/DmIuR.png)
| null | CC BY-SA 4.0 | null | 2022-12-29T12:02:28.993 | 2022-12-29T12:02:28.993 | null | null | 5,801,883 | null |
74,951,013 | 2 | null | 54,639,841 | 2 | null | For MacBook-
1. Go to System Preferences
2. Then, select Security & Privacy
3. There next go to top tapbar- in Privacy
4. At left, you will see Full Disk Access
5. For Full Disk Access, there will be list here have to select Terminal, if not selected
6. If there is no Terminal option . Then add it by clicking + plus and you will go to finder
7. Select application at left side
8. Then, go to Utilities 9.inside utilities, you will Terminal, select it and click on open button
That set
Now, you will get error-
| null | CC BY-SA 4.0 | null | 2022-12-29T12:18:03.070 | 2022-12-29T12:18:03.070 | null | null | 8,937,229 | null |
74,951,043 | 2 | null | 74,950,987 | 1 | null | Usually we run the file which will be referencing to the other files. you don't normally need to restructure the files as it is intended by the original author.
| null | CC BY-SA 4.0 | null | 2022-12-29T12:20:21.350 | 2022-12-29T12:20:21.350 | null | null | 20,885,766 | null |
74,951,318 | 2 | null | 74,948,467 | 0 | null | When you initialize an empty array without any type annotations, TypeScript infers the type of the array items to be `never`. So, you will have to give a type to your array:
```
interface Role {
id: string;
roleName: string;
}
export const appRolesSlice = createSlice({
...
initialState: {
role: [] as Array<Role>,
allRole: []
},
...
})
```
You need to do the same for the `allRole` property.
| null | CC BY-SA 4.0 | null | 2022-12-29T12:48:22.227 | 2023-01-06T17:04:45.480 | 2023-01-06T17:04:45.480 | 18,244,921 | 8,822,610 | null |
74,951,446 | 2 | null | 74,945,787 | 0 | null | You need to use `input.string()` and then pass the options you want to have to its `options` argument.
```
in_op_1 = input.string("Show all candle crosses below S-Line", "Title", ["Show all candle crosses below S-Line", "Show all candle crosses above S-Line"])
```
This would show up as:
[](https://i.stack.imgur.com/zVd1Q.png)
# Edit for v4:
```
in_op_1 = input(defval="Show all candle crosses below S-Line", title="Title", options=["Show all candle crosses below S-Line", "Show all candle crosses above S-Line"], type=input.string)
```
| null | CC BY-SA 4.0 | null | 2022-12-29T13:03:18.997 | 2023-01-03T07:49:05.207 | 2023-01-03T07:49:05.207 | 7,209,631 | 7,209,631 | null |
74,951,597 | 2 | null | 74,946,679 | 0 | null | You should not create new connection at every call getRanking.
Keep a fixed length pool of connections for use around all your application. Or your should close the connection after each call getRanking method. Read more attentively topic at the link you've give [https://stackoverflow.com/a/14607887/20872738](https://stackoverflow.com/a/14607887/20872738).
Also async await at your code do nothing if you are using callbacks.
You can use something like this.
```
async function getRanking() {
let result = '';
const client = new MongoClient(uri);
try {
await client.connect(uri);
const sort = {
lastValue: -1
};
result = (await client.db("cluster0").collection("users")
.find()
.sort(sort)
.limit(10)
.toArray()).reduce((res, item) => {
return res += '|' + item.styledUsername.toString() + "!" + item.lastValue;
}, '');
} catch(e) {
console.error(e);
} finally {
await client.close();
}
return result;
}
```
[https://www.mongodb.com/developer/languages/javascript/node-connect-mongodb/](https://www.mongodb.com/developer/languages/javascript/node-connect-mongodb/)
| null | CC BY-SA 4.0 | null | 2022-12-29T13:18:12.457 | 2022-12-30T05:37:48.637 | 2022-12-30T05:37:48.637 | 20,872,738 | 20,872,738 | null |
74,951,841 | 2 | null | 74,951,691 | 0 | null | It always depends on the Date field UI.
If it is with an input tag you can try
```
cy.get(':nth:child(3) > .form-control').clear().type('1999-02-01')
```
If not, it might be the date picker type. You can try to click it on the field and add the additional script.
```
cy.get(':nth:child(3) > .form-control').click()
```
| null | CC BY-SA 4.0 | null | 2022-12-29T13:40:22.770 | 2022-12-29T23:43:15.850 | 2022-12-29T23:43:15.850 | 2,452,869 | 7,614,784 | null |
74,952,050 | 2 | null | 74,945,922 | 0 | null | The surprising behavior is not really related to `Math.round()`. The rounding happens already at the point of parsing the numeric literal, and you can see it by echoing the numbers directly without any explicit rounding:
```
> 2.4999999999999998
2.5
> 2.4999999999999997
2.4999999999999996
```
So the first number is immediately rounded up and the second down - but not corresponding to the common rules of decimal rounding (e.g. the second number still have the same number of digits).
The reason is that the numeric literal is converted to a 64-bit floating point number. This has a precision of 53 binary digits. The input number is therefore rounded to the closest number which can be represented with 53 binary digits.
The binary representation of 2.4999999999999996 is:
```
10.011111111111111111111111111111111111111111111111111
```
This is 53 significant binary digits, and the next higher binary number is therefore:
```
10.100000000000000000000000000000000000000000000000000
```
Which is 2.5 in decimal.
So numbers between 2.4999999999999996 and 2.5 cannot be represented exactly and have to be rounded up or down to fit in the floating-point format. So 2.4999999999999997 is rounded down to 2.4999999999999996 and 2.4999999999999998 is rounded up to 2.5.
(There is a special rule because 2.4999999999999998 is halfway between the two valid values. In this case the value is rounded towards the even significand.)
Math.round() on the other hand follows decimal rounding rules, which means we round up on 0.5 and higher. The result of the Math.round() operation is then straightforward: 2.5 is rounded up to 3 and 2.4999999999999996 is rounded down to 2.
| null | CC BY-SA 4.0 | null | 2022-12-29T13:59:54.450 | 2022-12-29T15:46:58.610 | 2022-12-29T15:46:58.610 | 7,488 | 7,488 | null |
74,952,067 | 2 | null | 74,950,103 | 0 | null | It looks like based on tags you're using shiny and shinydashboard. You won't be able to add unicode `\n` newline for this; instead, you can wrap your text in `HTML` and then use `<br>` tag for line breaks. If you need to dynamically render the text in your `valueBox`, you can use `paste`. Below is a complete example.
```
library(shinydashboard)
library(shiny)
ui <- dashboardPage(
dashboardHeader(title = "Value box example"),
dashboardSidebar(),
dashboardBody(
fluidRow(
valueBoxOutput("myValueBox")
)
)
)
server <- function(input, output) {
output$myValueBox <- renderValueBox({
valueBox(
value = HTML("C: 7.07<br>A: 7.03<br>B: 6.82"), "Durchschnittliche Bewertungen der Filiale", color = "yellow"
)
})
}
shinyApp(ui, server)
```
[](https://i.stack.imgur.com/3yiH3.png)
| null | CC BY-SA 4.0 | null | 2022-12-29T14:01:38.753 | 2022-12-29T14:01:38.753 | null | null | 3,460,670 | null |
74,952,228 | 2 | null | 74,949,765 | 0 | null | First You have to run
npm ls react-native-webview
then see there are multiple Dependencies of react-native-webview installed on your project.
Please Run
yarn add react-native-webview-leaflet
| null | CC BY-SA 4.0 | null | 2022-12-29T14:15:30.193 | 2022-12-29T14:15:30.193 | null | null | 20,886,124 | null |
74,952,414 | 2 | null | 74,952,122 | -1 | null | You want to use [split](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
I use [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) and [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) to generate the HTML
I have used recommended eventListeners and also made the radios/checkboxes work since radios need the same name and the checkbox not
```
window.addEventListener("DOMContentLoaded", () => { // when page has loaded
const nameField = document.getElementById("names");
const typeField = document.getElementById("type");
const createBut = document.getElementById("create");
const resultDiv = document.getElementById("result");
createBut.addEventListener("click", () => {
const names = nameField.value.trim().split(/,\s?/); // split on comma with or without trailing space
console.log(names);
const type = typeField.value;
resultDiv.innerHTML = names
.map(name => `<label><input type="${type}"
name="${type==='checkbox' ? name : 'rad'}"
${type==='checkbox' ? '' : `value="${name}"`}"/>${name}`).join('<br/>');
});
});
```
```
Items: <input id="names" /><br /> Type:
<select id="type">
<option value="radio">Radio</option>
<option value="checkbox">Checkbox</option>
</select><br />
<button type="button" id="create">Create</button>
<div id="result"></div>
```
| null | CC BY-SA 4.0 | null | 2022-12-29T14:34:10.710 | 2022-12-29T14:41:21.867 | 2022-12-29T14:41:21.867 | 295,783 | 295,783 | null |
74,952,608 | 2 | null | 74,949,806 | 0 | null | Nearly everything is possible. Here, I would probably call this an annotation rather than a legend. Annotations work like any other plot element. It just needs a bit of experience how to implement this (there are a few things to consider - see my comments in the code).
Another option is to create the annotation as a separate plot and overlay them with another package (cowplot is really good for that, but patchwork works too).
```
library(ggplot2)
df <- data.frame(type = c("vision", "video"), date = as.Date(c("1950-07-02", "2022-09-21")))
# this will need careful adjustment by yourself
y_lab <- .25
## get first and last date from your data
lab_date <- range(df$date)
# this will need careful adjustment by yourself
x_lab <- c(2.75, 3)
x_points <- seq(x_lab[1], x_lab[2], len = 4)[1:3]
ggplot() +
geom_bar(data = df, aes(type, fill = type)) +
## for the arrow
annotate(
geom = "segment",
x = x_lab[1], xend = x_lab[2], y = y_lab, yend = y_lab,
arrow = arrow(type = "closed", length = unit(5, "pt")),
color = "grey30"
) +
## for the points
geom_point(aes(x = x_points, y = y_lab), color = "grey30", stroke = NA, size = 2) +
## for the dates
annotate(
geom = "text",
x = x_lab + c(-.1, .05), y = y_lab, label = format(lab_date, "%b\n%d,\n%Y"),
hjust = 0,
size = 8 * 5 / 14
) +
## now add a bit or margin to the right, otherwise text is cut
theme(plot.margin = margin(r = 30)) +
## limit the plot to the data area and turn clipping off
coord_cartesian(xlim = c(1, length(unique(df$type))), clip = "off")
```

| null | CC BY-SA 4.0 | null | 2022-12-29T14:50:38.867 | 2022-12-29T14:50:38.867 | null | null | 7,941,188 | null |
74,952,658 | 2 | null | 74,952,341 | 2 | null | When you reduce the grid step by half h -> h/2, the number of grid steps in turn grows N -> 2 * N, so you have to make two changes in your code:
1. Define x2 to have twice as many elements as x1
```
x2 = np.linspace(a, b, 2 * N)
```
1. Update N to be twice it was on the previous iteration
```
N = 2 * N
```
The resulting code would be
```
import numpy as np
from sympy import *
from scipy.integrate import simps
a = 0
b = np.pi * 2
N = 100
ra = 0.1 # ρα
R = 0.05
fa = 35 * (np.pi/180) # φα
za = 0.4
Q = 10**(-6)
k = 9 * 10**9
aa = sqrt(ra**2 + R**2 + za**2)
error = 5 * 10**(-9)
while True:
x1 = np.linspace(a, b, N)
f1 = 1 / ((aa ** 2 - 2 * ra * R * np.cos(x1 - fa)) ** (3 / 2))
sim1 = simps(f1, x1)
x2 = np.linspace(a, b, 2 * N)
f2 = 1 / ((aa ** 2 - 2 * ra * R * np.cos(x2 - fa)) ** (3 / 2))
sim2 = simps(f2, x2)
if abs(sim1 - sim2) < error:
break
else:
N = 2 * N
print(sim1)
```
And this prints the value
```
87.9765411043221
```
with error consistent with the threshold
```
abs(sim1 - sim2) = 4.66441463231604e-9
```
| null | CC BY-SA 4.0 | null | 2022-12-29T14:55:21.633 | 2022-12-29T14:55:21.633 | null | null | 1,328,439 | null |
74,952,822 | 2 | null | 74,952,341 | 2 | null | @DmitriChubarov's solution is correct. However, your implementation is very inefficient: it does double the work it needs to. Also, `simps` is deprecated, you should be using proper exponential notation, and your function expression can be simplified. For an equivalent error-free algorithm that still doubles the input array length on each iteration but doesn't throw away the intermediate result,
```
import numpy as np
from scipy.integrate import simpson
a = 0
b = 2*np.pi
N = 100
ra = 0.1 # ρα
R = 0.05
fa = np.radians(35) # φα
za = 0.4
aa = np.linalg.norm((ra, R, za))
error = 5e-9
sim1 = np.nan
while True:
x = np.linspace(a, b, N)
f = (aa**2 - 2*ra*R*np.cos(x - fa))**-1.5
sim2 = simpson(f, x)
if np.abs(sim1 - sim2) < error:
break
sim1 = sim2
N *= 2
print(sim1)
```
| null | CC BY-SA 4.0 | null | 2022-12-29T15:10:42.463 | 2022-12-29T15:32:27.467 | 2022-12-29T15:32:27.467 | 313,768 | 313,768 | null |
74,952,856 | 2 | null | 74,952,341 | 0 | null | When I modified your code by adding two lines to `print(len(x1), len(f1))` and `print(len(x2), len(f2))`, I got these results:
Output:
```
length of x1 and f1: 100 100
length of x2 and f2: 50 50
length of x1 and f1: 50 50
length of x2 and f2: 25 25
length of x1 and f1: 25 25
length of x2 and f2: 12 12
length of x1 and f1: 12 12
length of x2 and f2: 6 6
length of x1 and f1: 6 6
length of x2 and f2: 3 3
length of x1 and f1: 3 3
length of x2 and f2: 1 1
length of x1 and f1: 1 1
length of x2 and f2: 0 0
```
as you can see the length decreases each loop because `N` decreases and ends with an empty list `length of x2 and f2: 0 0` and this causes the error you have had. To fix the issue of 'the empty list' I suggest that you duplicate N; this means using `N*2` instead of `N/2`.
| null | CC BY-SA 4.0 | null | 2022-12-29T15:13:32.133 | 2022-12-29T15:20:24.083 | 2022-12-29T15:20:24.083 | 6,925,762 | 6,925,762 | null |
74,952,878 | 2 | null | 74,952,126 | 0 | null | This is one of the known issue in this library. For some reason its not working with "android.tools.gradle" version 7.3.1.
You might have to downgrade the version to 7.2.2 or lower.
In your build.gradle replace
> classpath 'com.android.tools.build:gradle:7.3.1'
with
> classpath 'com.android.tools.build:gradle:7.2.2'
and try if it's working.
This solution is mentioned in there git repo here [https://github.com/hui-z/image_gallery_saver/issues/220](https://github.com/hui-z/image_gallery_saver/issues/220)
| null | CC BY-SA 4.0 | null | 2022-12-29T15:15:50.680 | 2022-12-29T15:15:50.680 | null | null | 4,315,644 | null |
74,953,000 | 2 | null | 74,952,045 | 0 | null | We are working on the issue: [https://issues.apache.org/jira/browse/SOLR-16588](https://issues.apache.org/jira/browse/SOLR-16588) .
A solution is coming soon!
| null | CC BY-SA 4.0 | null | 2022-12-29T15:27:34.003 | 2022-12-29T15:27:34.003 | null | null | 19,941,536 | null |
74,953,305 | 2 | null | 74,953,222 | 2 | null | The correct logic is as below:
```
c = r = 0
for i in range(len(e)):
e[i].grid(column=c, row=r)
c += 1
if c == 8:
r += 1
c = 0
```
But it can be simplified by using `divmod()`:
```
for i in range(len(e)):
r, c = divmod(i, 8)
e[i].grid(column=c, row=r)
```
| null | CC BY-SA 4.0 | null | 2022-12-29T15:55:23.593 | 2022-12-29T15:55:23.593 | null | null | 5,317,403 | null |
74,953,329 | 2 | null | 73,660,275 | 0 | null | Maybe it is too late to answer the question. It seems that because you have a list of `Form` component and `formRef` is connected to each form, logically the reference value of the forms are replaced one by one in the `formRef` till it gets to the last one. If you want to prevent that you can initialize `formRef` as an empty array like this:
```
const formRef = useRef([]);
```
And define `ref` prop of the `Form` component like so:
```
ref={el => {
if (el) formRef.current[index] = el
}}
```
finally change `submitFunction` :
```
const submitFunction = (value) => {
formRef.current.map(form => {
form.validateFields().then((values) => {
console.log("Values:", values);
});
})
};
```
| null | CC BY-SA 4.0 | null | 2022-12-29T15:58:06.337 | 2022-12-29T15:58:06.337 | null | null | 15,235,482 | null |
74,953,651 | 2 | null | 74,945,279 | 0 | null | I was adding a new event listener on every render. Thank you so much Konrad!
| null | CC BY-SA 4.0 | null | 2022-12-29T16:27:28.133 | 2022-12-29T16:27:28.133 | null | null | 20,882,652 | null |
74,954,614 | 2 | null | 74,949,048 | 1 | null | Try converting it to an [AlphaShape](https://www.mathworks.com/help/matlab/ref/alphashape.html) then use [SurfaceArea](https://www.mathworks.com/help/matlab/ref/alphashape.surfacearea.html).
| null | CC BY-SA 4.0 | null | 2022-12-29T18:07:50.673 | 2022-12-29T18:07:59.987 | 2022-12-29T18:07:59.987 | 15,014,595 | 15,014,595 | null |
74,954,710 | 2 | null | 23,176,800 | 0 | null | I think understanding how the really works would assist to get into why it may fail.
It was first explored by Dan Kagel, read [here](http://www.kegel.com/peer-nat.html). In this technique, both peers are generally
assumed to be behind two different NATs. Both peers must be connected to an
intermediate server called a Rendezvous/Signaling server; there are many well-known Rendezvous protocols and SIP (RFC 3261) is the most famous one. As they are
connected to the server, they get to know about each other’s public transport
addresses through it. The public transport addresses are allocated by the NATs
in front of them. The Hole Punching process in short:
[](https://i.stack.imgur.com/Sx88i.png)
1. Peer 1 and Peer 2 first discover their Public Transport Addresses using STUN Bind Request as described in RFC 8589.
2. Using a signaling/messaging mechanism, they exchange their Public Transport Addresses. SDP(Session Description Protocol)[16] may be used to complete this. The Public Transport Address of Peer 1 and Peer 2 will be assigned by NAT 1 and NAT 2 respectively.
3. Then both peers attempt to connect to each other using the received Public Transport addresses. With most NATs, the first message will be dropped by the NAT except for Full Cone NAT. But the subsequent packets will penetrate the NAT successfully as by this time the NAT will have a mapping.
NAT can be of any type. If the NAT is, let's say, RFC 8489, Hole Punching won’t be possible. Because only an external host that receives a packet from an internal host can send a packet back. If this is the case, then the only possible way is .
Learn more about the current state of P2P communication: read RFC 5128.
| null | CC BY-SA 4.0 | null | 2022-12-29T18:18:30.800 | 2022-12-29T18:18:30.800 | null | null | 9,857,078 | null |
74,954,739 | 2 | null | 74,953,698 | 1 | null | It's not particularly clear what the source is and how the data is structured, but you can `JOIN` without a key to flatten. Example:
```
[t1]:
LOAD * INLINE [
Activity
A
B];
[t2]:
LOAD * INLINE [
"Activity Code"
A01
B02];
[final]:
LOAD
[Activity] AS [value]
RESIDENT [t1];
JOIN([final])
LOAD
[Activity Code] AS [value]
RESIDENT [t2];
DROP TABLES [t1],[t2];
```
This will result in a table with the structure of:
| value |
| ----- |
| A |
| B |
| A01 |
| B02 |
| null | CC BY-SA 4.0 | null | 2022-12-29T18:21:42.137 | 2022-12-29T18:21:42.137 | null | null | 10,166,276 | null |
74,954,918 | 2 | null | 74,954,756 | -1 | null | I forgot to define $row by $row = mysqli_fetch_array($result) that was the reason that my result was empty in this script. Also if you find this useful, this exactly code is not secure so be careful about SQL Injection. This was only a simple way to show my problem. Use only parameterized prepared statements.
```
if(isset($_POST['sndmesaj'])){
$id2= $_SESSION["id"];
$connDB=mysqli_select_db($conn,'reglog');
$result= mysqli_query($conn, "SELECT * FROM tb_user WHERE id= $id2");
$row = mysqli_fetch_array($result);
$expeditor = $row['username'];
echo
"<script> alert('$expeditor'); </script>";
}
```
| null | CC BY-SA 4.0 | null | 2022-12-29T18:40:55.443 | 2022-12-31T16:44:46.193 | 2022-12-31T16:44:46.193 | 18,846,567 | 18,846,567 | null |
74,954,970 | 2 | null | 74,954,851 | 2 | null | Use [merge](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.merge.html) and [combine_first](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.combine_first.html):
```
out = x[['a', 'b']].merge(y, on=['a', 'b'], how='left').combine_first(x)
```
Output:
```
a b c d
0 1.0 12 japan 12.0
1 2.0 13 NaN 15.0
2 2.0 14 india 10.0
3 3.0 15 sweden 25.0
4 3.0 16 spain 11.0
5 NaN 17 france 6.0
6 5.0 18 brazil 20.0
```
| null | CC BY-SA 4.0 | null | 2022-12-29T18:46:40.290 | 2022-12-29T18:46:40.290 | null | null | 16,343,464 | null |
74,955,231 | 2 | null | 74,954,851 | 0 | null | If `a` and `b` together act as unique keys, you can set them as the index and then use `combine_first` as @mozway has suggested.
```
x = x.set_index(["a", "b"])
y = y.set_index(["a", "b"])
out = x.combine_first(y)
```
```
c d
a b
1.0 12 japan 12.0
2.0 13 NaN 15.0
14 india 10.0
3.0 15 sweden 25.0
16 spain 11.0
NaN 17 france 6.0
5.0 18 brazil 20.0
```
You can optionally reset the index after
```
out.reset_index()
```
```
a b c d
0 1.0 12 japan 12.0
1 2.0 13 NaN 15.0
2 2.0 14 india 10.0
3 3.0 15 sweden 25.0
4 3.0 16 spain 11.0
5 NaN 17 france 6.0
6 5.0 18 brazil 20.0
```
References
- [pd.DataFrame.set_index](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.set_index.html)- [pd.DataFrame.reset_index](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reset_index.html)
| null | CC BY-SA 4.0 | null | 2022-12-29T19:16:51.247 | 2022-12-29T19:16:51.247 | null | null | 6,509,519 | null |
74,955,346 | 2 | null | 74,942,807 | 0 | null | 1.) create Expo Project
```
expo init rnwebviewnav
```
2.) install expo react navigation from react navigation
```
npx expo install react-native-screens react-native-safe-area-context
```
3.) install webview with expo
```
expo install react-native-webview
```
4.) Create a folder called src (for source) and add your files. For me, I added 2 files there Like this
[](https://postimg.cc/JDdzQmwv)
5.) make sure your package.json looks like this (or has this components as dependencies)
[](https://postimg.cc/9DYD665g)
6.) Make sure your App.js Looks like this
```
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import WebViewPage from "./src/WebViewPage";
import ButtonPage from "./src/ButtonPage";
const Stack = createStackNavigator();
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="ButtonPage"
component={ButtonPage}
options={{ headerShown: false }}
/>
<Stack.Screen
name="WebViewPage"
component={WebViewPage}
options={{ title: "Webview Page" }}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default App;
```
7.) Make sure the page that navigates to the Webview Looks like this
```
import { Button, StyleSheet, Text, View } from 'react-native'
import React from 'react'
import { useNavigation } from '@react-navigation/native';
const ButtonPage = () => {
const navigation = useNavigation();
const navigateToWebView = () =>{
navigation.navigate('WebViewPage');
}
return (
<View style={{flex:1, justifyContent:'center'}}>
<Text>ButtonPage</Text>
<Button onPress={navigateToWebView} title="Click to Navigate" color="#841584" />
</View>
)
}
export default ButtonPage
const styles = StyleSheet.create({})
```
8.) Make sure your Webview Page looks thus
```
import { SafeAreaView, StyleSheet, Text, View } from 'react-native'
import React from 'react'
import WebView from 'react-native-webview'
const WebViewPage = () => {
return (
<SafeAreaView style={{ flex: 1 }}>
<WebView
source={{ uri: 'https://reactnative.dev/' }}
/>
</SafeAreaView>
)
}
export default WebViewPage
const styles = StyleSheet.create({})
```
9.) run `npm start` on your terminal to see what you have done so far!
button page
[](https://postimg.cc/NyCxR9Mc)
webview page
[](https://postimg.cc/YjY1Cy1k)
I believe I have answered your question :) If yes , pls upvote my answer if it has helped you.
| null | CC BY-SA 4.0 | null | 2022-12-29T19:35:15.303 | 2023-01-02T06:27:15.183 | 2023-01-02T06:27:15.183 | 20,813,030 | 20,813,030 | null |
74,955,736 | 2 | null | 74,955,413 | 2 | null | You just need to change the maximum threshold of the `LinRange` to be fitted to the maximum value of bars (which is 1 in this case), and change the input data for plotting to be the proportion of each segment:
```
my_range = LinRange(0, 1, 11)
foo = @. measles + mumps + chickenPox
groupedbar(
[measles./foo mumps./foo chickenPox./foo],
bar_position = :stack,
bar_width=0.7,
xticks=(1:2, ["A", "B"]),
yticks=(my_range, 0:10:100),
label=["measles" "mumps" "chickenPox"],
legend=:outerright
)
```
[](https://i.stack.imgur.com/5yijV.png)
If you want to have the percentages on each segment, then you can use the following function:
```
function percentages_on_segments(data)
first_phase = permutedims(data)[end:-1:1, :]
a = [0 0;first_phase]
b = accumulate(+, 0.5*(a[1:end-1, :] + a[2:end, :]), dims=1)
c = vec(b)
annotate!(
repeat(1:size(data, 1), inner=size(data, 2)),
c,
["$(round(100*item, digits=1))%" for item=vec(first_phase)],
:white
)
end
percentages_on_segments([measles./foo mumps./foo chickenPox./foo])
```
Note that `[measles./foo mumps./foo chickenPox./foo]` is the same data that I passed to the `groupedbar` function:
[](https://i.stack.imgur.com/8IN0y.png)
| null | CC BY-SA 4.0 | null | 2022-12-29T20:22:13.257 | 2022-12-29T21:59:03.223 | 2022-12-29T21:59:03.223 | 11,747,148 | 11,747,148 | null |
74,955,942 | 2 | null | 19,214,914 | 2 | null | The problem is that the plot panel does not have defined dimensions until drawing ("NULL unit"), but your legend guide . See also [npc coordinates of geom_point in ggplot2](https://stackoverflow.com/questions/60803424/npc-coordinates-of-geom-point-in-ggplot2) or [figuring out panel size given dimensions for the final plot in ggsave (to show count for geom_dotplot)](https://stackoverflow.com/questions/71250264/figuring-out-panel-size-given-dimensions-for-the-final-plot-in-ggsave-to-show-c). I think it will be extremely tricky to draw the legend guide in the exact same size as your panel.
However, you can make use of a trick when dealing with complex legend formatting: . The challenge here is to adjust the fill scale to perfectly match the range of your plot (which is not usually exactly the range of your data values). The rest is just a bit of R semantics. Some important comments in the code.
```
library(ggplot2)
corrs <- structure(list(Var1 = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), levels = c("Var1", "Var2", "Var3"), class = "factor"), Var2 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), levels = c("Var1", "Var2", "Var3"), class = "factor"), value = c(1, -0.11814395012334, -0.91732952510938, -0.969618394505233, 1, -0.00122085912153125, -0.191116513684392, -0.0373711776919663, 1)), class = "data.frame", row.names = c(NA, -9L))
## to set the scale properly, you will need to set limits and breaks,
## I am doing this semi-automatically
range_fill <- range(corrs$value)
lim_fill <- c(floor(range_fill[1]), ceiling(range_fill[2]))
## len = 5 and round to 2 is hard coded, depending on the scale breaks that you want
breaks_fill <- round(seq(lim_fill[1], lim_fill[2], len = 5), 2)
## need to rescale the fill to the range of you y values,
## so that your fill scale correctly corresponds to the range of your y
## however, the actual range of your plot depends if you're in a discrete or continuous range.
## here in a discrete range
lim_y <- range(as.integer(corrs$Var2))
lim_x <- range(as.integer(corrs$Var1))
lim_vals <- lim_y + c(-.5, .5)
## actual rescaling happens here
new_y <- scales::rescale(breaks_fill, lim_vals)
## the position and width of the color bar are defined with
scl_x <- lim_x[2] + .7 # the constant is hard coded
scl_xend <- scl_x + .2 # also hard coded
## make a data frame for the segments to be created
## using approx so that we have many little segments
approx_fill <- approx(new_y, breaks_fill, n = 1000)
df_seg <- data.frame(y = approx_fill$x, color = approx_fill$y)
## data frame for labels, xend position being hard coded
df_lab <- data.frame(y = new_y, x = scl_xend + .1, label = breaks_fill)
## data frame for separators
sep_len <- .05
df_sep <- data.frame(
y = new_y, yend = new_y,
x = rep(c(scl_x, scl_xend - sep_len), each = 5),
xend = rep(c(scl_x + sep_len, scl_xend), each = 5)
)
ggplot(corrs) +
geom_tile(aes(x = Var1, y = Var2, fill = value)) +
geom_segment(
data = df_seg,
aes(x = scl_x, xend = scl_xend, y = y, yend = y, color = color)
) +
## now the labels, the size being hard coded
geom_text(data = df_lab, aes(x, y, label = label), size = 9 * 5 / 14) +
## now make the white little separators
geom_segment(
data = df_sep, aes(x = x, xend = xend, y = y, yend = yend),
color = "white"
) +
## set both color and fill scales exactly
scale_fill_continuous(limits = lim_fill, breaks = breaks_fill) +
scale_color_continuous(limits = lim_fill, breaks = breaks_fill) +
## turn off coordinate clipping and limit panel to data area)
coord_cartesian(xlim = lim_x, ylim = lim_y, clip = "off") +
## last but not least remove the other legends and add a bit of margin
theme(
legend.position = "none",
plot.margin = margin(r = 1, unit = "in")
)
```

[reprex v2.0.2](https://reprex.tidyverse.org)
| null | CC BY-SA 4.0 | null | 2022-12-29T20:50:48.900 | 2022-12-29T20:56:06.827 | 2022-12-29T20:56:06.827 | 7,941,188 | 7,941,188 | null |
74,956,186 | 2 | null | 19,214,914 | 5 | null | The following option is a function that can be added to a ggplot to take the plot and make the colorbar the same height as the panel.
Essentially it uses the same technique as Baptiste, but is a bit more robust to changes in the ggplot implementation, and moves the legend title to a more natural position, allowing neater alignment. It also allows more recognisable ggplot-style syntax.
```
make_fullsize <- function() structure("", class = "fullsizebar")
ggplot_add.fullsizebar <- function(obj, g, name = "fullsizebar") {
h <- ggplotGrob(g)$heights
panel <- which(grid::unitType(h) == "null")
panel_height <- unit(1, "npc") - sum(h[-panel])
g +
guides(fill = guide_colorbar(barheight = panel_height,
title.position = "right")) +
theme(legend.title = element_text(angle = -90, hjust = 0.5))
}
```
You can then do:
```
ggplot(corrs, aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
coord_cartesian(expand = FALSE) +
make_fullsize()
```
[](https://i.stack.imgur.com/SnrWa.png)
The drawback is that the plot needs re-drawn if the plotting window is resized after the plot is drawn. This is a bit of a pain, but it's a fairly quick-and-simple fix. It will still work well with ggsave.
Note that the color bar is the same height as the , which is why it looks a bit neater to turn the expansion off in `coord_cartesian`, so it matches the actual tiles of the heatmap.
Another example for one of the linked duplicates:
```
library(reshape2)
dat <- iris[,1:4]
cor <- melt(cor(dat, use="p"))
ggplot(data=cor, aes(x=Var1, y=Var2, fill=value)) +
geom_tile() +
labs(x = "", y = "") +
scale_fill_gradient2(limits=c(-1, 1)) +
coord_cartesian(expand = FALSE) +
make_fullsize()
```
[](https://i.stack.imgur.com/kVEra.png)
| null | CC BY-SA 4.0 | null | 2022-12-29T21:25:40.690 | 2022-12-30T15:11:30.760 | 2022-12-30T15:11:30.760 | 12,500,315 | 12,500,315 | null |
74,956,316 | 2 | null | 74,956,228 | 1 | null | conditional styles in bootstrap datatable: [https://mdbootstrap.com/docs/react/data/datatables/](https://mdbootstrap.com/docs/react/data/datatables/)
```
const conditionalRowStyles = [
{
when: row => row.coverage < 50,
style: {
backgroundColor: 'yellow',
},
},
];
const MyTable = () => (
<DataTable
title="Desserts"
columns={columns}
data={data}
conditionalRowStyles={conditionalRowStyles}
/>
);
```
| null | CC BY-SA 4.0 | null | 2022-12-29T21:45:32.927 | 2022-12-29T21:45:32.927 | null | null | 12,453,755 | null |
74,956,812 | 2 | null | 74,956,658 | 0 | null | You can set the font size of the li to 0 and then apply a proper font size to li>label.
| null | CC BY-SA 4.0 | null | 2022-12-29T23:08:41.537 | 2022-12-29T23:08:41.537 | null | null | 2,504,989 | null |
74,956,875 | 2 | null | 74,939,253 | 0 | null | The desktop edition of Outlook doesn't understand or render base64 images. If you need to get images delivered correctly you need to upload them to any web server and use a link to web server with such image. But that is not ideal too, Outlook also may block external images by default. The best solution is to embed images by attaching them to the mail item and then referring to them from the message body by using the CID attribute.
In Outlook you need to set the `PR_ATTACH_CONTENT_ID` MAPI property (the DASL name is "http://schemas.microsoft.com/mapi/proptag/0x3712001F") by using the `Attachment.PropertyAccessor.SetProperty` method. Then you can refer such attachments using the `src` attribute which matches the value of `PR_ATTACH_CONTENT_ID` set on the attachment. The `PR_ATTACH_CONTENT_ID` property corresponds to the `Content-ID` MIME header when the message is sent.
```
attachment = MailItem.Attachments.Add("c:\test\Picture.jpg")
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "YourId")
MailItem.HTMLBody = "<html><body>Your image embedded is <img src=""cid:YourId""></body></html>"
```
| null | CC BY-SA 4.0 | null | 2022-12-29T23:19:36.280 | 2022-12-29T23:19:36.280 | null | null | 1,603,351 | null |
74,957,026 | 2 | null | 74,956,119 | 1 | null | In django, form classes are provided to make this easier.
What you want is to create a form class with a ChoiceField.
You can grab the data in this form rather than the views.py and then create a tuple the choices available from your dataset. We will do this by overriding the form's __init__ field so that load a dynamic set of choices instead of static set of choices.
Example:
```
from django import forms
from yourapp.models import Brand
class BrandForm(forms.Form):
def __init__(self, *args, **kwargs):
super(BrandForm, self).__init__(*args, **kwargs)
brands = Brand.objects.all()
brand_choices = tuple(i, brand.brand_name for i, brand in enumerate(brands))
self.fields['brand'] = forms.ChoiceField(choices=brand_choices)
```
Now in views.py you need to initialize the form and pass it into the context when you call `render()`
Then just put `{{ form }}` inside your html form to load all the fields into your form
(if you didnt pass your form into the context as 'form' you will need to change the reference inside of `{{ }}`)
P.s. With a static set of choices, you can define the tuple outside of the class and define the class like this (without needing to override __init__):
```
class BrandForm(forms.Form):
brand = forms.ChoiceField(choices=choices)
```
More examples are available in the django documentation: [https://docs.djangoproject.com/en/4.1/topics/forms/](https://docs.djangoproject.com/en/4.1/topics/forms/)
| null | CC BY-SA 4.0 | null | 2022-12-29T23:51:51.843 | 2022-12-29T23:57:15.160 | 2022-12-29T23:57:15.160 | 14,852,793 | 14,852,793 | null |
74,957,757 | 2 | null | 74,957,732 | 1 | null | Try to cast your "Date" column into datetime, check if it does the trick:
```
train1.Date = pd.to_datetime(train1.Date)
train2 = train1.set_index('Date')
```
| null | CC BY-SA 4.0 | null | 2022-12-30T02:54:23.123 | 2022-12-30T02:54:23.123 | null | null | 18,624,778 | null |
74,957,748 | 2 | null | 74,955,988 | 0 | null | Try this. I fixed this problem before.
```
void setSelectComboBoxStyle(QComboBox* comboBox)
{
comboBox->setStyleSheet("QComboBox {"
"border:2px solid rgb(20,150,225);"
"border-radius: 10px;"
"padding-left: 5px;"
"background-color: white;"
"font: bold;"
"font-size: 16px;"
"color: rgb(107,107,107);}"
"QComboBox::drop-down{"
"border:none;"
"subcontrol-position: top right;"
"subcontrol-origin: padding;"
"width:40px;}"
"QScrollBar:vertical {"
"border: 1px transparent rgb(213, 218, 223);"
"background:rgb(213, 218, 223);"
"border-radius: 2px;"
"width:6px;"
"margin: 2px 0px 2px 1px;}"
"QScrollBar::handle:vertical {"
"border-radius: 2px;"
"min-height: 0px;"
"background-color: rgb(131, 131, 131);}"
"QScrollBar::add-line:vertical {"
"height: 0px;"
"subcontrol-position: bottom;"
"subcontrol-origin: margin;}"
"QScrollBar::sub-line:vertical {"
"height: 0px;"
"subcontrol-position: top;"
"subcontrol-origin: margin;}");
QListView *view = new QListView(comboBox);
view->setStyleSheet("QListView{top: 2px;"
"border:2px solid rgb(20,150,225);"
"border-radius: 8px;"
"background-color: white;"
"show-decoration-selected: 1;"
"margin-left: 0px;"
"margin-top: 6px;"
"padding-left: 5px;"
"padding-right: 6px;"
"padding-top: 6px;"
"padding-bottom: 2px;"
"font: bold;"
"font-size: 16px;}"
"QListView::item{"
"height: 30px;"
"background-color: white;"
"color: rgb(107,107,107);}"
"QListView::item:hover{"
"background-color: rgb(20, 150, 225);"
"color: white;}");
view->setCursor(Qt::PointingHandCursor);
comboBox->setView(view);
comboBox->setMaxVisibleItems(5);
comboBox->setFixedSize(500,45);
comboBox->view()->window()->setWindowFlags( Qt::Popup | Qt::FramelessWindowHint |Qt::NoDropShadowWindowHint);
}
```
qt 6.2.3 version:
```
void setSelectComboBoxStyle(QComboBox* comboBox)
{
comboBox->setStyleSheet("QComboBox {"
"combobox-popup: 0;"
"background: transparent;"
"border:2px solid rgb(20,150,225);"
"border-radius: 10px;"
"padding-left: 5px;"
"background-color: white;"
"font: bold;"
"font-size: 16px;"
"color: rgb(107,107,107);}"
"QComboBox::drop-down{"
"border:none;"
"subcontrol-position: top right;"
"subcontrol-origin: padding;"
"width:40px;}"
"QScrollBar:vertical {"
"border: 1px transparent rgb(213, 218, 223);"
"background:rgb(213, 218, 223);"
"border-radius: 2px;"
"width:6px;"
"margin: 2px 0px 2px 1px;}"
"QScrollBar::handle:vertical {"
"border-radius: 2px;"
"min-height: 0px;"
"background-color: rgb(131, 131, 131);}"
"QScrollBar::add-line:vertical {"
"height: 0px;"
"subcontrol-position: bottom;"
"subcontrol-origin: margin;}"
"QScrollBar::sub-line:vertical {"
"height: 0px;"
"subcontrol-position: top;"
"subcontrol-origin: margin;}");
QListView *view = new QListView(comboBox);
view->setStyleSheet("QListView{top: 2px;"
"border:2px solid rgb(20,150,225);"
"border-radius: 8px;"
"background-color: white;"
"show-decoration-selected: 1;"
"padding-left: 5px;"
"padding-right: 6px;"
"padding-top: 6px;"
"padding-bottom: 2px;"
"font: bold;"
"font-size: 16px;}"
"QListView::item{"
"height: 30px;"
"background-color: white;"
"color: rgb(107,107,107);}"
"QListView::item:hover{"
"background-color: rgb(20, 150, 225);"
"color: white;}");
view->setCursor(Qt::PointingHandCursor);
comboBox->setView(view);
comboBox->setMaxVisibleItems(5);
comboBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
comboBox->setFixedSize(500,45);
comboBox->view()->window()->setWindowFlags( Qt::Popup | Qt::FramelessWindowHint |Qt::NoDropShadowWindowHint);
}
```
| null | CC BY-SA 4.0 | null | 2022-12-30T02:51:51.183 | 2022-12-30T03:16:46.693 | 2022-12-30T03:16:46.693 | 5,840,683 | 5,840,683 | null |
74,957,990 | 2 | null | 73,709,081 | 1 | null | Had a similar problem (not sure if it's your case but maybe it'll help someone reading this).
I had to clear the pycache folder(s) and re-discover the tests (the reload/refresh button at the top).
Had to do that for each test folder but it all works now.
| null | CC BY-SA 4.0 | null | 2022-12-30T03:55:37.330 | 2022-12-30T12:46:09.683 | 2022-12-30T12:46:09.683 | 2,347,649 | 3,329,383 | null |
74,958,060 | 2 | null | 74,957,982 | 1 | null | The help page for `plot.performance` mentions that the axis is an exception for modifying the graphical parameter. It then suggests that you can increase/decrease the size of the axis tick labels with
```
par(cex.axis=2)
```
If you also want to increase the thickness of the axes (the box that is shown around the plot, then use
```
box(lwd=2)
```
You can change 2 to a larger number if desired. Your commands would then be:
```
library(ROCR)
...
opar <- par(cex.axis=2)
plot(perf.tpr.fpr.rocr, colorize = T, main = paste("AUC:", ([email protected])),
lwd=4,
cex.lab=3,
cex.main = 3,
cex.sub = 3)
abline(a=0, b=1)
box(lwd=2)
par(opar)
```
| null | CC BY-SA 4.0 | null | 2022-12-30T04:13:46.743 | 2022-12-30T04:13:46.743 | null | null | 7,514,527 | null |
74,958,708 | 2 | null | 74,946,942 | 1 | null | Notice these lines of code from [the lib's source on GitHub](https://github.com/sweetalert2/sweetalert2/blob/91147e9c2f67c3e4195f573619d82fec944c54e7/rollup.config.js#L14-L16):
> ```
if (typeof this !== 'undefined' && this.Sweetalert2) {
this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2
}
```
There are two solutions:
1. Use Sweetalert2 which is exposed by the JavaScript file in any case.
2. Enable sandbox mode by adding // @unwrap to the headers. While the loader injects the script into the page, the script lives in the sandbox, which is disabled if @grant is none. With // @unwrap, you can achieve the desired this behaviour and use any of the exposed swal, sweetAlert, Swal, SweetAlert names.
| null | CC BY-SA 4.0 | null | 2022-12-30T06:20:26.173 | 2022-12-30T06:20:26.173 | null | null | 10,607,772 | null |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.