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 |
|---|---|---|---|---|---|
56,012,817 | Git rebase, fix conflicts, then push is rejected | <p>When I <strong>rebase</strong>, and there are <strong>conflicts which I then resolve</strong>, I get the following message:</p>
<blockquote>
<p>hint: Updates were rejected because the tip of your current branch is behind</p>
</blockquote>
<hr>
<p>We have 2 branches:</p>
<ul>
<li><code>master</code> is our base</li>
<li><code>feature/fix-input-height</code> (new feature to merge into master)</li>
</ul>
<p>I am preparing <code>feature/fix-input-height</code> by rebasing master to locally resolve conflicts</p>
<pre><code>git checkout master
git pull origin master
git checkout feature/fix-input-height
git pull origin feature/fix-input-height
git rebase master
</code></pre>
<hr>
<ul>
<li>Conflicts arise</li>
<li>I resolve them</li>
<li>Then attempt to push the new feature branch</li>
</ul>
<pre><code>git push origin feature/fix-input-height
</code></pre>
<p>And end up with that <strong>rejected error message</strong> again:</p>
<blockquote>
<p>hint: Updates were rejected because the tip of your current branch is behind</p>
</blockquote>
<hr>
<p>Everyone on stackoverflow suggests:</p>
<pre><code>git push origin -f feature/fix-input-height
</code></pre>
<p><strong>But forcing the push just feels wrong</strong></p>
| <git><rebase><git-merge-conflict> | 2019-05-06 21:45:58 | HQ |
56,014,191 | Using jQuery DataTables with Rollup.js | <p>Ok I'm using the tool rollup for the first time and I love how small it is making the code. Tree shaking is great. However, I'm having some trouble getting it to include everything correctly. I tried having a single entry point, exp.js, where I export things from various files like this:</p>
<pre><code>export {
dashboardCharts
} from './dashboard.js';
</code></pre>
<p>my rollup.config.js looks like </p>
<pre><code>export default {
// tell rollup our main entry point
input: [
'assets/js/exp.js',
],
output: {
name: 'helloworld',
file: 'build/js/main.js',
format: 'iife'
// format: 'umd'
},
plugins: [
resolve({
// pass custom options to the resolve plugin
customResolveOptions: {
moduleDirectory: 'node_modules'
}
}),
multiEntry()
// terser(),
],
};
</code></pre>
<p>The file dashboard.js includes the datatables library, so datatables gets included in the bundle main.js. However, datatables tests whether it should take the commonjs path or not by testing </p>
<pre><code>else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
</code></pre>
<p>and I'm trying to execute this in the browser, so I don't want the commonjs path. Rollup's top level scope is declared like</p>
<pre><code>var helloworld = (function (exports) {
</code></pre>
<p>so exports ends up being an empty object, the browser tries to execute the commonjs path and we get a "module is not defined" error. </p>
<p>I feel like I'm really close, but I'm missing a simple solution here. I also tried doing a umd format instead of iife, but it didn't help. Is there a different version of datatables I should be using?</p>
| <javascript><jquery><datatables><rollupjs> | 2019-05-07 01:03:39 | HQ |
56,014,634 | Create Git Repo with New Project in Visual Studio 2019 | <p>In Visual Studio 2017, there used to be an option when creating a New Project to "Make a new Git Repository with Solution", or something similar.</p>
<p>I can't seem to find the option in Visual Studio 2019. Has it been removed? I was thinking maybe it requires an extension?</p>
| <visual-studio-2019> | 2019-05-07 02:14:49 | HQ |
56,015,271 | VBScript regex not working to grab status code | <p>I am getting a no match with the below VBScript. Is something off in my code?</p>
<p><strong>Test</strong></p>
<pre><code>Error Type: SMTP[nl] Remote server (166.216.149.129) issued an error.[nl] hMailServer sent: RCPT TO:<8583390609@txt.att.net>[nl] Remote server replied: 550 5.1.1 <8583390609@txt.att.net> recipient does not exist here.[nl]
</code></pre>
<p><strong>Pattern</strong></p>
<pre><code>^.*Remote server replied: ([0-9]{3}).*$
</code></pre>
<p><strong>Logging</strong></p>
<pre><code>3544 "2019-05-06 23:09:51.609" "Running"
3544 "2019-05-06 23:09:51.609" "Error Type: SMTP[nl] Remote server (166.216.149.129) issued an error.[nl] hMailServer sent: RCPT TO:<8583390609@txt.att.net>[nl] Remote server replied: 550 5.1.1 <8583390609@txt.att.net> recipient does not exist here.[nl]"
3544 "2019-05-06 23:09:51.609" "No Match"
</code></pre>
<p><strong>VBScript</strong></p>
<pre><code>Dim regex, matches, match, strResult
EventLog.Write("Running")
EventLog.Write(sErrorMessage)
Set regex = New RegExp
regex.IgnoreCase = True
regex.Pattern = "^.*Remote server replied: ([0-9]{3}).*$"
Set matches = regex.Execute(sErrorMessage)
If matches.Count >= 1 Then
Set match = matches(0)
If match.SubMatches.Count >= 1 Then
strResult = match.SubMatches(0)
EventLog.Write(strResult)
Else
EventLog.Write("NO SUBMATCHES")
strResult = ""
exit sub
End If
Else
EventLog.Write("No Match")
strResult = ""
exit sub
End If
</code></pre>
| <regex><vbscript> | 2019-05-07 03:48:00 | LQ_CLOSE |
56,016,696 | Argument of type 'HTMLElement' is not assignable to parameter of type 'CanvasImageSource' | <p>I am trying to get the same image to load into all of the canvas in my HTML. I had previously written my whole webpage in javascript but now I am learning angular and typescript.</p>
<p>I am getting this error highlighted in Visual Studio Code:</p>
<blockquote>
<p>Argument of type 'HTMLElement' is not assignable to parameter of type 'CanvasImageSource'.
Type 'HTMLElement' is missing the following properties from type 'HTMLVideoElement': height, msHorizontalMirror, msIsLayoutOptimalForPlayback, msIsStereo3D, and 80 more.ts(2345)</p>
</blockquote>
<p>But I get no error shown in the console. I can get the image to load on the HTML within the canvas (so it is working).</p>
<p>This is my ts:</p>
<pre><code>import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent implements OnInit {
constructor() { }
ngOnInit() {
document.querySelectorAll("canvas").forEach(c=>{
var ctx = c.getContext("2d");
var img = document.getElementById("P43");
ctx.drawImage(img,0,0,106,50); //(image, offsetx, offsety, x, y)
});
}
}
</code></pre>
<p>VS Code highlights the error on this line <code>ctx.drawImage(img,0,0,106,50); //(image, offsetx, offsety, x, y)</code>, it highlights <strong>img</strong> and displays the error.</p>
<p>I have tried to search this but the only solutions I have found are for when you had the ID for tag ( I don't as it is all canvas' on the page.) or if there is an input.</p>
<p>Any help is appreciated.</p>
| <angular><typescript><visual-studio-code> | 2019-05-07 06:27:21 | HQ |
56,017,155 | Add ssl certificate to selenium-webdriver | <p>I use selenium for end-to-end test with chromeDriver. The websites to test require an ssl certificate. When I manually open the browser, there is a popup that lets me select an installed certificate. Different tests access different URLs and also need different certificates. However, if I run the tests in headless mode, there is no popup. So I need a way to programatically set a certificate (eg. set a <code>.pem</code> file) to be used for the current test.</p>
<p>How can I achieve this?
I tried setting up a <a href="https://github.com/lightbody/browsermob-proxy" rel="noreferrer">browserMob</a> proxy which I then configured as a proxy in selenium - however, this does not seem to do anything... Are there better approaches? What am I doing wrong? Here's what I tried:</p>
<pre class="lang-java prettyprint-override"><code>PemFileCertificateSource pemFileCertificateSource = new PemFileCertificateSource(
new File("myCertificate.pem"),
new File("myPrivateKey.pem"),
"myPrivateKeyPassword");
ImpersonatingMitmManager mitmManager = ImpersonatingMitmManager.builder()
.rootCertificateSource(pemFileCertificateSource)
.build();
BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
browserMobProxy.setTrustAllServers(true);
browserMobProxy.setMitmManager(mitmManager);
browserMobProxy.start(8080);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setProxy(ClientUtil.createSeleniumProxy(browserMobProxy));
WebDriver webDriver = new ChromeDriver(chromeOptions);
// use the webdriver for tests, e.g. assertEquals("foo", webDriver.findElement(...))
</code></pre>
| <java><selenium><selenium-webdriver><ssl-certificate><browsermob-proxy> | 2019-05-07 06:58:50 | HQ |
56,018,167 | Typescript does not copy d.ts files to build | <p>So maybe I'm confused, but I thought that if I added <code>declaration:true</code> to my tsconfig.json I could have it tsc copy my <code>*.d.ts</code> files, along side the transpiled code & it's <code>d.ts</code> files?</p>
<p>EG:</p>
<pre><code>- src
- lib
- types.d.ts
- foo.ts
</code></pre>
<p>I would expect the result of tsc to be something like:</p>
<pre><code>- build
- lib
- types.d.ts
- foo.js
- foo.d.ts
</code></pre>
<p>However, I can't seem to get <code>types.d.ts</code> to be copied to my build directory. </p>
<p>Does typescript not provide any mechanism to copy <code>.d.ts</code> files? Or do I just have a misconfiguration somewhere? (I've tried a lot of different configurations at this point; nothing seems to work)</p>
| <typescript><typescript-typings><.d.ts> | 2019-05-07 08:08:37 | HQ |
56,018,174 | Hooks and Redux Saga | <p>I am learning redux hooks and wondering how to use it along with redux saga.</p>
<p>Currently the code written in saga is as follows.</p>
<blockquote>
<p>centers.js</p>
</blockquote>
<pre><code>componentDidMount() {
this.props.getCenters();
}
...
<tbody>
{
this.props.centers ?
<React.Fragment>
{
centers.map((center, index) =>
<tr key={index}>
<td>{center.name}</td>
<td>{center.zip}</td>
</tr>
)
}
</React.Fragment>
:
<tr>
<td> No data available</td>
</tr>
}
</tbody>
</code></pre>
<p>The actions file is defined as follows.</p>
<pre><code>export const getCenters = () => ({
type: types.CENTERS_REQUEST,
});
</code></pre>
<p>The saga file is defined as follows.</p>
<pre><code>import { DEFAULT_ERROR_MSG } from '../../constants';
import { instance as centerProvider } from '../services/centerProvider';
function* fetchCenters() {
try {
const response = yield call(centerProvider.getCenters);
const centers = response.data.data.centers;
// dispatch a success action to the store
yield put({ type: types.CENTERS_SUCCESS, centers});
} catch (error) {
// dispatch a failure action to the store with the error
yield put(DEFAULT_ERROR_MSG);
}
}
export function* watchCenterRequest() {
yield takeLatest(types.CENTERS_REQUEST, fetchCenters);
}
export default function* centerSaga() {
yield all([
watchCenterRequest()
]);
}
</code></pre>
<p>So the question is,</p>
<ul>
<li>Do we still need redux if we use hooks?</li>
<li>How can we rewrite the above code using hooks?</li>
</ul>
| <reactjs><redux><react-hooks> | 2019-05-07 08:08:59 | HQ |
56,019,534 | How the two list traversal output | <pre><code> List<String> list1=new ArrayList<String>();
list1.add("1");
list1.add("2");
list1.add("3");
list1.add("4");
List<String> list2=new ArrayList<String>();
list2.add("5");
list2.add("6");
list2.add("7");
list2.add("8");
</code></pre>
<p>//How the two list traversal output 1 5 2 6 3 7 4 8 </p>
| <java> | 2019-05-07 09:28:33 | LQ_CLOSE |
56,020,567 | Sow to fix size of function is unknown or zero and function call missing in main | I'm trying to complete this problem but I cant figure out how to get rid of the errors. Other code that I've looked at that uses arrays and functions looks the same and works but my code wont work for some reason. These are the errors that I'm getting:
Error E2121 Q1.cpp 27: Function call missing ) in function main()
Error E2449 Q1.cpp 32: Size of 'fifty' is unknown or zero
Error E2356 Q1.cpp 32: Type mismatch in redeclaration of 'fifty(int)'
Error E2344 Q1.cpp 10: Earlier declaration of 'fifty(int)'
Error E2063 Q1.cpp 32: Illegal initialization
Error E2293 Q1.cpp 32: ) expected
Error E2141 Q1.cpp 71: Declaration syntax error
#include <math.h>
#include <stdio.h>
#include <iostream>
void fifty(int money);
void twenty(int money);
void ten(int money);
void five(int money);
int main()
{
int money[5]; /*this contians all info about change and the money that you want change for*/
printf("Enter cash amount: ");
scanf("%d", &money[1]);
fifty(money[5]); /*Passing the array to each module*/
twenty(money[5]);
ten(money[5]);
five(money[5]);
/*The next two lines should print out how many of each denomination is needed*/
printf("Change to be given: \n");
printf("50 = %d, 20 = %d, 10 = %d, 5 = %d" money[1], money[2], money[3], money[4]);
return(0);
}
void fifty(int money, int 5)
{
/*This is getting the whole array from main() and modifying the values of each index*/
if (money[0] > 50) {
money[0] = money[0] - 50;
money[1]++;
}
return;
}
void twenty(int money, int 5)
{
if (money[0] > 20) {
money[0] = money[0] - 20;
money[2]++;
}
return;
}
void ten(int money, int 5)
{
if (money[0] > 10) {
money[0] = money[0] - 10;
money[3]++;
}
return;
}
void five(int money, int 5)
{
if (money[0] > 5) {
money[0] = money[0] - 5;
money[4]++;
}
return;
} | <c++> | 2019-05-07 10:28:01 | LQ_EDIT |
56,021,962 | Error:(5,19) java: package org.mockito does not exist | <p>I wanted to learn a bit about Mockito, but when I run my test class I get the following errors, even though I import the package:</p>
<p><a href="https://i.stack.imgur.com/eGEO2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eGEO2.png" alt="enter image description here"></a></p>
<p>What do I have to do, to make the code work?</p>
<p><a href="https://i.stack.imgur.com/FZO6Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FZO6Q.png" alt="enter image description here"></a></p>
| <java><testing><intellij-idea><junit><mockito> | 2019-05-07 11:50:07 | LQ_CLOSE |
56,022,415 | What is the easiest way to grab product description in WooCommerce programmatically? | I saw this, https://stackoverflow.com/questions/19763915/woocommerce-get-the-product-description-by-product-id
But I was hoping there's a shorter way to grab the product description? Any idea? I'm using WooCommerce 3.0 and above. | <php><wordpress><woocommerce><product> | 2019-05-07 12:13:53 | LQ_EDIT |
56,023,258 | MS access to sql migration issue | I have a sql query below
select LTRIM(RTRIM(Sub string([Short Description],9,Len([Short Description])-8))) AS PolicyNumber from x table
its giving error as this
Msg 537, Level 16, State 3, Line 10
Invalid length parameter passed to the LEFT or SUBSTRING function. | <sql-server><ms-access><database-migration> | 2019-05-07 13:02:10 | LQ_EDIT |
56,023,612 | How to assign value inside a Runnable Thread | <p>I have the next code:</p>
<pre><code> for(int i = 0; i < fileRefernces.size(); i++) {
Thread t = new Thread(new Runnable() {
public void run() {
JLabel pageNumber = new JLabel("<html><font color='#003b86'>PAGE" + (i + 1) + "</font></html>", JLabel.LEFT);
JLabel imageLabel = new JLabel(image, JLabel.LEFT);
// content would be probably some Image class or byte[]
// or:
// InputStream in = Loc.openStream();
// read image from in
}
});
}
</code></pre>
<p>But, just at the moment to assign the value, I get the next error:</p>
<blockquote>
<p>error: local variables referenced from an inner class must be final or
effectively final</p>
</blockquote>
<p>How I can assign values to those variables?</p>
| <java><multithreading> | 2019-05-07 13:20:34 | LQ_CLOSE |
56,024,761 | 3 x 3 cell with large center layout with flexbox simple implementation ideas needed | <p>With CSS Grid, it's pretty easy to implement something like this <a href="https://codepen.io/anon/pen/VOLPRV" rel="nofollow noreferrer">3 x 3 cell with large center with css grid</a></p>
<pre><code>.container {
display: grid;
grid-template-columns: 60px 1fr 60px;
grid-template-rows: 60px 1fr 60px;
}
</code></pre>
<p>Is there a simple way to implement this using flexbox?</p>
<p><a href="https://codepen.io/anon/pen/WBvRWr" rel="nofollow noreferrer">simple flexbox implementation?</a></p>
| <css><flexbox> | 2019-05-07 14:22:41 | LQ_CLOSE |
56,025,164 | firebase_messaging onResume and onLaunch not working | <p>I am getting the notification when the app is in the foreground but not when the app in the background. Also, I have google-ed/StackOverflow-ed for like 2 hours or more but able to resolves this.</p>
<p>My Configurations are :</p>
<pre><code> firebase_auth: ^0.10.0
firebase_messaging: ^5.0.0
</code></pre>
<p>The manifest is like this:</p>
<p><a href="https://i.stack.imgur.com/Y8IOB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Y8IOB.png" alt="Manifest"></a></p>
<p>The code is like this:</p>
<pre><code>final notifications = new FirebaseMessaging();
class AppNotifications {
static String fcmToken = '';
static Future<Null> init() async {
appLogs("AppNotifications init");
notifications.requestNotificationPermissions(const IosNotificationSettings(sound: true, badge: true, alert: true));
await configure();
fcmToken = await notifications.getToken();
appLogs("FCM TOKEN : " + fcmToken);
notifications.onTokenRefresh.listen((newToken) {
fcmToken = newToken;
appLogs("FCM TOKEN onTokenRefresh: " + fcmToken);
});
await updateFCMToken();
}
static Future<Null> configure() async {
appLogs("AppNotifications Configure");
notifications.configure(onMessage: (msg) {
appLogs('FCM onMessage: ' + msg.toString());
}, onLaunch: (lun) {
appLogs('FCM onLaunch: ' + lun.toString());
}, onResume: (res) {
appLogs('FCM onResume: ' + res.toString());
});
}
static Future<Null> updateFCMToken() async {
auth.currentUser.fcmToken = fcmToken;
await updateUserInSharedPreference();
}
}
</code></pre>
<p>I am calling the function like this:</p>
<pre><code>class HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();
Future.delayed(Duration(milliseconds: 100), () async {
await AppNotifications.init();
});
}
..... ....
</code></pre>
<p>I am using postman for sending the notification :</p>
<p><a href="https://i.stack.imgur.com/dYmEM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dYmEM.png" alt="Postman"></a> </p>
<p>My logs : </p>
<pre><code>**(App is Foreground)** I/flutter (31888): APPLOGS : FCM onMessage: {notification: {title: Test notification title, body: Test notification body}, data: {status: done, id: 1, foo: bar, click_action: FLUTTER_NOTIFICATION_CLICK}}
**(App is Background)** W/FirebaseMessaging(31888): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.
</code></pre>
<p>Flutter doctor :</p>
<pre><code>[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.4 18E226, locale en-GB)
• Flutter version 1.2.1 at /Users/Ajay/SDK/flutter
• Framework revision 8661d8aecd (3 months ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/Ajay/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• ios-deploy 1.9.4
• CocoaPods version 1.6.0
[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 34.0.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[!] VS Code (version 1.33.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)
• ONEPLUS A5000 • b47e8396 • android-arm64 • Android 9 (API 28)
</code></pre>
| <flutter><push-notification> | 2019-05-07 14:43:50 | HQ |
56,025,432 | jQuery Validation Input value not begining with multiple paterns | <p>I started using jQuery validation on this new project I'm working on, and I've been struggling to find a rule to validate if a text input doesn't start "057" or "089" or "093.</p>
<p>I know there is a notEqual rule that matches the whole input value,
is there any way I can achieve the same but only for the first 3 characters?</p>
| <javascript><jquery><regex><jquery-validate> | 2019-05-07 14:59:05 | LQ_CLOSE |
56,025,648 | how to get a number from an array? | question:
Suppose this is the number in my array 1,2,3,4,5,6,7,8
and each number is a position like ::
1=1 ,2=2 , 3=3, 4=4, 5=5, 6=6, 7=7, 8=8
It is not an array position just the number position
Now i want to remove the number in odd position then it becomes 2,4,6,8 ::
2=1, 4=2, 6=3, 8=4,
Now again i want to remove from the odd position so it becomes 4,8
4=1, 8=2
Now the answer is 8
so how to get this 8
Code:
int [] arr = new int [] {1, 2, 3, 4, 5, 6, 7, 8}; //I am taking certain
number in array
System.out.println("Elements of given array present on even position:");
for (int i = 1; i < arr.length; i = i+2)
{
System.out.println(arr[i]);
}
must get the value as 8 but in
output:
2
2
2
2
4
4
4
4
and so on
| <java><arrays> | 2019-05-07 15:11:46 | LQ_EDIT |
56,027,150 | How can I delete images from firebase storage? | I want to delete images from firebase storage.[This is my Firebase Database.][1]
[1]: https://i.stack.imgur.com/EDI00.png | <android><firebase><firebase-realtime-database> | 2019-05-07 16:46:26 | LQ_EDIT |
56,027,292 | Is reverse proxy actually needed on ASP.NET core? | <p>We're wondering if reverse proxy is actually required for most use cases and would appreciate additional information.</p>
<p>The Kerstel/Nginx documentation claims:
"Kestrel is great for serving dynamic content from ASP.NET Core. However, the web serving capabilities aren't as feature rich as servers such as IIS, Apache, or Nginx. A reverse proxy server can offload work such as serving static content, caching requests, compressing requests, and HTTPS termination from the HTTP server. A reverse proxy server may reside on a dedicated machine or may be deployed alongside an HTTP server."
<a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2</a></p>
<p>Could anyone please share some insights if this is actually relevant nowadays?</p>
<p>On our use case, we use Docker instances with external load balancing (AWS ALB).
Each docker instance has both Nginx and our ASP.NET Core application running.
We couldn't figure out the exact benefits of using Nginx.</p>
<ol>
<li><p>Serving static content
As we're using an external CRN (AWS CloudFront), I assume static caching doesn't really have any actual benefits, does it?</p></li>
<li><p>Caching requests
I believe this is the same as serving static content, as dynamic content isn't cached on most scenarios (on our use case - all scenarios).</p></li>
<li><p>Compressing requests
ASP.NET Core has a response compression middleware, however - it claims "The performance of the middleware probably won't match that of the server modules. HTTP.sys server server and Kestrel server don't currently offer built-in compression support.".
Perhaps some benchmarks could be created to validate this claim.
<a href="https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-2.2" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-2.2</a></p></li>
<li><p>HTTPS termination from the HTTP server
I assume most clients having load balancers can skip this part, as HTTPS termination can be done on the load balancer if needed.</p></li>
</ol>
<p>Thanks!
Effy</p>
| <asp.net-core><kestrel-http-server><asp.net-core-2.2><asp.net-docker-extensions> | 2019-05-07 16:55:56 | HQ |
56,029,007 | NativeModule: AsyncStorage is null, with @RNC/AsyncStorage | <p>I'm working on a React Native project created with Expo. I've been using regular old <code>AsyncStorage</code>, importing from <code>react-native</code>, and all has been well.</p>
<p>In looking up how to mock <code>AsyncStorage</code> for testing, I saw that <code>react-native-community/react-native-async-storage</code> has its own mock built in. </p>
<p>So I installed the community plugin with <code>yarn add</code> and switched out all my import statements.</p>
<p>When I run my app, I'm getting an error (which I'm retyping myself, excuse some ellipses): </p>
<pre><code>[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
To fix this issue try these steps:
-Run `react-native link @react-native-community/async-storage` in the project root.
-Rebuild and restart the app
-Run the packager with `--clearCache` flag.
-If you are using CocoaPods on iOS...
-If this happens while testing with Jest...
</code></pre>
<p>So I tried running <code>react-native link @react-native-community/async-storage</code> but I keep getting this error:</p>
<pre><code>Something went wrong while linking. Error: Cannot read property 'pbxprojPath' of null
</code></pre>
<p>Some research showed me that Expo apps can't (and don't need to) link. </p>
<p>I tried <code>npm start --clearCache</code> to no avail.</p>
<p>Also, I don't have an <code>ios</code> (or <code>android</code>) folder in my project. This has always been kind of confusing for me because I see it referenced all over the place. I run my app in the Simulator/Emulator (and device) through the Expo app. Once I tried ejecting and there were problems. So, I don't have an <code>ios</code> folder.</p>
<p>(I'll go back to using the old native <code>AsyncStorage</code> from <code>react-native</code> and creating a mock myself, but I'd like to know how to solve this, and similar problems that may arise in the future.)</p>
| <react-native><expo> | 2019-05-07 19:04:03 | HQ |
56,031,758 | How to read text file and insert to database vbsript | I have lot of text file with content below:
LOG_NAME=LOGX1245;
LOT_NO=NA;
STEP=NA;
NO=CS84E869500115;
TIME_START=20190506 094715;
TIME_END=20190506 094715
I need to read the text file and insert to database.
The column name is the first field and value is the second field.
How to read the text file and insert each of lines to database? | <sql><text><vbscript><sql-insert> | 2019-05-07 23:42:23 | LQ_EDIT |
56,031,952 | Google Play shows Unoptimized APK for Cordova App | <p>I was trying to publish my first Cordova app on Google Playstore.
When I upload my release apk, it shows below warning and I cannot rollout the release.</p>
<p>Unoptimized APK</p>
<p>Warning:</p>
<p>This APK results in unused code and resources being sent to users. Your app could be smaller if you used the Android App Bundle. By not optimizing your app for device configurations, your app is larger to download and install on users’ devices than it needs to be. Larger apps see lower install success rates and take up storage on users’ devices.</p>
| <android><cordova><google-play> | 2019-05-08 00:15:41 | HQ |
56,032,433 | how to get next user id? | I wanna print two rows, first with next five users and second with next 25 users after 5, I am getting an error while getting next id
$quary= mysql_query("SELECT * FROM user ORDER BY id ASC ");
while($auto_inc_result = mysql_fetch_array($quary))
{
$last_id = $auto_inc_result['id'];
}
$next_id = ($last_id+1);
echo $next_id; | <php><mysql> | 2019-05-08 01:41:09 | LQ_EDIT |
56,032,747 | How to run podman from inside a container? | <p>I want to run <a href="https://podman.io" rel="noreferrer">podman</a> as a container to run CI/CD pipelines. However, I keep getting this error from the podman container:</p>
<pre class="lang-sh prettyprint-override"><code>$ podman info
ERRO[0000] 'overlay' is not supported over overlayfs
Error: could not get runtime: 'overlay' is not supported over overlayfs: backing file system is unsupported for this graph driver
</code></pre>
<p>I am using the <a href="https://github.com/jenkinsci/kubernetes-plugin" rel="noreferrer">Jenkins Kubernetes plugin</a> to write CI/CD pipelines that run as containers within a Kubernetes cluster. I've been successful at writing pipelines that use a Docker-in-Docker container to run <code>docker build</code> and <code>docker push</code> commands.</p>
<p>However, running a Docker client and a Docker Daemon inside a container makes the CI/CD environment very bloated, hard to configure, and just not ideal to work with. So I figured I could use <a href="https://podman.io" rel="noreferrer">podman</a> to build Docker images from Dockerfiles without using a fat Docker daemon.</p>
<p>The problem is that <strong>podman</strong> is so new that I have not seen anyone attempt this before, nor I am enough of a podman expert to properly execute this.</p>
<p>So, using the <a href="https://github.com/containers/libpod/blob/master/install.md#ubuntu" rel="noreferrer">podman installation instructions for Ubuntu</a> I created the following Dockerfile:</p>
<pre><code>FROM ubuntu:16.04
RUN apt-get update -qq \
&& apt-get install -qq -y software-properties-common uidmap \
&& add-apt-repository -y ppa:projectatomic/ppa \
&& apt-get update -qq \
&& apt-get -qq -y install podman
# To keep it running
CMD tail -f /dev/null
</code></pre>
<p>So I built the image and ran it as follows:</p>
<pre class="lang-sh prettyprint-override"><code># Build
docker build -t podman:ubuntu-16.04 .
# Run
docker run --name podman -d podman:ubuntu-16.04
</code></pre>
<p>Then when running this command on the running container, I get an error:</p>
<pre class="lang-sh prettyprint-override"><code>$ docker exec -ti podman bash -c "podman info"
ERRO[0000] 'overlay' is not supported over overlayfs
Error: could not get runtime: 'overlay' is not supported over overlayfs: backing file system is unsupported for this graph driver
</code></pre>
<p>I install podman on an Ubuntu 16.04 machine I had and ran the same <code>podman info</code> command I got the expected results:</p>
<pre class="lang-sh prettyprint-override"><code>host:
BuildahVersion: 1.8-dev
Conmon:
package: 'conmon: /usr/libexec/crio/conmon'
path: /usr/libexec/crio/conmon
version: 'conmon version , commit: '
Distribution:
distribution: ubuntu
version: "16.04"
MemFree: 2275770368
MemTotal: 4142137344
OCIRuntime:
package: 'cri-o-runc: /usr/lib/cri-o-runc/sbin/runc'
path: /usr/lib/cri-o-runc/sbin/runc
version: 'runc version spec: 1.0.1-dev'
SwapFree: 2146758656
SwapTotal: 2146758656
arch: amd64
cpus: 2
hostname: jumpbox-4b3620b3
kernel: 4.4.0-141-generic
os: linux
rootless: false
uptime: 222h 46m 33.48s (Approximately 9.25 days)
insecure registries:
registries: []
registries:
registries:
- docker.io
store:
ConfigFile: /etc/containers/storage.conf
ContainerStore:
number: 0
GraphDriverName: overlay
GraphOptions: null
GraphRoot: /var/lib/containers/storage
GraphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
ImageStore:
number: 15
RunRoot: /var/run/containers/storage
VolumePath: /var/lib/containers/storage/volumes
</code></pre>
<p>Does anyone know how I can fix this error and get podman working from a container?</p>
| <docker><jenkins><kubernetes><containers><podman> | 2019-05-08 02:32:02 | HQ |
56,032,912 | VS Marketplace Add Member displayes Invalid Domain error | <p>I am trying to add a member to Visual Studio Marketplace. In my account I go to Manage Publishers & Extensions -> Members and click om '+ Add'. Whatever e-mail I provide shows "Invalid Domain" error:</p>
<p><a href="https://i.stack.imgur.com/thBKP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/thBKP.png" alt="enter image description here"></a></p>
<p>Is it a VS Marketplace bug or do I need to somehow link Azure directory (or any other users directory) first?</p>
| <visual-studio><permissions><user-management><marketplace> | 2019-05-08 02:57:44 | HQ |
56,034,478 | Why does my Toast.makeText dont show anything | <p>I have this problem that when I click my login button the Toast make text doesn't show up and I don't know what's wrong because</p>
<p>I can't see any error and when I change the toast.maketext to an Intent the app force closes. Hope someone can help. </p>
<p>I can't see any error and when I change the toast.maketext to an Intent the app force closes. Hope someone can help. </p>
<p>MainActivity.java</p>
<pre><code>public class MainActivity extends AppCompatActivity {
EditText email;
EditText password;
Button login;
Button signup;
DBHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
db = new DBHelper(this);
email = findViewById(R.id.editText_email);
password = findViewById(R.id.editText_password);
login = findViewById(R.id.btnlogin);
signup = findViewById(R.id.btnsignup);
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signupIntent = new Intent(MainActivity.this, SignUp.class);
startActivity(signupIntent);
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user = email.getText().toString();
String pass = password.getText().toString();
Boolean res = db.checkAcc(user,pass);
if(res==true){
Toast.makeText(MainActivity.this,"You are logged in",Toast.LENGTH_SHORT);
}
else{
Toast.makeText(MainActivity.this,"Please Enter Again",Toast.LENGTH_SHORT);
}
}
});
}
}
</code></pre>
<p>DBHelper.java</p>
<pre><code>public class DBHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME="register.db";
public static final String TABLE_NAME="register";
public static final String COL_1="ID";
public static final String COL_2="email";
public static final String COL_3="password";
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE register (ID INTEGER PRIMARY KEY AUTOINCREMENT,email TEXT UNIQUE, password TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(sqLiteDatabase);
}
public long AddAcc(String email, String password){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("email",email);
contentValues.put("password",password);
long res = db.insert("register",null,contentValues);
db.close();
return res;
}
public boolean checkAcc(String username,String password){
String[] columns = { COL_1 };
SQLiteDatabase db = getReadableDatabase();
String selection = COL_2 + "=?" + " and " + COL_3 + "=?";
String[] selectionArgs = {username,password};
Cursor cursor = db.query(TABLE_NAME,columns,selection,selectionArgs,null,null,null);
int count = cursor.getCount();
cursor.close();
db.close();
if(count>0)
return true;
else
return false;
}
}
</code></pre>
| <android><android-sqlite> | 2019-05-08 06:06:29 | LQ_CLOSE |
56,035,176 | How to get lifecycle.coroutineScope with new androidx.lifecycle:*:2.2.0-alpha01 | <p>On 7th May, 2019 <code>androidx.lifecycle:*:2.2.0-alpha01</code> was released announcing:</p>
<blockquote>
<p>This release adds new features that adds support for Kotlin coroutines for Lifecycle and LiveData. Detailed documentation on them can be found here.</p>
</blockquote>
<p>On <a href="https://developer.android.com/topic/libraries/architecture/coroutines#lifecyclescope" rel="noreferrer">documentation</a> it's mentioned that I can get the <code>LifecycleScope</code>:</p>
<blockquote>
<p>either via <code>lifecycle.coroutineScope</code> or <code>lifecycleOwner.lifecycleScope</code> properties</p>
</blockquote>
<p>But it seems that I'm not able to find none of them. My current dependencises are:</p>
<pre><code>def lifecycle_ver = "2.2.0-alpha01"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_ver"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_ver"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_ver"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1'
</code></pre>
<p>What may be the cause and how do get these apis?</p>
| <android><android-architecture-components><android-jetpack> | 2019-05-08 07:00:39 | HQ |
56,035,473 | Filter values from a list based on priority | <p>I have a list of valid values for a type:</p>
<pre><code>Set<String> validTypes = ImmutableSet.of("TypeA", "TypeB", "TypeC");
</code></pre>
<p>From a given list I want to extract the first value which has a valid type. In this scenario I would write something of this sort:</p>
<pre><code>public class A{
private String type;
private String member;
}
List<A> classAList;
classAList.stream()
.filter(a -> validTypes.contains(a.getType()))
.findFirst();
</code></pre>
<p>However I would like to give preference to <code>TypeA</code>, i.e. if <code>classAList</code> has <code>TypeA</code> and <code>TypeB</code>, I want the object which has <code>typeA</code>. To do this one approach I've is:</p>
<pre><code>Set<String> preferredValidTypes = ImmutableSet.of("TypeA");
classAList.stream()
.filter(a -> preferredValidTypes.contains(a.getType()))
.findFirst()
.orElseGet(() -> {
return classAList.stream()
.filter(a -> validTypes.contains(a.getType()))
.findFirst();
}
</code></pre>
<p>Is there a better approach? </p>
| <java><java-8> | 2019-05-08 07:17:54 | HQ |
56,035,584 | Why doesn't the next function work on the Iterator object without prior assignment? - python | In python 3.7 if I have:
>>> d1 = {2:5, 6:4, 7:8}
>>> d2 = {50:31, 51:32, 52: 36}
and applying next function:
>>> next(zip(d1, d2))
(2, 50)
>>> next(zip(d1, d2))
(2, 50)
>>> next(zip(d1, d2))
(2, 50)
.......
Though If I do an assignment
g = zip(d1, d2)
and applying next function it does give the correct results:
>>> next(g)
(2, 50)
>>> next(g)
(6, 51)
>>> next(g)
(7, 52)
I want to know why the next function does not work on a generator object without an assignment to a variable.
Thanks
| <python><python-3.7> | 2019-05-08 07:25:49 | LQ_EDIT |
56,035,691 | how to separate number using javascript? | <p>I have a quetion please help me.
I have number 21 or 22 or 23 etc.
and I want to separate that number to be 20 and 1 or 20 and 2 or 20 and 3 etc.
how to make it programmaticly in javascript. Sorry before cause I really confused and dont know the keyword to search on internet.
Thanks guys hope U all can help me</p>
| <javascript><jquery><separator><digit-separator> | 2019-05-08 07:33:09 | LQ_CLOSE |
56,036,031 | export GATSBY_CONTENTFUL_OFFLINE=true | I am new to gatsby, Last 1 week i'm facing this problem when run the dev server
Try running setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
I am searching in after i got this line, Where to add this line in Gatsby
*****export GATSBY_CONTENTFUL_OFFLINE=true*****
| <gatsby><contentful> | 2019-05-08 07:56:36 | LQ_EDIT |
56,036,350 | Specific questions about Blockchain | <p>I have familiarized with the blockchain technology for some time through internet research and tutorials, but, as blockchain often appears as a business topic, I could not find good answers to some technical questions. I hope, some of you could help me:</p>
<ol>
<li>The concept of blockchain says that all transaction data is stored on every node (e.g. computer) of the network. Isn’t that a huge and continuously growing amount of data every single participant should store? (If the answer is that just certain nodes have to save the whole history, wouldn’t this be in contrast to the idea of decentralization?)</li>
<li>What is the purpose for the very complex hashing procedure of Bitcoin? As far as I understand it, hashing is needed for the immutability of the chain, but why does it have to be so time-consuming as it is? On the other hand hashing is often considered as a „signature“ of the miner; what does that mean? Doesn’t signature usually mean something like a private key? </li>
<li>As blockchain is of course not bitcoin, is this complex hashing procedure also needed for other use cases (like supply chain applications…) or can it be replace by simpler hashes?</li>
<li>To protect privacy the participants of a blockchain are mostly hashed as well, which is often listed as a great advantage of the technology. In more exclusive blockchains than the bitcoin, isn’t it very simple to conclude some players through their behavior. I mean, if a very big party participates in the blockchain, it is well detectable by e.g. the frequency or volume of deals.</li>
<li>If a miner has hashed and added a block, do all the other miners instantly reject the block they currently try to create?</li>
<li>How does blockchain synchronize the transactions? In distributed systems it is always a big deal to clarify which action happened first. Some of the blockchain literature sources say that all transactions of a blockchain are first stored in a pool before adding to a block. This would be bad in e.g. auction-like deals.</li>
<li>Some sources state that a chain is considered correct when the majority (51%) of the nodes contains it. How does it work/ when is this checked? On the homepage <a href="https://medium.com/coinmonks/what-is-a-51-attack-or-double-spend-attack-aa108db63474" rel="nofollow noreferrer">https://medium.com/coinmonks/what-is-a-51-attack-or-double-spend-attack-aa108db63474</a> the 51% refer to the computational capacities and not the number of nodes and in the context of an attack…</li>
</ol>
<p>Thank you very much in advance! I will appreciate your answers.</p>
| <blockchain><bitcoin> | 2019-05-08 08:16:50 | LQ_CLOSE |
56,037,079 | What is a good way to allow only one non null field in an object | <p>I want to write a class with more than 1 fields of different types but at any time, there is one and only one field of an instance object having non null value.</p>
<p>What I did so far does not look really clean.</p>
<pre class="lang-java prettyprint-override"><code>class ExclusiveField {
private BigInteger numericParam;
private String stringParam;
private LocalDateTime dateParam;
public void setNumericParam(BigInteger numericParam) {
unsetAll();
this.numericParam = Objects.requireNonNull(numericParam);
}
public void setStringParam(String stringParam) {
unsetAll();
this.stringParam = Objects.requireNonNull(stringParam);
}
public void setDateParam(LocalDateTime dateParam) {
unsetAll();
this.dateParam = Objects.requireNonNull(dateParam);
}
private void unsetAll() {
this.numericParam = null;
this.stringParam = null;
this.dateParam = null;
}
}
</code></pre>
<p>Does Java support this pattern somehow or is there a more decent way to do it?</p>
| <java> | 2019-05-08 09:00:21 | HQ |
56,037,675 | Calculate mean of values based on matching strings in R | <p>Say I have a dataframe <code>df</code>:</p>
<pre><code>c1 c2
A 1
A 3
A 1
A 3
B 3
B 3
B 3
</code></pre>
<p>I want to use this dataframe to generate a table that shows each unique value from <code>c1</code> and the mean of its corresponding values from <code>c2</code>, resulting in this:</p>
<pre><code>v1 v2
A 2
B 3
</code></pre>
<p>because the mean of A's values is 2 ((1+1+3+3)/4) and B's is 3 ((3+3+3)/3).</p>
<p>I'm guessing I need to use aggregate but I'm not sure how.</p>
| <r><aggregate> | 2019-05-08 09:38:05 | LQ_CLOSE |
56,039,518 | \n not working in php code when using chrome browser | <p>I am using the \n to insert a new line when echoing a string in PHP. But the output does not seem to reflect this. I am using chrome browser to display the output. </p>
<p>Here is my code:</p>
<pre><code><?php
echo "Developers, Developers, developers, developers,\n developers,
developers, developers, developers, developers!";
?>
</code></pre>
<p>I expect the output to be:</p>
<p>Developers, Developers, developers, developers,<br>
developers, developers, developers, developers, developers!</p>
<p>But it is being displayed in a single line in chrome as:</p>
<p>Developers, Developers, developers, developers, developers, developers,
developers, developers, developers!</p>
<p><a href="https://imgur.com/g7tV48z" rel="nofollow noreferrer">https://imgur.com/g7tV48z</a></p>
| <php> | 2019-05-08 11:16:40 | LQ_CLOSE |
56,040,789 | How to make a for-loop more understandable in python? | <p>I am currently teaching some python programming to some fairly young students. One thing I want them to learn is how to write a for-loop.</p>
<p>So far, the way I have shown it to the students is like this:</p>
<pre><code>for i in range(1,11):
print(i)
</code></pre>
<p>which gives a loop where <code>i</code> goes from 1 to 10.</p>
<p>My problem is that it seems strange to students that they need to write 11 as the second argument to <code>range(1,11)</code> when they want the loop to go up to 10. The students find this confusing.</p>
<p>In C/C++ and related languages, such a loop can be written like this:</p>
<pre><code>for(int i = 1; i <= 10; i++)
{ /* do something */ }
</code></pre>
<p>It seems to me like the C++ way of expressing the loop is more intuitive since in that case I can explicitly write 1 and 10 which are the first and last values that I want the loop variable to take.</p>
<p>When working with for-loops in python, I end up telling the students something like <em>"we just have to accept that we need to write 11 when we want the loop to go to 10, it is a bit annoying but you just have to learn that the range function works in that way"</em>. I am not happy about that; I want them to learn that programming is fun and I am afraid this kind of thing makes it less fun.</p>
<p>Since python is often described as a language emphasizing readability, I suspect there is a nicer way to express a for-loop, a way that would cause less confusion for my students.</p>
<p>Is there a better and/or less confusing way to express this kind of for-loop in the python language?</p>
| <python><loops> | 2019-05-08 12:27:46 | HQ |
56,041,372 | Game: Countries and cities | so I try to do game with java.
Instruction: Console choose random letter and player have to write correct country and city.
In my code I would like to show computer answer after player choice. But my code it doesn't work correct.
It's my code:
public class MainGame {
public static int menu() {
System.out.println();
System.out.println(" ****************************************");
System.out.println(" * MENU *");
System.out.println(" ****************************************");
System.out.println(" 1. Start");
System.out.println(" 2. Instruction");
System.out.println(" 0. The End");
Scanner in = new Scanner(System.in);
int w = in.nextInt();
return w;
}
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int choice = menu();
while (choice != 0) {
switch (choice) {
case 1:
System.out.println("START");
country();
break;
case 2:
System.out.println("INSTRUCTION");
System.out.println("Bla bla bla");
break;
}
System.out.println("\nClick Enter, to continue...");
System.in.read();
choice = menu();
}
System.out.println(" ****************************************");
System.out.println("\n The end \n\n");
}
public static String answersCountry() {
char znak = RandomLetter.ranomRandom();
for (int i = 0; i < 1; i++) {
System.out.println("Wylosowana litera to: " + znak);
switch (znak) {
case 'A':
System.out.println("Anglia");
break;
case 'B':
System.out.println("Belgia");
break;
case 'C':
System.out.println("Czechy");
break;
case 'D':
System.out.println("Dania");
break;
case 'E':
System.out.println("Egipt");
break;
}
}
return answersCountry();
}
public static char country() {
Scanner scanner2 = new Scanner(System.in);
boolean result = false;
for (int i = 0; i < 1; i++) {
char randomLetter = RandomLetter.ranomRandom();
while (result == false) {
System.out.println("Entere country in the given letter: " + randomLetter);
String countryName = scanner2.next();
char firstLetter1 = countryName.charAt(0);
if (firstLetter1 == randomLetter) {
System.out.println("Correct country.");
System.out.println("Computer answer: " + answersCountry());
result = true;
} else {
System.out.println("Incorrect country");
result = false;
break;
}
}
boolean result1 = false;
while (result1 == false) {
System.out.println("Enter city in the given letter: " + randomLetter);
String cityName = scanner2.next();
char firstLetter2 = cityName.charAt(0);
if (firstLetter2 == randomLetter) {
System.out.println("Correct city");
result1 = true;
} else {
System.out.println("Incorrect city");
result1 = false;
break;
}
break;
}
}
return country();}}
and class with randomLetter:
public class RandomLetter {
public static char ranomRandom() {
Random random = new Random();
char[] abc = {'A', 'B', 'C', 'D', 'E'};
int index = random.nextInt(abc.length);
char randomLetter = abc[index];
return randomLetter;}}
Could you tell me how to show **1** computer answer? | <java> | 2019-05-08 12:57:49 | LQ_EDIT |
56,043,445 | How do i use the % placeholder to write something in python? | <p>I have been asked to use the % placeholder to write something in python. I don't know how to do it can you help. </p>
| <python><string> | 2019-05-08 14:48:25 | LQ_CLOSE |
56,043,559 | Folder in .gitignore is still in repo | <p>I have added a folder in my .gitignore file. But when I pushed to the repo it was still being pushed. my folder structure is:</p>
<pre><code>UI/node_modules
</code></pre>
<p>In the .gitignore I have added the following:</p>
<pre><code>/UI/node_modules
/UI/bin
</code></pre>
<p>Is there anything I am doing wrong? gitignore file sits at the same level as the UI folder</p>
| <git><github> | 2019-05-08 14:55:12 | LQ_CLOSE |
56,043,998 | Is there a way to group by multiple criteria and then count data in excel? | Pickup Received BUILDING ROOM
7/12/2018 50 0G39
7/12/2018 50 0G39
9/13/2018 101 0275B
9/13/2018 101 0275B
9/13/2018 101 0275B
8/10/2018 1000 206
8/10/2018 1000 206
8/22/2018 1000 208
I am looking to count data based off of a group of multiple criteria. I would like to group matching building and rooms with the same date and count them as one. My goal is to determine the number of pickups (where same date, building, and room is one trip).
Ex.
Pickup Received BUILDING ROOM
7/12/2018 50 0G39
7/12/2018 50 0G39
This is one
9/13/2018 101 0275B
9/13/2018 101 0275B
9/13/2018 101 0275B
This is one
8/10/2018 1000 206
8/10/2018 1000 206
This is one
8/22/2018 1000 208
This is one.
Is this possible with excel?
Thanks in advanced.
| <excel> | 2019-05-08 15:18:22 | LQ_EDIT |
56,044,065 | items in flex container overlap | When I try this code, the two dots overlap each other as well as the text.
Why?
How can I get them to be side by side?
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.container {
display: flex;
flex-direction: row;
}
.dot {
width: 8px;
height: 8px;
border-radius: 4px;
background: black;
}
<!-- language: lang-html -->
<div class="container">
<span class="dot" />
<span class="dot" />
some text
</div>
<!-- end snippet -->
| <css><flexbox> | 2019-05-08 15:21:51 | LQ_EDIT |
56,044,210 | How can I read data from file ? I can't fix it | <p>I record students informations to txt file but when I want to read data's from file
just read information's in the first row. Also I calculate the average of the students but when ı want to read average it's not working.</p>
<pre><code> FILE *fout;
fout = fopen("English Class.txt","w");
printf("Please enter student number of class : ");
scanf("%d", &x.classNum);
fprintf(fout, "Class Number : %d\n",x.classNum);
for(i=0; i<x.classNum; i++){
printf("Please Enter %d.Student Name : ",i+1);
scanf("%s",&x.Name);
printf("Please Enter %d.Student Surname : ",i+1);
scanf("%s",&x.Surname);
printf("Please Enter %d.Student Number : ",i+1);
scanf("%d",&x.StudentNumber);
printf("Please Enter %d.Student Score : ",i+1);
scanf("%d",&x.EnglishScore);
x.total = x.total + x.EnglishScore;
fprintf(fout, "\nStudent Name : %s %s Student Number : %d Student Score : %d\n", x.Name, x.Surname, x.StudentNumber, x.EnglishScore);
}
x.average = x.total / x.classNum;
fprintf(fout, "\n\nClass Average is : %f", x.average);
fclose(fout);
</code></pre>
<p>I get students records from top code</p>
<pre><code> FILE *fin;
fin = fopen("English Class.txt","r");
fscanf(fin, "Class Number : %d\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f",&x.classNum, &x.Name, &x.Surname, &x.StudentNumber, &x.EnglishScore, &x.average);
fclose(fin);
printf("Class Number : %d\n", x.classNum);
for(i=0; i<x.classNum; i++){
fscanf(fin, "\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f", &x.Name, &x.Surname, &x.StudentNumber, &x.EnglishScore);
fclose(fin);
printf("\nStudent Name : %s %s Student Number : %d Student Score : %d\n", x.Name, x.Surname, x.StudentNumber, x.EnglishScore);
}
printf("\n\nClass Average is : %f", x.average);
</code></pre>
| <c><file><structure> | 2019-05-08 15:29:41 | LQ_CLOSE |
56,044,726 | Is there a way to make randint() less pseudo and more random? | <p>I'm working on a lottery simulator and I'm not quiet happy with the draws generated by randint.</p>
<p>Are there any tricks to make it more random?</p>
| <python><random> | 2019-05-08 15:58:53 | LQ_CLOSE |
56,045,259 | How to replace a multi-character character constant with one character | <p>I'm attempting to replace <code>'%7C'</code> with a <code>'|'</code> in C but i'm getting a multi-character character constant warning. I was wondering if it was possible to do this and if so how? I was attempting using the code below but it gave this warning.</p>
<p><strong>Parse.c</strong></p>
<pre><code>char *parse(char *command){
char * newCommand = (char *)malloc(sizeof(char)*35);
newCommand = strtok(command, " ");
newCommand = strtok(NULL, "/run?command= ");
for(int i = 0; i<strlen(newCommand); i++){
if(newCommand[i] == '+')
{
newCommand[i] = ' ';
}
if(newCommand[i] == '%7C')
{
newCommand[i] = '|';
}
}
return newCommand;
}
</code></pre>
| <c><string> | 2019-05-08 16:32:56 | LQ_CLOSE |
56,045,930 | Diagrams symbols in UML , OOAD | <p>I have seen many symbols, notations related to UML and OOA&D. Most of the times those symbols don't have any labels so I am not able to understand what they are. For example, we have symbol for <code>Generalization</code> , <code>Realization</code>, <code>Uses</code> etc.</p>
<p>Is there any book , resource which depicts commonly used symbols and their meaning?</p>
| <design-patterns><uml><ooad> | 2019-05-08 17:15:04 | LQ_CLOSE |
56,046,039 | Why does this Integer become a string in javascript? | <p>So this little snippet of code takes an array <code>A</code> of integers and makes the integers strings when they become the keys of <code>pairs</code>. Why? Python is happy for them to remain integers, but Javascript seems to only want strings for keys.</p>
<pre><code> var pairs = {};
for(var i=0; i < A.length; ++i) {
var value = A[i];
if(pairs[value]) {
delete pairs[value];
} else {
pairs[value] = true;
}
}
console.log(A, pairs)
</code></pre>
<p>Produces:</p>
<pre><code>Example test: [9, 3, 9, 3, 9, 7, 9]
Output:
[ 9, 3, 9, 3, 9, 7, 9 ] { '7': true }
OK
Your test case: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Output:
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] { '10': true }
Returned value: 10
</code></pre>
<p>All the keys are integers when they are added to the pairs object, but they become strings when they are used as keys. This is a good bit different from python</p>
| <javascript> | 2019-05-08 17:22:08 | LQ_CLOSE |
56,046,142 | How to fix my non-starting little game app? | <p>I have to do a little game for my school, and I'm stuck in my program. When I launch the app it's working fine, but when I want to start a new game by the menubar, it says that the game is starting, but it isn't. I think the program is stuck in my FenRPS::newGame() function, but I don't know how to fix it.</p>
<pre><code>FenRPS::FenRPS() : wxFrame( NULL, wxID_ANY, "Rock–paper–scissors",
wxDefaultPosition, wxSize(607,650), wxCAPTION|wxCLOSE_BOX|wxCLIP_CHILDREN )
{
this->SetBackgroundColour( wxColor( 240,240,240 ));
this->SetIcon( wxIcon( AppRPS::Icone_xpm ));
//================ MENU ================
wxMenuItem* item;
#define Item( menu, fctEvenement, texte, aide ) \
item = menu->Append( wxID_ANY, texte, aide ); \
menu->Bind( wxEVT_MENU, fctEvenement, this, item->GetId() );
#define Separateur( menu ) menu->AppendSeparator();
menuGame = new wxMenu;
Item( menuGame, newGame, "&New Game", "Create a new game" );
Separateur( menuGame );
Item( menuGame, exit, "Exit", "Exit the game" );
menuAbout = new wxMenu;
Item( menuAbout, about, "&About", "Display app informations" );
menuBar = new wxMenuBar;
menuBar->Append( menuGame, "&Game" );
menuBar->Append( menuAbout, "&About" );
this->SetMenuBar( menuBar );
//=============== BOUTONS ==============
rock_png = new wxStaticBitmap(this, wxID_ANY, wxBitmap("img/rock.png",
wxBITMAP_TYPE_PNG), wxPoint(54,400), wxSize(128,128));
buttonRock.Create( this, wxID_ANY, "R O C K", wxPoint(54,538), wxSize(128,50));
buttonRock.Bind( wxEVT_BUTTON, playedRock, this );
paper_png = new wxStaticBitmap(this, wxID_ANY,
wxBitmap("img/paper.png", wxBITMAP_TYPE_PNG), wxPoint(236,400), wxSize(128,128));
buttonPaper.Create( this, wxID_ANY, "P A P E R", wxPoint(236,538), wxSize(128,50));
buttonPaper.Bind( wxEVT_BUTTON, playedPaper, this );
scissors_png = new wxStaticBitmap(this, wxID_ANY,
wxBitmap("img/scissors.png", wxBITMAP_TYPE_PNG), wxPoint(418,400), wxSize(128,128));
buttonScissors.Create( this, wxID_ANY, "S C I S S O R S", wxPoint(418,538), wxSize(128,50));
buttonScissors.Bind( wxEVT_BUTTON, playedScissors, this );
stTextBox = new wxStaticText;
stTextBox->Create( this, wxID_ANY, "\nWelcome in the Rock-Paper-Scissors game\n\n\n\nNo game is in progress", wxPoint(10,10), wxSize(580,364), wxALIGN_CENTRE_HORIZONTAL);
stTextBox->SetBackgroundColour( *wxLIGHT_GREY );
stTextBox->SetFont( wxFont( wxFontInfo(12).FaceName("Arial").Bold()));
if( hasPlayed )
{
srand(time(0));
choiceBot = (rand()%3)+1;
message << "Round n°" << nbrRound << "\n";
stTextBox->SetLabel( message );
if (choicePlayer == 1 && choiceBot == 1) message << message << "Equality\n\n\n";
else if (choicePlayer == 1 && choiceBot == 2)
{
message << message << "Round lost, the bot has made 'paper'\n\n\n";
scoreBot++;
}
else if (choicePlayer == 1 && choiceBot == 3)
{
message << message << "Round win, the bot had made 'scissors'\n\n\n";
scorePlayer++;
}
else if (choicePlayer == 2 && choiceBot == 1)
{
message << message << "Round win, the bot had made 'rock'\n\n\n";
scorePlayer++;
}
else if (choicePlayer == 2 && choiceBot == 2) message << message << "Equality\n\n\n";
else if (choicePlayer == 2 && choiceBot == 3)
{
message << message << "Round lost, the bot has made 'scissors'\n\n\n";
scoreBot++;
}
else if (choicePlayer == 3 && choiceBot == 1)
{
message << message << "Round lost, the bot has made 'rock'\n\n\n";
scoreBot++;
}
else if (choicePlayer == 3 && choiceBot == 2)
{
message << message << "Round win, the bot had made 'paper'\n\n\n";
scorePlayer++;
}
else if (choicePlayer == 3 && choiceBot == 3) message << message << "Equality\n\n\n";
stTextBox->SetLabel( message );
nbrRound++;
hasPlayed = false;
}
if( nbrRound > 5 )
{
message << "The game is over\n\n"
<< "Score :\n"
<< ">> Player : " << scorePlayer
<< "\n>> Computer : " << scoreBot;
if (scoreBot == scorePlayer)
message << message << "Equality. Try again\n";
else if (scoreBot > scorePlayer)
message << message << "You lost, you'll be luckier next time\n";
else if (scorePlayer > scoreBot)
message << message << "You won, congratulations !\n";
stTextBox->SetLabel( message );
wxSleep(2);
}
}
FenRPS::~FenRPS() {}
void FenRPS::playedRock( wxCommandEvent& ) { choicePlayer = 1; hasPlayed = true; }
void FenRPS::playedPaper( wxCommandEvent& ) { choicePlayer = 2; hasPlayed = true; }
void FenRPS::playedScissors( wxCommandEvent& ) { choicePlayer = 3; hasPlayed = true; }
void FenRPS::newGame( wxCommandEvent& )
{
stTextBox->SetLabel( "\nThe game is starting..." );
}
</code></pre>
| <c++><wxwidgets> | 2019-05-08 17:28:35 | LQ_CLOSE |
56,048,250 | Selenium Java: Detecting if a file has been generated and moving a file from one directory to another | For Selenium with Java, I have a test case scenario that involves many steps amongst which:
A- Checking whether a certain file has been generated in a certain directory.
B- moving this file from this directory to another specific directory.
How can A & B be implemented ? | <java> | 2019-05-08 20:03:21 | LQ_EDIT |
56,049,038 | DynamoDB alternatives in terms of pricing? (Only pay per requests and storage) | I've been learning and modeling DynamoDB for the last couple of weeks, it's been an hell and each day I run into a new wall, doesn't support batch updates/deletes, doesn't give you any tools to help manage replicated data.
What are other cloud-based, serverless, managed databases that have a pricing system similar to DynamoDB? | <nosql><amazon-dynamodb><cloud><serverless><amazon-timestream> | 2019-05-08 21:04:53 | LQ_EDIT |
56,049,344 | Why does reading a file take so much time? | I'm working on a project which requires sensor data from a temperature sensor. While accessing the file using open() and then read(), we found that it took too long. We have isolated problem to read() taking the most time (approximately 1 second). Is there a faster alternative to read() or am I using it incorrectly? Code:
```
import time, os, socket
#External thermometer address: 28-031897792ede
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
temp_sensor = '/sys/bus/w1/devices/28-031897792ede/w1_slave'
def temp_raw():
f = open(temp_sensor, 'r')
lines = f.read()
f.close()
return lines
def read_temp():
lines = temp_raw()
while lines[0].strip()[-3:] != 'YES':
lines = temp_raw()
temp_output = lines[1].find('t=')
if temp_output != -1:
temp_string = lines [1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
return round(temp_c, 1)
while True:
temp_raw()
``` | <python><python-3.x><read-write> | 2019-05-08 21:32:58 | LQ_EDIT |
56,050,824 | how to heck if the record exist in xamarin | Data Helper
public bool insertIntoTablePerson(Person person)
{
try
{
using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Persons.db")))
{
connection.Insert(person);
return true;
}
}
catch (SQLiteException ex)
{
Log.Info("SQLiteEx", ex.Message);
return false;
}
}
| <sqlite> | 2019-05-09 01:01:20 | LQ_EDIT |
56,052,248 | How to Move the files from one directory to another directory? directory file name should append with current date (yyyy-mm-dd) | import shutil
import os
source = '/path/to/source_folder'
dest1 = '/path/to/dest_folder'
files = os.listdir(source)
for f in files:
shutil.move(source+f, dest1) | <python><python-3.x><file><unix><file-copying> | 2019-05-09 04:32:55 | LQ_EDIT |
56,052,540 | How to run this c++ project in windows 10? | <p>Iam trying to run one c++ project form github to run on my windows 10. Please help me which IDE should i use to run and how to run?</p>
<p>Presently am using Atom but am not able to download gpp-compiler for atom</p>
<p>I have tried to add gpp-compiler to Atom and then run from Atom , but its not getting downloaded to Atom. Iam looking for new IDE suggestions to run it better</p>
<p>this is the github link <code>https://github.com/usnistgov/NFIQ2</code></p>
<p>SO am basically looking for an IDE where i can run and see the output</p>
| <c++><visual-c++> | 2019-05-09 05:07:25 | LQ_CLOSE |
56,053,161 | Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index | <p>Android Studio 3.4.</p>
<p>Project SDK (Android API 19 Platform).</p>
<p>Not using FindBugs or SpotBugs.</p>
<p>Every attempt to build, I get this error:</p>
<pre><code>Information:9/05/2019 4:02 PM - Compilation completed with 1 error and 0 warnings in 1 s 763 ms
Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index
java.lang.ClassNotFoundException: com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.intellij.util.indexing.counters.IndexCounters.<clinit>(IndexCounters.java:34)
at com.intellij.util.indexing.impl.MapReduceIndex.<init>(MapReduceIndex.java:86)
at org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex$CompilerMapReduceIndex.<init>(CompilerReferenceIndex.java:214)
at org.jetbrains.jps.backwardRefs.index.CompilerReferenceIndex.<init>(CompilerReferenceIndex.java:73)
at org.jetbrains.jps.backwardRefs.JavaCompilerBackwardReferenceIndex.<init>(JavaCompilerBackwardReferenceIndex.java:12)
at org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexWriter.initialize(JavaBackwardReferenceIndexWriter.java:74)
at org.jetbrains.jps.backwardRefs.JavaBackwardReferenceIndexBuilder.buildStarted(JavaBackwardReferenceIndexBuilder.java:40)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:358)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:229)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code></pre>
| <android-studio-3.4> | 2019-05-09 06:09:09 | HQ |
56,053,338 | Delete empty dictionary from dictionary of dictionaries | <p>I have a dictionary A:</p>
<pre><code>A = {"('All', 'Delhi', 'Mumbai')": {}, "('Container', 'Delhi', 'Mumbai')": {},
"('Open', 'Delhi', 'Mumbai')": {12: [12, 22, 25], 7: [9, 5]},
"('Open', 'Doon', 'Gurgaon')": {10: [1, 2, 24], 8: [4], 9: [28, 8], 7:[21]}}
</code></pre>
<p>I want to remove all the empty dictionaries, How can I do that ?</p>
| <python><python-3.x><dictionary> | 2019-05-09 06:23:57 | LQ_CLOSE |
56,053,770 | Why do we really need "fallthrough" in Golang? Which use case made Golang creators to include this in first place? | <p>"fallthrough" used in switch block, will transfer the execution to the next case's first statement without evaluating the next case statement. In real world, why do we need it? If at all we had to execute the next case block, we could have combined that code in the evaluated case already. Why do we really need "fallthrough"? What is its significance?</p>
| <go><switch-statement> | 2019-05-09 06:55:30 | LQ_CLOSE |
56,053,870 | Importing a JSON object into MongoDB - java | while ((line = br.readLine()) != null) {
Document document = Document.parse(String.format("{\"a\": %s}", line));
for(Document doc : document) {
docs.add(new InsertOneModel<Document>(doc));
}
I am getting the error in the for loop (for Document doc : document) as "can only iterate over an array or an instance of java.lang.Iterable. Can anyone please help | <java><mongodb> | 2019-05-09 07:02:42 | LQ_EDIT |
56,053,963 | Get Date As String and Remove Time in Javascript | <p>I have a simple problem. i need to get only the date as string and remove its time.
How can i do this? I tried new Date() but its not working.</p>
<pre><code>const value = '2018-04-09 00:00:00'
</code></pre>
| <javascript><ecmascript-6> | 2019-05-09 07:08:37 | LQ_CLOSE |
56,054,239 | i want to print last moth last date with time stamp '23:59:59' using command | Below is my output but i want to get output like Apr 30 23:59:59
please suggest
date -d "$(date +%Y-%m-01) -1 day"
Tue Apr 30 00:00:00 UCT 2019
I want below output
Tue Apr 30 23:59:59 UCT 2019 | <linux><datetime-format><date-manipulation> | 2019-05-09 07:27:31 | LQ_EDIT |
56,054,647 | Can I record video with CameraX (Android Jetpack)? | <p>Google has released the new CameraX library as part of Jetpack. It looks great for taking pictures, but my use case also require making video's. I tried googling for that, but couldn't find anything. </p>
<p>So, is it possible to record videos with the CameraX Jetpack library?</p>
| <android><android-jetpack><android-camerax> | 2019-05-09 07:51:41 | HQ |
56,055,975 | Why doesn't "go get" install the package to GOPATH? | <p>When I use go get command:</p>
<pre><code>sudo go get -u github.com/golang/dep/cmd/dep
</code></pre>
<p>My GOPATH is:</p>
<pre><code>GOPATH="/home/hadoop/gopath"
</code></pre>
<p>and i found go get will create a new directory which named "go" in /home,and the dep package is in it, I want to know why not in GOPATH but to create a new directory?</p>
| <go> | 2019-05-09 09:08:53 | LQ_CLOSE |
56,058,455 | Parse string to float/double | <p>I am getting values from jTable and putting it in my DataBase (MySQL). In my DB table there is column PAYMENT that is double. When I try to put values from my jTable there is a problem with it:</p>
<pre><code>String payment=(String) jTable1.getValueAt(row, 2);
double pay=double .parseDouble (payment);
........
pst.setDouble(3, zar);
</code></pre>
<p>I am getting this exception: </p>
<blockquote>
<p>Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "84,21834324"</p>
</blockquote>
<p>How can I put this column from jTable as double in my DB table?
P.S.: I tried with float too.</p>
| <java><database><parsing><double> | 2019-05-09 11:31:27 | LQ_CLOSE |
56,060,381 | Let's say I have a list. What's the difference between lst[0] and [lst[0]]? | <p>I know what lst[x] means in Python, which is basically the element in that index. But i'm not sure what [lst[x]] means.</p>
<p>new to programming btw so go ez</p>
| <python><indexing> | 2019-05-09 13:20:21 | LQ_CLOSE |
56,061,383 | Golang unable to parse TOML file in GoLand | I am using the GoLand editor on Windows and initially I installed dependency using:
go get github.com/BurntSushi/toml
I created a toml file in the same folder as my `main.go`:
```
.
|-- cloud.toml
`-- main.go
```
### cloud.toml
[database]
host = "localhost"
port = 8086
secure = false
username = "test"
password = "password"
dbName = "test"
### main.go
package main
import (
"fmt"
"github.com/BurntSushi/toml"
)
type tomlConfig struct {
DB dbInfo
}
type dbInfo struct {
Host string `toml:"host"`
Port int `toml: "port"`
Secure bool `toml: "secure"`
Username string `toml: "username"`
Password string `toml: "password"`
DbName string `toml:"dbName"`
}
func main() {
var dbConfig tomlConfig
if _, err := toml.DecodeFile("cloud.toml", &dbConfig); err != nil {
fmt.Println(err)
return
}
fmt.Println("Database Configuration")
fmt.Printf("Host: %s\n", dbConfig.DB.Host)
fmt.Printf("Port: %d\n", dbConfig.DB.Port)
}
### Output
go run main.go
Database Configuration
Host:
Port: 0
What am I doing wrong here?
my `go env` is:
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\des\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\des\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\des\AppData\Local\Temp\go-build309995570=/tmp/go-build -gno-record-gcc-switches
| <go><toml> | 2019-05-09 14:11:45 | LQ_EDIT |
56,061,590 | What is difference between reactstrap and react-bootstrap? | <p>I found two different bootstraps for reactjs </p>
<ol>
<li>npm install --save reactstrap react react-dom</li>
<li>npm install react-bootstrap bootstrap</li>
</ol>
<p>What is the basic and main difference between both?</p>
| <reactjs><react-bootstrap><reactstrap> | 2019-05-09 14:23:05 | HQ |
56,062,757 | What's the function of `<T>` in `fn foo<T>() = default`? | In `fn foo<T>() = default;` what does the `<T>` actually do and refer to? Can I omit it when my Event doesn't include for example `AccountId`?
This is referring to http://shawntabrizi.com/substrate-collectables-workshop/#/2/creating-an-event?id=depositing-an-event. | <rust><blockchain><substrate> | 2019-05-09 15:24:26 | LQ_EDIT |
56,063,066 | ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true | <p>I am facing this problem </p>
<p><code>Uglifier::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
</code>
while deploying the project through capistrano on production.</p>
<p>I followed this solution </p>
<p><a href="https://github.com/lautis/uglifier/issues/127#issuecomment-352224986" rel="noreferrer">https://github.com/lautis/uglifier/issues/127#issuecomment-352224986</a></p>
<p>which suggests</p>
<p>replacing</p>
<p><code>config.assets.js_compressor = :uglifier</code></p>
<p>with</p>
<p><code>config.assets.js_compressor = Uglifier.new(harmony: true)</code></p>
<p>but even after doing that I am still facing the same error. I dont understand what went wrong. I am using <code>uglifier (4.1.20)</code> version</p>
| <ruby-on-rails><ruby><uglifier> | 2019-05-09 15:39:01 | HQ |
56,063,351 | How to format time to "H:i:s" in laravel using carbon | <p>I would like to find total time spent on a project given that the user enters the "start time" and "stop time". I have been able to access the time spent but it comes as an array of Date Interval. </p>
<p>I want to just format the results to "H:i:s" (Hour:Minute:Seconds)</p>
<p>Here's the code from my controller</p>
<p>I have already declare the use of Carbon Class(use Carbon/Carbon;) at the top of the controller</p>
<pre><code> $start = Carbon::parse($request->strt_time);
$end = Carbon::parse($request->stp_time);
$time_spent = $end->diff($start);
$spent_time = $time_spent->format('H:i:s');
</code></pre>
<p>I expect the output to be 00:00:00 but I am getting a string "H:i:s"</p>
| <php><laravel><datetime><php-carbon> | 2019-05-09 15:56:40 | LQ_CLOSE |
56,063,455 | how to make a bot to message only certain people | i developed a welcome bot using microsoft bot framework. i want it add to teams . In teams i want the bot to send welcome messages to only certain members belonging to a particular team or group. please provide me advise or steps to do it. | <botframework><bots><chatbot> | 2019-05-09 16:02:22 | LQ_EDIT |
56,064,350 | VBA append some columns to another column and also create a seperate column to contain the appended columns title headers | I am working on a research portal for a client, they have their data in an excel workbook and each sheet containing stock prices for a particular year. There are about 11 worksheets (each representing a year i.e sheet 2008 - 2019). To keep things simple, each sheet has a column for Company Symbol Ticker, then other series of columns each representing a trading day. So it looks like (Symbol Ticker, 04 Jan 2008, 05 Jan 2008,06 Jan 2008,..,31 Dec 2008). I want to store this data in a database but dont want to have that huge freaking number of columns in the database one major reason being that the trading days is not the same for all sheets(years).
So how i want to store this data is have a date column in the database, values column , and the company's column , so basically (date,value,companyID).
I have transposed the table and placed the companies IDs (1,2,3,...) on each corresponding value columns to identify the company that has values in a particular column.
The next step now is to arrange these data in a 3 column (date,value,companyID) so that i can convert to CSV and import into the database. I know an excel macro can handle this very sure but cant figure out how to go about it as i am still a beginner in VBA. Thanks for your help in advance.
```
1 2 3
02-Jan-14 0.50 44.69 39.00
03-Jan-14 0.50 44.01 39.00
06-Jan-14 0.50 43.50 39.00
07-Jan-14 0.50 43.66 37.50
08-Jan-14 0.50 43.99 39.00
09-Jan-14 0.50 44.00 39.00
10-Jan-14 0.50 44.00 40.00
13-Jan-14 0.50 43.50 40.01
15-Jan-14 0.50 43.99 41.00
16-Jan-14 0.50 44.13 41.06
17-Jan-14 0.50 44.25 41.06
20-Jan-14 0.50 44.39 41.06
21-Jan-14 0.50 44.39 41.06
22-Jan-14 0.50 44.39 43.11
```
Expected result
```
02-Jan-14 0.50 1
03-Jan-14 0.50 1
06-Jan-14 0.50 1
07-Jan-14 0.50 1
08-Jan-14 0.50 1
09-Jan-14 0.50 1
10-Jan-14 0.50 1
13-Jan-14 0.50 1
15-Jan-14 0.50 1
16-Jan-14 0.50 1
17-Jan-14 0.50 1
20-Jan-14 0.50 1
21-Jan-14 0.50 1
22-Jan-14 0.50 1
02-Jan-14 44.69 2
03-Jan-14 44.01 2
06-Jan-14 43.50 2
07-Jan-14 43.66 2
08-Jan-14 43.99 2
09-Jan-14 44.00 2
10-Jan-14 44.00 2
13-Jan-14 43.50 2
15-Jan-14 43.99 2
16-Jan-14 44.13 2
17-Jan-14 44.25 2
20-Jan-14 44.39 2
21-Jan-14 44.39 2
22-Jan-14 44.39 2
02-Jan-14 39.00 3
03-Jan-14 39.00 3
06-Jan-14 39.00 3
07-Jan-14 37.50 3
08-Jan-14 39.00 3
09-Jan-14 39.00 3
10-Jan-14 40.00 3
13-Jan-14 40.01 3
15-Jan-14 41.00 3
16-Jan-14 41.06 3
17-Jan-14 41.06 3
20-Jan-14 41.06 3
21-Jan-14 41.06 3
22-Jan-14 43.11 3
``` | <excel><vba> | 2019-05-09 17:05:22 | LQ_EDIT |
56,064,503 | how to overwrite two dataframe in get the result like below | i have two dataframes DF1 and DF2 through pyspark, i want output like below.
DF1
Id|field_A|field_B|field_C|field_D
1 |cat |12 |black |1
2 |dog |128 |white |2
DF2
Id|field_A|field_B|field_C
1 |cat |13 |blue
OutPut required:-
DF3
Id|field_A|field_B|field_C|field_D
1 |cat |13 |blue |1
2 |dog |128 |white |2
i have tried through the join concept, but its not working through the below joins.
'inner',
'outer',
'full',
'fullouter',
'full_outer',
'leftouter',
'left',
'left_outer',
'rightouter',
'right',
'right_outer',
'leftsemi',
'left_semi',
'leftanti',
'left_anti',
'cross'.
DF3 = DF2.join(DF1, DF1.ID == DF2.ID,"leftouter") | <apache-spark><dataframe><pyspark> | 2019-05-09 17:18:36 | LQ_EDIT |
56,065,439 | Function which takes function/lambda/class with overloaded() as argument | <p>I need write a function which can take another function/lambda/class with () operator overloaded as a parametr and correctly work with them (like 3th arg of std::sort.
What it looks like in terms of C++ syntax?</p>
| <c++><function><comparator><functor> | 2019-05-09 18:21:21 | LQ_CLOSE |
56,065,463 | How to rename a dataframe with a list | <p>I have this dataset:</p>
<pre><code>library(tidyverse)
DF <- tribble(
~District, ~Income,
"District 1", 1610,
"district2", 4906,
"DISTRICT1", 12082,
"DISTRICT 1", 13791,
"district1", 21551,
"District 2", 35126,
)
DF
</code></pre>
<p>And I have a list with new variable names (in real life, I have a lot of variables).</p>
<pre><code>Nombres <- list(c("Distrito" , "Ingreso"))
</code></pre>
<p>I want to rename the dataset and my expective outcome is:</p>
<pre><code># A tibble: 6 x 2
Distrito Ingreso
<chr> <dbl>
1 District 1 1610
2 district2 4906
3 DISTRICT1 12082
4 DISTRICT 1 13791
5 district1 21551
6 District 2 35126
</code></pre>
<p>Thank you very much for your help. Greetings!</p>
| <r><list><dataframe><rename> | 2019-05-09 18:22:50 | LQ_CLOSE |
56,065,830 | Why is my dictionary value changing without me telling it to, and how do I stop it? | <p>This is my sample code:</p>
<pre><code>dict1 = {'a': 5, 'b': 6, 'c': 7}
dict2 = dict1
for i in dict1:
dict1[i] += 5
print dict1
print dict2
</code></pre>
<p>Output looks like this:</p>
<pre><code>{'a': 10, 'c': 12, 'b': 11}
{'a': 10, 'c': 12, 'b': 11}
</code></pre>
<p>Why is dict2 changing without me telling it to?</p>
<p>Python 2.7.10 on GCC 4.8.2 Linux.</p>
<p>Also tried on 2.7.12 on GCC 5.4.0, same result.</p>
| <python><python-2.7><dictionary> | 2019-05-09 18:50:06 | LQ_CLOSE |
56,066,234 | I need some advide about user type with hashmap | <p>I wrote user type as below</p>
<pre><code>class Item {
int first;
int second;
public boolean equals(Item p) {
if(first == p.first && second == p.second )
return true;
else if(first == p.second && second == p.first)
return true;
else
return false;
}
public int hashcode() {
return Objects.hash(first, second);
}
public void set(Object first, Object second) {
this.first = Integer.parseInt(first.toString());
this.second = Integer.parseInt(second.toString());
}
</code></pre>
<p>}</p>
<p>However, It doesn't work at all. Did I design the duplicate test incorrectly?</p>
| <java> | 2019-05-09 19:20:01 | LQ_CLOSE |
56,066,438 | C# How to sort string of objects by string value | <p>I have list of objects with different values int's, double's, string's.
In this case i want to sort list of objects by "name".
I done it for int's but can't by string.</p>
<p>,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,</p>
<pre><code>public void CreateMammal() // obj creating method
{
Console.WriteLine("Podaj Imie: ");
name = Console.ReadLine();
Console.WriteLine("Podaj Wiek: ");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Podaj Wagę: ");
weigth = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Podaj Kolor Futra: ");
furColour = Console.ReadLine();
ToString();
}
.
.
.
List<Animal> animals = new List<Animal>(); // list declaration
.
.
.
Mammal mammal = new Mammal();
mammal.CreateMammal();
Console.WriteLine("\n\nTwoj ssak:\n" +
mammal.ToString());
animals.Add(mammal);
.
.
.
//animals.Sort((x, y) => x."name" - y."name"); // algorytm sortowania
//printAnimals(animals);
animals.Sort(); // here we go with problem
foreach (string value in animals)
{
Console.WriteLine(value);
}
.
.
.
public static void printAnimals(List<Animal> animals)
{
foreach (var animal in animals)
{
Console.WriteLine(animal.ToString());
}
}
</code></pre>
| <c#><list><sorting> | 2019-05-09 19:35:50 | LQ_CLOSE |
56,066,832 | How to set SameSite cookie attribute to explicit None ASP NET Core | <p>Chrome 76 will begin to support an explicit <code>SameSite: None</code> attribute </p>
<p><a href="https://web.dev/samesite-cookies-explained/" rel="noreferrer">https://web.dev/samesite-cookies-explained/</a></p>
<p>I found that the current implementation of ASP.NET Core treats <code>SameSiteMode.None</code> as a no-op and does not send any attribute. How can I add a custom attribute to a cookie and thereby add an explicit <code>SameSite: None</code> to the cookie text?</p>
<p>Appending the attribute to the cookie value does not work as HttpResponse.Cookies.Append url-encodes the cookie value.</p>
| <c#><asp.net><asp.net-core> | 2019-05-09 20:08:11 | HQ |
56,067,467 | Is there a way to define an object using a function in C++? | <p>I have a function that returns an object after defining it with a class. When I call the function and then attempt to do anything with the object, it tells me that the object is undefined. Is there any way to use a function on it's own and then use the objects defined in that function?</p>
<p>Example code (Assume class has no issues):</p>
<pre><code>Class1 ReturnObject() {
Class1 Object1(1, 2);
return Object1;
}
int main() {
ReturnObject();
cout << Object1.ClassVariable1;
}
</code></pre>
| <c++><function><object><scope> | 2019-05-09 20:56:57 | LQ_CLOSE |
56,067,647 | Ada subtype equivalent in C++ | <p>Does C++ offer something similar to Ada's <code>subtype</code> to narrow a type?</p>
<p>E.g.: </p>
<pre><code>type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
subtype Working_Day is Weekday range Monday .. Friday;
</code></pre>
| <c++><ada><language-comparisons> | 2019-05-09 21:12:25 | HQ |
56,069,426 | Can a site like this be designed in full html and css? | <p>Currently the one shown is designed in html and images. Just wondering if it can be done before I can start including the center piece where it splits and turns. Doesnt have to be responsive but just be full width. I dont want to start and then be stuck where in the middle it does a split</p>
<p><a href="https://i.stack.imgur.com/H3xk4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H3xk4.jpg" alt="enter image description here"></a></p>
| <html><css><image> | 2019-05-10 01:03:26 | LQ_CLOSE |
56,072,099 | How to count sum of items, without sumimng duplicates, for 2 conditions | Related to the attached spreadsheet, (I have already created a dashboard that contains the list of regions)
Count the number of unique Items for each region IF Item Category equals N/B/C/H/P
Sum of the prices of the unique items for each region IF Item Category equals N/B/C/H/P
I have tried a bunch of combos, including Sumproduct but its not working out.[enter image description here][1]
[1]: https://i.stack.imgur.com/xz0GY.jpg | <excel><countif><sumifs> | 2019-05-10 06:42:18 | LQ_EDIT |
56,073,089 | Grouping and flattening array of objects by multiple keys | <p>I'm trying to group by and flatten this array of objects:</p>
<pre><code>const data = [
{ RoleId: 1, RoleName: 'Admin', Permissions: 1 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 38 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 4 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 18 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 4001 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 30 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 20 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 2 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 10 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 99 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 5 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 22 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 4002 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 34 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 32 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 3 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 14 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 6 },
{ RoleId: 1, RoleName: 'Admin', Permissions: 26 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 10 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 3 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 4001 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 18 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 4002 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 30 },
{ RoleId: 2, RoleName: 'AgencyAdmin', Permissions: 2 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 30 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 6 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 10 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 2 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 4002 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 18 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 3 },
{ RoleId: 3, RoleName: 'InstituteAdmin', Permissions: 4001 }
];
</code></pre>
<p>I've tried using lodash's groupBy method but I am unable to group by multiple keys and tried using zipObject as well but I was unable to get the expected results</p>
<pre><code>groupBy(data, 'RoleId')
</code></pre>
<p>Gives me an array that's grouped by the RoleId but the same doesn't work using an array of keys</p>
<p>What I want the resulting array to look like is as follows:</p>
<pre><code>[
{RoleId: 1, RoleName:'Admin', Permissions: [1, 38, 4, 18, ...]},
{RoleId: 2, RoleName:'AgencyAdmin', Permissions: [1, 38, 4, 18, ...]},
{RoleId: 3, RoleName:'InstituteAdmin', Permissions: [1, 38, 4, 18, ...]},
]
</code></pre>
<p>Does someone know how I can tackle this problem? Any help would be appreciated. Thank you!</p>
| <javascript><arrays><lodash> | 2019-05-10 07:53:38 | LQ_CLOSE |
56,073,135 | whats the assert keysize doing hear | def encryptData(key, data,mode=AESModeOfOperation.modeOfOperation["CBC"]):
"""encrypt `data` using `key`
`key` should be a string of bytes.
returned cipher is a string of bytes prepended with the initialization
vector.
"""
key = map(ord, key)
if mode == AESModeOfOperation.modeOfOperation["CBC"]:
data = append_PKCS7_padding(data)
keysize = len(key)
assert keysize in AES.keySize.values(), 'invalid key size: %s' % keysize
# create a new iv using random data
iv = [ord(i) for i in os.urandom(16)]
moo = AESModeOfOperation()
(mode, length, ciph) = moo.encrypt(data, mode, key, keysize, iv)
# With padding, the original length does not need to be known. It's a bad
# idea to store the original message length.
# prepend the iv.
return ''.join(map(chr, iv)) + ''.join(map(chr, ciph))
| <python> | 2019-05-10 07:57:29 | LQ_EDIT |
56,074,022 | Function returning blank string | <p>This function keeps on returning a blank string.</p>
<pre><code> public String getRandomWord() {
int id = (int)(Math.random())*(numberOfRows())+1;
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select word from words where id="+id+"", null );
String s = "";
if (res.moveToFirst())
s = res.getString(res.getColumnIndex("word"));
res.close();
return s;
}
</code></pre>
| <java><android><sqlite> | 2019-05-10 08:54:19 | LQ_CLOSE |
56,074,695 | How to calculate percentage of count to specific condition? | <p>I have data which look something like this.</p>
<pre><code>company date auditor change count
A 2016 ZXY 0 1
A 2015 ZXY 0 2
A 2014 ZXY 0 3
A 2013 FPQ 1 4
A 2012 ZXY 1 5
B 2017 ERW 0 1
B 2016 ERW 0 2
B 2015 ERW 0 3
B 2014 ERW 0 4
B 2013 ERW 0 5
.
.
.
.
</code></pre>
<p>This data tells whether auditor has switched in last five year. If there is switch then change value is '1'. I want to calculate</p>
<p>1) Percentage of companies who had switch in last year (count=1).</p>
<p>2) Percentage of companies who had no switch in last five year (change=0 for count=1,2,3,4,5).</p>
<p>3) Percentage of companies who experienced change more than once in five year (change=1 for count= more than once)</p>
<p>I just want the logic of how to do it.</p>
| <r><dplyr> | 2019-05-10 09:31:06 | LQ_CLOSE |
56,074,914 | i am unable to install java8 on my ubuntu gcp machine | i have tried with the commands
• sudo add-apt-repository ppa:webupd8team/java
• sudo apt-get update
• sudo apt install oracle-java8-installer
but after i could see java was not installed on my ubuntu machine.it hits the error like unable to locate package oracle-java8-installer
sudo apt install oracle-java8-installer
reading package lists...done
Building dependency tree
Reading state information...Done
E:Unable to locate package oracle-java8-installer
Hoe should i resolve this can someone tell me briefly to solve this. | <java><ubuntu><apt> | 2019-05-10 09:44:04 | LQ_EDIT |
56,077,091 | Why DOM-element <select> can't have :before or :after? | <p>I knew why inputs doesnt have it (except in Google Chrome), but why selects does not have it, when they have end tag?</p>
| <html><css> | 2019-05-10 11:47:22 | LQ_CLOSE |
56,077,156 | I'm looking for help to display a part on my database according to my previous choices in the select buttons | <p>i study the web developpement and i'm actually stuck with a problem.</p>
<p>I have two select buttons in which my database is displayed, the concern being that I would like the second select button to display only the results based on the first one. A bit like if the first button select would have inside "Numbers" and "Letters" and the second in consequences would have inside "1" "2" "3" if in the first select button we choose "Numbers" and "a" "b" "c" if we choose "Letters". I currently only have the full display of my entire database in the second and it does not do the sorting. </p>
<p>I tried a lot of thing but not realy working this is why i come here to have some help or tips.</p>
<p>I'm currently working with symfony 3.4 and on ubuntu.</p>
<p>Here is the code for my first select button:</p>
<pre><code><select id="sel1" class="formDevis" >
<option> Cliquez pour choisir </option>
{% for categorie in categories %}
<option>{{ categorie.nomCategories }}
</option>
{% endfor %}
</select>
</code></pre>
<p>Then this is the code for the second select button:</p>
<pre><code><select id="prod1" class="formDevis">
<option> Cliquez pour choisir </option>
<option>Non spécifié</option>
{% for produit in produits %}
<option>{{ produit.nomProduits }}
</option>
{% endfor %}
</select>
</code></pre>
<p>And finaly here is the code i use in my controller:</p>
<pre><code>/**
* Lists all devis entities.
*
* @Route("/", name="admin_devis_index")
* @Method("GET")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$devis = $em->getRepository('DevisBundle:Devis')->findAll();
$produits = $em->getRepository('DevisBundle:Produits')->findAll();
$categories = $em->getRepository('DevisBundle:Categories')->findAll();
return $this->render('categories/devis.html.twig', array(
'produits' => $produits,
'devis' => $devis,
'categories' => $categories
));
}
</code></pre>
<p>I tried to have on the second button select the display of my database according to the first button select but I managed to have the complete display.</p>
| <javascript><database><symfony><twig> | 2019-05-10 11:51:26 | LQ_CLOSE |
56,078,147 | Is it possiable to get Qlabel name from Qlabel text? | Our project, We have used Qlabels in different UI and different class.
like.
ui->label->setText(label_ABC);
we want to provide label name change access to the user.
default name already exists. if the user wants to change label name then first they change label_ABC to label_XYZ. this is saved in a database.
we want to replace lable_ABC to label_XYZ in all UI.
what is the best way to doing this? | <c++><qt><qlabel> | 2019-05-10 12:53:19 | LQ_EDIT |
56,079,650 | What happened to python's ~ when working with boolean? | <p>In a pandas DataFrame, I have a series of boolean values. In order to filter to rows where the boolean is True, I can use: <code>df[df.column_x]</code></p>
<p>I thought in order to filter to only rows where the column is False, I could use: <code>df[~df.column_x]</code>. I feel like I have done this before, and have seen it as the accepted answer. </p>
<p>However, this fails because <code>~df.column_x</code> converts the values to integers. See below. </p>
<pre><code>import pandas as pd . # version 0.24.2
a = pd.Series(['a', 'a', 'a', 'a', 'b', 'a', 'b', 'b', 'b', 'b'])
b = pd.Series([True, True, True, True, True, False, False, False, False, False], dtype=bool)
c = pd.DataFrame(data=[a, b]).T
c.columns = ['Classification', 'Boolean']```
print(~c.Boolean)
0 -2
1 -2
2 -2
3 -2
4 -2
5 -1
6 -1
7 -1
8 -1
9 -1
Name: Boolean, dtype: object
print(~b)
0 False
1 False
2 False
3 False
4 False
5 True
6 True
7 True
8 True
9 True
dtype: bool
</code></pre>
<p>Basically, I can use <code>c[~b]</code>, but not <code>c[~c.Boolean]</code></p>
<p>Am I just dreaming that this use to work?</p>
| <python><pandas><boolean> | 2019-05-10 14:26:38 | HQ |
56,080,506 | LocalDate.plus Incorrect Answer | <p>Java's LocalDate API seems to be giving the incorrect answer when calling <code>plus(...)</code> with a long <code>Period</code>, where I'm getting an off by one error. Am I doing something wrong here?</p>
<pre class="lang-java prettyprint-override"><code>import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.time.temporal.ChronoUnit;
public class Main
{
public static void main(String[] args)
{
// Long Period
LocalDate birthA = LocalDate.of(1965, Month.SEPTEMBER, 27);
LocalDate eventA = LocalDate.of(1992, Month.MAY, 9);
LocalDate halfA = eventA.plus(Period.between(birthA, eventA));
System.out.println(halfA); // 2018-12-21 ????
System.out.println(ChronoUnit.DAYS.between(birthA, eventA)); // 9721
System.out.println(ChronoUnit.DAYS.between(eventA, halfA)); // 9722 ????
// Short Period
LocalDate birthB = LocalDate.of(2012, Month.SEPTEMBER, 10);
LocalDate eventB = LocalDate.of(2012, Month.SEPTEMBER, 12);
LocalDate halfB = eventB.plus(Period.between(birthB, eventB));
System.out.println(halfB); // 2018-09-14
System.out.println(ChronoUnit.DAYS.between(birthB, eventB)); // 2
System.out.println(ChronoUnit.DAYS.between(eventB, halfB)); // 2
}
}
</code></pre>
| <java><java-8><localdate><off-by-one> | 2019-05-10 15:19:21 | HQ |
56,081,152 | How can I access member variables of a vector of objects that is a member variable from a class? | <p>I do know how to access member variables given a vector of objects but suppose </p>
<p>if I have a class called "layer" that is </p>
<pre><code>class layer{
public:
layer(.... that initializes "val" .... );
vector<vector<double>> getval(){return val;}
private:
vector<vector<double>> val;
}
</code></pre>
<p>and then suppose there is another class that is </p>
<pre><code>class Net{
public:
Net( ..... that initializes "nn" ..... );
vector<layer> getnn(){ return nn; }
private:
vector<layer> nn;
}
</code></pre>
<p>So in the main function, I could create an object like </p>
<pre><code>Net n( ....... )
</code></pre>
<p>and in the main function I could get vector of objects via </p>
<pre><code>n.getnn();
</code></pre>
<p>but the question is how could I get the specific, given i index, </p>
<pre><code>vector<vector<double>> val
</code></pre>
<p>at nn[i]</p>
| <c++><oop><object><pointers><vector> | 2019-05-10 16:01:59 | LQ_CLOSE |
56,081,463 | Getting address of class member function and calling it from pointer | <p>Trying to make LCD screen library for Arduino.
Made a class "ScreenHandlerClass". This has S1_stat() and S2_stat() functions that will write different things on LCD screen.
There's a "statScreenPointer", that I'm trying to make to call functions, however it does not work properly.</p>
<p>I tried to follow this guide:
<a href="https://stackoverflow.com/questions/25453259/calling-member-function-pointers">Calling Member Function Pointers</a>
That's the closest solution to my problem.
I tried:</p>
<p>this->*statScreenPointer</p>
<pre><code>Error compiling project sources
ScreenHandler.cpp: 14:26: error: invalid use of non-static member function
this->*statScreenPointer
</code></pre>
<p>Other I tried:
this->*statScreenPointer()</p>
<pre><code>Error compiling project sources
ScreenHandler.cpp: 14:27: error: must use '.*' or '->*' to call pointer-to-member function in '((ScreenHandlerClass*)this)->ScreenHandlerClass::statScreenPointer (...)', e.g. '(... ->* ((ScreenHandlerClass*)this)->ScreenHandlerClass::statScreenPointer) (...)
this->*statScreenPointer()
Build failed for project 'v1'
</code></pre>
<p>CODE:</p>
<pre><code>// ScreenHandler.h
#ifndef _SCREENHANDLER_h
#define _SCREENHANDLER_h
#include "arduino.h"
#include "debug.h"
#include "vezerles.h"
#include "EncoderHandler.h"
#include <LiquidCrystal_I2C.h>
extern EncoderHandlerClass encoder;
extern LiquidCrystal_I2C lcd;
enum screenType {
S1,
S2
};
extern screenType screen;
class ScreenHandlerClass
{
private:
void logic();
void (ScreenHandlerClass::*statScreenPointer)();
public:
ScreenHandlerClass();
void init();
void handle();
void S1_stat();
void S2_stat();
};
#endif
</code></pre>
<pre><code>// ScreenHandler.cpp
#include "ScreenHandler.h"
screenType screen;
ScreenHandlerClass::ScreenHandlerClass() {}
void ScreenHandlerClass::init() {
statScreenPointer = &ScreenHandlerClass::S1_stat;
this->*statScreenPointer; // ----> how to call this properly?
lcd.setCursor(0, 1);
lcd.print("init"); // this is DISPLAYED
}
void ScreenHandlerClass::handle()
{
logic();
}
void ScreenHandlerClass::logic()
{
// some logic for lcd screen switching
}
void ScreenHandlerClass::S1_stat() {
lcd.setCursor(0, 0);
lcd.print("S1_stat"); // this is NOT DISPLAYED
}
void ScreenHandlerClass::S2_stat() {
// some other text for lcd
}
</code></pre>
<pre><code>// v1.ino
#include "debug.h"
#include "global.h"
#include <TimerOne.h>
#include <LiquidCrystal_I2C.h>
#include "MillisTimer.h"
#include "vezerles.h"
#include "lcd.h"
#include "EncoderHandler.h"
#include "ScreenHandler.h"
extern EncoderHandlerClass encoder;
ScreenHandlerClass scrh;
LiquidCrystal_I2C lcd(0x3F, 20, 4);
void setup() {
Serial.begin(9600);
encoder.initButton(PIND, PD4, 500);
lcd.init();
lcd.backlight();
scrh.init();
}
void loop() {
// some code
}
</code></pre>
| <c++><arduino><function-pointers><member-function-pointers> | 2019-05-10 16:24:16 | LQ_CLOSE |
56,082,688 | How will I pass ranges instead of iterator-pairs in C++20? | <p>I've heard that C++20 will support acting on ranges, not just begin+end iterator pairs. Does that mean that, in C++20, I'll be able to write:</p>
<pre><code>std::vector<int> vec = get_vector_from_somewhere();
std::sort(vec);
std::vector<float> halves;
halves.reserve(vec.size());
std::transform(
vec, std::back_inserter(halves),
[](int x) { return x * 0.5; }
);
</code></pre>
<p>?</p>
| <c++><range><c++20> | 2019-05-10 18:00:06 | HQ |
56,083,140 | How can I compile this program in C with Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC | <p>Hello everyone Im triying to compile a C program correctly, but when I run the program throw the Error Ivalid Argument.</p>
<p>Im tried to put the architecture type like -xarch=sparc or -m64 but nothing</p>
<pre><code>bash-3.2$ cc -c Prueba.c -o Prueba.o -xarch=sparc
bash-3.2$ chmod 777 Prueba.o
bash-3.2$ ./Prueba.o
bash: ./Prueba.o: Invalid argument
bash-3.2$ cat /etc/release
Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
Assembled 17 January 2013
</code></pre>
| <c><solaris><sparc> | 2019-05-10 18:35:45 | LQ_CLOSE |
56,084,133 | Run a java application on linux | <p>I have created a java application run by main.
My development is done by Eclipse on PC and I would like to run it on linux scheduled by cronjob.
The application has dependencies. Some classes are self-created. Some are external jars.
What is the most convenient way to compile it to include all dependencies and put it on the linux?</p>
<p>Thanks</p>
| <java><eclipse> | 2019-05-10 20:01:49 | LQ_CLOSE |
56,084,945 | Session cleared, yet page still recognizes the user | <p>I'm using the simple chat code from here <a href="https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931" rel="nofollow noreferrer">https://code.tutsplus.com/tutorials/how-to-create-a-simple-web-based-chat-application--net-5931</a></p>
<p>It works, but the problem is that I want to show login form every time the user refreshes the page or closes the tab and then re-opens it.
Currently, I see login form only the first time I open the page and subsequently, the browser (both Chrome and Firefox) recognize the user.</p>
<p>Clearing cookies hasn't help.
Clearing the session in PHP ($_SESSION = array();) hasn't helped either.</p>
<p>Please, advise how to show the login form every time the user refreshes or closes and re-opens the tab.
Thank you!</p>
| <php><jquery><ajax><chat> | 2019-05-10 21:17:02 | LQ_CLOSE |
56,085,306 | Error Message: "An interface can only extend an object type or intersection of object types with statically known members" | <p>The following code:</p>
<pre class="lang-js prettyprint-override"><code>export type Partial2DPoint = { x: number } | { y: number }
export interface Partial3DPoint extends Partial2DPoint {
z: number
}
</code></pre>
<p>Fails with the following error:</p>
<blockquote>
<p>An interface can only extend an object type or intersection of object types with statically known members.</p>
</blockquote>
<p>Why is this happening?</p>
| <typescript> | 2019-05-10 21:57:45 | HQ |
56,085,545 | How do i filter out 'items' that doesn't match search result? | Show items with the same value as the search input, and hide if the value isn't the same.
function Search() {
var z = document.getElementById('inputSearch').value;
if (z == itemTitle)
} | <javascript><arrays><object> | 2019-05-10 22:28:43 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.