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 |
|---|---|---|---|---|---|
35,965,665 | A* algorithm sorting the spaces so i can get teh shortest and add to the openlist, closedlist which i have not yet created | ok so im trying to create a A* algorithm path finder. issue that i have is how do i sort which has teh lowest distance from the bot's space options from the goal.
here is my space class, bot class, goal class, and pathfinder class. its not really ordered but here it is. see if you can lead me in the right direction. this goes all under one src.
public class Space {
private int distance;
private int x;
private int y;
public Space(int x, int y){
int distancex =Math.abs((x) - Goal.getX());
int distancey= Math.abs((y) - Goal.getY());
this.x = x;
this.y = y;
this.distance = (distancex + distancey);
}
public int getDistance() {
return distance;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}
this is the pathfinder class.
import java.util.*;
public class Pathfinder {
public static void main(String[] args) {
// TODO Auto-generated method stub
Bot Dave = new Bot("Dave");
Goal goal = new Goal();
System.out.println("Dave's x positon is " + Dave.getX() +"and his y position is "+ Dave.getY());
System.out.println("the left space of the bot is " + Dave.checkleft(Dave.getX(), Dave.getY()));
System.out.println("the right space of the bot is " + Dave.checkright(Dave.getX(), Dave.getY()));
System.out.println("the bottom space of the bot is " + Dave.checkbottom(Dave.getX(), Dave.getY()));
System.out.println("the top space of the bot is " + Dave.checkbottom(Dave.getX(), Dave.getY()));
Space right = new Space(Dave.getX()+1, Dave.getY());
Space left = new Space(Dave.getX()-1, Dave.getY());
Space up = new Space(Dave.getX(), Dave.getY()+1);
Space down = new Space(Dave.getX(), Dave.getY()-1);
}
}
this is the bot class
import java.util.*;
public class Bot {
private int x;
private int y;
private String name;
public Bot(String Name){
this.name = Name;
this.x =(int) (Math.random()*100);
this.y =(int) (Math.random()*100);
}
public String getName() {
return name;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int checktop(int x, int y){
int distancex =Math.abs((x) - Goal.getX());
int distancey= Math.abs((y+1) - Goal.getY());
return (distancex + distancey);
}public int checkbottom(int x, int y){
int distancex =Math.abs(x - Goal.getX());
int distancey= Math.abs((y-1) - Goal.getY());
return (distancex + distancey);
}
public int checkright(int x, int y){
int distancex =Math.abs((x+1) - Goal.getX());
int distancey= Math.abs(y - Goal.getY());
return (distancex + distancey);
}
public int checkleft(int x, int y){
int distancex =Math.abs((x-1) - Goal.getX());
int distancey= Math.abs(y - Goal.getY());
return (distancex + distancey);
}
}
this is the goal class
public class Goal {
private static int x;
private static int y;
public Goal(){
this.x=(int) (Math.random()*100);
this.y =(int) (Math.random()*100);
}
public static int getX() {
return x;
}
public static int getY() {
return y;
}
} | <java><algorithm><sorting> | 2016-03-13 02:11:17 | LQ_EDIT |
35,966,447 | Kotlin: How to extend the enum class with an extension function | <p>I'm trying to extend enum classes of type <code>String</code> with the following function but am unable to use it at the call site like so: </p>
<pre><code>fun <T: Enum<String>> Class<T>.join(skipFirst: Int = 0, skipLast: Int = 0): String {
return this.enumConstants
.drop(skipFirst)
.dropLast(skipLast)
.map { e -> e.name }
.joinToString()
}
MyStringEnum.join(1, 1);
</code></pre>
<p>What am I doing wrong here?</p>
| <enums><kotlin><kotlin-extension> | 2016-03-13 04:24:45 | HQ |
35,966,605 | Using Laravel Socialite with an API? | <p>I'm trying to use Laravel Socialite package over an api. I try to pass the code into my api to fetch the user but it keeps giving me an error:</p>
<pre><code>Fatal error: Call to a member function pull() on null
</code></pre>
<p>Since I'm doing the request over an API, I take the following steps.</p>
<p>Send a request to api for the url to fetch the code:</p>
<pre><code>Socialite::with('facebook')->stateless()->redirect()->getTargetUrl()
</code></pre>
<p>Then make a request with the above fetched url, which redirects with the <code>code</code> parameter.</p>
<p>Send the code to the api and fetch the user:</p>
<pre><code>$fb_user = Socialite::with('facebook')->user();
</code></pre>
<p>This is where it crashes. I'm not sure why. </p>
<p>I've used the package before and it works fine when I just have an app that reloads the page. But when I send it to an api (on a different domain) it crashes. I'm thinking there is some issue with how the code is generated. Is there anyway to fix this?</p>
| <php><laravel><laravel-socialite> | 2016-03-13 04:47:02 | HQ |
35,966,844 | PreferenceFragmentCompat custom layout | <p>I need a custom layout for my PreferenceFragmentCompat. In the docs for <a href="http://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.html#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)" rel="noreferrer">PreferenceFragmentCompat</a> it seems that you can possibly inflate and return a view in onCreateView().</p>
<p>However a NPE results:-</p>
<pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setAdapter(android.support.v7.widget.RecyclerView$Adapter)' on a null object reference
at android.support.v7.preference.PreferenceFragmentCompat.bindPreferences(PreferenceFragmentCompat.java:511)
at android.support.v7.preference.PreferenceFragmentCompat.onActivityCreated(PreferenceFragmentCompat.java:316)
at com.cls.example.MyPrefFrag.onActivityCreated(MyPrefFrag.java:42)
</code></pre>
<p>After I checked the source of PreferenceFragmentCompat:onCreateView I found the following piece of code :-</p>
<pre><code> RecyclerView listView = this.onCreateRecyclerView(themedInflater, listContainer, savedInstanceState);
if(listView == null) {
throw new RuntimeException("Could not create RecyclerView");
} else {
this.mList = listView; //problem
...
return view;
}
</code></pre>
<p>So if you override onCreateView() and return a custom layout the onCreateRecyclerView() is not called plus the RecyclerView private field mList will not be set. So the NPE on setAdapter() results.</p>
<p>Should I assume that having a custom layout is not feasible for PreferenceFragmentCompat ?</p>
| <android><android-support-library><preferencefragment> | 2016-03-13 05:25:42 | HQ |
35,967,109 | How to compare the length of a list in html/template in golang? | <p>I am trying to compare the length of a list in golang html/template. But it is loading forever in html.</p>
<pre><code>{{ $length := len .SearchData }} {{ if eq $length "0" }}
Sorry. No matching results found
{{ end }}
</code></pre>
<p>Could anyone help me with this?</p>
| <html><go><equals><go-html-template> | 2016-03-13 06:06:50 | HQ |
35,967,277 | how to past value from textview to a variable for others activities in android | i having problem to assign a Text-view result[from database] to a new variable.
Text-view retrieve data from database no issue.
Now issue is i need to link the value in the Text-view to a new variable. Then use button function for my next activity.
| <android> | 2016-03-13 06:30:05 | LQ_EDIT |
35,968,047 | Using webpack, threejs examples, and typescript? | <p>I'm having a lot of trouble getting stuff in threejs's examples (like EffectComposer or Detector) to work with webpack and typescript.</p>
<p>First off the relevant <code>*.d.ts</code> files are all present and installed via <code>tsd</code>. My problem is getting webpack to actually include files outside of the default threejs build (namely things in <code>examples/js/</code>).</p>
<p>With <code>three</code> installed from npm I can do something like</p>
<pre><code>import THREE = require('three');
</code></pre>
<p>Which works fine but lacks any of the aforementioned goodies. There are a few other threejs packages on npm that bundle plugins but I don't think they work with typescript (since <code>require('three-js')(['EffectComposer'])</code> is rejected by the typescript compiler.</p>
<p>Has anyone gotten something in this package (like postprocessing) to work with typescript?</p>
| <typescript><three.js><webpack> | 2016-03-13 08:12:02 | HQ |
35,968,310 | Java Scanner won't read through the whole file | <p>So I'm trying to read through a whole file and print its content, which it does. But when I go through it again with a new Scanner to print the content with some section names, it only goes through some of the file.</p>
<p>Here's my code:</p>
<pre><code>import java.util.*;
import java.io.*;
public class FileReader {
public static void main(String[] args) throws FileNotFoundException {
Scanner read = new Scanner(new File("sample.txt"));
while(read.hasNextLine()) {
System.out.println(read.nextLine());
}
System.out.println();
Scanner read2 = new Scanner(new File("sample.txt"));
int numQuestions = read2.nextInt();
System.out.println("Numbers of questions: " + numQuestions);
System.out.println();
while(read2.hasNextLine()) {
int points, numChoices;
String question, answer;
if(read2.next().equals("TF")) {
points = read2.nextInt();
System.out.println("Points for TF: " + points);
read2.nextLine(); // must be done because it does not consume the \n character
question = read2.nextLine();
System.out.println("Question for TF: " + question);
answer = read2.next();
System.out.println("Answer for TF: " + answer);
}
else if(read2.next().equals("SA")) {
points = read2.nextInt();
System.out.println("Points for SA: " + points);
read2.nextLine(); // must be done because it does not consume the \n character
question = read2.nextLine();
System.out.println("Question for SA: " + question);
answer = read2.next();
System.out.println("Answer for SA: " + answer);
}
else if(read2.next().equals("MC")) {
points = read2.nextInt();
System.out.println("Points for MC: " + points);
read2.nextLine(); // must be done because it does not consume the \n character
question = read2.nextLine();
System.out.println("Question for MC: " + question);
read2.nextLine();
numChoices = read2.nextInt();
for(int i = 0; i < numChoices; i++) {
System.out.println(read2.nextLine());
}
answer = read2.next();
System.out.println("Answer for MC: " + answer);
}
}
}
}
</code></pre>
<p>Here's the file I'm reading from:</p>
<pre><code>3
TF 5
There exist birds that can not fly. (true/false)
true
MC 10
Who was the president of the USA in 1991?
6
Richard Nixon
Gerald Ford
Jimmy Carter
Ronald Reagan
George Bush Sr.
Bill Clinton
E
SA 20
What city hosted the 2004 Summer Olympics?
Athens
</code></pre>
<p>And here is the output I get:</p>
<pre><code>3
TF 5
There exist birds that can not fly. (true/false)
true
MC 10
Who was the president of the USA in 1991?
6
Richard Nixon
Gerald Ford
Jimmy Carter
Ronald Reagan
George Bush Sr.
Bill Clinton
E
SA 20
What city hosted the 2004 Summer Olympics?
Athens
Numbers of questions: 3
Points for TF: 5
Question for TF: There exist birds that can not fly. (true/false)
Answer for TF: true
</code></pre>
<p>As you can see, the first <code>Scanner</code> reads through the whole file and prints it. But when I try for the second time with the section names, it only goes through question 1's part.</p>
| <java><file><java.util.scanner> | 2016-03-13 08:47:37 | LQ_CLOSE |
35,968,611 | UVA.112 Tree Summing and Runtime Error | For a couple of weeks ago, I got some homeworks from my university and the thing is that, though other problems are accepted on the uva, I cannot figure out what is going wrong with this problem. I've already run the input from udebug website and there was no problem. I double-checked the result and now, I'm sick and tired of solving this issue.
Here are details about what has happeded. First of all, I increase the BUFSIZE to 2^20 in order to avoid any memory overflow. The result? Failed. Second, I downsized the size of the element in the stack I made. The result? Failed. Lastly, I removed an eol character of the result just in case. The result? Failed.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define BUFSIZE 16384
typedef struct node {
int element[BUFSIZE];
int size;
int current;
}Stack;
static Stack *stack;
static int level;
static int integer;
bool initialize(void) {
if (stack == NULL)
stack = (Stack *)malloc(sizeof(Stack));
stack->size = BUFSIZE;
stack->current = 0;
return true;
}
bool push(int number) {
if (stack == NULL)
return false;
if ((stack->current + 1) > stack->size)
return false;
stack->element[stack->current] = number;
stack->current++;
return true;
}
int pop() {
if (stack->current <= 0)
return 0xFFFFFFFF;
stack->current--;
return stack->element[stack->current];
}
int sum() {
int result = 0;
int i;
if (stack == NULL)
return 0xFFFFFFFF;
if (stack->current == 0)
return 0xFFFFFFFF;
for (i = 0; i < stack->current; i++)
result += stack->element[i];
return result;
}
void replace(char * o_string, char * s_string, char * r_string) {
char *buffer = (char *)calloc(BUFSIZE, sizeof(char));
char * ch;
if (!(ch = strstr(o_string, s_string)))
return;
strncpy(buffer, o_string, ch - o_string);
buffer[ch - o_string] = 0;
sprintf(buffer + (ch - o_string), "%s%s", r_string, ch + strlen(s_string));
o_string[0] = 0;
strcpy(o_string, buffer);
free(buffer);
return replace(o_string, s_string, r_string);
}
int main(void) {
char *buffer;
char *line;
char *restOfTheString;
char *token;
bool checked = false, found = false;
int i = 0, j = 0, scannedInteger, result = 0, array[4096];
buffer = (char *)calloc(BUFSIZE, sizeof(char));
restOfTheString = (char *)calloc(BUFSIZE, sizeof(char));
line = (char *)calloc(BUFSIZE, sizeof(char));
memset(buffer, 0, BUFSIZE);
for (i = 0; i < 4096; i++) {
array[i] = -1;
}
level = 0;
integer = 0;
while (fgets(line, sizeof(line), stdin) != NULL) {
if (line[0] != '\n') {
token = strtok(line, "\n");
if (strlen(line) >= 1) {
strcat(buffer, token);
}
}
}
replace(buffer, " ", "");
replace(buffer, "()()", "K");
strcpy(restOfTheString, buffer);
i = 0;
while (restOfTheString[i] != 0) {
if (level == 0 && !checked) {
initialize();
sscanf(&restOfTheString[i], "%d%s", &integer, &restOfTheString[0]);
i = -1;
checked = true;
}
if (restOfTheString[i] == '(') {
checked = false;
level++;
}
else if (restOfTheString[i] == ')') {
if (restOfTheString[i - 1] != '(')
if (pop() == 0xFFFFFFFF)
return 0;
level--;
if (!found && level == 0) {
array[j] = 0;
j++;
free(stack);
stack = NULL;
}
else if (found && level == 0) {
array[j] = 1;
j++;
free(stack);
stack = NULL;
found = false;
}
}
else if (restOfTheString[i] == '-' && !checked) {
if (sscanf(&restOfTheString[i], "%d%s", &scannedInteger, &restOfTheString[0]) == 2) {
if (push(scannedInteger) == false)
return 0;
i = -1;
}
}
else if (restOfTheString[i] >= 48 && restOfTheString[i] <= 57 && !checked) {
if (sscanf(&restOfTheString[i], "%d%s", &scannedInteger, &restOfTheString[0]) == 2) {
if (push(scannedInteger) == false)
return 0;
i = -1;
}
}
else if (restOfTheString[i] == 'K') {
if ((result = sum()) == 0xFFFFFFFF)
return 0;
if (result == integer) {
found = true;
}
}
i++;
}
i = 0;
while (array[i] != -1) {
if (array[i] == 1)
printf("yes\n");
else if (array[i] == 0)
printf("no\n");
i++;
}
return 0;
}
Though it is cleary suspicious about the memory usage, I don't know how to track the stack on my system. So if you guys have any idea about this problem, please help me cause I'm stuck and the deadline of this homework is within the next 18 hous.
Thanks
| <c><algorithm> | 2016-03-13 09:26:10 | LQ_EDIT |
35,968,766 | How to figure out which SIM received SMS in Dual SIM Android Device | <p>I'm working on a project to sync sms received in a Android phone to a online database. I can get sender's number by calling <code>getOriginatingAddress()</code> method. But I can't find any solution to figure out which SIM in my device received the sms.</p>
<p>I searched the web about it, but couldn't find a way to figure this out. Is there any way to get SMS receiver's number?</p>
| <android><sms><telephonymanager> | 2016-03-13 09:45:29 | HQ |
35,968,781 | why c accept a string in a int variable | <p>This is my first question here, sorry if I did something wrong.
I have to make a program that identify the classification of a swimmer. The program does this, but when i write a string, it accept like a int variable.
why this happens and how I fix this.
thanks </p>
<pre><code>printf("Write the age of the swimmer\n");
scanf("%d", &age);
if(age < 5)
printf("minimum age is five years old\n");
else if(age >= 5 && age <= 7)
printf("Category: child A\n");
else if(age >= 8 && age <= 11)
printf("Category: child B\n");
else if(age >= 12 && age <= 13)
printf("Category: Juvenile A\n");
else if(age >= 14 && age <= 17)
printf("Category: Juvenile A\n");
else if(age >= 18)
printf("Category: Adult\n");
else
printf("Write only numbers\n");
system("PAUSE");
return 0;
</code></pre>
| <c> | 2016-03-13 09:47:08 | LQ_CLOSE |
35,969,359 | How To Create MS Word Macro To Check Bold Paragraphs And Add Comments For Each | I've tried to create a macro to check bold paragraphs and add comments for each by using macro record function in word application. But it's not work for me.
I need to create a macro for below criteria.
01. Search all bold paragraphs + without keep with next.
02. Then Add comments for each bold + without keep with next. (Ex Comment: Check Keep With Next)
How do I do this. | <vba><ms-word> | 2016-03-13 10:57:00 | LQ_EDIT |
35,969,495 | React.js How to render component inside component? | <p>I am stuck. I have several seperate components on seperate files. If I render them in main.jsx like following: </p>
<pre><code>ReactDOM.render(<LandingPageBox/>, document.getElementById("page-landing"));
ReactDOM.render(<TopPlayerBox topPlayersData={topPlayersData}/>, document.getElementById("wrapper profile-data-wrapper"));
ReactDOM.render(<RecentGamesBox recentGamesData={recentGamesData}/>, document.getElementById("history wrapper"));
</code></pre>
<p>Everything works fine, but I wonder if it is a good practice? Maybe it is possible to do something like there would be only one ReactDom.render like: </p>
<pre><code>ReactDOM.render(<LandingPageBox recentGamesData={recentGamesData} topPlayersData={topPlayersData}/>, document.getElementById("page-landing"));
</code></pre>
<p>I tried different kinds of variatons of LandingPageBox to somehow include those other two components, but had no luck. They sometimes rendered outside the page and so on. I thought it should look something like this:</p>
<pre><code>import React from 'react';
import RecentGames from '../RecentGames/RecentGames.jsx';
import TopPlayers from '../TopPlayers/TopPlayers.jsx';
import PageTop from './PageTop.jsx';
import PageBottom from './PageBottom.jsx';
class LandingPageBox extends React.Component {
render() {
return (
<body className="page-landing">
<PageTop>
<TopPlayers topPlayersData={this.props.topPlayersData} />
</PageTop>
<PageBottom>
<RecentGames recentGamesData= {this.props.recentGamesData}/>
</PageBottom>
</body>
);
}
}
export default LandingPageBox;
</code></pre>
<p>But this code only renders PageTop and PageBottom, without player or game components. </p>
<p>So my question would be, how to set up LandingPageBox file so that TopPlayers component would render inside PageTop component and RecentGames component would render inside PageBottom component? Thank you.</p>
| <javascript><reactjs> | 2016-03-13 11:10:06 | HQ |
35,969,508 | Git. How to download new project file? | for example, in a project by another developer a new file was added. How using TortoiseGit I can download the file to your local repository? | <git><tortoisegit> | 2016-03-13 11:11:39 | LQ_EDIT |
35,969,730 | How to read output from cmd.exe using CreateProcess() and CreatePipe() | <blockquote>
<p>How to read output from cmd.exe using CreateProcess() and CreatePipe() </p>
</blockquote>
<p>I have been trying to create a child process executing <code>cmd.exe</code> with a command-line designating <code>/K dir</code>. The purpose is to read the output from the command back into the parent process using pipes. </p>
<p>I've already got <code>CreateProcess()</code> working, however the step involving pipes are causing me trouble. Using pipes, the new console window is not displaying (like it was before), and the parent process is stuck in the call to <code>ReadFile()</code>.</p>
<p>Does anyone have an idea of what I'm doing wrong?</p>
<pre><code>#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#define BUFFSZ 4096
HANDLE g_hChildStd_IN_Rd = NULL;
HANDLE g_hChildStd_IN_Wr = NULL;
HANDLE g_hChildStd_OUT_Rd = NULL;
HANDLE g_hChildStd_OUT_Wr = NULL;
int wmain(int argc, wchar_t* argv[])
{
int result;
wchar_t aCmd[BUFFSZ] = TEXT("/K dir"); // CMD /?
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES sa;
printf("Starting...\n");
ZeroMemory(&si, sizeof(STARTUPINFO));
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
// Create one-way pipe for child process STDOUT
if (!CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &sa, 0)) {
printf("CreatePipe() error: %ld\n", GetLastError());
}
// Ensure read handle to pipe for STDOUT is not inherited
if (!SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)) {
printf("SetHandleInformation() error: %ld\n", GetLastError());
}
// Create one-way pipe for child process STDIN
if (!CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &sa, 0)) {
printf("CreatePipe() error: %ld\n", GetLastError());
}
// Ensure write handle to pipe for STDIN is not inherited
if (!SetHandleInformation(g_hChildStd_IN_Rd, HANDLE_FLAG_INHERIT, 0)) {
printf("SetHandleInformation() error: %ld\n", GetLastError());
}
si.cb = sizeof(STARTUPINFO);
si.hStdError = g_hChildStd_OUT_Wr;
si.hStdOutput = g_hChildStd_OUT_Wr;
si.hStdInput = g_hChildStd_IN_Rd;
si.dwFlags |= STARTF_USESTDHANDLES;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
// Pipe handles are inherited
sa.bInheritHandle = true;
// Creates a child process
result = CreateProcess(
TEXT("C:\\Windows\\System32\\cmd.exe"), // Module
aCmd, // Command-line
NULL, // Process security attributes
NULL, // Primary thread security attributes
true, // Handles are inherited
CREATE_NEW_CONSOLE, // Creation flags
NULL, // Environment (use parent)
NULL, // Current directory (use parent)
&si, // STARTUPINFO pointer
&pi // PROCESS_INFORMATION pointer
);
if (result) {
printf("Child process has been created...\n");
}
else {
printf("Child process could not be created\n");
}
bool bStatus;
CHAR aBuf[BUFFSZ + 1];
DWORD dwRead;
DWORD dwWrite;
// GetStdHandle(STD_OUTPUT_HANDLE)
while (true) {
bStatus = ReadFile(g_hChildStd_OUT_Rd, aBuf, sizeof(aBuf), &dwRead, NULL);
if (!bStatus || dwRead == 0) {
break;
}
aBuf[dwRead] = '\0';
printf("%s\n", aBuf);
}
// Wait until child process exits
WaitForSingleObject(pi.hProcess, INFINITE);
// Close process and thread handles
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
printf("Stopping...\n");
return 0;
}
</code></pre>
| <c++><windows><cmd> | 2016-03-13 11:35:54 | HQ |
35,969,852 | Don't work colspan or rowspan in trable html | I don't span a cells "cell1_1" and "cell1_2". When I'm use colspan="2" at #cell1_1 it don't work. My [example](https://jsfiddle.net/Erush/xcwk3d09/)
I try use [method](http://stackoverflow.com/questions/15571556/html-colspan-rowspan?answertab=votes#tab-top) at [jsfiddler](http://jsfiddle.net/Tyriar/tAsbE/)
,but don't work tag `br` when I use rowspan.
<br>I don't understand how working skipping cells?
<br>But can't find solution! Please help! | <html><html-table> | 2016-03-13 11:48:13 | LQ_EDIT |
35,970,521 | gcc bug? It inexplicably decays array to pointer, while clang does not | <p>This is a simplified version which illustrate the problem:</p>
<pre><code>struct Foo {
Foo() = default;
template <std::size_t N>
Foo(const char(&)[N]) {}
};
template <std::size_t N>
auto foo(const char (&arr)[N]) -> Foo
{
return arr;
}
auto main() -> int
{
foo("Stack Overflow");
}
</code></pre>
<p>g++ seems to decay <code>arr</code> to <code>const char *</code>, although an array reference argument is passed to an array reference parameter . It gives this error:</p>
<blockquote>
<p>In instantiation of <code>Foo foo(const char (&)[N]) [with long unsigned
int N = 4ul]</code>:</p>
<p>error: could not convert <code>(const char*)arr</code> from <code>const char*</code> to
<code>Foo</code></p>
<pre><code> return arr;
^
</code></pre>
</blockquote>
<p>While clang++ behaves how I expect and compiles the code.</p>
<p>The code compiles fine on gcc with any of those modifications:</p>
<pre><code>return {arr};
return Foo(arr);
return (Foo)arr;
return static_cast<Foo>(arr);
</code></pre>
<p>Is it a gcc bug?</p>
<p>Tried it with <del>all</del> g++ and clang++ versions which support <code>c++14</code>.(*)</p>
<p>(*) I just tried it with a snapshot of <code>gcc 6</code> and it compiles OK. So it does look like a bug fixed in <code>gcc 6</code></p>
| <c++><g++><language-lawyer><c++14><clang++> | 2016-03-13 12:57:33 | HQ |
35,970,686 | Ansible: SSH Error: unix_listener: too long for Unix domain socket | <p>This is a known issue and I found a solution but it's not working for me.</p>
<p>First I had:</p>
<pre><code>fatal: [openshift-node-compute-e50xx] => SSH Error: ControlPath too long
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
</code></pre>
<p>So I created a <code>~/.ansible.cfg</code>. The content of it:</p>
<pre><code>[ssh_connection]
control_path=%(directory)s/%%h‐%%r
</code></pre>
<p>But after rerunning my ansible I stil have an error about 'too long'.</p>
<pre><code>fatal: [openshift-master-32axx] => SSH Error: unix_listener: "/Users/myuser/.ansible/cp/ec2-xx-xx-xx-xx.eu-central-1.compute.amazonaws.com-centos.AAZFTHkT5xXXXXXX" too long for Unix domain socket
while connecting to 52.xx.xx.xx:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
</code></pre>
<p>Why is it still too long?</p>
| <ssh><amazon-ec2><ansible> | 2016-03-13 13:14:54 | HQ |
35,970,727 | Use of variables like %{buildDir} in QtCreator kit settings in Qt5 | <p>In <a href="http://doc.qt.io/qtcreator/creator-run-settings.html" rel="noreferrer">this documentation</a> (under section "Specifying a Custom Executable to Run") I noticed that there is mention of what looks like a variable <code>%{buildDir}</code> in the field "Working directory".</p>
<p><a href="https://i.stack.imgur.com/dShAh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dShAh.png" alt="enter image description here"></a></p>
<p>I have struggled for a while now to find documentation for this feature. I would like to know first of all <strong>is there documentation for this somewhere?</strong>.</p>
<p>Secondary questions: </p>
<ul>
<li>What other variables are available?</li>
<li>In which fields can they be used?</li>
<li>Can I access variables that I created in my project's <code>.pro</code> file?</li>
<li>Are there any other eval features or is this mechanism limited to variables?</li>
</ul>
<p>Thanks!</p>
| <qt><variables><qt5><qt-creator><eval> | 2016-03-13 13:20:30 | HQ |
35,970,970 | Django rest framework permission_classes of ViewSet method | <p>I'm writing a rest API with the Django REST framework, and I'd like to protect certain endpoints with permissions. The permission classes look like they provide an elegant way to accomplish this. My problem is that I'd like to use different permission classes for different overridden ViewSet methods.</p>
<pre><code>class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
def create(self, request, *args, **kwargs):
return super(UserViewSet, self).create(request, *args, **kwargs)
@decorators.permission_classes(permissions.IsAdminUser)
def list(self, request, *args, **kwargs):
return super(UserViewSet, self).list(request, *args, **kwargs)
</code></pre>
<p>In the code above I'd like to allow registration (user creation) for unauthenticated users too, but I don't want to let list users to anyone, just for staff.</p>
<p>In the <a href="http://www.django-rest-framework.org/api-guide/permissions/" rel="noreferrer">docs</a> I saw examples for protecting API views (not ViewSet methods) with the <code>permission_classes</code> decorator, and I saw setting a permission classes for the whole ViewSet. But it seems not working on overridden ViewSet methods. Is there any way to only use them for certain endpoints? </p>
| <python><django><rest><django-rest-framework> | 2016-03-13 13:42:32 | HQ |
35,971,024 | Can i turn my eclipse project into linux application? | <p>Right now I'm working on a app, using eclipse on windows 10. I want to know can i turn my project into a linux runable file?</p>
| <java> | 2016-03-13 13:47:36 | LQ_CLOSE |
35,971,452 | What is the right way to send Alt + Tab in Ahk? | <p>Ok. I know this is a very stupid question.
But I'm stuck already for an hour.</p>
<p>I got very little experience with ahk, however I made work every script until now with no problems. I explored the ahk tutorials but found no solution up to now.</p>
<p>I'm trying to switch to prev. app with a single numpad off key.
I've tried:</p>
<pre><code>!{Tab}
</code></pre>
<p>,</p>
<pre><code>{Alt down}{Tab}{Alt up}
</code></pre>
<p>I've tried it with Sleep delays, multiline, multiline inside brackets, with and without commas after commands, etc.</p>
<p>I'm quite sure is very simple but something I've not tried yet.</p>
<p>Any suggestion?</p>
| <autohotkey> | 2016-03-13 14:27:44 | HQ |
35,971,589 | Angular 2 ngModelChange select option, grab a specific property | <p>I have a dropdown select form in angular 2. </p>
<p>Currently: When I select an option the <code>option name</code> gets passed into my <code>onChange</code> function as <code>$event</code> </p>
<p>Wanted: When I select an option I would like to pass <code>workout.id</code> into my <code>onChange</code> function. </p>
<p>How can I achieve that?</p>
<pre><code><select class="form-control" [ngModel]="selectedWorkout" (ngModelChange)="onChange($event)">
<option *ngFor="#workout of workouts">{{workout.name}}</option>
</select>
</code></pre>
<p><code>Controller</code></p>
<pre><code>onChange(value){
alert(JSON.stringify(value));
}
</code></pre>
| <angular> | 2016-03-13 14:41:02 | HQ |
35,972,270 | Dagger 2: Unable to inject singleton in other scope | <p>I have Singleton scoped module that provides some standard singletons: Application, DB services, etc.
But for Activity I have separate module that should create Presenter for he Activity and I need to pass Application context to it. However I get following error when trying to compile the project:</p>
<pre><code>Error:(13, 1) error: xxx.SplashComponent scoped with @xxx.ViewScope may not reference bindings with different scopes:
@Provides @Singleton xxx.ApplicationModule.provideAppContext()
</code></pre>
<p>Here is snippet of my Application module:</p>
<pre><code>@Singleton
@Module
public class ApplicationModule {
private Application app;
public ApplicationModule(Application app) {
this.app = app;
}
@Provides
@Singleton
@Named("ui")
Scheduler provideUIScheduler() {
return AndroidSchedulers.mainThread();
}
@Provides
@Singleton
@Named("io")
Scheduler provideIOScheduler() {
return Schedulers.io();
}
@Provides
@Singleton
Application provideApplication() {
return app;
}
@Provides
@Singleton
Context provideAppContext() {
return app;
}
}
</code></pre>
<p>And here is Activity module and Component:</p>
<pre><code>@Module
public class SplashModule {
private final FragmentManager fragmentManager;
public SplashModule(FragmentManager fragmentManager) {
this.fragmentManager = fragmentManager;
}
@Provides
@ViewScope
Presenter getPresenter(Context context) {
return new SplashPresenter(context, fragmentManager);
}
}
</code></pre>
<p>Component:</p>
<pre><code>@ViewScope
@Component(modules = {SplashModule.class, ApplicationModule.class})
public interface SplashComponent {
void inject(SplashActivity activity);
}
</code></pre>
<p>What am I doing wrong?</p>
| <android><dagger-2> | 2016-03-13 15:44:07 | HQ |
35,972,859 | Some questions about PDO, safety and correct syntax | <p>I apologize if this may be a ready-made topic, but I need an answer in detail. I would like to learn to program in PDO, but I have lots of bases being self-taught.</p>
<p>I have a few simple questions:</p>
<p>1) Program in PDO is equally satisfying to create your own scripts or is an old and unsafe method? Schedule in OOP when I get quite complex.</p>
<p>2) programming in PDO, what are the correct Prepared Statement to be written? Pass the data-bind?</p>
<p>3) As an example of security, this script for login and user registration using a library to encrypt your password, so it is quite safe against attacks? </p>
<p><a href="http://thisinterestsme.com/php-user-registration-form/" rel="nofollow">http://thisinterestsme.com/php-user-registration-form/</a></p>
<p>I repeat, I know that I would find some answers to my questions, but I need answers to my details, thanks.</p>
| <php><mysql><pdo> | 2016-03-13 16:41:18 | LQ_CLOSE |
35,973,094 | C# Not responding | I would just like to say that this is my first windows form application so bare with me :)
**What the application should do**
This application should take the input of time (seconds, minutes and hours) and shutdown the computer after that time. It should also update the text box with how long left until the computer has shut down.
**What the application actually does**
I had an issue that I 'fixed' where the called ac across threads weren't safe, so I fixed it and I don't get that error now. However, the updateThread doesn't update and print the time left; and the text box doesn't get "test" appended to it. The UI also becomes Not Responding. Any help would be much appreciated.
Also, if you see anything else that could be done better, please comment and explain. Thanks!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShutdownPC
{
public partial class Form1 : Form
{
int inputHours;
int inputMinutes;
int inputSeconds;
Thread sleepingThread;
Thread updatingThread;
NotifyIcon shutdownPCIcon;
Icon defaultIcon;
public Form1()
{
InitializeComponent();
defaultIcon = new Icon("defaultIcon.ico");
shutdownPCIcon = new NotifyIcon();
shutdownPCIcon.Icon = defaultIcon;
shutdownPCIcon.Visible = true;
MenuItem progNameMenuItem = new MenuItem("ShutdownPC by Conor");
MenuItem breakMenuItem = new MenuItem("-");
MenuItem quitMenuItem = new MenuItem("Quit");
ContextMenu contextMenu = new ContextMenu();
contextMenu.MenuItems.Add(progNameMenuItem);
contextMenu.MenuItems.Add(breakMenuItem);
contextMenu.MenuItems.Add(quitMenuItem);
shutdownPCIcon.ContextMenu = contextMenu;
shutdownPCIcon.Text = "ShutdownPC";
quitMenuItem.Click += QuitMenuItem_Click;
}
private void QuitMenuItem_Click(object sender, EventArgs e)
{
shutdownPCIcon.Dispose();
sleepingThread.Abort();
updatingThread.Abort();
this.Close();
}
public void sleepThread()
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(sleepThread));
}
else {
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
button1.Enabled = false;
int totalMilliseconds = ((inputHours * 3600) + (inputMinutes * 60) + inputSeconds) * 1000;
Thread.Sleep(totalMilliseconds);
//Process.Start("shutdown", "/s /t 0");
richTextBox1.AppendText(String.Format("test"));
}
}
public void updateThread()
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(updateThread));
}
else {
int totalSeconds = (inputHours * 3600) + (inputMinutes * 60) + inputSeconds;
while (totalSeconds > 0)
{
TimeSpan time = TimeSpan.FromSeconds(totalSeconds);
string timeOutput = time.ToString(@"hh\:mm\:ss");
richTextBox1.AppendText(String.Format(timeOutput));
Thread.Sleep(1000);
richTextBox1.Clear();
totalSeconds--;
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
inputHours = Convert.ToInt32(textBox1.Text);
inputHours = int.Parse(textBox1.Text);
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
inputMinutes = Convert.ToInt32(textBox2.Text);
inputMinutes = int.Parse(textBox2.Text);
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
inputSeconds = Convert.ToInt32(textBox3.Text);
inputSeconds = int.Parse(textBox3.Text);
}
private void button1_Click(object sender, EventArgs e)
{
updatingThread = new Thread(new ThreadStart(updateThread));
updatingThread.Start();
sleepingThread = new Thread(new ThreadStart(sleepThread));
sleepingThread.Start();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
| <c#><.net><winforms> | 2016-03-13 17:04:13 | LQ_EDIT |
35,973,336 | How Do I Catch Errors for JUnit Tests? | I'm writing tests for some code I was given. There is a constructor that takes and int as the first parameter. I want to test that it gives an error if something such as a boolean is passed in so I wrote this code.
try
{
nanReview = new WorkshopReview(true, "test");
}
catch (Error err)
{
assertEquals(err.getMessage(), "incompatible types: boolean cannot be converted to int");
}
When I run the test it just throws the error into the console again, shouldn't the test pass at this point because it throws the expected error message?
How do I go about testing stuff like this / should I even be testing this in the first place? | <java><junit> | 2016-03-13 17:26:11 | LQ_EDIT |
35,973,361 | fill array with random but unique numbers in C# | <p>Okay I know there are few posts like this but I need to use only loops (for,do,while) and if, else to fill array with random but unique numbers so how shall i edit this code</p>
<pre><code> int[] x = new int[10];
Random r = new Random();
int i;
for (i = 0; i < x.Length; i++) {
x[i] = r.Next(10);
Console.WriteLine("x[{0}] = {1}", i, x[i]);
}
</code></pre>
| <c#> | 2016-03-13 17:28:57 | LQ_CLOSE |
35,973,479 | how does pointer of pointer work in this c code | int r = 50;
int *p;
int **k;
int ***m;
printf( "r: %d ", r );
p = &r;
k = &p;
m = &k;
***m = 100; //line 9
printf( "r: %d\n", r );
When there is only one pointer, i can understand that we take 100 and we assign it to the variable at the adress which is being held by the pointer. But what exactly is happening step by step when we do this with more than one pointer level? (line 9)
| <c><pointers> | 2016-03-13 17:38:59 | LQ_EDIT |
35,973,764 | Write a C++ program that prompts the user for the radius of a circle then calls inline function circleArea() to calculate the area of that circle | #include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
class Circle
{
private:
float radius;
public:
inline void circleArea(float)
void input()
{
cout<<"\nEnter the radius of circle";
cin>>radius;
}
Circle()
{
float radius=0.0;
}
};
void circleArea()
{
float a,r;
a=(3.14*r*r);
}
int main()
{
Circle c;
c.input();
c.circleArea();
}
Here i dont undestand how to put inline function,and i am not getting any output,my output shows blank space after putting the value of radius please help.. | <c++><oop> | 2016-03-13 18:01:45 | LQ_EDIT |
35,973,914 | Can React Native apps be tested in a browser? | <p>Realizing that React Native apps are designed to be developed / tested using simulators, is it possible to use a web browser to also test an application?</p>
<p>Services such as <a href="https://rnplay.org/" rel="noreferrer">https://rnplay.org/</a> exist, however my concern is it's powered by <a href="https://appetize.io/" rel="noreferrer">https://appetize.io/</a> it might be limited by the # of minutes per month. I'd also like to utilize free / open-source technology to accomplish this, as compared to a paid screen streaming service.</p>
<p>Along these lines, in order to test the app in a browser, would the app be required to use one or more libraries which allow the app to be run in both React Native and also simply React? I'd like to find an alternative to this particular approach as I'd like to code for React Native specifically.</p>
| <testing><reactjs><react-native><simulator> | 2016-03-13 18:15:35 | HQ |
35,974,249 | Using WireMock with SOAP Web Services in Java | <p>I am totally new to <a href="http://wiremock.org/index.html" rel="noreferrer">WireMock</a>.</p>
<p>Until now, I have been using mock responses using SOAPUI. My use case is simple:</p>
<p>Just firing SOAP XML requests to different endpoints (<a href="http://localhost:9001/endpoint1" rel="noreferrer">http://localhost:9001/endpoint1</a>) and getting canned XML response back. But MockWrire has to be deployed as a standalone service onto a dedicated server which will act a central location from where mock responses will be served.</p>
<p>Just wanted some starting suggestions. As I can see WireMock is more suitable towards REST web services. So my doubts are:</p>
<p>1) Do I need to deploy it to a java web server or container to act as always running standalone service. I read that you can just spin off by using</p>
<pre><code>java -jar mockwire.jar --port [port_number]
</code></pre>
<p>2) Do I need to use MockWire APIs? Do I need to make classes for my use case? In my case, requests will be triggered via JUnit test cases for mocking.</p>
<p>3) How do I achieve simple URL pattern matching? As stated above, I just need simple mocking i.e get response when request is made to <a href="http://localhost:9001/endpoint1" rel="noreferrer">http://localhost:9001/endpoint1</a></p>
<p>4) Is there a better/easier framework for my usecase? I read about Mockable but it has restrictions for 3 team members and demo domain in free tier.</p>
| <java><web-services><soap><mocking><wiremock> | 2016-03-13 18:46:12 | HQ |
35,974,895 | How to Create a Sell Button Code In Visual Studio C# with MySql as database | Hi Im Using Visual Studio C# and Im Having conflict on how to create a sell button as well how can I get the total amount of product that had been sold here is my code
try
{
if (txtID.Text != "" && txtCategory.Text != "" && txtName.Text != "" && txtQty.Text != "" && txtQty.Text != "" && PriceText.Text != "" && SuppNameText.Text != "")
{
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO Sold_Inventory (ProductName,Description,Category,Quantity_Sold,Price,TotalAmount,SuppliersName) VALUES(@ProductName,@Description,@Category,@Quantity,@Price,@Supplier)WHERE TotalAmount = @Quantity * @Price", con);
cmd.Parameters.AddWithValue("@ProductName", txtID.Text);
cmd.Parameters.AddWithValue("@Description", txtName.Text);
cmd.Parameters.AddWithValue("@Category", txtCategory.Text);
cmd.Parameters.AddWithValue("@Quantity", txtQty.Text);
cmd.Parameters.AddWithValue("@Price", PriceText.Text);
cmd.Parameters.AddWithValue("@Supplier", SuppNameText.Text);
cmd.ExecuteNonQuery();
SqlCommand cmd1 = new SqlCommand("Update Quantity FROM Inventory SET Quantity = Quantity - @Quantity");
cmd1.Parameters.AddWithValue("@Quantity", txtQty.Text);
cmd1.ExecuteNonQuery();
con.Close();
ClearTextbox();
btnSearch.Enabled = true;
txtSearch.Enabled = true;
groupBox4.Enabled = true;
btnSubmit.Enabled = false;
btnCancel.Enabled = false;
ClearTextbox();
DisabledTextbox();
btnAdd.Enabled = true;
RefreshDGV(this.dataGridView1);
}
else
{
MessageBox.Show("You left an empty field!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
} | <c#><sql-server><visual-studio-2012> | 2016-03-13 19:42:18 | LQ_EDIT |
35,974,974 | Why my HTML page is so small? | <p>i cant see why this website registration page is so small.
Im newbie to HTML.. Just want to help with UX.</p>
<p><a href="http://weelytics.com/app#register" rel="nofollow">http://weelytics.com/app#register</a></p>
<p>Thank you!</p>
| <html><css> | 2016-03-13 19:50:04 | LQ_CLOSE |
35,975,581 | python double colon with -1 as third parameter | <p>Take <code>a = [1,2,3,4,5]</code> as an example. From my instinct, I think <code>a[::-1]</code> is the same as <code>a[0:len(a):-1]</code>. But the result turns to be wrong:</p>
<pre><code>>>> a = [1,2,3,4,5]
>>> print a[::-1]
[5, 4, 3, 2, 1]
>>> print a[0:len(a):-1]
[]
>>> print a[0:3:-1]
[]
>>> print a[0:2:-1]
[]
>>> print a[:2:-1]
[5, 4]
>>> print a[:0:-1]
[5, 4, 3, 2]
>>> print a[0:-1]
[1, 2, 3, 4]
</code></pre>
<p>I actually can't understand the last 6 attempt's output. Could anyone give me some idea? Thanks tons.</p>
| <python><python-2.7> | 2016-03-13 20:42:15 | HQ |
35,975,810 | Checking file existence in Julia | <p>Is there a simple way in Julia to check whether a file in the current working directory exists (something like <code>test = os.path.isfile("foo.txt")</code> in Python or <code>inquire(file = "foo.txt", exist = test)</code> in Fortran)?</p>
| <julia> | 2016-03-13 21:00:34 | HQ |
35,975,915 | Array Sorting in PHP. I need to write my own asort() and ksort() functions? | <p>So I have this array</p>
<pre><code>$employee_salary = array("Peter"=>35000, "Ben"=>25000, "Joe"=>48000);
</code></pre>
<p>and I need to sort the array : 1) by value, ascending order 2) by key, ascending order. </p>
<p>I am not allowed to use the asort and ksort functions, so I have no idea how else to do it. Any ideas please? Thank you!</p>
| <php><arrays><sorting><asort><ksort> | 2016-03-13 21:10:17 | LQ_CLOSE |
35,976,005 | How to access global variable from a function when the name is same as argument name in JavaScript? | <p>How to access global variable from a function when the name is same as argument name in JavaScript ?</p>
<pre><code>var name = null;
function func(name) {
// How to set the global variable with the passed value
}
</code></pre>
| <javascript><variables><scope><global> | 2016-03-13 21:19:35 | LQ_CLOSE |
35,976,087 | Exporting a database in phpmyadmin fails (localhost) | <p>When I try to export a database sql file in phpmyadmin it fails. I get the following error: "Your output is incomplete, due to a low execution time limit on PHP level" .</p>
<p>I don't know what to do..</p>
| <php><mysql><database><phpmyadmin><localhost> | 2016-03-13 21:28:45 | HQ |
35,976,321 | Find last iteration of foreach loop in laravel blade | <p>In blade template i use last() method to find last iteration of foreach loop:</p>
<pre><code>@foreach ($colors as $k => $v)
<option value={!! $v->id !!} {{ $colors->last()->id==$v->id ? 'selected':'' }} > {!! $v->name !!} </option>
@endforeach
</code></pre>
<p>Is it ok? Perhaps there is a Laravel-style way to do the same?</p>
| <php><laravel><laravel-5><blade><laravel-blade> | 2016-03-13 21:51:57 | HQ |
35,976,848 | Trying to style an hr tag to have end caps | <p>I'm attempting to style an hr tag to have end caps like the attached image. While I could just remove the background from that image and set that as background, that won't change width with the page. At the moment, how to get this correctly made is eluding me.</p>
<p><a href="https://gyazo.com/a89aafb7a2d6c137a9052e6f111691ae" rel="nofollow">Image of the desired hr.</a></p>
| <html><css> | 2016-03-13 22:46:18 | LQ_CLOSE |
35,977,475 | linked list syntax in C | <p>I am trying to understand the syntax of linked lists by visualising it through diagrams. However I am getting confused. This code prints out 0-9. I don't understand the commented bits, please explain visually.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
struct node
{
int item;
struct node* link;
};
int main()
{
struct node *start,*list;
int i;
start = (struct node *)malloc(sizeof(struct node)); //???????
list = start; // ????????
start->link = NULL; // ??????????
for(i=0;i<10;i++)
{
list->item = i;
list->link = (struct node *)malloc(sizeof(struct node));
list = list->link;
}
list->link = NULL; //????????????
while(start != NULL) //??????????????
{
printf("%d\n",start->item);
start = start->link;
}
return 0;
}
</code></pre>
| <c><linked-list> | 2016-03-13 23:58:53 | LQ_CLOSE |
35,978,296 | Display Who Follows You on Instagram | <p>I am trying to create a simple script that displays who a user follows and if that person follows them back or not. Is there a way to fetch this information with Instagram API?</p>
| <php><instagram><instagram-api> | 2016-03-14 01:49:55 | LQ_CLOSE |
35,978,862 | Github pages: Why do I need a gh-pages | <p>I have deployed a personal blog using Github pages and I see that some tutorials tell you to create a gh-pages branch. I did that, however, my changes to the website are visible only if I make changes to my master. So, I'm confused as to why I need gh-pages? Can someone please explain this. Thanks</p>
| <jekyll><jekyll-extensions><jekyll-bootstrap><jekyll-paginator> | 2016-03-14 03:00:43 | HQ |
35,978,863 | Allow All Content Security Policy? | <p>Is it possible to configure the Content-Security-Policy to not block anything at all? I'm running a computer security class, and our web hacking project is running into issues on newer versions of Chrome because without any CSP headers, it's automatically blocking certain XSS attacks.</p>
| <javascript><web><http-headers><xss><content-security-policy> | 2016-03-14 03:01:04 | HQ |
35,979,344 | Can you tell me why I get "Can't use query methods that take a query string on a PreparedStatement."? | <p>I keep hitting an error "Can't use query methods that take a query string on a PreparedStatement." when trying to debug the following code & SQL Select query. (Postgres 9.4, jdk 1.8) Maybe I'm blind and it's a simple type, but I could use some help.</p>
<p>My Console Ouput: </p>
<blockquote>
<p>SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice FROM qbirt.person WHERE pr_sms = 47 ORDER BY lastupdt DESC</p>
<p>E R R O R
JDBC Prep'd Stmt error on Primary Phone FKey...
Phone FKey: 47 </p>
<p>SQLException: Can't use query methods that take a query string on a PreparedStatement.
SQLState: 42809
VendorError: 0
org.postgresql.util.PSQLException: Can't use query methods that take a query string on a PreparedStatement.
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:102) at solutions.demand.qbirt.Person.findMember(Person.java:762)`</p>
</blockquote>
<p>Portion of code:</p>
<pre><code> if (!foundMbr && foundPhoneID > 0) {
if (QbirtUtils.verbose) {
System.out.println("Querying Person by FK ID for phones: " + foundPhoneID + "\n");
}
if (mode.equals(pMode.SMS)) {
qry = "SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, "
+ "status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice "
+ "FROM qbirt.person "
+ "WHERE pr_sms = ? "
+ "ORDER BY lastupdt DESC;";
} else {
if (mode.equals(pMode.VOICE)) {
qry = "SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, "
+ "status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice "
+ "FROM qbirt.person "
+ "WHERE pr_phonevoice = ? "
+ "ORDER BY lastupdt DESC;";
} else {
if (mode.equals(pMode.PHONE)) {
qry = "SELECT DISTINCT ON (rowid) rowid, firstname, lastname, prefname, email1, email2, email3, type, "
+ "status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice "
+ "FROM qbirt.person "
+ "WHERE (pr_sms = ? OR pr_phonevoice = ?) "
+ "ORDER BY lastupdt DESC, rowid DESC;";
}
}
}
try {
PreparedStatement pStmt = conn.prepareStatement(qry);
pStmt.setInt(1, foundPhoneID);
if (mode.equals(pMode.PHONE)) {
pStmt.setInt(2, foundPhoneID);
}
System.out.println(pStmt.toString());
ResultSet rs = pStmt.executeQuery(qry); <-------
</code></pre>
<p>I have confirmed that the fields contain the following values:<br>
<code>foundMbr</code> = false, <code>foundPhoneID</code> = 47, <code>mode</code> = SMS, and that <code>qry = "SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice FROM qbirt.person WHERE pr_sms = ? ORDER BY lastupdt DESC;";</code></p>
<p>I get the error on the line: <code>ResultSet rs = pStmt.executeQuery(qry);</code></p>
<p>As you can see in the console, I have even confirmed that the pStmt is holding the correct binding because I print it out. - That said, it seems to be missing the ending ';'. Not sure why that is because I can see it in the qry string. I assume that is just a quirk of the preparedStatment.</p>
<p>I have also copied this exact SQL into pgAdmin III and successfully executed it manually. Although, I did have to add back the ';'. I use virtually this same code in many other areas without problem.</p>
<p>Could it be that the missing ';'?<br>
Maybe some sort of type mismatch? (foundPhoneID is an int., rowid is a serial/integer, pr_sms is an integer FKey)<br>
Could it be the block of if statements that defines the qry string?</p>
<p>TIA!</p>
| <java><postgresql><prepared-statement> | 2016-03-14 04:02:57 | HQ |
35,980,134 | How to find longest substring using Regular Expression in PHP | I have the following array:
$array = array("6", "66", "67", "68", "69", "697", "698", "699");
I have the following strings:
"69212345", "6209876544", "697986546"
I want to find the array element which matches longest part from beginning of the string, i.e.
for "69212345" array value "69" will be selected.
for "6209876544" array value "6" will be selected.
for "697986546" array value "697" will be selected.
Please help me how can I achieve this? | <php><arrays><regex><sequence> | 2016-03-14 05:28:17 | LQ_EDIT |
35,980,885 | iOS table view don't start with first row | <p>I do everything in tutorial but row don't start in first row</p>
<p><a href="http://i.stack.imgur.com/52Oat.png" rel="nofollow">Table View in Storyboard</a></p>
<p><a href="http://i.stack.imgur.com/gtDeq.png" rel="nofollow">Code for table view</a></p>
| <ios><swift><uitableview> | 2016-03-14 06:30:08 | LQ_CLOSE |
35,982,256 | create a class that derives from string builder to append any number of strings | i want to create a class that derives from string builder to append any number of strings.
My Program should allow the user input their own number of strings
example usage:
//Format Post Data
//Format Post Data
StringBuilder postData = new StringBuilder();
postData.Append("dst");
postData.Append("&popup=true");
postData.Append(String.Format("&username={0}", USERNAME_Validate1));// reads username from username textbox
postData.Append(String.Format("&password={0}", PASSWORD_Validate1));// reads password from password textbox
//Write Post Data To Server
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
writer.Write(postData); | <c#> | 2016-03-14 08:01:30 | LQ_EDIT |
35,982,431 | Hexagon grid shortest path weighted tiles | <p>I'm not a programmer by trade (Chemical Engineer) but I'm working on some hobby code for a kid's science Olympics. </p>
<p>Essentially, there is a Catan like (hexagonal) board with different tiles (8 types) with a start tile and end tile. Movement has no cost but moving through a tile incurs the tile's cost (example: moving to the tile A would incur a cost of 2). you can move in 6 directions through the sides of the hexagon (you don't ride the edge like Catan).</p>
<p>The goal of the game is to get the lowest score for your path at the end.</p>
<p><strong>What I've researched and tried</strong></p>
<p>So far I've tried to code a shortest path algorithm using matlab and dijkstra. However, I'm finding I have to do a lot of work because there are 250 nodes and each require 6 exiting lines that are weighted. I don't know how to place these nodes in a space and essentially say, "alright, you're worth X amount and can travel to any adjacent space" without manually coding each line. </p>
<p>FWIW i'm using matlab and was trying to adapt <a href="http://www.mathworks.com/matlabcentral/fileexchange/20025-dijkstra-s-minimum-cost-path-algorithm" rel="nofollow">this code</a> but am struggling on populating the table for E3 and V, less so V but mostly an easy way to say "okay, here are the tiles that are worth X."</p>
<p>Thanks in advance,</p>
| <matlab><shortest-path><a-star><hexagonal-tiles> | 2016-03-14 08:13:55 | LQ_CLOSE |
35,982,610 | TortoiseGit: What's the difference between "Git Sync", "Fetch" and "Pull"? | <p>I am moving from TortoiseSvn to TortoiseGit. But enountered some unexpected difficulties.</p>
<p>My working paradigm is as simple as:</p>
<ol>
<li>Check out code</li>
<li>Change some code</li>
<li>Share with others for code review</li>
<li>Commit changes</li>
</ol>
<p>Why bother to have the 3 <code>syntactically</code> similar commands below?</p>
<p>And <code>Pull</code> and <code>Fetch</code> even share the identical icon. What a user-friendly design!</p>
<p><a href="https://i.stack.imgur.com/OOSUj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OOSUj.png" alt="enter image description here"></a></p>
| <git><tortoisegit> | 2016-03-14 08:26:15 | HQ |
35,982,864 | Why base class and dervied class constructor is getting called when creating object of child class | Code :
class A
{
public A()
{
}
}
class B : A
{
public B()
{
}
}
class C : B
{
public C()
{
}
}
Main()
{
C a =new C();
}
Construcotrs CallS: First A constructor get called then B Cons get call then C Cons get called. Suppose i donot want to use any vairable of A in child class ,
Then **Why Base class constructor is getting called?**
| <c#><c#-4.0> | 2016-03-14 08:41:08 | LQ_EDIT |
35,983,458 | Javscript based nested for loop along with Objects | I'm new to javascript. when I was working with objects and nested loop. [plunker][1] is available
var a = [{b:[{c:null}]}]
for(var x= 0 ; x<10;x++){
for(var y= 0 ; y<10;y++){
console.log(a);
a[x].b[y].c = y;
console.log(a);
}
}
I was getting error like `TypeError: Cannot set property 'c' of undefined` can some one please explain why it is working like this
[1]: https://plnkr.co/edit/EodiL1wo6xqNEPK4StcS?p=preview | <javascript><object><for-loop><nested-loops> | 2016-03-14 09:13:44 | LQ_EDIT |
35,983,565 | How is the parameter "weight" (DMatrix) used in the gradient boosting procedure (xgboost)? | <p>In xgboost it is possible to set the parameter <code>weight</code> for a <code>DMatrix</code>. This is apparently a list of weights wherein each value is a weight for a corresponding sample.
I can't find any information on how these weights are actually used in the gradient boosting procedure. Are they related to <code>eta</code> ? </p>
<p>For example, if I would set <code>weight</code> to 0.3 for all samples and <code>eta</code> to 1, would this be the same as setting <code>eta</code> to 0.3 and <code>weight</code> to 1?</p>
| <xgboost> | 2016-03-14 09:20:32 | HQ |
35,983,775 | Visual Studio - Create Class library targeting .Net Core | <p>How do I create a class library targeting .Net Core in visual studio 2015?<br/>
I found this getting started “<a href="https://dotnet.github.io/getting-started/">guide</a>”, which shows how to create a new .Net Core project using the <em>dotnet</em> command line tool.<br/>
Do I need to create somehow a VS project manual based on the generated files (<em>project.json</em>…)?<br/>
Is there a way to create a .Net Core DLL inside of VS without using the “dotnet” tool?</p>
| <c#><visual-studio><class-library><.net-core> | 2016-03-14 09:29:51 | HQ |
35,983,840 | I want to run a stopwatch program in the background of my main program , and print the time at the end of th emain programe | <p>I am new to programming ,and i want to know how to run a stopwatch program in the background without displaying the time constantly and at the end i want it to print how long the user took to go through the program </p>
| <python> | 2016-03-14 09:32:31 | LQ_CLOSE |
35,985,090 | Meaning of ${project.basedir} in pom.xml | <p>What is the meaning of </p>
<pre><code><directory>${project.basedir}</directory>
</code></pre>
<p>and</p>
<pre><code>${project.build.directory}
</code></pre>
<p>in pom.xml</p>
| <java><maven><pom.xml> | 2016-03-14 10:31:07 | HQ |
35,985,592 | Is if (condition) try {...} legal in C++? | <p>For example:</p>
<pre><code>if (true) try
{
// works as expected with both true and false, but is it legal?
}
catch (...)
{
// ...
}
</code></pre>
<p>In other words, is it legal to put the try-block <em>right after the if condition</em>?</p>
| <c++><exception><try-catch><language-lawyer> | 2016-03-14 10:54:02 | HQ |
35,985,931 | How to generate Signature in AWS from Java | <p>When I invoke API endpoints from REST client, I got error by concerning with Signature.</p>
<p>Request:</p>
<blockquote>
<p><strong>Host</strong>: <a href="https://xxx.execute-api.ap-southeast-1.amazonaws.com/latest/api/name" rel="noreferrer">https://xxx.execute-api.ap-southeast-1.amazonaws.com/latest/api/name</a></p>
<p><strong>Authorization</strong>: AWS4-HMAC-SHA256 Credential=<code>{AWSKEY}</code>/20160314/ap-southeast-1/execute-api/aws4_request,SignedHeaders=host;range;x-amz-date,Signature=<code>{signature}</code></p>
<p><strong>X-Amz-Date</strong>: 20160314T102915Z</p>
</blockquote>
<p>Response:</p>
<pre><code>{
"message": "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. The Canonical String for this request should have been 'xxx' "
}
</code></pre>
<p>From Java code, I followed AWS reference of how to generate Signature.</p>
<pre><code> String secretKey = "{mysecretkey}";
String dateStamp = "20160314";
String regionName = "ap-southeast-1";
String serviceName = "execute-api";
byte[] signature = getSignatureKey(secretKey, dateStamp, regionName, serviceName);
System.out.println("Signature : " + Hex.encodeHexString(signature));
static byte[] HmacSHA256(String data, byte[] key) throws Exception {
String algorithm="HmacSHA256";
Mac mac = Mac.getInstance(algorithm);
mac.init(new SecretKeySpec(key, algorithm));
return mac.doFinal(data.getBytes("UTF8"));
}
static byte[] getSignatureKey(String key, String dateStamp, String regionName, String serviceName) throws Exception {
byte[] kSecret = ("AWS4" + key).getBytes("UTF8");
byte[] kDate = HmacSHA256(dateStamp, kSecret);
byte[] kRegion = HmacSHA256(regionName, kDate);
byte[] kService = HmacSHA256(serviceName, kRegion);
byte[] kSigning = HmacSHA256("aws4_request", kService);
return kSigning;
}
</code></pre>
<p>May I know what I was wrong while generating Signature?</p>
<p>Reference how to generate Signature : <a href="http://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-java" rel="noreferrer">http://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-java</a></p>
| <java><rest><amazon-web-services><signature> | 2016-03-14 11:11:18 | HQ |
35,986,314 | Android - setAdapter in Fragment | <p>I'm attempting to populate a list in a ListView.
The Fragment I'm using is a tab in my activity.
When I'm trying to create the adapter for the ListView, I encounter an issue.
The adapter I've created TaskItemAdapter up to this point was used in an activity in which there were no tabs, so the contractor was:</p>
<pre><code> public TaskItemAdapter(Context context, List<Task> list) {
this.itemList = list;
this.context = context;
inflater = LayoutInflater.from(this.context);
}
</code></pre>
<p>This is the initialization:</p>
<pre><code>list.setAdapter(new TaskItemAdapter(context, itemList));
</code></pre>
<p>But when I try this in a Fragment, I encounter an issue, as there is no Context to transfer to the contractor.
How can I resolve this?</p>
| <android><listview><android-fragments><android-adapter> | 2016-03-14 11:29:16 | LQ_CLOSE |
35,986,329 | How to generate C# client from Swagger 1.2 spec? | <p>There seems to be millions of options out there for every platform, but I'm struggling to find a simple solution for C#. All the ones I have found seem to have given me trouble: either they simply don't work (e.g. <a href="http://swaggercodegen.azurewebsites.net/" rel="noreferrer">http://swaggercodegen.azurewebsites.net/</a>), or only support 2.0 (e.g. <a href="https://github.com/Azure/autorest" rel="noreferrer">AutoRest</a> and <a href="https://github.com/NSwag/NSwag" rel="noreferrer">NSwag</a>). Half the tools are not even clear what versions they support :-(</p>
<p>I'm aware of the <a href="https://github.com/swagger-api/swagger-codegen/" rel="noreferrer">official tool</a>, but that requires JDK 7 which is not currently an option for me.</p>
<p>In desperation I have even tried converting the swagger spec to 2.0, but half the conversion tools I tried didn't work, gave conflicting advice, or I couldn't figure out how to use (I found myself knee deep in nodejs very quickly...is this really the brave new world?! Bring back WSDL ;-) ).</p>
| <c#><.net><code-generation><swagger> | 2016-03-14 11:29:53 | HQ |
35,986,733 | i am trying to pass values to an array in another class | <p>i am trying to pass values to an array in another class
this is an example of what i am trying to do in detail:</p>
<pre><code>public class CustomString
{
private string[] StringToAppend;
public string[] StringToAppend1
{
get
{
return StringToAppend;
}
set
{
StringToAppend = value;
}
}
public Class Form1:Form
{
CustomString strng1 = new CustomString();
strng1.StringToAppend1 = {"sssf","vfdr";} //Fails to compile Here
</code></pre>
<p>}</p>
| <c#> | 2016-03-14 11:48:55 | LQ_CLOSE |
35,986,776 | How to sum up value in string c++ | Well i try to sum up a strings that contains number(only) in ex.
String a = 103
String b = 13
And i want it to sum up so the result will be 113
I was wondering about substring or charAt but dunno is it good idea.
I hope that's well explained. | <c++><string> | 2016-03-14 11:50:50 | LQ_EDIT |
35,987,043 | Counting records in JSON array using javascript and Postman | <p>I have a control that returns 2 records:</p>
<pre><code>{
"value": [
{
"ID": 5,
"Pupil": 1900031265,
"Offer": false,
},
{
"ID": 8,
"Pupil": 1900035302,
"Offer": false,
"OfferDetail": ""
}
]
}
</code></pre>
<p>I need to test via Postman, that I have 2 records returned. I've tried various methods I've found here and elsewhere but with no luck. Using the code below fails to return the expected answer.</p>
<pre><code>responseJson = JSON.parse(responseBody);
var list = responseBody.length;
tests["Expected number"] = list === undefined || list.length === 2;
</code></pre>
<p>At this point I'm not sure if it's the API I'm testing that's at fault or my coding - I've tried looping through the items returned but that's not working for me either. Could someone advise please - I'm new to javascript so am expecting there to be an obvious cause to my problem but I'm failing to see it. Many thanks. </p>
| <javascript><json><postman> | 2016-03-14 12:02:47 | HQ |
35,987,178 | How to reverse order a list? (Python 3.x) | <p>How to reverse order the list containing strings where def view(self), because with reversed() I get an error that it can't be done with strings. Any help? </p>
<pre><code>class Stack():
def __init__(self):
self.stack = []
def view(self):
for x in reversed(self.stack):
print(self.stack[x])
def push(self):
item = input("Please enter the item you wish to add to the stack: ")
self.stack.append(item)
def pop(self):
item = self.stack.pop(-1)
print("You just removed item: {0}".format(item))
stack = Stack()
</code></pre>
| <python-3.x> | 2016-03-14 12:09:51 | LQ_CLOSE |
35,987,276 | Need to replace numbers between [...] with Javascript or jQuery | <p>Inside a string: I need to replace the number between <code>[ ]</code> by another number with Javascript or jQuery.</p>
<p>What is the best way to proceed ?</p>
<p>Eamples</p>
<pre><code>"[12345].Checked" > "[1].Checked"
"[123].RequestID" > "[21].RequestID"
</code></pre>
<p>Thanks for your help.</p>
| <javascript><jquery> | 2016-03-14 12:14:15 | LQ_CLOSE |
35,987,596 | JavaScript Function within a function undefined | <p>Can someone explain to me why the second function within the first function is undefined?</p>
<pre><code>var a = 1
function abc () {
alert(a);
function xyz () {
alert(a);
}
}
</code></pre>
<p><a href="https://jsfiddle.net/kp950/yLs73cth/" rel="nofollow">https://jsfiddle.net/kp950/yLs73cth/</a></p>
| <javascript> | 2016-03-14 12:30:05 | LQ_CLOSE |
35,988,242 | SIGSEGV crash in iOS (Objective c) | Incident Identifier: 64E7437E-C37F-425C-8582-18A14C43F95A
CrashReporter Key: b90a1226375d6bce87d7c4fc6288d7951058aec4
Hardware Model: iPad2,1
Process: LolMess [428]
Path: /private/var/mobile/Containers/Bundle/Application/B1A322EE-F140-49CB-B1D2-84601F0BE962/LolMess.app/LolMess
Identifier: com.mobulous.LolMess
Version: 1 (1.0)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2016-03-14 17:55:49.49 +0530
Launch Time: 2016-03-14 17:42:36.36 +0530
OS Version: iOS 9.2.1 (13D15)
Report Version: 104
**Exception Type: EXC_BAD_ACCESS (SIGSEGV)**
Exception Subtype: KERN_INVALID_ADDRESS at 0x0002c9f0
Triggered by Thread: 24
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x245c0c24 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x245c0a28 mach_msg + 40
2 CoreFoundation 0x24903354 __CFRunLoopServiceMachPort + 136
3 CoreFoundation 0x249016dc __CFRunLoopRun + 1036
4 CoreFoundation 0x24854bf8 CFRunLoopRunSpecific + 520
5 CoreFoundation 0x248549e4 CFRunLoopRunInMode + 108
6 GraphicsServices 0x25aa0ac8 GSEventRunModal + 160
7 UIKit 0x28ae4ba0 UIApplicationMain + 144
8 LolMess 0x002171d0 main (main.m:15)
9 libdyld.dylib 0x24503872 start + 2
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x245d6320 kevent_qos + 24
1 libdispatch.dylib 0x244ce098 _dispatch_mgr_invoke + 256
2 libdispatch.dylib 0x244cddf6 _dispatch_mgr_thread$VARIANT$mp + 38
Thread 22:
0 libsystem_kernel.dylib 0x245c0c74 semaphore_wait_trap + 8
1 LolMess 0x0078ea9e thread_encoding_proc + 510
2 libsystem_pthread.dylib 0x2467985a _pthread_body + 138
3 libsystem_pthread.dylib 0x246797ce _pthread_start + 110
4 libsystem_pthread.dylib 0x24677724 thread_start + 8
Thread 23:
0 libsystem_kernel.dylib 0x245c0c74 semaphore_wait_trap + 8
1 LolMess 0x0078efda thread_loopfilter + 54
2 libsystem_pthread.dylib 0x2467985a _pthread_body + 138
3 libsystem_pthread.dylib 0x246797ce _pthread_start + 110
4 libsystem_pthread.dylib 0x24677724 thread_start + 8
Thread 24 Crashed:
0 LolMess 0x00781380 vp8_copy_mem16x16_neon + 16
1 LolMess 0x0077f828 vp8_build_inter16x16_predictors_mb + 188
2 LolMess 0x0077fa76 vp8_build_inter_predictors_mb + 414
3 LolMess 0x007a9f00 vp8_decode_frame + 11088
4 LolMess 0x007ab088 vp8dx_receive_compressed_data + 276
5 LolMess 0x007a537e vp8_decode + 1114
6 LolMess 0x007776ae vpx_codec_decode + 62
7 LolMess 0x007363ca -[VPXDecoder decode:rawOutFrame:inFrameSize:frameInfo:] (VPXDecoder.m:105)
8 LolMess 0x006f93ea -[RTPVideoHandler getDecodedVideoFrame:frameInfo:forStream:withOptions:] (RTPVideoHandler.m:1145)
9 LolMess 0x006f95ba -[RTPVideoHandler getDecodedVideoFrame:] (RTPVideoHandler.m:1184)
10 LolMess 0x00603b20 -[SCVideoCallController run:] (SCVideoCallController.m:896)
11 Foundation 0x25159164 __NSThread__start__ + 1148
12 libsystem_pthread.dylib 0x2467985a _pthread_body + 138
13 libsystem_pthread.dylib 0x246797ce _pthread_start + 110
14 libsystem_pthread.dylib 0x24677724 thread_start + 8
Error Formulating Crash Report:
Failed while requesting activity/breadcrumb diagnostics
Using C2callSdk in app | <ios><segmentation-fault><c2call> | 2016-03-14 12:59:23 | LQ_EDIT |
35,988,329 | Same layout Look different in to device which have same screen size | I have 2 phone amsung s6 edge+ & Samsung note 4, Both have same same screen size 5.7 inch & same screen resolution 1440X2560 & both layout have xxxhdpi density. still same layout look different on both device.
even top status bar & action bar is also look different on both device which is system genereated.
any one can suggest some solution to have same UI on each and every android device.
[Screen shot of same layout in both devices][1]
[1]: http://i.stack.imgur.com/AzMve.jpg
| <android><xml><android-layout> | 2016-03-14 13:02:31 | LQ_EDIT |
35,988,842 | The questions connected with Android Studio | I hope for a ponimayeniye, a beginner.
I can't solve these two problems:
1.Error:(20, 20) error: cannot find symbol variable mQuestionBank
2.Error:(20, 20) error: cannot find symbol variable mQuestionBank
Code:
enter code here
`enter code here`import android.os.Bundle;
`enter code here`import android.support.v7.app.AppCompatActivity;
`enter code here`import android.widget.Button;
`enter code here`import android.widget.TextView;
`enter code here`import android.widget.Toast;
public class QuizActivity extends AppCompatActivity {
private android.widget.Button mTrueButton;
private android.widget.Button mFalseButton;
private Button mNextButton;
private TextView mQuestionTextView;
private int mCurrentIndex = 0;
private void updateQuestion() {
int question;
question = mQuestionBank[mCurrentIndex].getQuestion();
mQuestionTextView.setText(question);
}
private void checkAnswer(boolean userPressedTrue) {
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isTrueQuestion();
int messageResId = 0;
if (userPressedTrue == answerIsTrue) {
messageResId = R.string.correct_toast;
} else {
messageResId = R.string.incorrect_toast;
}
Toast.makeText(this, messageResId , Toast.LENGTH_SHORT)
.show();
}
private TrueFalse[] mQuesionBank = new TrueFalse[] {
new TrueFalse(R.string.question_1, false),
new TrueFalse(R.string.question_2, true),
new TrueFalse(R.string.question_3, false),
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
mQuestionTextView = (TextView)findViewById(R.id.question_text_view);
mTrueButton = (android.widget.Button)findViewById(R.id.true_button);
mTrueButton.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(android.view.View v) {
checkAnswer(true);
}
});
mFalseButton = (android.widget.Button)findViewById(R.id.false_button);
mFalseButton.setOnClickListener(new android.view.View.OnClickListener() {
public void onClick(android.view.View v) {
checkAnswer(false);
}
});
mNextButton = (Button)findViewById(R.id.next_button);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
updateQuestion();
}
});
updateQuestion();
}
}
I will be very grateful to those who will intelligibly and it is clear explain! Thanks!
Sorry, if has issued something not so. First time ;) | <java><android> | 2016-03-14 13:26:14 | LQ_EDIT |
35,989,847 | my running c++ baclground | i've re installed my dev c++ and now i have problem that when i run the app of this simple code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout<<"hi mateen";
return 0;
}
it shows me this:
[![enter image description here][1]][1]
how can i delete this?it wasnt showing before alwaays used to use
getche()
but even when i use
return 0;
the problem is still the same.
thanks
[1]: http://i.stack.imgur.com/GNvTn.png | <c++><dev-c++> | 2016-03-14 14:12:43 | LQ_EDIT |
35,990,394 | eclipse error cannot make a static reference to a non-static field | <p>import java.util.Scanner;</p>
<p>public class Account {
int number1,number2,sum;</p>
<pre><code>public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Enter your first number");
number1 = input.nextInt();
System.out.println("Enter your Second number");
number2 = input.nextInt();
sum = number1 + number2;
System.out.println("Your Answer is" + sum);
input.close();
}
</code></pre>
<p>}</p>
| <java> | 2016-03-14 14:34:11 | LQ_CLOSE |
35,990,750 | C++ Overload the subscript operator to call a function based on the type assigned | I have an object that has functions like "addString" and "addInteger". These functions add data to a JSON string. At the end, the JSON string can be obtained and sent out. How can this be made easier by overloading subscript operators to do the following?
jsonBuilder builder();
builder[ "string_value" ] = "Hello";
builder[ "int_value" ] = 5;
builder[ "another_string" ] = "Thank you"; | <c++><operator-overloading><subscript-operator> | 2016-03-14 14:50:21 | LQ_EDIT |
35,991,032 | How do I debug a Python program (I am coming from a Ruby on Rails/JavaScript background)? | <p>I make web applications using Ruby on Rails as my backend. I use React and Flux on the frontend, which is JavaScript. I can fully use the debugging tools I need. I simply add the line of code "debugger" anywhere in my app, so that execution stops there. I use byebug gem in Rails. When the "debugger" line of code is executed on backend code, the debugging happens on the command line; when it happens in JavaScript code, the debugging happens in Chrome Dev Tools. In other words, I can work very quickly to debug.</p>
<p>What is the equivalent convenient debugging tool in Python? In other words, what should a person who can already program in general, and just wants to rapidly be able to debug in Python use? I am using Atom editor (like I use when I am making a web app).</p>
| <python><debugging> | 2016-03-14 15:02:45 | HQ |
35,991,985 | find the largest substring that contains all of occurrence of a character | <p>I need to find out largest sub string that contains all of occurrence of a character in C#.</p>
<p>Example - Input string : "my name is granar"
Nee to find out largest sub string that contains all of occurrence of a character "a", the result is "<strong>ame is grana</strong>"</p>
<p>Please help me in algorithm?</p>
| <c#> | 2016-03-14 15:44:34 | LQ_CLOSE |
35,992,492 | Python: Savefig cuts off title | <p>Hey I try to savefig my plot, but it allways cuts off my title.
I think it is because of y=1.05 (to set a distance to the title).
I can not fix it. Is there a way to save the entire graph?</p>
<pre><code>time=round(t[time_period],0)
most_sensitive=sorted(most_sensitive)
plt.figure(figsize=(10, 5))
plt.suptitle("Scatterplot "+str(name)+" , "+r'$\Delta$'+"Output , Zeit= "+str(time)+" s",fontsize=20,y=1.05)
figure_colour=["bo","ro","go","yo"]
for i in [1,2,3,4]:
ax=plt.subplot(2,2,i)
plt.plot(parm_value[:,most_sensitive[i-1]], Outputdiff[:,most_sensitive[i-1]],figure_colour[i-1])
ax.set_xlabel(name+"["+str(most_sensitive[i-1])+"] in "+str(unit))
ax.set_ylabel(r'$\Delta$'+"Output")
lb, ub = ax.get_xlim( )
ax.set_xticks( np.linspace(lb, ub, 4 ) )
lb, ub = ax.get_ylim( )
ax.set_yticks( np.linspace(lb, ub, 8 ) )
ax.grid(True)
plt.tight_layout()
newpath = r'C:/Users/Tim_s/Desktop/Daten/'+str(name)+'/'+str(time)+'/'+'scatterplot'+'/'
if not os.path.exists(newpath):
os.makedirs(newpath)
savefig(newpath+str(name)+'.png')
</code></pre>
| <python><matplotlib><plot><save><title> | 2016-03-14 16:08:07 | HQ |
35,993,272 | After encryption using RSA algorithm, what will be the size of 1 mb file | <p>I am developing an android app and in it I want to use encryption. Basically I want to encrypt files for the purpose but I'm afraid that encryption will increase the size of the file. So can you guyz please help me by telling me that if I encrypt a 1 MB of file what will its size be after encryption. I will be using java for programming.</p>
| <java><encryption><rsa> | 2016-03-14 16:43:46 | LQ_CLOSE |
35,993,968 | How to prevent IIS from shutting down Web Site when not in use? | <p>I have a web application hosted under IIS. It is a data warehouse, and during its startup process it requires instantiating a large set of items in memory (takes roughly ~20 minutes to fully set up). Because this website is critical to our company, this system <strong>must be online 100%</strong> during the daytime, and only can be restarted during off-work hours.</p>
<p>For some reason, this web application seems to be "offline" when there is no usage for some time. I know this because the cache is not fully instantiated when the website is visited. This is unacceptable.</p>
<p>It is not clear to me why the website is shut off. The application pool is only set to recycle daily at 4:00 AM (it is 11 AM now). </p>
<p>Are there other settings which I'm not aware of on the IIS part that causes it to shut down the website automatically?</p>
<p>Addl Note: The website does not shut off automatically when running in <strong>IISExpress</strong> in Visual Studio. Only the production version hosted on IIS shuts off.</p>
<p>Here's a screen of the Advanced Settings for the Application Pool the web site is running under. (Not sure if it's useful.)</p>
<p><a href="https://i.stack.imgur.com/J86DI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J86DI.png" alt="Application Pool Settings"></a></p>
<p>I'm on IIS 7.5, Server 2008 R2. It is an ASP.NET 5 Web App.</p>
| <iis><iis-7.5><application-pool><application-restart> | 2016-03-14 17:16:01 | HQ |
35,994,570 | How to fill color in a rectangle percentage wise? | <p>Hi how to paint a rectangle partially filled with color ?
I need to fill this according to the percentage of value generated by program.
I am using swing for my Java GUI <a href="https://i.stack.imgur.com/iyLz5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iyLz5.jpg" alt="enter image description here"></a></p>
| <java><swing> | 2016-03-14 17:51:28 | LQ_CLOSE |
35,994,640 | What is a vertical bar in jade? | <p>To convert HTML to jade is use this <a href="http://html2jade.aaron-powell.com/" rel="noreferrer">jade converter</a>.</p>
<p>When I enter the following HTML,</p>
<pre><code><!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
</head>
<body>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</body>
</html>
</code></pre>
<p>the output is as follows:</p>
<pre><code>doctype html.no-js
head
meta(charset='utf-8')
|
body
.container
.header
ul.nav.nav-pills.pull-right
li.active
a(href='#') Home
|
li
a(href='#') About
|
li
a(href='#') Contact
</code></pre>
<p>What is the purpose of the vertical bars (<code>|</code>) ?</p>
| <pug> | 2016-03-14 17:55:11 | HQ |
35,995,273 | How to run html file using node js | <p>I have a simple html page with angular js as follows:</p>
<pre><code> //Application name
var app = angular.module("myTmoApppdl", []);
app.controller("myCtrl", function ($scope) {
//Sample login function
$scope.signin = function () {
var formData =
{
email: $scope.email,
password: $scope.password
};
console.log("Form data is:" + JSON.stringify(formData));
};
});
</code></pre>
<p>HTML file:</p>
<pre><code><html>
<head>
<link href="bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body ng-app="myTmoApppdl" ng-controller="myCtrl">
<div class="container">
<div class="form-group">
<form class="form" role="form" method="post" ng-submit="signin()">
<div class="form-group col-md-6">
<label class="">Email address</label>
<input type="email" class="form-control" ng-model="email" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group col-md-6">
<label class="">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" ng-model="password" placeholder="Password" required>
</div>
</form>
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
</div>
</body>
<script src="angular.min.js" type="text/javascript"></script>
<!--User defined JS files-->
<script src="app.js" type="text/javascript"></script>
<script src="jsonParsingService.js" type="text/javascript"></script>
</html>
</code></pre>
<p>I am new to node js. I have installed node js server in my system but I am not sure how to run a simple html file using node js?</p>
| <javascript><angularjs><node.js> | 2016-03-14 18:29:53 | HQ |
35,995,707 | How should I refer to inner enums (defined within an entity) from a JPQL query using Hibernate? | <p>I have an entity class as follows:</p>
<pre><code>package stuff;
@Entity
class Thing {
@Id
@GeneratedValue
private Long id;
@Basic
@Enumerated
private State state;
public enum State {
AWESOME,
LAME
}
}
</code></pre>
<p>How can I select all Things with state AWESOME using JPQL and Hibernate?</p>
<pre><code>select t from Thing t where t.state=stuff.Thing.State.AWESOME
</code></pre>
<p>...gives the error...</p>
<pre><code>org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'stuff.Thing.State.AWESOME'
</code></pre>
| <java><hibernate><jpa><enums><jpql> | 2016-03-14 18:51:36 | HQ |
35,997,073 | Converting an method from objective c to swift | <p>Hi guys how can i convert this code into swift.</p>
<pre><code> (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
{
}
</code></pre>
<p>I have been trying to figure it out but cant.</p>
<p>Thanks in advance
Aryan</p>
| <ios><objective-c><swift> | 2016-03-14 20:08:17 | LQ_CLOSE |
35,997,376 | How to order regular expression alternatives to get longest match? | <p>I have a number of regular expressions <code>regex1</code>, <code>regex2</code>, ..., <code>regexN</code> combined into a single regex as <code>regex1|regex2|...|regexN</code>. I would like to reorder the component expressions so that the combined expression gives the longest possible match at the beginning of a given string.</p>
<p>I believe this means reordering the regular expressions such that "if <code>regexK</code> matches a prefix of <code>regexL</code>, then <code>L < K</code>". If this is correct, is it possible to find out, in general, whether <code>regexK</code> can match a prefix of <code>regexL</code>?</p>
| <regex><language-agnostic> | 2016-03-14 20:25:24 | HQ |
35,997,885 | retreiving URL from MySQL database | Okay, So I have a database which holds the following values; Restaurant Name, Address, Town, County, Postcode, Tel, Email, Website and Rating. I have a search box that allows the user to search via Town, County or Postcode and then echo's out those relevant using the attached code.
Problem is, my Website URL's when clicked just reload the same page the info is displayed on and not the actual website of the restaurants? I know this is going to be something silly!!!!
Thanks
<!-- language: lang-html -->
<td>
<?php echo $results[ 'RestaurantName']?>
</td>
<br>
<td>
<?php echo $results[ 'AddressLine1']?>
</td>
<br>
<td>
<?php echo $results[ 'AddressLine2']?>
</td>
<br>
<td>
<?php echo $results[ 'Town']?>
</td>
<br>
<td>
<?php echo $results[ 'County']?>
</td>
<br>
<td>
<?php echo $results[ 'Postcode']?>
</td>
<br>
<td>
<?php echo $results[ 'Telephone']?>
</td>
<br>
<td>
<?php echo $results[ 'Email']?>
</td>
<br>
<td>
<a href>
<?php echo $results[ 'Website']?>
</a>
</td>
<br>
<td>
<?php echo $results[ 'Rating']?>
</td>
<br>
<!-- end snippet -->
| <html><mysql> | 2016-03-14 20:54:42 | LQ_EDIT |
35,998,067 | ruby creating hash for array.each | <p>This is my code: </p>
<pre><code>@games.each do |game| #@games is an array
#definitely working
game = Hash.new 0
end
</code></pre>
<p>And as you can guess... it's not working. No errors. Just variables like that don't exist. I want my hashes be called by a title of games. Plenty of this, because there are 240titles. </p>
<p>I am pretty sure I have to take this "game = Hash.new 0" out of block, but to be honest I don't have any ideas.</p>
<p>Regards.</p>
| <ruby><hash> | 2016-03-14 21:05:57 | LQ_CLOSE |
35,998,830 | REST API Security Issues | <p>I have an html5 webapp that fetches data using jquery from rest java api. I have two questions:</p>
<ol>
<li>How can I encrypt data on server and decrypt it locally with different key for each user. Where can I store this key in client side? Does it needed, or it is just enough to secure the rest service call with some authentication method?</li>
<li>Is there any standard way to prevent other rest clients (except browsers) to hit this rest api?</li>
</ol>
| <rest><security> | 2016-03-14 21:54:38 | LQ_CLOSE |
35,998,902 | Creating a program that will tell a user what month it will be x months from now ( C++) | <p>I am completely stuck / lost. I need to write a program that will tell a user what month it will be in x amount of months from March. I need a point in the right direction to start me off.</p>
<p>I am still learning c++, so I'm trying to keep it as basic as possible. Any help will be a lifesaver !! </p>
<p>Example:</p>
<p>User enters 6, the result would display September.</p>
<p>User enters 239, the result would be February. </p>
| <c++><visual-c++> | 2016-03-14 21:59:43 | LQ_CLOSE |
35,998,958 | How can I remove every 6th comma in a CSV file using Regex and Python3? | <p>For a current project I need to remove the 6th comma on every line of a CSV file with a "\n" newline. Could someone suggest how I could do this using regex or any other easier method. Thanks for your help.</p>
| <python><regex><csv><python-3.x> | 2016-03-14 22:03:03 | LQ_CLOSE |
35,999,344 | How to determine what version of python3 tkinter is installed on my linux machine? | <p>Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?</p>
| <python-3.x><tkinter> | 2016-03-14 22:30:07 | HQ |
35,999,637 | how to flip the elements of a list without using list[::-1] in PYTHON | <p>How can a I take a list of any size and reverse the order of the elements?</p>
<p>list=[1,5,9,23....n]</p>
<p>and it spits out [n...23,9,5,1] without using list[::-1]?</p>
| <python><list> | 2016-03-14 22:55:25 | LQ_CLOSE |
35,999,725 | java decompiler JD-Gui correctness | <p>Let's say I have a java class A that I want to decompile using JD-GUI. After fixing minor compilation issues (casting and initialize local variable), I compile the decompiled code as class B.</p>
<p>How guarantee is it that class A and class B function the same?</p>
| <java><jdk1.6><decompiler><jd-gui> | 2016-03-14 23:04:05 | LQ_CLOSE |
35,999,881 | How to access BLE on Raspberry Pi 3 using Java? | <p>The Raspberry Pi 3 includes BLE support. I confirmed it works by </p>
<p>sudo hcitool lescan</p>
<p>which returned the MAC and BLE 'complete local name' for neighboring advertisers.</p>
<p>How does one access this programmatically, in Java?</p>
| <java><bluetooth-lowenergy><raspberry-pi3> | 2016-03-14 23:17:37 | HQ |
35,999,906 | "pg_dump: invalid option -- i" when migrating | <p>When I run <code>rake db:migrate</code> on my Rails project (3.2.22.2) I get <code>pg_dump: invalid option -- i</code>. Here's the full trace:</p>
<pre><code>Celluloid 0.17.1.1 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
[DEPRECATION] `last_comment` is deprecated. Please use `last_description` instead.
pg_dump: invalid option -- i
Try "pg_dump --help" for more information.
rake aborted!
Error dumping database
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/gems/activerecord-3.2.22.2/lib/active_record/railties/databases.rake:429:in `block (3 levels) in <top (required)>'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/gems/activerecord-3.2.22.2/lib/active_record/railties/databases.rake:202:in `block (2 levels) in <top (required)>'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/gems/activerecord-3.2.22.2/lib/active_record/railties/databases.rake:196:in `block (2 levels) in <top (required)>'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/bin/ruby_executable_hooks:15:in `eval'
/Users/jasonswett/.rvm/gems/ruby-2.1.4@bm43/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:structure:dump
(See full trace by running task with --trace)
</code></pre>
<p>I notice that there's a <a href="https://github.com/rails/rails/pull/21931">bugfix in Rails</a> pertaining to this issue. The bugfix seems not to have been applied to Rails versions < 4 since it's not a security fix, which makes sense.</p>
<p>What I don't understand is what I'm supposed to do now. If there's a fix for 3.2.x, I haven't been able to find it yet. I guess if there's no fix for 3.2.x, I guess that means I have to upgrade to Rails 4.x, which seems a bit drastic. I doubt that's really the only solution. And why did the issue only recently pop up out of nowhere?</p>
<p>Any suggestions are appreciated.</p>
| <ruby-on-rails><postgresql> | 2016-03-14 23:20:35 | HQ |
35,999,988 | Beginning C and I have a bug that is killing me | <p>I am writing some code and I have a prompt in the program driven by a while loop where you make a choice. However, it prints the prompt twice every time it goes through the loop and I just can't figure it out.</p>
<pre><code> while (choice != 'x');
{
printf("\nChoice (a)dd (v)iew e(X)it [ ]\b\b");
scanf("%c",&choice);
if (choice == 'a') add_record();
if (choice == 'v') view_record();
}
</code></pre>
<p>The printf line is the one that prints twice. Thanks in advance for any help.</p>
| <c><loops><debugging><if-statement> | 2016-03-14 23:28:41 | LQ_CLOSE |
36,000,127 | Can I have multiple service workers both intercept the same fetch request? | <p>I'm writing a library which I will provide for 3rd parties to run a service worker on their site. It needs to intercept all network requests but I want to allow them to build their own service worker if they like.</p>
<p>Can I have both service workers intercept the same fetches and provide some kind of priority/ordering between them? Alternatively is there some other pattern I should be using?</p>
<p>Thanks</p>
| <service-worker><progressive-web-apps> | 2016-03-14 23:40:44 | HQ |
36,000,718 | Why does this for loop work | <p>I have this code:</p>
<pre><code>int k;
for (k=0; k>-3; k=-2;); {
System.out.println(k);
}
</code></pre>
<p>The output is negative four. I don't understand why this code still runs even though there is a semi colon after the statements in the for loop. </p>
| <java><loops> | 2016-03-15 00:38:32 | LQ_CLOSE |
36,001,477 | Why can't a string be nil in Go? | <p>The program <a href="https://play.golang.org/p/2gLydmLeHf" rel="noreferrer">available on The Go Playground</a> reads</p>
<pre><code>package main
import "fmt"
func main() {
var name string = nil
fmt.Println(name)
}
</code></pre>
<p>and yields an error</p>
<pre><code>prog.go:6: cannot use nil as type string in assignment
</code></pre>
<p>I understand <a href="https://tour.golang.org/basics/12" rel="noreferrer"><code>""</code> is the "zero value" for strings</a>. I don't understand why I cannot assign <code>nil</code> to my <code>string</code>.</p>
| <go><variable-assignment> | 2016-03-15 02:10:26 | HQ |
36,002,413 | Conventions for app.js, index.js, and server.js in node.js? | <p>In node.js, it seems I run into the same 3 filenames to describe the main entry point to an app:</p>
<ul>
<li>When using the <code>express-generator</code> package, an <strong><code>app.js</code></strong> file is created as the main entry point for the resulting app.</li>
<li>When creating a new <code>package.json</code> file via <code>npm init</code>, one is prompted for the main entry point file. The default is given as <strong><code>index.js</code></strong>.</li>
<li>In some programs I have seen, <strong><code>server.js</code></strong> serves as the main entry point as well.</li>
</ul>
<p>Other times, still, it seems as though there are subtle differences in their usage. For example, this node app directory structure uses <code>index.js</code> and <code>server.js</code> in different contexts:</p>
<pre><code>app
|- modules
| |- moduleA
| | |- controllers
| | | |- controllerA.js
| | | +- controllerB.js
| | |- services
| | | +- someService.js
| | +- index.js <--------------
| +- index.js <-------------------
|- middleware.js
+- index.js <------------------------
config
+- index.js <------------------------
web
|- css
|- js
server.js <----------------------------
</code></pre>
<p>What are the differences, if any, between these three names?</p>
| <node.js><conventions> | 2016-03-15 03:54:14 | HQ |
36,002,866 | Configure tmux scroll speed | <p>Can tmux scroll speed (using a mouse wheel or touch pad) be configured?</p>
<p>Tmux 2.1 sort of broke scrolling (depending on your configuration), forcing me to update my config. I did that a few weeks ago.</p>
<p>But now I think tmux scrolls* slower than it used to. I think I read you can configure the scroll speed but I can't find any mention of that anywhere now.</p>
<p>* Scrolling with a mouse wheel that is. (I'm actually using a Macbook trackpad but I think it's equivalent to a mouse wheel.)</p>
<p>I know you can do 10C-u (with vi key bindings) to jump up 10 pages, but I'd also like to be able to just scroll fast with the mouse.</p>
<p>I think this is all the relevant config I personally have currently:</p>
<pre><code># Use the mouse to select panes, select windows (click window tabs), resize
# panes, and scroll in copy mode.
# Requires tmux version >= 2.1 (older versions have different option names for mouse)
set -g mouse on
# No need to enter copy-mode to start scrolling.
# From github.com/tmux/tmux/issues/145
# Requires tmux version >= 2.1 (older versions have different solutions)
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
</code></pre>
| <tmux> | 2016-03-15 04:46:25 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.