Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
57,696,734 | event: "Deprecated symbol used, consult docs for better alternative" | <p>It's been a while that PyCharm (I suppose it's the same with WebStorm and other JetBrains IDEs) raise a weak warning on the <code>event</code> variables I use in my code.</p>
<p>For instance in the following code</p>
<pre class="lang-html prettyprint-override"><code><div id="my-div" onclick="event.preventDefault();">...</div>
</code></pre>
<p>PyCharm displays this message "Deprecated symbol used, consult docs for better alternative".</p>
<p>The problem seems to be that the <code>event</code> variable refers to <code>Window.event</code>, and according to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/event" rel="noreferrer">MDN Web Docs</a>:</p>
<blockquote>
<p>You should avoid using this property in new code, and should instead use the Event passed into the event handler function. This property is not universally supported and even when supported introduces potential fragility to your code.</p>
</blockquote>
<p>I know that a correct workaround would be to write in a javascript tag:</p>
<pre><code>document.getElementById("my-div").addEventListener("click", function(event) {
console.log("And use this " + event + " instead");
});
</code></pre>
<p>I am just wondering what would be, if it exists, the correct way to use events in the HTML code (<code>onclick</code> attribute).</p>
<p>Thank you in advance!</p>
| <javascript><html><pycharm><dom-events><event-listener> | 2019-08-28 16:37:50 | HQ |
57,697,196 | How to write hello world in Python | <p>I am new to Python language.
Please how can I write "hello world" using Python?
I've try IF "Hello" PRINT "hello world", but it didn't work.
So please help me out.
Anybody.</p>
| <python> | 2019-08-28 17:13:39 | LQ_CLOSE |
57,697,443 | Is there something like a backtrace to indicate which path a variable has reached to its current value? | <p>I have a source like this</p>
<pre><code> //file1.cpp
int var_1=getDB(" Table_name","column_name");
...
//file2.cpp
int var2=func2(var_1);
...
//filen.cpp
int var_n=funcn(var_n_1);
</code></pre>
<p>In debugging, I first diagnose var_n error message type, but the goal is to modify the table, is there an easy way like backtrace to get to the source of the error, namely the table and field name?</p>
| <c++><debugging><gdb> | 2019-08-28 17:32:11 | LQ_CLOSE |
57,697,851 | .toggle is not a function | <p>In my website I have a lot of buttons. When the page loads, I need the first button to be clicked.</p>
<p>I tried getting the first button and then using the function .toggle('click').</p>
<p>var $btn = $('.btn-personalizar-tamanho')[0];
if($btn != undefined) $btn.toggle('click');</p>
<p>The console says .toggle it's not a function.</p>
| <javascript><jquery> | 2019-08-28 18:02:12 | LQ_CLOSE |
57,698,167 | Template factorial function without template specialization | <p>I don't understand the following behavior.</p>
<p>The following code, aimed at computing the factorial at compile time, doesn't even compile:</p>
<pre><code>#include <iostream>
using namespace std;
template<int N>
int f() {
if (N == 1) return 1; // we exit the recursion at 1 instead of 0
return N*f<N-1>();
}
int main() {
cout << f<5>() << endl;
return 0;
}
</code></pre>
<p>and throws the following error:</p>
<pre><code>...$ g++ factorial.cpp && ./a.out
factorial.cpp: In instantiation of ‘int f() [with int N = -894]’:
factorial.cpp:7:18: recursively required from ‘int f() [with int N = 4]’
factorial.cpp:7:18: required from ‘int f() [with int N = 5]’
factorial.cpp:15:16: required from here
factorial.cpp:7:18: fatal error: template instantiation depth exceeds maximum of 900 (use ‘-ftemplate-depth=’ to increase the maximum)
7 | return N*f<N-1>();
| ~~~~~~^~
compilation terminated.
</code></pre>
<p>whereas, upon adding the specialization for <code>N == 0</code> (which the template above doesn't even reach),</p>
<pre><code>template<>
int f<0>() {
cout << "Hello, I'm the specialization.\n";
return 1;
}
</code></pre>
<p>the code compiles and give the correct output of, even if the specialization is never used:</p>
<pre><code>...$ g++ factorial.cpp && ./a.out
120
</code></pre>
| <c++><templates><recursion><template-specialization><factorial> | 2019-08-28 18:25:34 | HQ |
57,699,252 | Qt How to pass data from a GUI to another thread | <p>I have an application that can start pause and cancel the thread.
i would like to pass data from the main gui to the thread.
in this example i have a spinbox.
i wish to reset the counter in the worker thread everytime i change the spin box. </p>
<p>for some reason i can't seem to update the counter variable in the worker thread.
what am i missing in my program?</p>
<p>MAINWINDOW.h</p>
<pre><code>#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QThread>
#include "worker.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
signals:
void updatecounter(int val);
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_Time_valueChanged(const QString &arg1);
void on_Start_clicked();
void on_Stop_clicked();
void on_Pause_clicked();
private:
Ui::MainWindow *ui;
QThread *m_Thread;
Worker *m_Worker;
};
#endif // MAINWINDOW_H
</code></pre>
<p>WORKER.h</p>
<pre><code>#ifndef WORKER_H
#define WORKER_H
#include <QObject>
#include <QMutex>
#include <QThread>
#include <QDebug>
#include <QEventLoop>
#include <QAbstractEventDispatcher>
class Worker : public QObject
{
Q_OBJECT
public:
Worker();
~Worker();
public slots:
void process();
signals:
void started();
void finished();
public slots:
void updatecounter(int val)
{
counter = val;
}
void pause()
{
auto const dispatcher = QThread::currentThread()->eventDispatcher();
if (!dispatcher)
{
qCritical() << "thread with no dispatcher";
return;
}
if (state != RUNNING)
return;
state = PAUSED;
qDebug() << this;
qDebug() << "paused";
do
{
dispatcher->processEvents(QEventLoop::WaitForMoreEvents);
} while (state == PAUSED);
}
void resume()
{
if (state == PAUSED)
{
state = RUNNING;
qDebug() << this;
qDebug() << "resumed";
updatecounter(0);
}
}
void cancel()
{
if (state != IDLE)
{
state = IDLE;
qDebug() << this;
qDebug() << "cancelled";
}
}
protected:
enum State { IDLE, RUNNING, PAUSED };
State state = IDLE;
int counter = 0;
bool isCancelled()
{
auto const dispatcher = QThread::currentThread()->eventDispatcher();
if (!dispatcher)
{
qCritical() << "thread with no dispatcher";
return false;
}
dispatcher->processEvents(QEventLoop::AllEvents);
return state == IDLE;
}
};
#endif // WORKER_H
</code></pre>
<p>MAINWINDOW.cpp</p>
<pre><code>#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug() << "main thread";
m_Thread = new QThread();
ui->Start->setEnabled(true);
ui->Pause->setEnabled(false);
ui->Stop->setEnabled(false);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_Time_valueChanged(const QString &arg1)
{
emit updatecounter(arg1.toInt());
//auto const m = m_Worker->metaObject();
//m->invokeMethod(m_Worker, "updatecounter",Qt::QueuedConnection,Q_ARG(int,arg1.toInt()));
}
void MainWindow::on_Start_clicked()
{
if(!m_Thread->isRunning())
{
m_Thread = new QThread();
m_Worker = new Worker();
m_Worker->moveToThread(m_Thread);
connect(m_Thread, &QThread::started, m_Worker, &Worker::process);
connect(this,&MainWindow::updatecounter, m_Worker, &Worker::updatecounter, Qt::QueuedConnection);
connect(m_Worker, &Worker::finished, m_Thread, &QThread::quit);
m_Thread->start();
}
else
{
auto const m = m_Worker->metaObject();
m->invokeMethod(m_Worker, "resume");
}
ui->Start->setEnabled(false);
ui->Pause->setEnabled(true);
ui->Stop->setEnabled(true);
}
void MainWindow::on_Stop_clicked()
{
auto const m = m_Worker->metaObject();
m->invokeMethod(m_Worker, "cancel");
ui->Start->setEnabled(true);
ui->Pause->setEnabled(false);
ui->Stop->setEnabled(false);
}
void MainWindow::on_Pause_clicked()
{
auto const m = m_Worker->metaObject();
m->invokeMethod(m_Worker, "pause");
ui->Start->setEnabled(true);
ui->Pause->setEnabled(false);
ui->Stop->setEnabled(true);
}
</code></pre>
<p>WORKER.cpp</p>
<pre><code>#include "worker.h"
#include <QDebug>
#include <QThread>
#include <QTimer>
Worker::Worker()
{
qDebug() << this << " worker thread started";
}
Worker::~Worker()
{
qDebug() << "worker thread finished";
}
void Worker::process()
{
if (state == PAUSED)
// treat as resume
state = RUNNING;
if (state == RUNNING)
return;
state = RUNNING;
qDebug() << "started";
emit started();
// This loop simulates the actual work
for (auto i = counter; state == RUNNING; ++i)
{
QThread::msleep(100);
if (isCancelled())
{
break;
}
qDebug() << i;
}
qDebug() << this;
qDebug() << "finished";
emit finished();
}
</code></pre>
| <c++><qt> | 2019-08-28 19:54:37 | LQ_CLOSE |
57,699,393 | Swift How combine to Numeric Type | <p>I am kind of new to Swift, and wonder how to create a combined types.</p>
<pre><code>typealisa Number = Int & Float & Double
</code></pre>
<p>Isnt work.</p>
<pre><code>public protocol Number {} ;
extension Int : Number {} ;
extension Double : Number {} ;
extension Float : Number {} ;
</code></pre>
<p>When you try </p>
<pre><code>var a : Number = 1 ;
var b : Number = 2 ;
a * b
//Binary operator '*' cannot be applied to two 'Number' operands
</code></pre>
<p>In TS, this cloud be simple as </p>
<pre><code>type Number = Number = Int & Float & Double
</code></pre>
<p>Thank you so much!</p>
| <swift> | 2019-08-28 20:06:07 | LQ_CLOSE |
57,699,571 | UISplitViewController will not correctly collapse at launch on iPad iOS 13 | <p>I am transitioning my app to iOS 13, and the UISplitViewController collapses onto the detail view, rather than the master at launch — only on iPad. Also, the back button is not shown - as if it is the root view controller.</p>
<p>My app consists of a <code>UISplitViewController</code> which has been subclassed, conforming to <code>UISplitViewControllerDelegate</code>. The split view contains two children — both <code>UINavigationControllers</code>, and is embedded in a <code>UITabBarController</code> (subclassed <code>TabViewController</code>)</p>
<p>In the split view <code>viewDidLoad</code>, the delegate is set to <code>self</code> and <code>preferredDisplayMode</code> is set to <code>.allVisible</code>. </p>
<p>For some reason, the method <code>splitViewController(_:collapseSecondary:onto:)</code> not being called.</p>
<p>In <strong>iOS 12</strong> on <strong>iPhone</strong> and <strong>iPad</strong>, the method <code>splitViewController(_:collapseSecondary:onto:)</code> is correctly called at launch, in between <code>application(didFinishLaunchingWithOptions)</code> and <code>applicationDidBecomeActive</code>.</p>
<p>In <strong>iOS 13</strong> on <strong>iPhone</strong>, the method <code>splitViewController(_:collapseSecondary:onto:)</code> is correctly called at launch, in between <code>scene(willConnectTo session:)</code> and <code>sceneWillEnterForeground</code>.</p>
<p>In <strong>iOS 13</strong> on <strong>iPad</strong>, however, if the window has compact width at launch e.g. new scene created as a split view, the <code>splitViewController(_:collapseSecondary:onto:)</code> method is not called at all. Only when expanding the window to regular width, and then shrinking is the method called.</p>
<pre class="lang-swift prettyprint-override"><code>class SplitViewController: UISplitViewController, UISplitViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
preferredDisplayMode = .allVisible
}
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool {
print("Split view controller function")
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
if topAsDetailController.passedEntry == nil {
return true
}
return false
}
}
</code></pre>
<pre><code>class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Setup split controller
let tabViewController = self.window!.rootViewController as! TabViewController
let splitViewController = tabViewController.viewControllers![0] as! SplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
navigationController.topViewController!.navigationItem.leftBarButtonItem?.tintColor = UIColor(named: "Theme Colour")
splitViewController.preferredDisplayMode = .allVisible
}
</code></pre>
<pre><code>class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 13.0, *) {
} else {
let tabViewController = self.window!.rootViewController as! TabViewController
let splitViewController = tabViewController.viewControllers![0] as! SplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
navigationController.topViewController!.navigationItem.leftBarButtonItem?.tintColor = UIColor(named: "Theme Colour")
splitViewController.preferredDisplayMode = .allVisible
}
return true
}
</code></pre>
<p>It stumps me why the method is being called in iPhone, but not in iPad! I am a new developer and this is my first post, so apologies if my code doesn't give enough detail or is not correctly formatted!</p>
| <ios><swift><ipad><uisplitviewcontroller><ios13> | 2019-08-28 20:23:25 | HQ |
57,699,625 | How to change access modifier without hiding class base variable? | <p>I'm trying to extend the Process class a bit, to add access control of Process.Exited delegates and limit them to one. So far, I have this result:</p>
<pre><code>public class ProcessWithData : Process
{
public EventHandler CurrentEventHandler { get; private set; }
public new bool EnableRaisingEvents = true;
private new EventHandler Exited;
public void SetHandler(EventHandler eventHandler)
{
if (CurrentEventHandler != null) Exited -= CurrentEventHandler;
CurrentEventHandler = eventHandler;
Exited += CurrentEventHandler;
}
}
</code></pre>
<p>However, the line</p>
<pre><code>private new EventHandler Exited;
</code></pre>
<p>overwrites existing EventHandler of Process class being the base. Therefore</p>
<pre><code>var proc = Process.Start("foo.exe");
ProcessWithData procwithdata = (ProcessWithData)proc;
</code></pre>
<p>should destroy Exited event handler upon cast.</p>
<p>How could I set <code>private</code> modifier to it without redefining(and destroying) existing instance inside Process class?</p>
| <c#><casting><process> | 2019-08-28 20:28:17 | LQ_CLOSE |
57,699,839 | GitHub Actions: how to target all branches EXCEPT master? | <p>I want to be able to let an action run on any given branch except master.
I am aware that there is a prebuilt <code>filter</code> action, but I want the exact opposite. </p>
<p>More like GitLab's <code>except</code> keyword.
Since this is not inside the official docs, has anyone prepared a decent workaround?</p>
<p>Thank you very much.</p>
| <git><github><github-actions> | 2019-08-28 20:47:50 | HQ |
57,700,304 | Previewing ContentView with CoreData | <p>When I try to a SwiftUI ContentView that contains a CoreData fetch request, the preview crashes. Wondering what the correct way to setup the @environment so the preview can access the coredata stack. This works fine when building to a simulator but not with a PreviewProvider</p>
<pre><code>import SwiftUI
struct ContentView: View {
@Environment(\.managedObjectContext) var managedObjectContext
@FetchRequest(entity: ProgrammingLanguage.entity(), sortDescriptors: [
NSSortDescriptor(keyPath: \ProgrammingLanguage.name, ascending: true),
NSSortDescriptor(keyPath: \ProgrammingLanguage.creator, ascending: false)
]) var languages: FetchedResults<ProgrammingLanguage>
var body: some View {
NavigationView {
List {
ForEach(languages, id: \.self) { language in
Text("Language: \(language.name ?? "Anonymous")")
}
}
.navigationBarTitle("My Languages")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
</code></pre>
<p>When I try to pass in argument to the ContentView in ContentView_Previews like so I get the following compiler error. </p>
<pre><code>ContentView(managedObjectContext: managedObjectContext)
</code></pre>
<p>Error: Instance member 'managedObjectContext' cannot be used on type 'ContentView_Previews'</p>
<p>Maybe this isn't supported by SwiftUI previews yet? Or is there anything that could fix this?</p>
<p>I'm running Xcode 11 Beta 7.</p>
| <core-data><swiftui> | 2019-08-28 21:31:47 | HQ |
57,700,791 | IEnumerable<T> returning function implemented using 'yield return' versus creating a collection | <p>I am debating which of the following is an efficient way to implement the function <code>CreatePlayerData</code></p>
<pre><code>Method1: yield return
private static IEnumerable<IPlayerData> CreatePlayerData(int gameId, PlayerProfiles profiles)
{
foreach (var data in profiles.data)
{
yield return new PlayerData
{
GameId = gameId,
GameName = data.GameName,
ProfileId = data.ProfileId
};
}
}
Method2: Creating a collection
private static IEnumerable<IPlayerData> CreatePlayerData(int gameId, PlayerProfiles profiles)
{
var collection = new List<IPlayerData>();
foreach (var data in profiles.data)
{
collection.Add(new PlayerData
{
GameId = gameId,
GameName = data.GameName,
ProfileId = data.ProfileId
});
}
return collection;
}
</code></pre>
<p>There is a log function that uses function <code>CreatePlayerData</code> as an argument:
The signature of the log function is:</p>
<pre><code>void LogPlayerData(IEnumerable<IPlayerData> players);
</code></pre>
<p>If I use <code>Method1</code> to implement <code>CreatePlayerData</code> function, I call the log function as:</p>
<pre><code>LogPlayerData(CreatePlayerData().ToArray());
</code></pre>
<p>Or if I use <code>Method2</code> to implement <code>CreatePlayerData</code> function, I call the log function as:</p>
<pre><code>LogPlayerData(CreatePlayerData());
</code></pre>
<p>Not sure which among <code>Method1</code> or <code>Method2</code> is the best way to implement the function <code>CreatePlayerData</code>. Any suggestions?</p>
| <c#> | 2019-08-28 22:29:01 | LQ_CLOSE |
57,701,391 | Get string between string/ and / | <p>Ive been trying for ages to get the id <code>30393</code> from the below string.</p>
<p><code>https://example.com/service_requests/30393/journey</code></p>
<p>Any ideas how? Its the <code>/</code> causing me issues. Been trying <code>(?<=/).*?(?=/)</code> but obviously it doesn't work.</p>
| <regex> | 2019-08-29 00:06:28 | LQ_CLOSE |
57,703,197 | How to use SEP in for loop? | <p>I can't sep="_" in my code</p>
<p>How can i do.</p>
<pre><code>'''python'''
def sequence(num):
for i in range(1, num+1):
print(i, sep="_", end=""
sequence()
</code></pre>
<pre><code>num = 6
i want = 1_2_3_4_5_6
but it show = 123456
</code></pre>
| <python><for-loop> | 2019-08-29 04:55:28 | LQ_CLOSE |
57,704,218 | Read a file and put specific values to an array | <p>I am a newbie to bash scripting. I have a file containing some values. I want to put all the values of a specific key into an array in bash. The file looks like this.</p>
<pre><code>file.properties
name=val1
name=val2
name=val3
age=val4
</code></pre>
<p>I want to read this file and get all the name values into one array in bash.</p>
| <bash><shell><file-read> | 2019-08-29 06:28:51 | LQ_CLOSE |
57,704,493 | set position of row by own on SQL | <p>I have a result of SQL like this </p>
<pre><code>status || value
green 3
blue 39
pink 2
black 300
</code></pre>
<p>I want to change the row of blue and pink </p>
<p>I want to sort like this from <code>green, pink, blue, and black</code> for that row and value also
is that possible to the condition that row to be by own? </p>
<p>so the result will be like this </p>
<pre><code>status || value
green 3
pink 2
blue 39
black 300
</code></pre>
| <mysql><sql> | 2019-08-29 06:47:25 | LQ_CLOSE |
57,706,657 | Why should I reduce the skewness of my data before applying a Machine Learning algorithm? | <p>What is the problem with skewed data? Why should we make the distribution more like a Gaussian?</p>
| <machine-learning><skew> | 2019-08-29 09:01:57 | LQ_CLOSE |
57,707,305 | I have a problem with Laravel, when i try to logout users I get Method Illuminate\Database\Query\Builder::pullCache does not exist | <p>Help... I Recently upgraded Laravel from 5.5 to >> 5.6 and now when I logout I get...</p>
<p>Arguments</p>
<blockquote>
<blockquote>
<p>Method Illuminate\Database\Query\Builder::pullCache does not exist.</p>
</blockquote>
</blockquote>
<pre class="lang-php prettyprint-override"><code> /**
* Handle dynamic method calls into the method.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->macroCall($method, $parameters);
}
if (Str::startsWith($method, 'where')) {
return $this->dynamicWhere($method, $parameters);
}
throw new BadMethodCallException(sprintf(
'Method %s::%s does not exist.', static::class, $method
));
}
}
</code></pre>
| <php><laravel><laravel-5.6> | 2019-08-29 09:37:55 | LQ_CLOSE |
57,707,626 | How to import data saved in word.doc into R-studio | <p>I've just received a dataset saved in word.doc. The owner of the data did not work with R. I would like to import this data into R-studio. I am familiar with Excel data but never work with word.doc. Is it possible to import this data automatically into R-studio?</p>
| <r> | 2019-08-29 09:54:43 | LQ_CLOSE |
57,708,179 | How to communicate between python and html page using flask framework? | <p>I am building a web-app on top of hadoop(its for internal use) using python's flask framework using jinja2 templates. I have a requirement where I need to communicate/do some changes on existing html. I am not sure how to do that.</p>
<p>The only way I know is to use:</p>
<pre><code>render_template('xyz.html',some_vale=some_value)
</code></pre>
<p>But this will render the template again.</p>
<p>Following are the task that I need to achieve:</p>
<ol>
<li><p>The requirement would be to pop up a bootstrap toast when I get an acknowledgement that the data is inserted into hive successfully. I do not want to use flash module in flask.</p></li>
<li><p>One more requirement is to show/hide loading dialog while I fetch the data from database. Once the search request is initiated, till the data is fetched, the dialog should be visible and then it should disappear.</p></li>
</ol>
<p>How can talk to HTML from python like we do in java script using id.</p>
<p>Appreciate the help.</p>
| <python><html><flask> | 2019-08-29 10:27:28 | LQ_CLOSE |
57,708,454 | How can I check if a sequence of numbers is a fibonnaci sequence and obtain the next value In R? | <p>How can we create a function to do this? So given these numbers, how can we check whether they are in fact a fibonacci sequence and then predict the next value in the sequence?</p>
<p>1 1 2 3 5<br>
1 2 3 5 8<br>
2 3 5 8 13<br>
3 5 8 13 21<br>
5 8 13 21 34<br>
8 13 21 34 55<br>
13 21 34 55 89<br>
21 34 55 89 144<br>
34 55 89 144 233</p>
| <r><math><data-manipulation> | 2019-08-29 10:43:41 | LQ_CLOSE |
57,710,335 | Window width doesn't fit to device fit | <p>I'm trying to make a Bootstrap 3 navbar and it should collapse at the 768px width size. But it doesn't work. I checked it why it's happening and I realized it sees window width as 980px whatever its size is. </p>
<p>My site is: <a href="http://dev.semcoled.com" rel="nofollow noreferrer">http://dev.semcoled.com</a></p>
<p>I console.log'ged and alerted the window width, it always prompts 980px even if the device is smaller than it.</p>
<p>I don't know why does that happen.</p>
<p>Thanks</p>
| <javascript><html><css><twitter-bootstrap-3><window> | 2019-08-29 12:34:10 | LQ_CLOSE |
57,710,905 | Rename columns in postgres | <p>I am running next postgres command in cmd to rename column, but getting next error: </p>
<pre><code>postgres=> ALERT TABLE tableName RENAME "colum1" TO "column2";
ERROR: syntax error at or near "ALERT"
LINE 1: ALERT TABLE tableName RENAME "colum1" TO "co...
</code></pre>
| <sql><postgresql> | 2019-08-29 13:06:31 | LQ_CLOSE |
57,710,920 | How can I find a solution for the "FileNotFoundError" | <p>I'm currently working on an image classifier project. During the testing of the predict function, I receive the error: FileNotFoundError: [Errno 2] No such file or directory: 'flowers/test/1/image_06760'</p>
<p>the path of the file is correct.
You can find the whole notebook here:
<a href="https://github.com/MartinTschendel/image-classifier-1/blob/master/190829-0510-Image%20Classifier%20Project.ipynb" rel="nofollow noreferrer">https://github.com/MartinTschendel/image-classifier-1/blob/master/190829-0510-Image%20Classifier%20Project.ipynb</a></p>
<p>Here is the respective predict function and the test of this function:</p>
<pre><code>def predict(image_path, model, topk=5):
''' Predict the class (or classes) of an image using a trained deep learning model.
'''
#loading model
loaded_model = load_checkpoint(model)
# implement the code to predict the class from an image file
img = Image.open(image_name)
img = process_image(img)
# convert 2D image to 1D vector
img = np.expand_dims(img, 0)
img = torch.from_numpy(img)
#set model to evaluation mode and turn off gradients
loaded_model.eval()
with torch.no_grad():
#run image through network
output = loaded_model.forward(img)
#calculate probabilities
probs = torch.exp(output)
probs_top = probs.topk(topk)[0]
index_top = probs.topk(topk)[1]
# Convert probabilities and outputs to lists
probs_top_list = np.array(probs_top)[0]
index_top_list = np.array(index_top[0])
#load index and class mapping
loaded_model.class_to_idx = train_data.class_to_idx
#invert index-class dictionary
idx_to_class = {x: y for y, x in class_to_idx.items()}
#convert index list to class list
classes_top_list = []
for index in index_top_list:
classes_top_list += [idx_to_class[index]]
return probs_top_list, classes_top_list
</code></pre>
<pre><code># test predict function
# inputs equal paths to saved model and test image
model_path = '190824_checkpoint.pth'
image_name = data_dir + '/test' + '/1/' + 'image_06760'
probs, classes = predict(image_name, model_path, topk=5)
print(probs)
print(classes)
</code></pre>
<p>This is the error I receive: </p>
<pre><code>FileNotFoundError: [Errno 2] No such file or directory: 'flowers/test/1/image_06760'
</code></pre>
| <python><pytorch> | 2019-08-29 13:07:16 | LQ_CLOSE |
57,711,323 | Convert dataframe numeric column to character | <p>I have a data frame with character and numeric columns, when plotting a PCA later on, I need to plot character columns so I wanted to convert column "station" to character.</p>
<p>The data frame:</p>
<pre><code>coldata <- data.frame(Location = c(West,West,East,East),
Station = c(1,2,3,4),
A = c("0.3","0.2","0.8","1"))
</code></pre>
<p>And the type of columns:</p>
<pre><code>sapply(coldata, mode) location station A
"character" "numeric" "numeric"
</code></pre>
<p>I would like to have this:</p>
<pre><code>sapply(coldata, mode) location station A
"character" "character" "numeric"
</code></pre>
<p>Can a column be labelled as "character" if containing numbers? Or would I have to convert the numbers into words: ie: 1, 2, 3,4 to one, two, three, four? </p>
<p>I have seen many posts converting character into numeric, but not numeric to character.</p>
| <r> | 2019-08-29 13:31:00 | LQ_CLOSE |
57,712,711 | can't install any go script in linux can any one help please | when i try to run any go script it show me this error
i installed go lang step by step from this link
https://www.tecmint.com/install-go-in-linux/
when i setup go script like this
go get github.com/tomnomnom/waybackurls
i got error like this
github.com/tomnomnom/waybackurls
src/github.com/tomnomnom/waybackurls/main.go:191: u.Hostname undefined (type *url.URL has no field or method Hostname)
| <go> | 2019-08-29 14:47:55 | LQ_EDIT |
57,712,766 | Recreate iOS 13' share sheet modal in swift (not the share sheet itself, but the way it's presented) | <p>is there a way to easily recreate the modal presentation style of ios 13' new share sheet? (At first, it's only presented halfway and you can swipe up to make it a "full" modal sheet) I can do it using a completely custom presentation and stuff but is there a "native" api for this behavior so that you don't have to use custom code?</p>
<p>Thanks!</p>
<p><a href="https://i.stack.imgur.com/5DUcI.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/5DUcI.gif" alt="enter image description here"></a></p>
| <ios><swift> | 2019-08-29 14:50:51 | HQ |
57,713,712 | Group by consecutive index numbers | <p>I was wondering if there is a way to groupby consecutive index numbers and move the groups in different columns. Here is an example of the DataFrame I'm using:</p>
<pre><code> 0
0 19218.965703
1 19247.621650
2 19232.651322
9 19279.216956
10 19330.087371
11 19304.316973
</code></pre>
<p>And my idea is to gruoup by sequential index numbers and get something like this:</p>
<pre><code> 0 1
0 19218.965703 19279.216956
1 19247.621650 19330.087371
2 19232.651322 19304.316973
</code></pre>
<p>Ive been trying to split my data by blocks of 3 and then groupby but I was looking more about something that can be used to group and rearrange sequential index numbers.
Thank you!</p>
| <python><pandas><numpy><group-by> | 2019-08-29 15:46:59 | HQ |
57,715,057 | How can I get a value from the select box in JQuery | I want to get the value of the selected option from the selected box by using JQuery but it ain't working.
I have tried a million ways to do it. Trying to get its text instead, tried to get the value from multiple ways. To know what is coming in my jquery variable.
```
<!-- HTML Code -->
<select class="form-control" id="cateogry" name="category">
<option value="0" disabled selected>Choose Project Category</option>
<option value="active">Active Project</option>
<option value="drafted">Drafted Project</option>
</select>
<!-- JQuery Script -->
<script>
$(document).ready(function () {
//First thing i tried
var category = $('#category').val();
alert(Category);
//Second thing i tried
var category = $('#category').filter(":selected").val();
alert(Category);
//Third thing i tried
var category = $('#category').find(":selected").text();
alert(Category);
//Fourth thing i tried
var category = $('#category').find(":selected").val();
alert(Category);
//Fourth thing i tried
var category = document.getElementById('category').value;
alert(Category);
//Now directly taking the value of selected option by id
alert($("#category :selected").attr('value'));
//These are the code snippets I tried at different times so don't
think that I did this all a time which can obviously throw some
exception.
});
</script>
```
All the options I have given above and tried all of them one by one and put an alert to see what is it getting and the alert said undefined. What can I do? | <javascript><jquery><html><drop-down-menu> | 2019-08-29 17:16:34 | LQ_EDIT |
57,716,968 | Convert Bitbucket Mercurial repository to Git. Maintain branches and history. Online solution | <p>How do I convert a Bitbucket Mercurial repository (Hg repository) to a Git repository? I want to keep branches and commit history.</p>
| <git><mercurial><bitbucket> | 2019-08-29 19:53:55 | HQ |
57,717,256 | Extract a given ancestor path form a deeper path in MS-DOS | I have no idea how to get what described here using an MS-DOS batch script:
__pseudo-code__
```
set aPath=C:\just\a\long\path\to\a\file\in\the\file\system
set aDir=file
... some logic here
echo %result%
```
Should print
```
C:\just\a\long\path\to\a\file
```
__ONLY MS-DOS SOLUTIONS ARE WELCOME__ no Powershell code nor external tools, please. I'm looking for a pure MS-DOS solution. | <windows><batch-file> | 2019-08-29 20:18:48 | LQ_EDIT |
57,719,497 | Generate a prettier plot with the data | <p>I am looking for all prettier ways to represent my data in any plots. I hope can get more suggestions so that I can learn and note as reference. So please do provide me with more examples of any idea you have. Thank you.</p>
<pre><code>import pandas as pd
a = pd.DataFrame({"label":["a","b","c","d"],
"value1":[2,4,6,8],
"value2":[11,12,13,14],
"value3":[5,6,7,8]})
fig = plt.figure(figsize=(20,20))
plt.subplot(2, 2, 1)
plt.plot(a.label, a.value1, "r--", linewidth=5, label="a")
plt.plot(a.label, a.value2, "b-", linewidth=5, label="b")
plt.plot(a.label, a.value3, "g-", linewidth=5, label="c")
plt.legend()
plt.show()
</code></pre>
<p>Above is my plot. But it is not really that nice though.</p>
| <python><matplotlib> | 2019-08-30 01:39:51 | LQ_CLOSE |
57,720,023 | Program wont move past delete | <p>So I can not figure out why my program halts at the delete statement inside my purge loop. It's not crashing it just won't execute or give my any sort of error.</p>
<p>I have double checked that I am deleting an array and need the brackets, and verified that it is valid new memory. It will not work if its called by the destructor or explicitly </p>
<pre><code>int main()
{
darray DA1;
DA1.Add("Hello");
DA1.Add("Good Morning");
return 0;
}
void Add(const char * string)
{
char ** temp = new char *[m_count + 1];
for (int i = 0; i < m_count; ++i)
temp[i] = m_array[i];
temp[m_count] = new char[strlen(string)];
strcpy(temp[m_count], string);
delete[] m_array;
m_array = temp;
m_count++;
}
void Purge()
{
for (int i = 0; i < m_count; ++i)
{
delete [] m_array[i];
m_array[i] = nullptr;
}
delete[] m_array;
m_array = nullptr;
m_count = 0;
}
</code></pre>
<p>I expect it to go through the 2d dynamic array deleting each array and then delete the final array.</p>
| <c++> | 2019-08-30 03:10:37 | LQ_CLOSE |
57,722,093 | No overload matches this call. Type 'string' is not assignable to type 'Signals' | <p>I am using typescript to build a micro service and handling signals as well. The code was working fine till few days ago but recently it started throwing error. Couldn't find a fix for the issue. </p>
<p>code for handling signals. It is just part of the file.
<code>src/main.ts</code></p>
<pre><code> enum signals {
SIGHUP = 1,
SIGINT = 2,
SIGTERM = 15
}
const shutdown = (signal, value) => {
logger.warn("shutdown!")
Db.closeAll()
process.exit(value)
}
Object.values(signals).forEach(signal => {
process.on(signal, () => {
logger.warn(`process received a ${signal} signal`)
shutdown(signal, signals[signal])
})
})
</code></pre>
<p>When I do <code>ts-node src/main.ts</code> The following error throws and fails and exit.</p>
<pre><code>
/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:245
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
src/main.ts:35:16 - error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'string | signals' is not assignable to parameter of type 'Signals'.
Type 'string' is not assignable to type 'Signals'.
35 process.on(signal, () => {
~~~~~~
node_modules/@types/node/base.d.ts:653:9
653 on(event: Signals, listener: SignalsListener): this;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last overload is declared here.
at createTSError (/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:245:12)
at reportTSError (/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:249:19)
at getOutput (/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:362:34)
at Object.compile (/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:395:32)
at Module.m._compile (/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:473:43)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/meraj/.nvm/versions/node/v8.10.0/lib/node_modules/ts-node/src/index.ts:476:12)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
</code></pre>
<p>Any fix would be appreciated. Or If you can tell why it was working earlier just 2 days ago and not now. </p>
| <javascript><node.js><typescript><signals> | 2019-08-30 07:07:58 | HQ |
57,722,249 | How to build multiple containers in jenkins file? | I have 3 different docker images. I need to build these images from Jenkins file. I have wildfly, Postgres, virtuoso docker images with individual docker file. As of now, I am using the below command to build these images:
'sh docker build docker docker-compose.yml'
My question is how build these 3 images from Jenkins file?
Thanks in advance. | <docker><kubernetes><jenkins-pipeline><devops><docker-container> | 2019-08-30 07:17:59 | LQ_EDIT |
57,722,416 | Changing logo on different background colors | <p>I am making a custom website where each section has a different background colour, on the scroll of each section the logo should change the colour of the logo is purple for eg. if the first section has a carousel and below there is a red background when scrolled the logo should change to white.</p>
| <javascript><jquery><html><css> | 2019-08-30 07:30:25 | LQ_CLOSE |
57,723,938 | How to center any element in HTML | <p>I want to center <code>textarea</code> element, but <code>margin: 0 auto</code> doesn't work properly.</p>
<p>Also I tried to wrap element in <code>div</code> which has <code>margin: 0 auto</code> style.</p>
<pre><code><div style="margin: 0 auto;">
<textarea rows="4" cols"100"></textare>
</div>
</code></pre>
| <html><css> | 2019-08-30 09:20:35 | LQ_CLOSE |
57,724,443 | Hello Everyone i have one issues on go green wordpress premium theme | <p>I am new in WordPress and when I install fresh Wordpress and buy one premium Theme <strong>go green</strong> when I try to save my content on this theme editore I got internal server error can anyone help here </p>
<p>please check the screenshot here <a href="http://prntscr.com/ozjp6l" rel="nofollow noreferrer">http://prntscr.com/ozjp6l</a></p>
| <wordpress><editor> | 2019-08-30 09:50:37 | LQ_CLOSE |
57,725,481 | Send data to another page - html | <p>Hello I wanted to send data from one html page to another </p>
<p>For eg this is my index.html page</p>
<pre><code><html>
<body>
<script>
var uname = "karan"; // I want to send this
</script>
</body>
</html>
</code></pre>
<p>And this is newPage.html:</p>
<pre><code><html>
<body>
<script>
console.log(uname); // I want the uname form index.html
</script>
</body>
</html>
</code></pre>
<p>I have already tried declaring a new class in another javascript file but it gives <code>undefined</code></p>
<p>Is there any way I can do this? Thank you</p>
| <javascript><html> | 2019-08-30 10:59:05 | LQ_CLOSE |
57,725,684 | Allow unique $_GET request only? Generate, verify, forbid values | <p>Hello everyone again here,
I want to create a PHP script for my software which generates and returns the specific code using one $_GET request with a string and using another verificates this code, then forbid running same string.</p>
<p>Something what should work like this:
1st user's software runs "<a href="http://example.com/codes.php?create=" rel="nofollow noreferrer">http://example.com/codes.php?create=</a>" and string like "abc".
and script returns code based on "abc", e.g. "4aO45k", "12sdF4" etc.
2nd user's software runs "<a href="http://example.com/codes.php?verify=" rel="nofollow noreferrer">http://example.com/codes.php?verify=</a>" and this code.
If this code exists, return true and remove it FOREVER, meaning this code will never be generated again. If this code doesn't exist, return false.
If 1st user's software will run "<a href="http://example.com/codes.php?create=abc" rel="nofollow noreferrer">http://example.com/codes.php?create=abc</a>" another code will be generated.</p>
<p>In simple words:</p>
<pre><code>if $_GET is create, then
generate random alphanumeric string, save it and return
if $_GET is verify, then
check if this string exists, if so, then
return true, remove from saved
otherwise
return false
</code></pre>
<p>Possible without databases, SQL, mySQL, FireBird...?
How do I make it using .ini files as storage?</p>
<p>Thanks.</p>
| <php> | 2019-08-30 11:12:48 | LQ_CLOSE |
57,729,518 | How to get rid of the warning .ts file is part of the TypeScript compilation but it's unused | <p>I Just updated angular to latest <code>9.0.0-next.4</code>. I am not using routing but suddenly after updating I keep seeing this warning. How Do I remove this warning</p>
<blockquote>
<p>WARNING in <code>src/war/angular/src/app/app-routing.module.ts</code> is part of
the TypeScript compilation but it's unused. Add only entry points to
the 'files' or 'include' properties in your tsconfig.</p>
</blockquote>
<p><strong>package.json</strong></p>
<pre><code> "dependencies": {
"@angular/animations": "^9.0.0-next.4",
"@angular/cdk": "^8.1.4",
"@angular/common": "^9.0.0-next.4",
"@angular/compiler": "^9.0.0-next.4",
"@angular/core": "^9.0.0-next.4",
"@angular/forms": "^9.0.0-next.4",
"@angular/material": "^8.1.4",
"@angular/platform-browser": "^9.0.0-next.4",
"@angular/platform-browser-dynamic": "^9.0.0-next.4",
"@angular/router": "^9.0.0-next.4",
"@ng-bootstrap/ng-bootstrap": "^5.1.0",
"bootstrap": "^4.3.1",
"hammerjs": "^2.0.8",
"moment": "^2.24.0",
"ng-image-slider": "^2.0.1",
"panzoom": "^8.1.2",
"rxjs": "~6.5.2",
"tslib": "^1.9.0",
"zone.js": "^0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.2",
"@angular/cli": "^8.3.2",
"@angular/compiler-cli": "^9.0.0-next.4",
"@angular/language-service": "^9.0.0-next.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "^5.15.0",
"typescript": "^3.5.3"
}
</code></pre>
<p><strong>tsconfig.json</strong></p>
<pre><code> {
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
</code></pre>
| <angular><typescript><angular-cli> | 2019-08-30 15:27:20 | HQ |
57,729,682 | Connection closed by EC2 IP - port 22 | <p>Below is the security group(first one) applied to EC2 instance.</p>
<h2><a href="https://i.stack.imgur.com/XCthf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XCthf.png" alt="enter image description here"></a></h2>
<p>Rules for this security group is:</p>
<h2><a href="https://i.stack.imgur.com/sry4x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sry4x.png" alt="enter image description here"></a></h2>
<p>But ssh command give below error:</p>
<pre><code>$ ssh -i ./xyz.pem ec2-user@ec2-xx-xx-xx-xx.ca-central-1.compute.amazonaws.com
Connection closed by xx.xx.xx.xx port 22
</code></pre>
<hr>
<p>Why ssh client is unable to connect to ubuntu instance type?</p>
| <amazon-web-services><amazon-ec2><ssh> | 2019-08-30 15:38:11 | LQ_CLOSE |
57,729,841 | How to substitute several regex in Python? | <p>I would like to loop on every lines from a .txt file and then use <code>re.sub</code> method from Python in order to change some contents if there is a specific pattern matcing in this line.</p>
<p>But how can I do that for two different pattern in the same file ?</p>
<p>For example, here's my code :</p>
<pre><code>file = open(path, 'r')
output = open(temporary_path, 'w')
for line in file:
out = re.sub("patternToChange", "patternToWrite", line) #Here I would like to also do the same trick with "patternToChange2 and patternToWrite2 also in the same file
output .write(out)
</code></pre>
<p>Do you have any ideas ?</p>
| <python><regex><file> | 2019-08-30 15:49:09 | LQ_CLOSE |
57,730,097 | How can i swap between two images on click | How can i swap between two images on click forever ( not once ) using JS or jQeury
$("button").click(function(){
$("img").attr("src","The New SRC");
});
This code works but just once | <javascript><jquery><click> | 2019-08-30 16:09:32 | LQ_EDIT |
57,730,991 | Login with different role | I am new to php. I could not log in either from the user or the admin. How do make it so the user could log in and will be redirected to index.php, and once the admin login will be redirected to admin.php.
I did some research with youtube and could not find anything helpful on what I need.
---html
<form action="login.php" method="post">
<input class="space" name="username" type="text"
placeholder="Username/E-
mail" required="required"></input>
<br />
<input class="space" name="password" type="password"
placeholder="Password" required="required"></input>
<br />
<input type="submit" class="log-btn" value="Login" />
<button type="button" class="log-btn" onclick="return
abc(1,'reg.html')">Register</button>
</form>
[this is the database table][1]
I had also included the admin username and password in the database so admin does not have to register
---php
<?php
include ("conn.php");
session_start();
$sql="SELECT * FROM user WHERE email = '".$_REQUEST['username']."' and
password = '".$_REQUEST['password']."' or username =
'".$_REQUEST['username']."' and password = '".$_REQUEST['password']."'
LIMIT 1";
$result=mysqli_query($con,$sql);
if(mysqli_num_rows($result) <= 0)
{
$cred = mysqli_fetch_row($result);
$_SESSION['user'] = $cred[1];
echo "<script>window.location.href='index.php';</script>";
}
else
echo "<script>window.location.href='index.php?msg=Invalid+Credential';
</script>";
if($row=mysqli_fetch_array($result))
{
$_SESSION['role']=$row['user_role'];
}
if($row['user_role']==="1"])
{
echo "<script>alert('Welcome back admin!');";
echo "window.location.href='admin.html';</script>";
}
?>
I expect that the user will be able to login and will be redirected to the index.php and the admin will be able to login as well as but will be redirected to the admin.pbp. But what I am seeing a white page and some error code on line 20. I know my if-else statement has some issue but not sure on how to fix it to be working
[1]: https://i.stack.imgur.com/owVvk.png | <php><html><mysqli> | 2019-08-30 17:29:49 | LQ_EDIT |
57,731,810 | Datasets not joining | <p>I'm having trouble joining FBI crime data with school districts. </p>
<p>There are some cities/towns that have the same name in the same state, so county is given as a way to separate these values. For the years 2003-2017 there are roughly 1700 values that also have counties. However, when I try to join this dataset with another school district dataset, limited values join (if I inner join, I'll get 200 out of the 1700). On this forum, with another question (<a href="https://stackoverflow.com/questions/57715121/issues-with-character-values/57727781#57727781">Issues with Character Values</a>), other members helped me solve an issue with whitespace, but oddly, this didn't help the joining of the datasets. Below is a dput for Adams county in Pennsylvania for both the crime data and the school districts. </p>
<p>A simple left_join should work, but you'll see that I don't get any of the district values. Inner_join yields zero rows, so there's some issue in the data where something isn't being recognized. STATE, COUNTY, and CITY are all character, year is numeric. These are the variables by which the two columns are joined.</p>
<p>I tried trimming white space around all categorical variables. No dice.</p>
<p>As a rule of thumb, I join by district_ids, place_ids, etc., but the FBI crime data is clunky, and doesn't have any of that, so categorical it is.</p>
<p>crime data</p>
<pre><code>structure(list(CITY = c("conewago", "conewago", "cumberland",
"conewago", "cumberland", "liberty", "conewago", "liberty", "conewago",
"cumberland", "liberty", "conewago", "cumberland", "liberty",
"conewago", "cumberland", "liberty", "conewago", "cumberland",
"conewago", "cumberland", "conewago", "cumberland", "conewago",
"cumberland", "conewago", "cumberland", "liberty", "conewago",
"cumberland"), COUNTY = c("adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county"), STATE = c("pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania"), year = c(2006, 2007, 2007, 2008, 2008, 2008,
2009, 2009, 2010, 2010, 2010, 2011, 2011, 2011, 2012, 2012, 2012,
2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016, 2017, 2017, 2017,
2003, 2003)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-30L))
</code></pre>
<p>district data</p>
<pre><code>structure(list(CITY = c("east berlin", "york springs", "abbottstown",
"bonneauville", "mcsherrystown", "new oxford", "carroll valley",
"fairfield", "gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "east berlin", "york springs",
"abbottstown", "bonneauville", "mcsherrystown", "new oxford",
"carroll valley", "fairfield", "gettysburg", "bonneauville",
"littlestown", "arendtsville", "bendersville", "biglerville",
"east berlin", "york springs", "abbottstown", "bonneauville",
"mcsherrystown", "new oxford", "carroll valley", "fairfield",
"gettysburg", "bonneauville", "littlestown", "arendtsville",
"bendersville", "biglerville", "hampton", "idaville", "lake meade",
"midway", "orrtanna", "cashtown", "hunterstown", "lake heritage",
"mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale",
"gardners", "heidlersburg", "table rock", "hampton", "idaville",
"lake meade", "midway", "orrtanna", "cashtown", "hunterstown",
"lake heritage", "mcknightstown", "orrtanna", "lake heritage",
"aspers", "flora dale", "gardners", "heidlersburg", "table rock",
"hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown",
"hunterstown", "lake heritage", "mcknightstown", "orrtanna",
"lake heritage", "aspers", "flora dale", "gardners", "heidlersburg",
"table rock", "hampton", "idaville", "lake meade", "midway",
"orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown",
"orrtanna", "lake heritage", "aspers", "flora dale", "gardners",
"heidlersburg", "table rock", "hampton", "idaville", "lake meade",
"midway", "orrtanna", "cashtown", "hunterstown", "lake heritage",
"mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale",
"gardners", "heidlersburg", "table rock", "hampton", "idaville",
"lake meade", "midway", "orrtanna", "cashtown", "hunterstown",
"lake heritage", "mcknightstown", "orrtanna", "lake heritage",
"aspers", "flora dale", "gardners", "heidlersburg", "table rock",
"hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown",
"hunterstown", "lake heritage", "mcknightstown", "orrtanna",
"lake heritage", "aspers", "flora dale", "gardners", "heidlersburg",
"table rock", "hampton", "idaville", "lake meade", "midway",
"orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown",
"orrtanna", "lake heritage", "aspers", "flora dale", "gardners",
"heidlersburg", "table rock", "hampton", "idaville", "lake meade",
"midway", "orrtanna", "cashtown", "hunterstown", "lake heritage",
"mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale",
"gardners", "heidlersburg", "table rock", "hampton", "idaville",
"lake meade", "midway", "orrtanna", "cashtown", "hunterstown",
"lake heritage", "mcknightstown", "orrtanna", "lake heritage",
"aspers", "flora dale", "gardners", "heidlersburg", "table rock",
"hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown",
"hunterstown", "lake heritage", "mcknightstown", "orrtanna",
"lake heritage", "aspers", "flora dale", "gardners", "heidlersburg",
"table rock", "hampton", "idaville", "lake meade", "midway",
"orrtanna", "cashtown", "hunterstown", "lake heritage", "mcknightstown",
"orrtanna", "lake heritage", "aspers", "flora dale", "gardners",
"heidlersburg", "table rock", "hampton", "idaville", "lake meade",
"midway", "orrtanna", "cashtown", "hunterstown", "lake heritage",
"mcknightstown", "orrtanna", "lake heritage", "aspers", "flora dale",
"gardners", "heidlersburg", "table rock", "hampton", "idaville",
"lake meade", "midway", "orrtanna", "cashtown", "hunterstown",
"lake heritage", "mcknightstown", "orrtanna", "lake heritage",
"aspers", "flora dale", "gardners", "heidlersburg", "table rock",
"hampton", "idaville", "lake meade", "midway", "orrtanna", "cashtown",
"hunterstown", "lake heritage", "mcknightstown", "orrtanna",
"lake heritage", "aspers", "flora dale", "gardners", "heidlersburg",
"table rock"), COUNTY = c("adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county", "adams county",
"adams county", "adams county", "adams county"), STATE = c("pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania", "pennsylvania", "pennsylvania", "pennsylvania",
"pennsylvania"), year = c(2003, 2003, 2003, 2003, 2003, 2003,
2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2004, 2004, 2004,
2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004,
2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005,
2005, 2005, 2005, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006,
2006, 2006, 2006, 2006, 2006, 2006, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2011, 2011, 2011, 2011,
2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013,
2013, 2013, 2013, 2013, 2013, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2015, 2015, 2015,
2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015,
2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016,
2016, 2016, 2016, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017,
2017, 2017, 2017, 2017, 2017, 2017, 2003, 2003, 2003, 2003, 2003,
2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003,
2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004,
2004, 2004, 2004, 2004, 2004, 2005, 2005, 2005, 2005, 2005, 2005,
2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2006,
2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006, 2006,
2006, 2006, 2006, 2006, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2010, 2010, 2010,
2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
2010, 2010, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011, 2011,
2011, 2011, 2011, 2011, 2011, 2011, 2011, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013,
2013, 2013, 2013, 2013, 2013, 2013, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015,
2015, 2015, 2015, 2015, 2015, 2016, 2016, 2016, 2016, 2016, 2016,
2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2016, 2017,
2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017,
2017, 2017, 2017, 2017)), class = c("spec_tbl_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -450L))
</code></pre>
| <r><join> | 2019-08-30 18:43:21 | LQ_CLOSE |
57,732,258 | C how to insert string into array? | I want to insert string to the array until I type "ok". Why I am getting just "ok" and original array at the output?
int main(void)
{
char b[20];
char* str[10] = { "1","2" };
int i = 2;
while (1) {
gets(b);
if (strcmp(b, "ok") == 0) break;
str[i] = b;
i++;
}
for (int j = 0; j < i; j++)
printf("%s ", str[j]);
return 0;
} | <c><arrays> | 2019-08-30 19:25:28 | LQ_EDIT |
57,733,305 | What's the purpose of this lambda? | <p>I see the following lambda in C++ code. What's the purpose of it?</p>
<pre class="lang-cpp prettyprint-override"><code>static const auto faster = [](){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
return nullptr;
}();
</code></pre>
| <c++><c++14> | 2019-08-30 21:16:51 | HQ |
57,733,392 | How to convert a number to a linked list in C++ | <p>I am starting out learning about linked lists and am trying to solve a programming problem. The output needs to be a number represented as a linked list. For example, if the number is 123, the linked list needs to be 3->2->1. </p>
<p>According to my implementation, I am doing all other functions beforehand and have the final output number as an int, and need to convert it to a linked list. I tried the following code.</p>
<pre><code> ListNode* numToLL(int sum){
ListNode* mainHead;
int remainder = sum % 10;
mainHead->val = remainder;
sum = sum / 10;
ListNode* head;
head = mainHead;
while (sum != 0){
ListNode* nextNode;
int remainder = sum % 10;
nextNode->val = remainder;
head->next = nextNode;
head = nextNode;
sum = sum / 10;
}
return mainHead;
}
</code></pre>
<p>I know this is incorrect, but I am not sure how to correct it. The error message for this says: "runtime error: member access within null pointer of type 'struct ListNode'" on the 3rd line inside the function.</p>
| <c++> | 2019-08-30 21:27:15 | LQ_CLOSE |
57,735,029 | I'm new to this and i need help please <3 | <p>So basically when i run a command, the bot spams its response.</p>
<pre><code> bot.on('message', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'embed':
const embed = new Discord.RichEmbed()
.setTitle('User Information')
.addField('Player Name', message.author.username)
.addField('Version', version)
.addField('Current Server', message.guild.name)
.setThumbnail(message.author.avatarURL)
.setFooter('Made By NotBanEvading')
message.channel.sendEmbed(embed);
break;
}
})
</code></pre>
<p><a href="https://gyazo.com/a1c71fc097e1253bc036d1ef293f034e" rel="nofollow noreferrer">https://gyazo.com/a1c71fc097e1253bc036d1ef293f034e</a></p>
| <discord.js> | 2019-08-31 03:47:51 | LQ_CLOSE |
57,736,432 | Creation tool for flutter? | <p>does anyone know if there is a way to build a flutter UI just by dragging items onto the screen? Like I want a text layer, then I will just drag the text item on the screen and move it around? Like with swift?</p>
| <flutter> | 2019-08-31 08:35:35 | LQ_CLOSE |
57,736,699 | how to parse the JSON data start with "/{}" in android | I want to parse the JSON data which response starts with the slash. I am using retrofit for parsing the data. thanks in advance.
/{
"data": [
{
"id": "1",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
},
{
"id": "2",
"text": "Felis donec et odio pellentesque diam volutpat commodo sed. Non arcu risus quis varius quam quisque. Nibh nisl condimentum id venenatis a condimentum vitae. Vel pharetra vel turpis nunc eget. "
},
{
"id": "3",
"text": "Volutpat sed cras ornare arcu dui vivamus arcu felis bibendum. Lobortis mattis aliquam faucibus purus in. Aliquam sem fringilla ut morbi tincidunt augue interdum."
},
{
"id": "4",
"text": "Elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique. Bibendum at varius vel pharetra vel turpis nunc. Pellentesque sit amet porttitor eget dolor morbi non."
},
{
"id": "5",
"text": "Urna condimentum mattis pellentesque id. Ac tincidunt vitae semper quis. Massa tincidunt dui ut ornare lectus sit amet. Netus et malesuada fames ac turpis. Nulla facilisi cras fermentum odio eu feugiat pretium nibh."
},
{
"id": "6",
"text": "Tincidunt id aliquet risus feugiat in ante. Id donec ultrices tincidunt arcu non sodales neque sodales. Turpis massa tincidunt dui ut ornare lectus sit amet est. At ultrices mi tempus imperdiet nulla malesuada pellentesque elit."
},
{
"id": "7",
"text": "Fermentum posuere urna nec tincidunt praesent semper feugiat. Nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum. At auctor urna nunc id cursus metus aliquam eleifend mi."
},
{
"id": "8",
"text": "Quisque sagittis purus sit amet volutpat consequat mauris nunc congue. Malesuada fames ac turpis egestas sed. Volutpat ac tincidunt vitae semper. Aliquam nulla facilisi cras fermentum."
}
]
}
I am getting this error
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 2 path $ | <java><android><json> | 2019-08-31 09:19:14 | LQ_EDIT |
57,737,498 | Shrinking a String to substrings | <p>I am new to android and working on a project, and in a part of that I need to shrink a string to smaller substrings.</p>
<p>For example let's assume the string is "A-87B9C143D24E940|jOmbFACBBAAAAADB2" and length of this string is not fixed.
The thing I want is that put characters from A to B to a string variable (like S0 = 87), from B to C to another one (like S1 = 9) from D to E to another one (like S3 = 143) from E to | to another one (like S4 = 940) and everything after | goes to another substring (like S5 = jOmbFACBBAAAAADB2);</p>
| <java><android><android-studio> | 2019-08-31 11:10:19 | LQ_CLOSE |
57,738,994 | How do I make my code look for a name in my list instead of a number? | <p>I have a file called classgrades.txt and it contains student data from a sample class. Each line in the file consists of a student's last name, a space, and a sequence of integers (separated by spaces), which represent scores on assignments.</p>
<p>I am trying to write a Python program to read the data from this file and to write a new file called classscores.txt . Each line of classscores.txt should consist of a student's last name and their average score on the assignments, rounded <strong>down</strong> to the nearest integer.</p>
<p>I've tried to find a way using the length of the list to go through it and once it reaches a name, it stops and takes all the previous numbers and finds the average and puts it next to the name.</p>
<pre class="lang-py prettyprint-override"><code>inFile = open('classgrades.txt','r')
lines = inFile.read()
outFile = open('classcores.txt','w')
fix_list = lines.replace('\n',' ')
new_list = fix_list.split(' ')
length_list = len(new_list) - 1
</code></pre>
<p>Here is what my current list looks like after this code:</p>
<p><code>['Chapman', '90', '100', '85', '66', '80', '55', 'Cleese', '80', '90', '85', '88', 'Gilliam', '78', '82', '80', '80', '75', '77', 'Idle', '91', 'Jones', '68', '90', '22', '100', '0', '80', '85', 'Palin', '80', '90', '80', '90', '']</code></p>
<p>It should output everything nicely in classscores.txt</p>
| <python><file><python-3.7> | 2019-08-31 14:45:58 | LQ_CLOSE |
57,740,695 | From a list, how to Print from certain string to certain string | <p>I want to print the Strings in a list.</p>
<p>For example, if my list contains like below, I would like to print the strings between Deer to Crazy, but not Deer and crazy.</p>
<p>['black', 'white', 'Deer', 'Blue', 'More', 'Crazy']</p>
| <python> | 2019-08-31 18:32:10 | LQ_CLOSE |
57,742,269 | Python gives me last value of list when I ask it to give the the value at -1 | <p>I am on python 3.7.1.</p>
<p>I am working with data structures, and when using lists, I ran into a bug.
When I try to access index -1, python gives me the last entry in the list.</p>
<p>I opened python shell, and ran the following commands:</p>
<pre class="lang-py prettyprint-override"><code>>>> l = [0,1,2]
>>> l[-1]
2
>>> l[3]
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
l[3]
IndexError: list index out of range
</code></pre>
<p>This is probably due to a bug on python 3.7.1, but is there a way other than updating python that fixes this? I'm in the middle of a project.</p>
| <python><python-3.7> | 2019-08-31 23:35:36 | LQ_CLOSE |
57,743,651 | How to make visible mobile status bar in React Native Navigation | <p>How to make a visible mobile status bar in React Native Navigation</p>
<p>Screenshot: Status bar not visible.</p>
<p><a href="https://i.stack.imgur.com/E8Bgh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8Bgh.png" alt="enter image description here"></a></p>
| <react-native><react-native-android><react-native-navigation> | 2019-09-01 06:13:34 | LQ_CLOSE |
57,744,669 | Why does the count variable has to be defined outside the curly brackets of the for loop? (Refer to the codes) | Please read till the end, so that you will understand the problem completely.
As you can see in the two below codes, I get different results when I use the count variable outside the for loop curly brackets. Can someone please tell me why?
As you can see the first result only prints three i values.
So my question is why the count variable can not be defined in the curly brackets of the for loop as I have done in the first code. Please help. Thank you.
public class Main {
public static void main(String[] args) {
int count = 0;
for (int i=0; i<5; i++) {
System.out.println(i);
count++;
if (count == 3) {
break;
}
}
}
}
public class Main {
public static void main(String[] args) {
for (int i=0; i<5; i++) {
int count = 0;
System.out.println(i);
count++;
if (count == 3) {
break;
}
}
}
} | <java><loops> | 2019-09-01 09:08:21 | LQ_EDIT |
57,744,723 | Function to count small letters and Capital in a string , spaces? | I created a function that you type a string and it will bring back the amount of small letters and the amount of capital letters in that string the program works for 1 word but as soon I add two letters the 'space' between two words messes things up. spaces counts too.
What is your thoughts?
```
def myfunc(s):
s = str(s)
upperl = 0
lowerl = 0
for i in s:
if i == i.lower():
lowerl += 1
if i == i.upper():
upperl += 1
if i == ' ':
continue
return upperl,lowerl
x = myfunc('hello G')
print (x)
```
```
def myfunc(s):
s = str(s)
upperl = 0
lowerl = 0
for i in s:
if i == i.lower():
lowerl += 1
if i == i.upper():
upperl += 1
if i == ' ':
continue
return upperl,lowerl
x = myfunc('hello G')
print (x)
```
from the word 'hello G' we expect upperletter,lowerletters
I expect 1,5 but that space between two words make it: 2,6 | <python> | 2019-09-01 09:19:05 | LQ_EDIT |
57,746,506 | Python says that elif statement is a Syntax Error | <p>I am new to python, and I have just started to learn from a book that I have recently bought.
I am at the if, elif and else chapter.
I have copied the code from the book, and I ran it.
Suddenly, it says about "elif", that is a Syntax Error.
Please help</p>
<pre class="lang-py prettyprint-override"><code>num = int(input('Please Enter A Number:'))
if num > 5:
print('Number Exceeds 5')
elif num < 5:
print('Number is Less than 5')
else:
print('Number is 5')
</code></pre>
| <python><python-3.x> | 2019-09-01 13:45:55 | LQ_CLOSE |
57,748,555 | How to create synthetic customer data in python | <p>I have some customer data with me -</p>
<pre><code>Name | Age | Gender | Phone Number | Email Id |
abc. | 25 | M. | 234 567 890 | example.com|
</code></pre>
<p>There are 60k rows of data like this and multiple tables. How can I make synthetic data for this dataset using python ?</p>
<p>I have no knowledge about this. Any suggestions would be helpful. Thanks!</p>
| <python><synthetic> | 2019-09-01 18:36:20 | LQ_CLOSE |
57,748,619 | There is a polygon in 2D space. Find its area | <p>There is a polygon in 2D space. Find its area.
An array of numbers:</p>
<ol>
<li><p>Positive integer n, the quantity of the polygon vertices.</p></li>
<li><p>Sequence of reals with n subsequences of two numbers, each subsequence contains the 2D coordinates of a vertex of the polygon.
Output:</p></li>
</ol>
<p>A real, the area of the polygon</p>
<p>What is wrong with my code? </p>
<p>Example: </p>
<p>Input:
3 1.0 0.0 0.0 2.0 -1.0 0.0
Output:
2</p>
<p>class Program
{</p>
<pre><code> static void Main(string[] args)
{
var input = Console.ReadLine();
var numbers = input.Split(' ').Select(x => double.Parse(x)).ToArray();
var a = (int) numbers[0];
double[] arr = numbers.Skip(1).Take(a).ToArray();
double[,] coord = new double[2, a];
for(int i = 0; i <= arr.Length/2; i++)
{
coord[0, i] = arr[i];
coord[1, i] = arr[1+i];
}
double sum1 = 0;
double sum2 = 0;
for(int i = 0; i < a - 1; i++)
{
sum1 += coord[0, i] * coord[1, i + 1];
sum2 += coord[1, i] * coord[0, i + 1];
}
double area = Math.Abs((sum1 - sum2) / 2d);
Console.Write(coord[0,2]);
Console.ReadKey();
}
}
</code></pre>
| <c#> | 2019-09-01 18:48:13 | LQ_CLOSE |
57,750,583 | how to fix [-Wreturn-type] error in mac OS | I have program a scheduler of one compiler when I run in OS Debian 9 all ok, but I trying to run in my computer who is mac OS then show lot of warnings and this error:
```c
error: non-void function 'CloseForLoops' should return a value [-Wreturn-type] return;
```
grateful! | <c> | 2019-09-02 01:29:47 | LQ_EDIT |
57,751,683 | How to make custom validation for all datatype in c# using extension methods | <p>hi i am want to make custom conman validation using c# extension method for all datatype please give me some idea about it and some examples?</p>
<p>Thanks</p>
| <c#><validation><extension-methods> | 2019-09-02 05:10:30 | LQ_CLOSE |
57,752,342 | How to get the value of every incrementation in the list combined? | Given the list of `[0, 10, 20, 5, 10, 30, 20, 35]`, how do I get the list of `[20, 25, 15]` for every incrementation of the values in the initial list? `[0, 10, 20]` turns into `[20]`, `[5, 10, 30]` turns into `[25]`, and `[20, 35]` turns into `[15]`. | <python><list> | 2019-09-02 06:32:46 | LQ_EDIT |
57,753,906 | Stream filter regex | <pre><code>List<File> fileListToProcess = Arrays.stream(allFolderPath)
.filter(myFile -> myFile.getName().matches("archive_"))
.collect(Collectors.toList());
</code></pre>
<p>I am filtering files which starts with "archive_" to process using regex and streams. This does not work. What am i doing wrong here? </p>
| <java> | 2019-09-02 08:45:01 | LQ_CLOSE |
57,754,348 | How to read CheckBox out of a text file WPF | <p>Well i have figured out how to save a checkbox value into a text file but now i need to now how to read it an load the settings for de application.</p>
<pre><code>private void Load_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == true)
{
using (StreamReader read = new StreamReader(File.OpenRead(ofd.FileName)))
{
TBSOMS.Text = read.ReadLine();
TBWVB.Text = read.ReadLine();
TBWNB.Text = read.ReadLine();
TBASPMM1.Text = read.ReadLine();
TBASPMM2.Text = read.ReadLine();
TBDUM.Text = read.ReadLine();
TBADPR.Text = read.ReadLine();
TBAR.Text = read.ReadLine();
// Not working part
CBXY1.IsChecked = read.ReadLine();
read.Close();
read.Dispose();
}
}
}
</code></pre>
<p>everything works properly except the checkbox value and i cant figure out how to fix it</p>
| <c#><wpf> | 2019-09-02 09:17:07 | LQ_CLOSE |
57,754,971 | Callback Problem: Can't return a value from a method with void result type | <p>I want to return the <code>List<Product></code> as result value without blocking, how is it done?</p>
<pre><code>public static List<Product> getProducts(@NonNull Context context){
ProductDataSource.getInstance(context).readProducts(new IProductDataSource.IReadProductsCallback() {
@Override
public void onSuccess(List<Product> result) {
return result; // error in here
}
@Override
public void onFailure() {
return null; // error in here
}
});
}
</code></pre>
| <java><android> | 2019-09-02 10:01:14 | LQ_CLOSE |
57,755,997 | jquery-3.3.1.js:9600 POST http://127.0.0.1:8000/api/edit-data 500 (Internal Server Error) | With the help of Jquery ajax i am trying to edit the data in the form.
According to other solutions, i have already included csrf token in both meta and ajax setup.
```
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});```
In header
<meta name="csrf-token" content="{{ csrf_token() }}">
```
```
$.ajax({
type : "POST",
url: "{{url('api/edit-data')}}",
data : {
id : id,
name: name,
contact: contact,
email: email,
valley: valley,
paddress: paddress,
taddress: taddress,
qualification: qualification,
ts: ts,
experiences: experiences,
tob: tob,
es: es,
level: level,
ey: ey,
cn: cn,
cv: cv,
},
success: function(res)
{
console.log(res.sessiondata);
// alert('successful');
}
});
});
```
controller
```
public function editdata(Request $request)
{
$id = $request->id;
$data['name'] = $request->name;
$data['contact'] = $request->contact;
$data['email'] = $request->email;
$data['valley'] =$request->valley;
$data['paddress'] = $request->paddress;
$data['taddress'] = $request->taddress;
$data['qualification'] = $request->qualification;
$data['ts'] = $request->ts;
$data['experiences'] = $request->experiences;
$data['tob'] = $request->tob;
$data['es'] = $request->es;
$data['level'] = $request->level;
$data['ey'] = $request->ey;
$data['cn'] = $request->cn;
$data['cv'] = $request->cv;
if(cv::find($id)->update($data))
{
return response([
'sessiondata' => $data
]);
}else{
return response([
'sessiondata'=> $request->name
]);
}
}
```
Actual error
POST http://127.0.0.1:8000/api/edit-data 500 (Internal Server Error)
There's already a lots of solution regarding this error.
I have followed them accordingly but i still get this error.
I have already include csrf_token both in header in jquery too.
Thanks for help.
| <jquery><ajax><laravel> | 2019-09-02 11:15:35 | LQ_EDIT |
57,756,722 | How to check if token already exists in database table | <p>I stuck with this,</p>
<p>show an error if the token is already exists in the database table,
and if there is no token in database table this will show success message for example</p>
<pre><code>$token = cleanfrm($_REQUEST['t']);
$user = $user_info['id'];
$ad_info = $db->fetchRow(("SELECT * FROM video WHERE token='" . $token . "'"));
$logs_info = $db->fetchRow(("SELECT token FROM video_ WHERE uid='" . $user . "'"));
if ($logs_info = " . $ad_token . ") {
$error_msg = "<div class='message'>you already watch this video </div>";
}else {
$error_msg = "<div class='message'>Click here to watch </div>";
}
</code></pre>
| <php><mysql> | 2019-09-02 12:09:48 | LQ_CLOSE |
57,757,941 | Java: How to convert a list to HashMap (key being the list) in one line | <p>I have an arraylist of Strings:</p>
<pre><code>ArrayList<String> list = Arrays.asList("A", "B", "C", "D");
</code></pre>
<p>I would like to initialize a map <code>HashMap<String, List<Integer>></code> with the element of my list being the key and an empty list of integers being the value.</p>
<p>Of course there is a way to do it using a loop, but I wonder whether there is a way to do it in one line. After seeing the questions and answers in <a href="https://stackoverflow.com/questions/8261075/adding-multiple-entries-to-a-hashmap-at-once-in-one-statement">a similar question</a>, I am aware that it is doable by:</p>
<pre><code>HashMap<String, List<Integer>> bigMap = ImmutableMap.<String, List<Integer>>builder()
.put("A", new ArrayList<Integer>)
.put("B", new ArrayList<Integer>)
.put("C", new ArrayList<Integer>)
.put("D", new ArrayList<Integer>)
.build();
</code></pre>
<p>But that only applies to the scenario that the size of the list is small. How can I do it using stream, like the way mentioned in <a href="https://stackoverflow.com/questions/4138364/java-how-to-convert-list-to-map">another question</a>?</p>
| <java><list><arraylist><java-8><hashmap> | 2019-09-02 13:38:07 | LQ_CLOSE |
57,757,972 | Understanding dictionary flashcard game errors | <p>I have defined a variable (show_definition) and have a dictionary (glossary).</p>
<p>My end goal is to provide the user with a random definition of an unknown word, the user to answer in their head then provide them with an answer after the input of a button.</p>
<pre><code>def show_definition():
""" Show the user a random defintion and ask them
to define it. Show the flashcard
when the user presses return.
"""
random_defin = choice(list(glossary.values()))
print('Define: ', random_defin)
input('Press return to see the definition')
print(glossary.values()[random.defin])
</code></pre>
<p>The first part works intially choosing a random value from the dictionary however I am completely misunderstanding how to then find the key which correlates to the value getting this error.</p>
<p>TypeError: 'dict_values' object is not subscriptable. </p>
<p>What am I not understanding here?</p>
| <python><dictionary> | 2019-09-02 13:39:56 | LQ_CLOSE |
57,758,017 | How does and&or work in print() function? | <p>Saw this while searching and I couldn't understand the logic behind. How does and & or methods work in print()?</p>
<pre class="lang-py prettyprint-override"><code>T=[int(s) for s in input().split()]
print(T and sorted(sorted(T,reverse=True),key=abs)[0] or 0)
</code></pre>
<p>I've tried simplifying it to understand how it handles different inputs.</p>
<pre class="lang-py prettyprint-override"><code>print(A and B or C)
</code></pre>
<p>Returns B when B is not 0, and returns C when B is 0 but never gets to A.</p>
| <python> | 2019-09-02 13:43:18 | LQ_CLOSE |
57,758,861 | Find first empty cell in column range | <p>I'm trying to create a loop to find the first empty cell in Column D of highlighted range (See picture) and return the row value (integer). However, I'm struggling to find a solution. </p>
<p>Does anyone have any ideas?</p>
<p><a href="https://i.stack.imgur.com/XYQJW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XYQJW.png" alt="enter image description here"></a></p>
| <google-apps-script><google-sheets> | 2019-09-02 14:41:51 | LQ_CLOSE |
57,759,082 | Jlabel multiline with html | I have a jlabel that I would like to contain a text that can go over multiple lines, and resizes if the window changes shape.
I've looked this up and most people seem to recommend wrapping the jlabel text in html. This however does not make new lines for me.
my jlabel is located in a Jpanel and I suspect that the problem may be that my Jpanel has misconfigured its border. and so the jlabel text just continues beyond the jpanel border.
here is how the jlabel looks inside the status panel
https://imgur.com/a/X19xPsu
here are the settings of my Jpanel:
```
private final JPanel statusPanel = new JPanel(new FlowLayout());
statusPanel.setBackground(Color.white);
statusPanel.add(latestOrdreLabel);
this.add(statusPanel, new GridBagConstraints(0, 0, 6, 1, 1.0, 1.0
, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
```
then my jlabel is set up like this:
```
private final JLabel latestOrdreLabelResult = new JLabel();
String latestOrdreStatus = getBean().getLatestOrdreStatus(etelOrderInterface.getOrderId());
latestOrdreLabelResult.setText("<html>"+latestOrdreStatus+"</html>");
statusPanel.add(latestOrdreLabelResult);
``` | <java><html><swing><jlabel> | 2019-09-02 14:57:40 | LQ_EDIT |
57,759,195 | Why is 'should equal' comming in between for the output ? And why is it repeating? | def alphabet_position(text):
a= range(1,27)
z=""
b=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
o=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in text:
if i in b:
k=b.index(i)
z=z+" "+ str(a[k])
elif i in o:
k=o.index(i)
z=z +" "+ str(a[k])
else:
pass
return(z)
Output:
' 20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11' should equal '20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11'
Input:
test.assert_equals(alphabet_position("The sunset sets at twelve o' clock."), "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11")
Why is 'should equal' comming in between for the output ? And why is it repeating ? | <python> | 2019-09-02 15:05:00 | LQ_EDIT |
57,760,765 | I'm Beginner in Java, I have a error message with .gradle and Soursets with main. How can I solve this problem? | I'm beginner in Java and Android-Studio.
From the first step, i got a big problem.
When I typed my first Java code in And-Stu and I ran the code, but I got this error message...
---------------------------------------------------------
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\Users\forma\AppData\Local\Temp\asdb_main__.gradle' line: 20
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:asdb.main()'.
> SourceSet with name 'main' not found.
---------------------------------------------------------
So, I looked for the .gradle file, but I don't know what the problem is.
How can I solve this problem?
i ran this code but i got the error message.
package com.example.myapplication;
public class asdb {
public static void main(String[] args) {
int a;
a=10;
System.out.println(a);
}
}
and this is .gralde code including line 20.
def gradlePath = ':app'
def runAppTaskName = 'asdb.main()'
def mainClass = 'com.example.myapplication.asdb'
def javaExePath = 'C:/Program Files/Android/Android Studio/jre/bin/java.exe'
def _workingDir = 'C:/Users/forma/Desktop/practice/java2'
def sourceSetName = 'main'
def javaModuleName = null
allprojects {
afterEvaluate { project ->
if(project.path == gradlePath && project?.convention?.findPlugin(JavaPluginConvention)) {
project.tasks.create(name: runAppTaskName, overwrite: true, type: JavaExec) {
if (javaExePath) executable = javaExePath
classpath = project.sourceSets[sourceSetName].runtimeClasspath
main = mainClass | <java><android-studio><android-gradle-plugin><build.gradle> | 2019-09-02 17:22:08 | LQ_EDIT |
57,761,621 | What is Getter and Setter in Android | <h1>What is getter and setter in android development.</h1>
<p>And what is the use of <strong>@Expose</strong> in GSON.</p>
<pre><code>@SerializedName("url")
@Expose
private String url;
</code></pre>
| <java><android><json><gson> | 2019-09-02 18:57:21 | LQ_CLOSE |
57,761,801 | How can I combine row values into a new row in pandas | <p><a href="https://i.stack.imgur.com/uRW4d.png" rel="nofollow noreferrer">I would like to merge multiple rows with different names into a new row.</a></p>
| <pandas> | 2019-09-02 19:22:53 | LQ_CLOSE |
57,761,894 | Scirpt didn't work on Firefox, 0 reaction on hover | I have a script that working perfectly on Chrome, but in Firefox there is no action after hovering linked object.
I tried to divide the script.js file for separate documents, but It won't help at all.
Here is the whole effect:
https://jsfiddle.net/lszewczyk45/9unawydo/9/
```javascript
$(document).ready(function () {
const effect = new Effects('hover-effects');
effect.addEffect(document.querySelector('#cityEffect'), 'city', [ONMOUSEOVER]);
});
```
I think the problem is in calling the script - the lines at the end of the file, I pasted it above. | <javascript><css><firefox> | 2019-09-02 19:33:25 | LQ_EDIT |
57,763,132 | SKStoreKitReviewController and Darkmode | <p>Is there any way to alter the colors/tint of an SKStoreKitReviewController? When I am modifying my apps to support DarkMode, when in dark mode, the presented viewController does not look good.</p>
<p><a href="https://i.stack.imgur.com/iishh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iishh.png" alt="enter image description here"></a></p>
| <ios><ios13><skstorereviewcontroller><ios-darkmode> | 2019-09-02 22:14:57 | HQ |
57,763,903 | Unexpected side effect with java streams reduce operation | <p>I'm observing a side effect on an underlying collection when calling 'reduce' on a Stream. This is so basic. I can't believe what I am seeing, but I can't find the error. Below is the code and the resulting output. Can anyone explain to me why one of the underlying collections of the Stream is mutating?</p>
<pre><code>package top;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) throws Exception {
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
ArrayList<Integer> list3 = new ArrayList<>();
list1.addAll(Arrays.asList(1, 2, 3));
list2.addAll(Arrays.asList(4, 5, 6));
list3.addAll(Arrays.asList(7, 8, 9));
System.out.println("Before");
System.out.println(list1);
System.out.println(list2);
System.out.println(list3);
ArrayList<Integer> r1 = Stream.of(list1, list2, list3).reduce((l, r) -> {
l.addAll(r);
return l;
}).orElse(new ArrayList<>());
System.out.println("After");
System.out.println(list1);
System.out.println(list2);
System.out.println(list3);
System.out.println("Result");
System.out.println(r1);
}
}
// Output
Before
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
After
[1, 2, 3, 4, 5, 6, 7, 8, 9] // Why is this not [1,2,3]?
[4, 5, 6]
[7, 8, 9]
Result
[1, 2, 3, 4, 5, 6, 7, 8, 9]
</code></pre>
| <java><java-8><java-stream><side-effects> | 2019-09-03 01:04:16 | LQ_CLOSE |
57,765,243 | Mulitplying bits | <p>My textbook says this:</p>
<p><a href="https://i.stack.imgur.com/spBV5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/spBV5.png" alt="enter image description here"></a></p>
<p>I don’t get this quote in the multiplication section:</p>
<blockquote>
<p>The first observation is that the number of digits in the product is considerably larger than the number in either the multiplicand or the multiplier. In fact, if we ignore the sign bits, the length of the multiplication of an n-bit multiplicand and an m-bit multiplier is a product that is n + m bits long. That is, n + m bits are required to represent all possible products.</p>
</blockquote>
<p>I see 7 digits in the product but this quote implies there should be 8</p>
| <computer-science><bit> | 2019-09-03 04:55:40 | LQ_CLOSE |
57,765,958 | How to detect iPad and iPad OS version in iOS 13 and Up? | <p>I can detect iOS 13 on iPhone but in iPad OS 13 <code>navigator.platform</code> comes as MacIntel. So it is not possible to get iPad identified using below code, but it works perfectly on iPhone.</p>
<pre><code> if (/iP(hone|od|ad)/.test(navigator.platform)) {
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
var version = [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
return version;
}
</code></pre>
<p>When we request for mobile website using the browser on iPad <code>navigator.platform</code> returns as iPad and works perfectly.</p>
<p>Can anyone suggest a way to identify <strong>iPad running on iOS 13 and up</strong> using Javascript?</p>
| <javascript><ios><ipad><ios13><ipados13> | 2019-09-03 06:16:09 | HQ |
57,766,061 | How to make this type degine any one Know That in adnroid | Design Like circle Show in Activity How to make this type of design or what to call it Please Suggest Me[enter image description here][1]
[enter image description here][1]
[1]: https://i.stack.imgur.com/VadV3.jpg | <android> | 2019-09-03 06:25:58 | LQ_EDIT |
57,767,106 | Filter through an array of objects | <p>Having an array of objects with this structure<a href="https://i.stack.imgur.com/hJRWZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJRWZ.png" alt="enter image description here"></a>
My question is how should a filter it to return, for example, only the objects with meterName = "Bay-3". That hexadecimal header at each object tangles me.</p>
| <javascript> | 2019-09-03 07:42:17 | LQ_CLOSE |
57,768,147 | how to check if there is any string from index 0 to 5 in an array of type Any | <p>I have an array of type any in which i am appending string data. now how do i check that the array i.e final list contains alphabets from index position 0 to 5</p>
| <arrays><swift> | 2019-09-03 08:49:18 | LQ_CLOSE |
57,768,190 | Distinct Column gives me incorrect results | I have DISTINCT and wanted to use MIN and MAX functions in queries.
Just using DISTINCT it gives me proper results count: 1348
But if I just add MIN() and MAX() Function in query the query just returns one record having MAX column.
I want all those records proper but need to find MAX amount from price column as well.
Here is my query:
SELECT DISTINCT a.*, (a.price * 1) as calculatedPrice, py.package_id as py_package_id
FROM qd_posts as a
INNER JOIN qd_categories as c ON c.id=a.category_id AND c.active=1
LEFT JOIN qd_categories as cp ON cp.id=c.parent_id AND cp.active=1
LEFT JOIN (SELECT MAX(id) max_id, post_id FROM qd_payments WHERE active=1 GROUP BY post_id) mpy ON mpy.post_id = a.id AND a.featured=1
LEFT JOIN qd_payments as py ON py.id=mpy.max_id
LEFT JOIN qd_packages as p ON p.id=py.package_id
WHERE a.country_code = 'CA' AND (a.verified_email = 1 AND a.verified_phone = 1) AND a.archived != 1 AND a.deleted_at IS NULL
ORDER BY p.lft DESC, a.created_at DESC
After adding MAX to query
SELECT DISTINCT a.*, (a.price * 1) as calculatedPrice, py.package_id as py_package_id, MAX(a.price) as maxprice
FROM qd_posts as a
INNER JOIN qd_categories as c ON c.id=a.category_id AND c.active=1
LEFT JOIN qd_categories as cp ON cp.id=c.parent_id AND cp.active=1
LEFT JOIN (SELECT MAX(id) max_id, post_id FROM qd_payments WHERE active=1 GROUP BY post_id) mpy ON mpy.post_id = a.id AND a.featured=1
LEFT JOIN qd_payments as py ON py.id=mpy.max_id
LEFT JOIN qd_packages as p ON p.id=py.package_id
WHERE a.country_code = 'CA' AND (a.verified_email = 1 AND a.verified_phone = 1) AND a.archived != 1 AND a.deleted_at IS NULL
ORDER BY p.lft DESC, a.created_at DESC
Not sure what to do next. | <mysql> | 2019-09-03 08:51:24 | LQ_EDIT |
57,768,921 | TypeError: TypeError: undefined is not an object (evaluating 'theme.label') Error | <p>I am having this issue with expo and npm. Anyone has any idea how to resolve this?<a href="https://i.stack.imgur.com/zHbd2.jpg" rel="nofollow noreferrer">Error is here!</a></p>
| <react-native><expo> | 2019-09-03 09:35:37 | LQ_CLOSE |
57,770,836 | HOW TO ROTATE AN OBJECT IN ONE AXIS BY ROTATING ANOTHER OBJECT | I HAVE A STARING WHEEL THAT I WANT TO ROTATE IN Y AXIS. BY ROTATING THIS WHEEL I WANT TO ROTATE A MIRROR AND THIS MIRROR TO FOLLOW THE ROTATION OF STAIRING WHEEL BUT IN Z AXIS AND NOT IN Y. CAN SOMEONE PLS HELP ME?
I TRIED THIS ONE BUT IT IS ROTATING THE 2 OBJECT IN SAME AXIS
void Update()
{
mirror.transform.localRotation = stairing.transform.localRotation;
} | <c#><unity3d> | 2019-09-03 11:32:20 | LQ_EDIT |
57,771,252 | How to fix Worker Pool Deadlock | <p>I wrote a pool of workers, where the job is to receive an integer and return that number converted to string. However I faced a <code>fatal error: all goroutines are asleep - deadlock!</code> error. What am I doing wrong and how can I fix it?</p>
<p><a href="https://play.golang.org/p/U814C2rV5na" rel="nofollow noreferrer">https://play.golang.org/p/U814C2rV5na</a></p>
| <go> | 2019-09-03 11:54:16 | LQ_CLOSE |
57,772,137 | TabView resets navigation stack when switching tabs | <p>I have a simple TabView: </p>
<pre class="lang-swift prettyprint-override"><code>TabView {
NavigationView {
VStack {
NavigationLink(destination: Text("Detail")) {
Text("Go to detail")
}
}
}
.tabItem { Text("First") }
.tag(0)
Text("Second View")
.tabItem { Text("Second") }
.tag(1)
}
</code></pre>
<p>When I go to the detail view on tab 1, switch to tab 2 then switch back to tab 1 I would assume to go back to the detail view (a basic UX found everywhere in iOS). Instead it resets to the root view of tab 1.</p>
<p>Since SwiftUI doesn't look to support this out of the box, how do I work around this?</p>
| <swiftui> | 2019-09-03 12:50:26 | HQ |
57,772,238 | how can we slove dynamic pattern program for odd no of values | what is the solution of the pattern program given below.
like if we have, n=3 then pattern should be
*
* *
*
for n=5
*
* *
* * *
* *
*
and so on for n= odd values
| <python-3.x><design-patterns><pattern-matching><coding-style> | 2019-09-03 12:56:32 | LQ_EDIT |
57,773,613 | Sort a array to form three array | I want to sort an array in a way that it give back three arrays. So`
``` var myArray = ['1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3','1','2','3'];
```
here the values can be numbers, string, objects etc.
I want three arrays Like :
```
var myArray1 = ['1','1','1','1','1','1','1','1','1','1'];
var myArray2 = ['2','2','2','2','2','2','2','2','2','2'];
var myArray3 = ['3','3','3','3','3','3','3','3','3','3'];
```
I want to know the Logic. | <javascript><arrays> | 2019-09-03 14:18:52 | LQ_EDIT |
57,773,826 | Is there a way to get the next letter in the alphabet | <p>I am trying to create a method which takes in a character from the alphabet (for example 'd') and return the next character from the alphabet (aka. e). How can I do that?</p>
| <c#><arrays><string> | 2019-09-03 14:31:41 | LQ_CLOSE |
57,773,915 | Loop over Foreach Values | <p>I have a Nested array, within my JSON <code>$repsonse</code> The <code>ImageURI</code> vary from <code>[0]-[16]</code> sometimes there is 5 sometimes there is 16.</p>
<p>I would like to loop over <code>$car['Images'][0]['ImageURI'];</code> for example:
This is car has 4 cars and for the rest responds with a <code>Notice: Undefined offset:</code> So that when there is not 16 cars it accepts that's how many there are. </p>
<pre><code>https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&VUID=39bcc4df-b550-e911-a2cf-00155d187d03&Rank=1&Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&VUID=39bcc4df-b550-e911-a2cf-00155d187d03&Rank=2&Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&VUID=39bcc4df-b550-e911-a2cf-00155d187d03&Rank=3&Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&VUID=39bcc4df-b550-e911-a2cf-00155d187d03&Rank=4&Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&VUID=39bcc4df-b550-e911-a2cf-00155d187d03&Rank=5&Width=960
Notice: Undefined offset: 5 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 101 Notice: Undefined offset: 6 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 102 Notice: Undefined offset: 7 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 103 Notice: Undefined offset: 8 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 104 Notice: Undefined offset: 9 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 105 Notice: Undefined offset: 10 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 106 Notice: Undefined offset: 11 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 107 Notice: Undefined offset: 12 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 108 Notice: Undefined offset: 13 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 109 Notice: Undefined offset: 14 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 110 Notice: Undefined offset: 15 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 111 Notice: Undefined offset: 16 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 112 `
</code></pre>
<p>Heres my Code:</p>
<pre><code>if(array_key_exists(0,$car['Images'])) {
if( isset($car['Images']) ) {
//it exists
echo $car['Images'][0]['ImageURI'];
echo $car['Images'][1]['ImageURI'];
echo $car['Images'][2]['ImageURI'];
echo $car['Images'][3]['ImageURI'];
echo $car['Images'][4]['ImageURI'];
echo $car['Images'][5]['ImageURI'];
echo $car['Images'][6]['ImageURI'];
echo $car['Images'][7]['ImageURI'];
echo $car['Images'][8]['ImageURI'];
echo $car['Images'][9]['ImageURI'];
echo $car['Images'][10]['ImageURI'];
echo $car['Images'][11]['ImageURI'];
echo $car['Images'][12]['ImageURI'];
echo $car['Images'][13]['ImageURI'];
echo $car['Images'][14]['ImageURI'];
echo $car['Images'][15]['ImageURI'];
echo $car['Images'][16]['ImageURI'];
echo "<br>";echo "<br>";echo "<br>";
}
}else{
continue;
}
</code></pre>
| <php><arrays><foreach> | 2019-09-03 14:36:59 | LQ_CLOSE |
57,775,511 | Visualize DynamoDB data in AWS Quicksight | <p>I am looking for an AWS-centric solution (avoiding 3rd party stuff if possible) for visualizing data that is in a very simple DynamoDB table.</p>
<p>We use AWS Quicksight for many other reports and dashboards for our clients so that is goal to have visualizations made available there. </p>
<p>I was very surprised to see that DynamoDB was not a supported source for Quicksight although many other things are like S3, Athena, Redshift, RDS, etc.</p>
<p>Does anyone have any experience for creating a solution for this?</p>
<p>I am thinking that I will just create a job that will dump the DynamoDB table to S3 every so often and then use the S3 or Athena integrations with Quicksight to read/display it. It would be nice to have a simple solution for more live data.</p>
| <amazon-web-services><amazon-dynamodb><amazon-quicksight> | 2019-09-03 16:24:00 | HQ |
57,775,766 | Im not getting the else output | Im new on python, and while i was testing a few things i tried this idea, but i can't get it works
`
parx = input("Write your parX: ")
pary = input("Write your parY: ")
while pary != 0 and parx != 0:
cociente = int(parx) / int(pary)
print ("Su cociente es: ",cociente)
parx = input("Write your parX: ")
pary = input("Write your parY: ")
else:
print("your ordered pair is not divisible")
`
i expect the output of the else , but it only shows an error when i write 0,0 on my variables, i want that when i enter 0 0 the program says " your ordered pair is not divisible"
the error says: " File "Ejercicio2PDF3.py", line 6, in <module>
ZeroDivisionError: division by zero" | <python><python-3.x><while-loop> | 2019-09-03 16:42:32 | LQ_EDIT |
57,775,826 | Wordpress redirected automatically to other site | <p>My wordpress website was redirecting to other site. It was hacked. I just delete the folder cache in wp-content folder. And it resolved.</p>
<p>Can u tell me where was exact problem?</p>
| <wordpress> | 2019-09-03 16:46:52 | LQ_CLOSE |
57,775,963 | Recommendations on improving my built-in linked list garbage collection | <p>I'm currently learning about linked lists, and I'm building one myself in C++ in order to fully grasp the concept. Every method seems to work. However, I'm not confident in my implemented garbage collection of my Node class and LinkedList class. Can anyone look at it and give any suggestions for improval? Thank you!</p>
<pre><code>#include <iostream>
#include <vector>
#include <map>
template<class T>
struct Node
{
T value;
Node* next;
Node() {
next = nullptr; // Set the default of next to nullptr
}
~Node() {
if (next) {
delete next;
next = nullptr;
}
}
};
template<class T>
class LinkedList
{
private:
Node<T>* head;
Node<T>* tail;
unsigned int length;
Node<T>* traverseToIndex(const unsigned short& index);
public:
LinkedList();
~LinkedList();
void append(const T& value);
void prepend(const T& value);
void insert(const unsigned short& index, const T& value);
void remove(const unsigned short& index);
};
int main()
{
LinkedList<int> nums;
nums.append(5);
nums.append(1);
nums.append(3);
nums.append(4);
nums.remove(2);
return 0;
}
template<class T>
LinkedList<T>::LinkedList()
{
this->length = 0;
head = new Node<T>;
tail = head;
}
template<class T>
LinkedList<T>::~LinkedList()
{
delete head;
}
template<class T>
Node<T>* LinkedList<T>::traverseToIndex(const unsigned short& index)
{
if (index >= this->length) return tail;
Node<T>* currentNode = head;
for (unsigned short i = 0; i < index; i++) {
currentNode = currentNode->next;
}
return currentNode;
}
template<class T>
void LinkedList<T>::append(const T& value)
{
if (length == 0) {
head->value = value;
} else {
Node<T>* newNode = new Node<T>;
newNode->value = value;
tail->next = newNode;
tail = newNode;
}
length++;
}
template<class T>
void LinkedList<T>::prepend(const T& value)
{
Node<T>* newNode = new Node<T>;
newNode->value = value;
newNode->next = head;
head = newNode;
}
template<class T>
void LinkedList<T>::insert(const unsigned short& index, const T& value)
{
if (index >= this->length || index <= 0) return;
Node<T>* before = this->traverseToIndex(index - 1);
Node<T>* after = before->next;
Node<T>* newNode = new Node<T>;
newNode->value = value;
newNode->next = after;
before->next = newNode;
this->length++;
}
template<class T>
void LinkedList<T>::remove(const unsigned short& index)
{
Node<T>* before = this->traverseToIndex(index - 1);
Node<T>* deletedNode = before->next;
Node<T>* after = deletedNode->next;
before->next = after;
this->length--;
}
</code></pre>
| <c++><linked-list> | 2019-09-03 16:58:10 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.