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 |
|---|---|---|---|---|---|
37,081,666 | media query does not switch below 768 when resize window | <pre><code>@media(min-width:768px){body:border:1px solid red;}
</code></pre>
<p>if i resize the window below 768px , it does not switch to iphone6+ media query</p>
<pre><code>@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (-webkit-min-device-pixel-ratio: 3) and (orientation: landscape) { body:border:1px solid red;}
</code></pre>
<p>Please suggest</p>
| <twitter-bootstrap><css><responsiveness> | 2016-05-06 21:25:21 | LQ_CLOSE |
37,082,380 | What wrong in the SELECT CODE? | <p>Im trying to pull out only "completed" orders
whats the problem in this select code?</p>
<pre><code>('SELECT * FROM orders WHERE OrderUserID = :OrderUserID AND WHERE OrderStatus='Completed');
</code></pre>
| <mysql> | 2016-05-06 22:35:54 | LQ_CLOSE |
37,082,409 | Generate random equations with random numbers | <p>I want to generate random equations in JavaScriptp and then output them into an HTML tag.
This is the code:</p>
<pre><code><!DOCTYPE html>
<body>
<p>Click the button below to generate a random equation.</p>
<button onclick="change();">Generate</button>
<p id="generate"></p>
<script>
function getRandomizer(bottom, top) {
return function() {
return Math.floor( Math.random() * ( 1 + top - bottom ) ) + bottom;
}
}
function getRandomNumber(results) {
var rollDie = getRandomizer( 1, 10 );
for ( var i = 0; i < 3; i++ ) {
results += rollDie() + "";
}
getRandomNumber.result = results;
}
function getRandomEquation(num1, num2, num3, num4, num5, num6, num7, output) {
var num_7,
num_6,
num_5,
num_4,
num_3,
num_2,
num_1
getRandomNumber(num1).result = num_7;
getRandomNumber(num2).result = num_6;
getRandomNumber(num3).result = num_5;
getRandomNumber(num4).result = num_4;
getRandomNumber(num5).result = num_3;
getRandomNumber(num6).result = num_2;
getRandomNumber(num7).result = num_1;
var equation1 = "" + num_1 + " x " + num_2 + " + {" + num_3 + " x [(" + num_4 + " x " + num_5 + ") - " + num_6 + "] + " + num_7 + "} = x",
equation2 = "" + num_1 + " x " + num_2 + " = y",
equation3 = "" + num_1 + "s x " + num_2 + " = z, s = " + num_3,
equation4 = "" + num_1 + " + {" + num_2 + " x [" + num_3 + " + (" + num_4 + " x " + num_5 + ") + " + num_6 + "] + " + num_7 + "} = x",
equation5 = "" + num_1 + "e + " + num_2 + "l x " + num_3 + " + " + num_4 + "a, e = " + num_5 + ", l = " + num_6 + ", a = " + num_7,
equation6 = "[" + num_1 + " x " + num_2 + "z] + {" + num_3 + " - " + num_4 + "} + (" + num_5 + " + " + num_6 + ") = e, z = " + num_7,
equation7 = "p" + " x " + num_1 + " / " + num_2 + " - " + num_3 + " + " + num_4 + " = e, p = " + num_5
var values = [
// there is an easier way to do this, too lazy
"" + equation1,
"" + equation2,
"" + equation3,
"" + equation4,
"" + equation5,
"" + equation6,
"" + equation7
]
var i = 0;
var e;
if (i > values.length) {
i = 0;
}
var randomEquation = values[i];
i++;
e = values[i];
this.output = randomEquation;
this.e = e;
}
function getEquation() {
var bl1,
bl2,
bl3,
bl4,
bl5,
bl6,
bl7,
equationOutput;
var eq = getRandomEquation(bl1, bl2, bl3, bl4, bl5, bl6, bl7, equationOutput).e;
getEquation.equation = eq;
}
function change() {
var final = getEquation().equation;
document.getElementById("generate").innerHTML = final;
}
</script>
</body>
</html>
</code></pre>
<p>But it dosen't work. Any help?</p>
<p>P.S. My teacher assigned this to me. Please respond as soon as possible. Thanks.</p>
| <javascript><html><random> | 2016-05-06 22:39:19 | LQ_CLOSE |
37,083,058 | Programmatically searching google in Python using custom search | <p>I have a snippet of code using the pygoogle python module that allows me to programmatically search for some term in google succintly:</p>
<pre><code> g = pygoogle(search_term)
g.pages = 1
results = g.get_urls()[0:10]
</code></pre>
<p>I just found out that this has been discontinued unfortunately and replaced by something called the google custom search. I looked at the other related questions on SO but didn't find anything I could use. I have two questions:</p>
<p>1) Does google custom search allow me to do exactly what I am doing in the three lines above?</p>
<p>2) If yes - where can I find example code to do exactly what I am doing above? If no then what is the alternative to do what I did using pygoogle?</p>
| <python><google-custom-search> | 2016-05-07 00:04:53 | HQ |
37,083,326 | Use a CURSOR to move data in MS SQL | I maintain a list of new contacts that is sent from a subsidiary. Each month a list of contacts is sent to me. The list is complete and I only need the last few dozen rows to be added to the contacts list. I need to maintain the redundant lists for records purposes.
I am trying to use a CURSOR to inspect the monthly inbound tables and place them into master list? | <sql-server><tsql> | 2016-05-07 00:44:25 | LQ_EDIT |
37,083,920 | Is it safe to delete /root/sent in ubuntu? | <p>I have a server running ubuntu 14.04
What is inside of /root/sent?
It is currently taking of 34GB of my server space.
It is safe to delete it? </p>
| <ubuntu><mutt> | 2016-05-07 02:37:49 | LQ_CLOSE |
37,084,019 | Ocaml: How can I return the first element of a list and after that remove it from the list? | I'm new in Functional Programming and I'm trying to learn a little bit of Ocaml and I tried to use **List.hd** and **List.tl** for this task:
`let takeCard fst deck =
fst = List.hd deck
List.tl deck`
'List.hd' takes two arguments but I don't understand why.
Please, help ! :'( | <list><functional-programming><ocaml><tail> | 2016-05-07 02:55:34 | LQ_EDIT |
37,084,620 | why is the output of this program 0 in c? | In this code i am trying to pass a pointer to the structure and then using this pointer to work on the structure members but why the output is always showing 0 ?
#include<stdio.h>
#include<string.h>
struct student
{
int go;
}s;
void m();
void main()
{
m(&s);
printf("%d",s.go);
}
void m(struct student *ptr)
{
ptr->go;
}
| <c> | 2016-05-07 04:51:02 | LQ_EDIT |
37,085,036 | Checking if the table has rows results in Null Pointer Exception in SQLiite Android | <p>I want to check if the table has rows and if it contains, then I want to delete it. Below is my code for checking if table has rows in it.</p>
<pre><code> boolean empty = true;
Cursor cursor = db.rawQuery("SELECT count(*) FROM TABLE_NAME",null);
cursor.moveToFirst();
if (cursor.getInt(0) > 0)
{
empty = false;
}
else
{
empty= true;
}
return empty;
</code></pre>
<p>I even tried checking with below code,</p>
<pre><code> boolean empty = true;
Cursor cur = db.rawQuery("SELECT COUNT(*) FROM TABLE_NAME", null);
if (cur != null && cur.moveToFirst()) {
empty = (cur.getInt (0) == 0);
}
cur.close();
return empty;
</code></pre>
<p>Both of the above code, throws NullPointerException in line</p>
<p>("SELECT COUNT(*) FROM TABLE_NAME", null);</p>
<p>Any help would be great !! Thanks </p>
| <android><sqlite><count> | 2016-05-07 05:54:44 | LQ_CLOSE |
37,085,074 | Java function to C# | Hi i can't seem to get this to work after converting it to C#
I need it to work like the Java one but i can't seem to be able to do that what am i doing wrong?
Can anyone supply a fix and explain it please.
C#:
public static string Encrypt1(string strIn)
{
string strOut = "";
int lenIn = strIn.Length;
int i = 0;
while (i < lenIn)
{
double numRand = (int)Math.Floor(new Random().NextDouble() * 66) + 33;
strOut += Convert.ToString((int)(strIn[i] + (char)numRand), 27) +
Convert.ToString((int)numRand, 27);
i++;
}
return strOut;
}
Java:
public String Encrypt1(String strIn) {
String strOut = "";
int lenIn = strIn.length();
int i = 0;
double numRand;
while (i < lenIn) {
numRand = Math.floor(Math.random() * 66) + 36;
strOut += Integer.toString((int)(strIn.charAt(i) + (char)numRand), 27) +
Integer.toString((int)numRand, 27);
i++;
}
return strOut;
} | <java><c#> | 2016-05-07 05:58:30 | LQ_EDIT |
37,085,563 | C++ Division Error? | <p>Hi so whenever I try to do division such as <strong>double x = 3 * (5/10);</strong> it will make x = 0 for some reason. Is there a reason this happens in c++ I'm learning and have no clue why this happens. </p>
| <c++> | 2016-05-07 07:03:41 | LQ_CLOSE |
37,085,566 | Search Youtube video through android app | <p>I am making app that search Yoututbe video through the app. But it throw exception on <code>SearchListResponse searchResponse = search.execute();</code>
How to resolve this problem. Please help</p>
<p>below is my exception that raise during search perform</p>
<pre><code> 05-07 12:26:33.163 26111-26111/com.dp.videostoreadmin W/System.err: android.os.NetworkOnMainThreadException
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:215)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:437)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:93)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:981)
05-07 12:26:33.164 26111-26111/com.dp.videostoreadmin W/System.err: at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.dp.videostoreadmin.MainActivity.displaySearchResult(MainActivity.java:62)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.dp.videostoreadmin.MainActivity.access$000(MainActivity.java:22)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.dp.videostoreadmin.MainActivity$1.onClick(MainActivity.java:40)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at android.view.View.performClick(View.java:5204)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at android.view.View$PerformClick.run(View.java:21153)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at android.os.Looper.loop(Looper.java:148)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at java.lang.reflect.Method.invoke(Native Method)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
05-07 12:26:33.165 26111-26111/com.dp.videostoreadmin W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
</code></pre>
<p>below is my code</p>
<pre><code>import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.io.IOException;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.youtube.YouTube;
import com.google.api.services.youtube.model.SearchListResponse;
import com.google.api.services.youtube.model.SearchResult;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private static final String YOUTUBE_API_KEY = "AIzaSyCxmfKGyNqlQIEtY0XWxGzC4QHX08BWmks";
EditText searchText;
Button submit;
private static YouTube youtube;
private static final long NUMBER_OF_VIDEOS_RETURNED = 25;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
searchText = (EditText) findViewById(R.id.editText);
submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
displaySearchResult();
}
});
}
private void displaySearchResult() {
try {
youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer() {
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("VideoStoreAdmin").build();
YouTube.Search.List search = youtube.search().list("id,snippet");
search.setKey(YOUTUBE_API_KEY);
search.setQ(searchText.getText().toString());
search.setType("video");
search.setFields("items(id/kind,id/videoId,snippet/title,snippet/publishedAt,snippet/thumbnails/default/url),nextPageToken");
search.setMaxResults(NUMBER_OF_VIDEOS_RETURNED);
// Call the API and print results.
SearchListResponse searchResponse = search.execute();
List<SearchResult> searchResultList = searchResponse.getItems();
if (searchResultList != null) {
Log.d("TAG",searchResultList.toString());
}
} catch (GoogleJsonResponseException e) {
System.err.println("There was a service error: " + e.getDetails().getCode() + " : "
+ e.getDetails().getMessage());
} catch (IOException e) {
System.err.println("There was an IO error: " + e.getCause() + " : " + e.getMessage());
} catch (Throwable t) {
t.printStackTrace();
}
}
/*
* Prompt the user to enter a query term and return the user-specified term.
*/
}
</code></pre>
| <android><android-youtube-api> | 2016-05-07 07:03:57 | LQ_CLOSE |
37,085,653 | When bulding a CNN, I am getting complaints from Keras that do not make sense to me. | <p>My input shape is supposed to be 100x100. It represents a sentence. Each word is a vector of 100 dimensions and there are 100 words at maximum in a sentence. </p>
<p>I feed eight sentences to the CNN.I am not sure whether this means my input shape should be 100x100x8 instead. </p>
<p>Then the following lines</p>
<pre><code>Convolution2D(10, 3, 3, border_mode='same',
input_shape=(100, 100))
</code></pre>
<p>complains:</p>
<p>Input 0 is incompatible with layer convolution2d_1: expected ndim=4, found ndim=3</p>
<p>This does not make sense to me as my input dimension is 2. I can get through it by changing input_shape to (100,100,8). But the "expected ndim=4" bit just does not make sense to me. </p>
<p>I also cannot see why a convolution layer of 3x3 with 10 filters do not accept input of 100x100. </p>
<p>Even I get thru the complains about the "expected ndim=4". I run into problem in my activation layer. There it complains:</p>
<p>Cannot apply softmax to a tensor that is not 2D or 3D. Here, ndim=4</p>
<p>Can anyone explain what is going on here and how to fix it? Many thanks. </p>
| <python><neural-network><keras> | 2016-05-07 07:13:29 | HQ |
37,085,753 | Android Studio Image Asset Launcher Icon Background Color | <p>I have a .png logo for my app which doesn't have a background, when I add it to android studio as an Image Asset I am forced to have a background. The hex field doesn't accept 8 digit color codes, 6 digits only. Is there anyway to keep the background invisible?</p>
| <android><background> | 2016-05-07 07:24:48 | HQ |
37,086,098 | Does tensorflow map_fn support taking more than one tensor? | <p>Does tf.map_fn support taking more than one tensors as is supported by python's native map function (example provided below)?</p>
<pre><code>a = [1,2,3,4]
b = [17,12,11,10]
print(map(lambda x,y:x+y, a,b)) # ==> [18, 14, 14, 14]
</code></pre>
| <python><tensorflow> | 2016-05-07 08:06:35 | HQ |
37,086,562 | What kind of font files do I need for modern browsers, Android and IOS? | <p>I have these as my font files:</p>
<pre><code>@font-face {
font-family: 'FontAwesome';
src: url('@{fa-font-path}/fontawesome-webfont.eot') format('embedded-opentype'),
url('@{fa-font-path}/fontawesome-webfont.woff2') format('woff2'),
url('@{fa-font-path}/fontawesome-webfont.woff') format('woff'),
url('@{fa-font-path}/fontawesome-webfont.ttf') format('truetype'),
url('@{fa-font-path}/fontawesome-webfont.svg fontawesomeregular') format('svg');
// src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts
font-weight: normal;
font-style: normal;
}
</code></pre>
<p>Would just these meet my needs:</p>
<pre><code>@font-face {
font-family: 'FontAwesome';
src: url('@{fa-font-path}/fontawesome-webfont.eot');
src: url('@{fa-font-path}/fontawesome-webfont.woff2') format('woff2'),
url('@{fa-font-path}/fontawesome-webfont.woff') format('woff'),
url('@{fa-font-path}/fontawesome-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
</code></pre>
<p>Would just the woff and woff2 meet my needs?</p>
| <android><html><ios><css><fonts> | 2016-05-07 08:59:48 | HQ |
37,086,605 | Disable WKWebView for opening links to redirect to apps installed on my iPhone | <p>When I'm searching google and click on Etsy.com for exmaple, WKWebView redirect me to Etsy app installed on my iPhone.
How can I disable this behavior? I want WKWebView to redirect me to etsy.com mobile website.
I'm using swift.</p>
| <ios><swift><wkwebview> | 2016-05-07 09:04:26 | HQ |
37,087,169 | How to chain match and replace in JavaScript | str="abc { return false;}"
I just want to get the word "false" from the string "str", as follows,
str.match(/return \w+;/g).replace(/return/,"")
It 's wrong !
How can I correct this expression to get the desired word?
| <javascript><regex> | 2016-05-07 10:08:13 | LQ_EDIT |
37,087,355 | Set checked checkbox from array | <p>I have 2 set of array which represent all data and selected data</p>
<pre><code>$all_data = ["admin","member","editor"];
$selected = ["admin","member"];
</code></pre>
<p>I want to make all list of data that have checked if $all_data value = $selected value
What the best method to make it possible?</p>
| <php><html><checkbox><selected> | 2016-05-07 10:26:52 | LQ_CLOSE |
37,087,430 | Mysterious Issue in Replicating Binary files in C | <p>Hey community i'm having trouble in replicating binary files from the command line have a look at my try. The code under copies the first character on the srcFile and stops somehow, can you guys help me figure the way i can fix this and the reason it happens?</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 8500
int main(int argc, char** argv)
{
char buffer[BUFSIZE];
size_t currBit;
FILE *srcFile = fopen(argv[1], "r+b");
if (!srcFile)
{
printf("source file doesnt exist or problem with allocating the memory");
return 1;
}
FILE *dstFile = fopen(argv[2], "r+b");
if (dstFile)
{
printf("Destination file already exists\nfor overwriting enter 1 \nfor exit enter 2\n");
_flushall();
switch (getchar())
{
case '1':
fclose(dstFile);
dstFile = fopen(argv[2], "w+b");
if (!dstFile)
{
printf("Problem with allocating the memory");
}
while ((currBit = fread(buffer, sizeof(char),BUFSIZE, srcFile) > 0))
{
fwrite(buffer, sizeof(char), currBit, dstFile);
}
break;
case '2':
system("pause");
return 0;
break;
default:
printf("next time you should enter numbers as following");
}
}
else
{
dstFile = fopen(argv[2], "w+b");
while ((currBit = fread(buffer, sizeof(char), BUFSIZE, srcFile) > 0))
{
fwrite(buffer, sizeof(char), currBit, dstFile);
}
if (!dstFile)
{
printf("Problem with allocating the memory");
}
}
fclose(srcFile);
fclose(dstFile);
getchar();
return 0;
}
</code></pre>
<p>Input Source file:
10100101</p>
<p>Expected Output From Destination File:
10100101</p>
<p>Destination File Output:
1</p>
| <c><file-io><binaryfiles><argv> | 2016-05-07 10:34:30 | LQ_CLOSE |
37,087,707 | mysql select query based on array value | I have a dynamic array . For example like this.
$color = array('red','blue','green');
"SELECT * FROM mytable where colors=(red or blue or green)"
But my array is dynamic. So i dont know the values and how can I loop the array and select the rows. PLz help me.
| <mysql> | 2016-05-07 10:59:24 | LQ_EDIT |
37,088,571 | Keras loading color images | <p>I have 3 folders with color images. Name of the folder is label for the images inside.</p>
<pre><code>cls1
|____img_0.png
|____ ...
|____img_n.png
cls2
|____img_0.png
|____ ...
|____img_n.png
cls3
|____img_0.png
|____ ...
|____img_n.png
</code></pre>
<p>I would like to use Keras library to create Convolutional neural network for classification, but I can't find, how to create dataset from color images.
Can you help me?</p>
| <python><deep-learning><keras> | 2016-05-07 12:31:12 | HQ |
37,088,679 | Kotlin Regex named groups support | <p>Does Kotlin have support for named regex groups?</p>
<p>Named regex group looks like this: <code>(?<name>...)</code></p>
| <regex><kotlin><regex-group> | 2016-05-07 12:41:51 | HQ |
37,088,883 | How can I matlab from a matrix on matlab? | so I have a matrix:
a = [16 456 22 85 93;11 78 310 62 36;1 66 23 67 405];
Whis is the command to graph the 3rd row of the matrix - the grid of the graph should be set to visable and the x (sample) and Y (value) axis labels should be included.
thank you guys :) | <matlab><matrix><plot><graph> | 2016-05-07 13:01:21 | LQ_EDIT |
37,088,912 | C CreateThread() to slow? | i have a following code for matrix-vector multiplication:
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
std::chrono::steady_clock::time_point start, end2;
void fillMatrixConditions(LPVOID lpv) {
end2 = std::chrono::steady_clock::now();
std::cout << "Time difference = " << std::chrono::duration_cast<std::chrono::microseconds>(end2 - start).count() << std::endl;
std::cout << "Time difference = " << std::chrono::duration_cast<std::chrono::nanoseconds> (end2 - start).count() << std::endl;
int i, j = horizontControl;
for (i = 0; i < horizontControl; i++, j++) {
b[i] = akcni - uMin;
b[j] = uMax - akcni;
}
j = 2 * horizontControl + N - N1 + 1;
int k = 0;
for (i = 2 * i; i < (2 * horizontControl + N - N1 + 1); i++, j++, k++) {
b[i] = MpDup[k] - yMin;
b[j] = yMax - MpDup[k];
};
RtPrintf("Thread");
}
int _tmain(int argc, _TCHAR * argv[])
{
HANDLE hThread;
DWORD id;
int k = 0;
double temp;
double g[50];
for (int j = 0; j < N - N1 + 1; j++)
{
temp = 0;
for (int m = 0; m < horizontPrediction - 1; m++, k++)
{
temp = temp + Mp[k] * dup[m];
}
MpDup[j] = temp;
tempMatrix[j] = setPoint - y - temp;
}
start = std::chrono::steady_clock::now();
hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)fillMatrixConditions, NULL, NULL, &id);
k = 0;
for (int j = 0; j < horizontControl; j++)
{
temp = 0;
for (int m = 0; m < N - N1 + 1; m++, k++)
{
temp = temp + Mtranspose[k] * tempMatrix[m];
}
g[j] = -2 * temp;
}
RtPrintf("Point\n");
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
return 0;
}
<!-- end snippet -->
But CreateThread() is to slow, because this is output program:
Point
Time difference = 247
Time difference = 247261
I thought first will be write Time difference in thread and then "Point". Or is it normal? I must use CreateThread. I can't pthread etc. Matrix Mtranspose has 2025 cells.
Thanks for help :-) | <c++><winapi> | 2016-05-07 13:04:02 | LQ_EDIT |
37,089,162 | Docker-compose volume mount before run | <p>I have a Dockerfile I'm pointing at from a docker-compose.yml.</p>
<p>I'd like the volume mount in the docker-compose.yml to happen before the <code>RUN</code> in the Dockerfile. </p>
<p>Dockerfile:</p>
<pre><code>FROM node
WORKDIR /usr/src/app
RUN npm install --global gulp-cli \
&& npm install
ENTRYPOINT gulp watch
</code></pre>
<p>docker-compose.yml</p>
<pre><code>version: '2'
services:
build_tools:
build: docker/gulp
volumes_from:
- build_data:rw
build_data:
image: debian:jessie
volumes:
- .:/usr/src/app
</code></pre>
<p>It makes complete sense for it to do the Dockerfile first, then mount from docker-compose, however is there a way to get around it.</p>
<p>I want to keep the Dockerfile generic, while passing more specific bits in from compose. Perhaps that's not the best practice?</p>
| <docker><docker-compose><dockerfile> | 2016-05-07 13:29:32 | HQ |
37,089,343 | Tarck anonymous users without forcing users to go through authentication proccess | i want to track all users ( both authenticated users and anonymous users) , so far the solution i found are not good.
first of all we can use cookie but as we all know its not a reliable solution ,
second of all we can use browser finger printing, but until this moment i did not find any solution for server side.
i found this solution [valve][1] but it is for client side , i want an approach which user does not find any token in request , i want to create the key in server side so i can track users.
does any one know any solution ?
note : my server side technology is Asp.net Mvc
use case : users can comment on m site and also they can like or dislike comments, i want to allow all users to do this and also i want to track users before action ( like or dislike )
[1]: https://github.com/Valve/fingerprintjs | <asp.net-mvc><anonymous-users> | 2016-05-07 13:47:05 | LQ_EDIT |
37,089,977 | How to get current value of RxJS Subject or Observable? | <p>I have an Angular 2 service:</p>
<pre><code>import {Storage} from './storage';
import {Injectable} from 'angular2/core';
import {Subject} from 'rxjs/Subject';
@Injectable()
export class SessionStorage extends Storage {
private _isLoggedInSource = new Subject<boolean>();
isLoggedIn = this._isLoggedInSource.asObservable();
constructor() {
super('session');
}
setIsLoggedIn(value: boolean) {
this.setItem('_isLoggedIn', value, () => {
this._isLoggedInSource.next(value);
});
}
}
</code></pre>
<p>Everything works great. But I have another component which doesn't need to subscribe, it just needs to get the current value of isLoggedIn at a certain point in time. How can I do this?</p>
| <javascript><angular><rxjs> | 2016-05-07 14:54:35 | HQ |
37,090,038 | Overriding Bootstrap's CSS | <p>I can't seem to override Bootstrap's CSS despite following instructions found in other questions. </p>
<pre><code><!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/styles.css">
...
<!-- GRID SECTION -->
<div class="container">
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<h1 id="title">TITLE</h1>
</div>
<div class="col-md-2">
</div>
</div>
</div>
</code></pre>
<p>The CSS it this:</p>
<pre><code>@font-face {
font-family: hnl;
src: url('fonts/hnl.otf');
}
body {
font-family: hnl;
}
#title {
font-family: hnl;
text-align: center;
}
</code></pre>
<p>However, the font doesn't change, and the text does not align.
How can override Bootstrap's CSS?</p>
| <html><css><twitter-bootstrap> | 2016-05-07 14:59:50 | LQ_CLOSE |
37,090,877 | Dynamic classname inside ngClass in angular 2 | <p>I need to interpolate a value inside of an <code>ngClass</code> expression but I can't get it to work.</p>
<p>I tried these solution which are the only ones that makes sense to me, these two fails with the interpolation:</p>
<pre><code><button [ngClass]="{'{{namespace}}-mybutton': type === 'mybutton'}"></button>
<button [ngClass]="{namespace + '-mybutton': type === 'mybutton'}"></button>
</code></pre>
<p>This one works with the interpolation but fails with the dynamically added class because the entire string gets added as a class:</p>
<pre><code><button ngClass="{'{{namespace}}-mybutton': type === 'mybutton'}"></button>
</code></pre>
<p>So my question is how do you use dynamic classnames in <code>ngClass</code> like this?</p>
| <angular> | 2016-05-07 16:19:38 | HQ |
37,090,911 | how to make use of hashmap in following code. | how do i make use of hashmap in this code.i have rosters that hold ArrayList of students. i know hashmap use key and value pair, but i'm confuse on what would be my key and value if i use hashmap in the following classes that use arraylist.
this is my modify class where i make some modificaton on basis of user input that i get in may main class.
public class modify{
ArrayList<Roster> rList;
public modify{
rList = new ArrayList<Roster>();
}
public void addRoster(){
System.out.println("Enter name for roster: ");
String name = newObj.nextLine();
//Teacher t = new Teacher().addTeacher();
Student s = new Student().addStudent();
Roster addR = new Roster(s, name, 0);
rList.add(addR);
System.out.println("New Roster Created: ");
}//end of addRoster
/*
code
*/
}//end of class
this is my roster class. it hold the arralist of students.
public class Roster{
int id;
String name;
List<Student> students;
public Roster(Student s, String name, int id){
this.students = new ArrayList<Student>();
this.students.add(s);
this.id = ranObj.rand();
this.name = name;
}//constructor
}//end of roster
this is my student class
public class Student {
private int studentId;
public Student(String firstName, String lastName, int age) {
super( firstName, lastName, age);
this.studentId = ranObj.rand();
}
public String toString(){
return String.format("Student:\n" +
" Id = %d\n" +
" Age = %d\n" +
" firstName = %s\n" +
" lastName = %s\n\n" +
" ",getStudentId(),super.getAge(), super.getFirstName(),super.getLastName());
}// end of tostring class
}//end of student | <java><hashmap> | 2016-05-07 16:22:58 | LQ_EDIT |
37,091,308 | How can i remove a sublist of a list in Ocaml? | the problem is the next: I want to delviver the first seven carts of a deck of cards. A cart is a string, and the player and the deck are lists of strings.
So i need to do a function that:
- Append the first seven strings of a list of strings (deck of cards) to other list of string (player)
- remove the first seven strings of a list of strings (deck of cards)
- it must return the player with the new cards and the deck of cards without those cards.
Thanks, i am new in Ocaml and i cant do it with loops or recursion, i cant, help.
| <ocaml> | 2016-05-07 17:00:51 | LQ_EDIT |
37,091,316 | How to get the realtime output for a shell command in golang? | <p>I am trying to call shell command with os/exec in golang, that command will take some time, so I would like to retrieve the reatime output and print the processed output (a progressing ratio number).</p>
<pre><code>package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"strings"
)
func main() {
cmdName := "ffmpeg -i t.webm -acodec aac -vcodec libx264 cmd1.mp4"
cmdArgs := strings.Fields(cmdName)
cmd := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
stdout, _ := cmd.StdoutPipe()
cmd.Start()
go print(stdout)
cmd.Wait()
}
// to print the processed information when stdout gets a new line
func print(stdout io.ReadCloser) {
r := bufio.NewReader(stdout)
line, _, err := r.ReadLine()
fmt.Println("line: %s err %s", line, err)
}
</code></pre>
<p>I want to have a function where can update the screen when the command print something, </p>
<p>The ffmpeg command output is as follows:</p>
<pre><code>frame= 101 fps=0.0 q=28.0 size= 91kB time=00:00:04.13 bitrate= 181.2kbits/
frame= 169 fps=168 q=28.0 size= 227kB time=00:00:06.82 bitrate= 272.6kbits/
frame= 231 fps=153 q=28.0 size= 348kB time=00:00:09.31 bitrate= 306.3kbits/
frame= 282 fps=140 q=28.0 size= 499kB time=00:00:11.33 bitrate= 360.8kbits/
</code></pre>
<p>in fact, the above 4 line is the last line of ffmpeg command output which keeps changing, I want to print that change out, like </p>
<pre><code>18%
44%
69%
100%
</code></pre>
<p>how could I achieve this?</p>
| <shell><go> | 2016-05-07 17:01:37 | HQ |
37,091,357 | What's the difference between getElementById and getElementsByClassName | <p>I know maybe is not the right way of using the <code>getElementsByClassName</code>. For example the code below doesn't work as it is ¿why?, but when change <code>getElementsByClassName("demo")</code> for <code>getElementById("demo2")</code> does work</p>
<pre><code><!DOCTYPE html>
<html>
<body>
<p>Click the button.</p>
<button onclick="myFunction()">Try it</button>
<p class="demo" id="demo2">anything</p>
<script>
function myFunction() {
var str = "How are you doing today?";
var res = str.split(" ");
document.getElementsByNameClass("demo").innerHTML = res;
}
</script>
</body>
</html>
</code></pre>
| <javascript> | 2016-05-07 17:06:29 | LQ_CLOSE |
37,091,751 | Keras learning rate not changing despite decay in SGD | <p>For some reason my learning rate does not appear to change eventhough I set a decay factor. I added a callback to view the learning rate and it appears to be the same after each epoch. Why is it not changing</p>
<pre><code>class LearningRatePrinter(Callback):
def init(self):
super(LearningRatePrinter, self).init()
def on_epoch_begin(self, epoch, logs={}):
print('lr:', self.model.optimizer.lr.get_value())
lr_printer = LearningRatePrinter()
model = Sequential()
model.add(Flatten(input_shape = (28, 28)))
model.add(Dense(200, activation = 'tanh'))
model.add(Dropout(0.5))
model.add(Dense(20, activation = 'tanh'))
model.add(Dense(10, activation = 'softmax'))
print('Compiling Model')
sgd = SGD(lr = 0.01, decay = 0.1, momentum = 0.9, nesterov = True)
model.compile(loss = 'categorical_crossentropy', optimizer = sgd)
print('Fitting Data')
model.fit(x_train, y_train, batch_size = 128, nb_epoch = 400, validation_data = (x_test, y_test), callbacks = [lr_printer])
lr: 0.009999999776482582
Epoch 24/400
60000/60000 [==============================] - 0s - loss: 0.7580 - val_loss: 0.6539
lr: 0.009999999776482582
Epoch 25/400
60000/60000 [==============================] - 0s - loss: 0.7573 - val_loss: 0.6521
lr: 0.009999999776482582
Epoch 26/400
60000/60000 [==============================] - 0s - loss: 0.7556 - val_loss: 0.6503
lr: 0.009999999776482582
Epoch 27/400
60000/60000 [==============================] - 0s - loss: 0.7525 - val_loss: 0.6485
lr: 0.009999999776482582
Epoch 28/400
60000/60000 [==============================] - 0s - loss: 0.7502 - val_loss: 0.6469
lr: 0.009999999776482582
Epoch 29/400
60000/60000 [==============================] - 0s - loss: 0.7494 - val_loss: 0.6453
lr: 0.009999999776482582
Epoch 30/400
60000/60000 [==============================] - 0s - loss: 0.7483 - val_loss: 0.6438
lr: 0.009999999776482582
Epoch 31/400
</code></pre>
| <python><neural-network><keras> | 2016-05-07 17:42:53 | HQ |
37,092,737 | How to auto reload apps | <p>I'm just wondering how do apps like Facebook and Twitter automatically reload. For instance, if you get a message or a notification, you haven't requested it yourself. Is there a timer of sorts, or is there a smarter implementation?</p>
<p>Thanks in advance.</p>
| <android><ios><iphone><facebook> | 2016-05-07 19:20:50 | LQ_CLOSE |
37,092,911 | I want to use SQL in my app | Alamofire, Swift | <p>I want to use a localhost database in SQL for my IOS's app, how can I use .POST in a specific table ?</p>
<p>PD: I use Alamofire in Swift.</p>
| <iphone><database><swift><post><alamofire> | 2016-05-07 19:38:47 | LQ_CLOSE |
37,093,114 | Analysis of hostile code. How to deal with packer and how to figure out the language it is written on? | <p>I received a tailored email with an infected attachment from a public email. I would like to more about the payload. What is the right way to study this? I would like to use a debugger. Easier, but riskier option is to run it on Windows guest/Linux host on a sacrificial box without wifi card and comparing disk images before and after infection.
If I go the debugger way, how should I unpack the code?<br>
How to tell in what language the malware was written?<br>
Can any code be debugged by changing defensive conditional jumps (like "if debugger present" jump, or there are other pitfalls?<br>
How likely is it for malware jailbreak vmware and infect Linux host? </p>
| <debugging><malware> | 2016-05-07 20:00:36 | LQ_CLOSE |
37,093,773 | How to return array in php ? Acctually I want to return whole value of $x[] insted of last index of $x[].Please help me | How to return array in php ? Acctually I want to return whole value of $x[] insted of last index of $x[].Please help me...
<?php
function top() {
require './php/connection.php';
$sql = "SELECT * FROM tbl_add";
$query = mysqli_query($connect, $sql);
$n = 0;
while ($result = mysqli_fetch_assoc($query)) {
$a[$n] = $result['add_id'];
$n = $n + 1;
}
$n = $n - 1;
for ($j = 0; $j < $n; $j++) {
for ($i = 0; $i < $n - 1 - $j; $i++) {
if ($a[$i] > $a[$i + 1]) {
$tmp = $a[$i];
$a[$i] = $a[$i + 1];
$a[$i + 1] = $tmp;
}
}
}
for ($i = 0; $i <= $n; $i++) {
echo $a[$i] . '<br>';
}
$j = 1;
for ($i = 0; $i <= 5; $i++) {
$r = $a[$i];
$sql = "SELECT * FROM tbl_add WHERE add_id='$r'";
$query = mysqli_query($connect, $sql);
$result = mysqli_fetch_assoc($query);
if ($result) {
$x[] = $result['mail'];
return $x[];
}
}
}
?> | <php> | 2016-05-07 21:12:21 | LQ_EDIT |
37,094,520 | Laravel - route to folder inside public folder | <p>I install Laravel and inside laravel public folder I install Wordpress inside folder wordpress.</p>
<p>Now I need to make a route at domain.com to public/wordpress folder...</p>
<p>How to do that?</p>
<p>I try:</p>
<pre><code>Route::get('/', [function () {
return Redirect::to('/wordpress');
}]);
</code></pre>
<p>but this show me path in browser url ... domain.com/wordpress and I want only user to see just domain.com</p>
| <php><wordpress><laravel><routes> | 2016-05-07 22:54:38 | LQ_CLOSE |
37,095,061 | C++ difference between : , :: operators | <p>I new to programming. In stack overflow i couldn't see difference between <code>:</code> & <code>::</code> is mentioned. Could anyone can explain in detail it helps to beginner learners like me. Thank you. </p>
| <c++> | 2016-05-08 00:39:17 | LQ_CLOSE |
37,095,161 | Number of rows changes even after `pandas.merge` with `left` option | <p>I am merging two data frames using <code>pandas.merge</code>. Even after specifying <code>how = left</code> option, I found the number of rows of merged data frame is larger than the original. Why does this happen?</p>
<pre><code>panel = pd.read_csv(file1, encoding ='cp932')
before_len = len(panel)
prof_2000 = pd.read_csv(file2, encoding ='cp932').drop_duplicates()
temp_2000 = pd.merge(panel, prof_2000, left_on='Candidate_u', right_on="name2", how="left")
after_len = len(temp_2000)
print(before_len, after_len)
> 12661 13915
</code></pre>
| <python><pandas> | 2016-05-08 00:59:34 | HQ |
37,095,370 | Move a variable and operate on it | <p>Is the following code safe?</p>
<pre><code>struct Foo {
Foo bar() { return *this; }
} foo;
foo = std::move(foo).bar(); // is this safe?
</code></pre>
<p>I'm wondering if calling methods on an rvalue is safe.</p>
| <c++><c++11> | 2016-05-08 01:41:07 | LQ_CLOSE |
37,095,390 | I am very inexperienced with MySQL and I don't know how to troubleshoot this error. | I'm making a simple website for a class, and I am trying to save information to my database. The error is not very specific and I do not know which part of my code I need to fix.
Error message: "check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 2"
My PHP code:
<?php
include 'mysqli.php' ;
$result = $con->query("select * from setList s
left join songTable t on s.SetList_ID = t.Song_ID
left join bands b on s.SetList_ID = b.Band_ID");
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$setList = $_POST['setlist'];
$venue = $_POST['venue'];
$date = $_POST['dateOfShow'];
$band= $_POST['band'];
$set = $result->fetch_object();
//error handling and form
try {
if (empty($setList) || empty($venue) || empty($date) || empty($band)) {
throw new Exception(
"All Fields Required");
}
if (isset($set)) {
$id = $set->SetList_ID;
$q = "update setList set SetList_Name = '$setList',
Venue = '$venue', Show_Date = $date, Band_Name = '$band')";
}
else{
$q = "insert setList (SetList_Name, Venue, Show_Date, Band_Name)
values ('$setList', '$venue', $date, '$band')";
}
$result = $con->query($q);
if (!$result) {
throw new Exception($con->error);
}
header('Location:my_set-lists.php');
} catch(Exception $e) {
echo '<p class ="error">Error: ' .
$e->getMessage() . '</p>';
}
}
?> | <php><mysql> | 2016-05-08 01:46:06 | LQ_EDIT |
37,095,435 | Swift: Convenience initializers - Self used before self.init call | <p>We are getting the following error on the convenience method below:</p>
<blockquote>
<p>Self used before self.init call</p>
</blockquote>
<pre><code>class MyClass {
var id : Int
var desc : String
init?(id : Int, desc : String) {
self.id = id
self.desc = desc
}
convenience init?(id : Int?) {
guard let x = id else {
return
}
self.init(id : x, desc : "Blah")
}
}
</code></pre>
<p>How can we implement this type of behavior in Swift?</p>
| <ios><swift><initialization> | 2016-05-08 01:56:02 | HQ |
37,095,575 | Bootstrap button outline not working | <p>I am pretty new to Bootstrap, and am having a bit of trouble with getting my buttons styled correctly. I want a green(success) colored button, with just an outline as documented on their website <a href="http://v4-alpha.getbootstrap.com/components/buttons/#outline-buttons">here</a>. When I use the code suggested <code><button type="button" class="btn btn-success-outline">Success</button></code>, I get a grey button that has no apparent styling <a href="http://i.stack.imgur.com/vnA46.png">which looks like this</a>... Could anybody help me out?
Thanks!</p>
| <html><twitter-bootstrap><twitter-bootstrap-3> | 2016-05-08 02:21:40 | HQ |
37,095,809 | Macro and function with same name in header file | <p><code>tool.c</code></p>
<pre><code>#include <stdlib.h>
#include "tool.h"
void safeFree(void** pp) {
if (pp != NULL & *pp != NULL) {
free(*pp);
*pp = NULL;
}
}
</code></pre>
<p><code>tool.h</code></p>
<pre><code>#ifndef tool_h
#define tool_h
void safeFree(void** pp);
#define safeFree(p) safeFree((void**)&(p))
#endif /* tool_h */
</code></pre>
<p>I want to use the macro after I import <code>tool.h</code> in <code>main.c</code>, but the programme can't be compiled. Is there any way I could define macro and function with same name?</p>
| <c><macros> | 2016-05-08 03:09:45 | LQ_CLOSE |
37,096,367 | How to convert seconds to minutes and hours in javascript | <p>I have a count of seconds stored in variable <code>seconds</code>. I want to convert for example 1439 seconds to 23 minutes and 59 seconds. And if the time is greater than 1 hour (for example 9432 seconds), to 2 hours, 37 minutes and 12 seconds.</p>
<p>How can I achieve this?</p>
<p>I'm thinking of:</p>
<pre><code>var sec, min, hour;
if(seconds<3600){
var a = Math.floor(seconds/60); //minutes
var b = seconds%60; //seconds
if (b!=1){
sec = "seconds";
}else{
sec = "second";
}
if(a!=1){
min = "minutes";
}else{
min = "minute";
}
$('span').text("You have played "+a+" "+min+" and "+b+" "+sec+".");
}else{
var a = Math.floor(seconds/3600); //hours
var x = seconds%3600;
var b = Math.floor(x/60); //minutes
var c = seconds%60; //seconds
if (c!=1){
sec = "seconds";
}else{
sec = "second";
}
if(b!=1){
min = "minutes";
}else{
min = "minute";
}
if(c!=1){
hour = "hours";
}else{
hour = "hour";
}
$('span').text("You have played "+a+" "+hour+", "+b+" "+min+" and "+c+" "+sec+".");
}
</code></pre>
<p>But that's a lot of code, and it has to be calculated each second. How can I shrink this up?</p>
| <javascript> | 2016-05-08 04:58:11 | HQ |
37,096,521 | Why int32_t faster then int64_t? | <p>Example code:</p>
<pre><code>template<typename T>
inline void Solution() {
T n = 0;
T k = 0;
T s = 1;
while (k < 500) {
n += s++;
k = 2;
T lim = n;
for (T i = 2; i < lim; i++) {
if (n % i == 0) {
lim = n / i;
k += 2;
}
}
}
std::cout << "index: " << s << std::endl;
std::cout << "value: " << n << std::endl;
}
</code></pre>
<p>There is a difference between calculation time when i use int32_t and int64_t (more then 2x times). So, simple question is: "Why?"</p>
<pre><code>Solution<int32_t> -> 0.35s on x32 build
Solution<int64_t> -> 0.75s on x32 build
</code></pre>
| <c++> | 2016-05-08 05:24:08 | LQ_CLOSE |
37,096,550 | OCaml main fuction | I a bit new in OCaml and I am finishing my card game program.
I need a main function to run the others functions.
I try this:
let main () =
let deck = make_mazo in
let jugadores = players [] 0 in
dothemagic deck jugadores 0 [] [] [];;
But i get this error:
File "game.ml", line 329, characters 37-39:
Error: Syntax error
I think ;; is the problem and I need a different way to end the code. Also try with only ; and the problem is the same. | <functional-programming><ocaml><main> | 2016-05-08 05:28:06 | LQ_EDIT |
37,097,062 | PHP :Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, string given | <p>i am trying to fetch data as per following query </p>
<pre><code>$query= "SELECT * FROM residential ";
if($type!=""){
$query.=" AND type='$type'";
}
if($unit_type!=""){
$query.=" AND unit_type='$unit_type'";
}
if(($min_price!="") && ($max_price!="")){
$query.=" AND price BETWEEN '$min_price' AND '$max_price' ";
}
if(($min_bedrooms!="") && ($max_bedrooms!="")){
$query.=" AND bedrooms BETWEEN '$min_bedrooms' AND '$max_bedrooms'";
}
if($query==FALSE){
echo mysqli_error($connect);
die;
}
$result= mysqli_query($connect,$query);
</code></pre>
<p>this is how i use it </p>
<pre><code><div class="row">
<?php if(mysqli_num_rows($query)>0):?>
<?php while($row= mysqli_fetch_assoc($query)):
print_r($row);
die;
?>
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="row property-listing">
<div class="col-md-6 col-sm-6 col-xs-12">
<img src="images/1.png" class="img-responsive full-width">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 property-desc">
<h3>AED<br/> <?php echo $row['price'];?></h3>
<h5>Unit Type: <?php echo $row['unit_type'];?></h5>
<h5>Available for :<?php echo $row['type'];?></h5>
<h5>Location :<?php echo $row['area'];?></h5>
<h5>Bedrooms :<?php echo $row['bedrooms'];?></h5>
</div>
</div>
</div>
<?php endwhile;?>
<?php else:
echo 'We found no record for your search criteria ';
echo '<a href="index.html">Refine Search</a>'
?>
<?php endif;?>
</div>
</code></pre>
<p>This is what i get as error </p>
<blockquote>
<p>( ! ) Warning: mysqli_num_rows() expects parameter 1 to be
mysqli_result, string given</p>
</blockquote>
<p>values being posted and fetched are correct but something is wrong with query , Please help me sort it out </p>
<p>Thanks </p>
| <php><mysql><mysqli> | 2016-05-08 06:48:15 | LQ_CLOSE |
37,097,214 | This MySQL syntax (function) is error. I had checked it, but I can't repaired. How I can repair it? | CREATE FUNCTION FC_IDKRITERIA()
RETURNS CHAR(3)
AS
BEGIN
DECLARE @MAX INT , @KODEBARU CHAR(3)
SELECT @MAX = MAX (RIGHT(IDKRITERIA,2)) FROM KRITERIA
IF @MAX IS NULL
SET @MAX = 0
SET @KODEBARU = 'K' + RIGHT('0'+CONVERT(VARCHAR(3),@MAX+ 1 ) ,2)
RETURN @KODEBARU
END | <mysql><function><syntax-error> | 2016-05-08 07:09:58 | LQ_EDIT |
37,097,293 | How to return different value in Mockito based on parameter attribute? | <p>The class that I test receive a client wrapper:</p>
<p>The tested class (snippest)</p>
<pre><code>private ClientWrapper cw
public Tested(ClientWrapper cw) {
this.cw = cw;
}
public String get(Request request) {
return cw.getClient().get(request);
}
</code></pre>
<p>The test initialization:</p>
<pre><code>ClientWrapper cw = Mockito.mock(ClientWrapper.class);
Client client = Mockito.mock(Client.class);
Mockito.when(cw.getClient()).thenReturn(client);
//Here is where I want to alternate the return value:
Mockito.when(client.get(Mockito.any(Request.class))).thenReturn("100");
</code></pre>
<p>In the exmaple I always return "100", but the Request have an attribute <code>id</code> and I would like to return different values to <code>client.get(Request)</code> based on the <code>request.getId()</code> value.</p>
<p>How can I do it?</p>
| <java><mockito> | 2016-05-08 07:20:03 | HQ |
37,097,624 | I want to perform login and logout in ios | <p>I applied login and logout using variables but it's not successfully perform.
I want to perform login and logout functionality in ios, how can i achieve the functionality. I am new in ios please help me out. </p>
| <ios><objective-c><iphone><swift><generics> | 2016-05-08 08:07:15 | LQ_CLOSE |
37,097,662 | Android Spinner - How to position dropdown arrow as close to text as possible when options have different length? | <p>The options in my spinner has different length and currently the dropdown arrow is positioned far to the right based on the longest option, as shown in the screenshot below.</p>
<p><a href="https://i.stack.imgur.com/kt0ajm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kt0ajm.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/jPwEVm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jPwEVm.png" alt="enter image description here"></a></p>
<p>Is it possible to move the dropdown arrow so that it is dynamically positioned based on currently selected option? </p>
<p>Especially when the first option is just 'All', it looks weird when the dropdown arrow is so far away to the right.</p>
<p>Referring to Google Translate App where dropdown arrow is always positioned next to its text:
<a href="https://i.stack.imgur.com/IPMISm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IPMISm.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/paWgQm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/paWgQm.png" alt="enter image description here"></a></p>
| <android><android-spinner> | 2016-05-08 08:12:20 | HQ |
37,097,998 | How to make simple "linq" request? | I want to make "LINQ" request, where I have two lists (you can see on picture). Request should work with List<G> and i want to get GW2-GW5. I want to see it in style like "model.Select<G>( ... ).Where( ... ) ..."
 | <c#><linq> | 2016-05-08 08:52:56 | LQ_EDIT |
37,098,052 | Macros for excel to remove certain columns | I have an master sheet, but out of this sheet i only need certain columns to be displayed. Doing it manually is taking a long time and this worksheet is something i have to do once in a fortnight. Can anyone please suggest a macro formula. Thank you. | <vba><excel> | 2016-05-08 08:57:58 | LQ_EDIT |
37,098,405 | Javascript .querySelector find <div> by innerTEXT | <p>How can I find DIV with certain text? For example:</p>
<pre><code><div>
SomeText, text continues.
</div>
</code></pre>
<p>Trying to use something like this:</p>
<pre><code>var text = document.querySelector('div[SomeText*]').innerTEXT;
alert(text);
</code></pre>
<p>But ofcourse it will not work. How can I do it?</p>
| <javascript><innertext><selectors-api> | 2016-05-08 09:41:48 | HQ |
37,098,718 | Client OAuth Settings are not showing in my app advance settings in facebook login | <p>I am working and actually creating a login through facebook system and in order to redirect it, i am not getting any client OAuth settings in advance setting options while creating the app.</p>
| <facebook-javascript-sdk><facebook-oauth> | 2016-05-08 10:22:21 | HQ |
37,100,053 | How to define a mathematical function in SymPy? | <p>I've been trying this now for hours. I think I don't understand a basic concept, that's why I couldn't answer this question to myself so far.</p>
<p>What I'm trying is to implement a simple mathematical function, like this:</p>
<pre><code>f(x) = x**2 + 1
</code></pre>
<p>After that I want to derive that function.</p>
<p>I've defined the symbol and function with:</p>
<pre><code>x = sympy.Symbol('x')
f = sympy.Function('f')(x)
</code></pre>
<p>Now I'm struggling with defining the equation to this function <code>f(x)</code>. Something like <code>f.exp("x**2 + 1")</code> is not working.</p>
<p>I also wonder how I could get a print out to the console of this function after it's finally defined. </p>
| <python><sympy> | 2016-05-08 12:53:57 | HQ |
37,100,082 | Java project with Gradle and building jar file in Intellij IDEA - how to? | <p>Is there anywhere a tutorial on how to create Java project with Gradle and then build the jar file?</p>
<p>I'm running into various problems with that. When I create Java project and then add Gradle with File -> New -> Module -> Gradle -> ... then I get some errors about Java EE websocket's not available (I'm using Ultimate Edition) but nevermind about that, I managed to create that project by selecting File -> New -> Project... -> Gradle -> ... and now I have my Java project with Gradle working properly (I can debug it in IDE) but when I try to create an artifact (jar file) I get various errors depending on how much I messed up in project structure settings...</p>
<pre><code>Buildfile: build.xml does not exist!
Build failed
</code></pre>
<p>or</p>
<pre><code>Error: Could not find or load main class Main
</code></pre>
<p>I think that this project is such a mess right now that the best solution would be to create another new project and just copy Main.class and Gradle's dependencies into this new project.</p>
<p>But how to make it properly?</p>
| <java><jakarta-ee><intellij-idea><gradle><jar> | 2016-05-08 12:56:54 | HQ |
37,100,341 | Shared Item Transition not working in fragment on back | <p>I'm working on an Android app with the <a href="https://www.toptal.com/android/android-fragment-navigation-pattern" rel="noreferrer">Fragment Navigation Pattern</a> (one Activity with many Fragments). I've managed to implement <em>Shared Item Transitions</em> by following <a href="https://medium.com/@bherbst/fragment-transitions-with-shared-elements-7c7d71d31cbb" rel="noreferrer">this guide</a> but they <strong>only work going forward, not on hitting back.</strong></p>
<p>My Fragment (called <code>UserFragment</code>) is composed of a <code>ViewPager</code> with 3 more fragments with RecyclerViews. Clicking any item in the RecyclerViews opens another <code>UserFragment</code> with the same views. The transition works perfectly when switching to the new fragment, but <strong>I'm unable to get it to work when closing it</strong>. When hitting back, the fragment simply fades out and the previous fragment fades in.</p>
<h2>TL;DR:</h2>
<ul>
<li>The Shared Element in question is the Circular Image View on top</li>
<li>Its <code>transitionName</code> is <em>profile</em></li>
<li><code>SharedItemTransition</code> is a custom class that extends <code>TransitionSet</code></li>
<li>I've given each item in each recyclerview unique transition names, by including their user id, list type and position index (and if they weren't unique, it also wouldn't work going forward)</li>
</ul>
<hr>
<p>Here's the <code>onBindViewHolder</code> method of my <strong>RecyclerView Adapter:</strong></p>
<pre><code>public void onBindViewHolder(final UserViewHolder uvh, int position) {
final LocUser user = users.get(position);
String transition = "user_" + user.id() + "_type_" + type + "_item_" + position + "_profile_image";
uvh.name.setText(user.name());
uvh.username.setText(user.handle());
Global.setImage(uvh.userImage, user.profileImage());
ViewCompat.setTransitionName(uvh.userImage, transitionName(position));
uvh.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.openUserProfile(user, uvh.userImage);
}
});
}
</code></pre>
<hr>
<p>Here's my <strong>activity method</strong> that invokes the <code>FragmentManager</code> and starts the animation:</p>
<pre><code>public void openUserProfile(LocUser user, ImageView view) {
UserProfileFragment uf = UserProfileFragment.create(user);
uf.setExitTransition(new Fade());
uf.setEnterTransition(new Fade());
uf.setSharedElementEnterTransition(new SharedItemTransition());
uf.setSharedElementReturnTransition(new SharedItemTransition());
getSupportFragmentManager()
.beginTransaction()
.addSharedElement(view, "profile")
.replace(R.id.container, uf)
.addToBackStack(null)
.commit();
}
</code></pre>
<hr>
<p>This is what it looks like:</p>
<p><a href="https://i.stack.imgur.com/FJ9DC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FJ9DC.png" alt="Screenshot"></a></p>
| <android><android-fragments><transitions> | 2016-05-08 13:25:52 | HQ |
37,100,665 | TCL - Create a regexp which will return the first match in a repeating string | <p>I'm trying to create a regexp that will capture the first occurrence of a repeating string.</p>
<p>The string is a "list" of RSA certificates , in succession. I am only interested in the first. </p>
<p>The string looks like:</p>
<pre><code>-----BEGIN CERTIFICATE-----
CERT1..........
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
CERT2............
-----END CERTIFICATE-----
...
...
...
</code></pre>
<p>I've tried variations on the following , but it is returning the full list rather than the first item:</p>
<pre><code>set match [regexp {(-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----$).*} $certs matchAll firstCert]
</code></pre>
| <regex><list><tcl> | 2016-05-08 14:02:14 | LQ_CLOSE |
37,100,715 | retrieve data from a form and insert it in a database using adapters in worklight? | <p>i have an inscription form , and i don't know how to retrieve data from this form and send it to the database using adapter in worklight
i think that i should use jquery . val() to retrieve data and use it in a procedure to put it in the database , please some help :/
thanks !!</p>
<p>var procedure1Statement = WL.Server.createSQLStatement("select COLUMN1, COLUMN2 from TABLE1 where COLUMN3 = ?");
function procedure1(param) {
return WL.Server.invokeSQLStatement({
preparedStatement : procedure1Statement,
parameters : [param]
});
}</p>
| <database><forms><ibm-mobilefirst><adapter> | 2016-05-08 14:07:39 | LQ_CLOSE |
37,100,721 | Biztalk Design patterns | I am very new to Biztalk. I have been asked to create a application in Biztalk. I am facing some design level challenges.
Following are some of them:
1. Best approach in creating a project
How to crate Biztalk solution. Means how to create projects. Do we need to create different projects for Maps/Orchestation/pipelines and references. Which is the best approach to develop a project?
2. Can we check in a Biztalk project in TFS
How multiple people can work on a single Biztalk solution? Can it be checked in in TFS and multiple people can take it and work on it? How merging will work?
3. Code review
Is there any way to review a Biztalk package? What are the best practices?
Thanks in advance.
| <visual-studio><biztalk><biztalk-2010><biztalk-2013> | 2016-05-08 14:08:54 | LQ_EDIT |
37,101,114 | What to download in order to make nltk.tokenize.word_tokenize work? | <p>I am going to use <code>nltk.tokenize.word_tokenize</code> on a cluster where my account is very limited by space quota. At home, I downloaded all <code>nltk</code> resources by <code>nltk.download()</code> but, as I found out, it takes ~2.5GB.</p>
<p>This seems a bit overkill to me. Could you suggest what are the minimal (or almost minimal) dependencies for <code>nltk.tokenize.word_tokenize</code>? So far, I've seen <code>nltk.download('punkt')</code> but I am not sure whether it is sufficient and what is the size. What exactly should I run in order to make it work?</p>
| <python><nltk> | 2016-05-08 14:49:14 | HQ |
37,101,173 | An error occurred when attaching the database(s). Click the hyperlink in the Message column for details | <p>i am trying to attach external database named ( HaseebProject.mdf) but every time i got an error
" An error occurred when attaching the database(s). Click the hyperlink in the Message column for details."
What'sthe error is there..?? even there is any error message in message field as shown.<a href="http://i.stack.imgur.com/ds1db.png" rel="noreferrer">enter image description here</a> </p>
<p>When i click on add button to add database there are two paths in directory for database. i have tried with both but he same error.<a href="http://i.stack.imgur.com/LfYL5.png" rel="noreferrer">enter image description here</a></p>
| <sql-server><database-connection> | 2016-05-08 14:56:21 | HQ |
37,101,240 | Do deleted Amazon S3 Bucket names become available for re-use | <p>If I delete a Bucket from my Amazon S3 account, does the name become available for use elsewhere?
I setup a bucket named "WXY234" in my S3 account, but now I'd like to have that bucket name in a different account. If I delete it from my account, will the name be released into the wild so I can use it elsewhere? If so, how long does it take for the released name to become available?</p>
| <amazon-s3> | 2016-05-08 15:02:51 | HQ |
37,101,301 | Is this std::ref behaviour logical? | <p>Consider this code:</p>
<pre><code>#include <iostream>
#include <functional>
int xx = 7;
template<class T>
void f1(T arg)
{
arg += xx;
}
template<class T>
void f2(T arg)
{
arg = xx;
}
int main()
{
int j;
j=100;
f1(std::ref(j));
std::cout << j << std::endl;
j=100;
f2(std::ref(j));
std::cout << j << std::endl;
}
</code></pre>
<p>When executed, this code outputs</p>
<pre><code>107
100
</code></pre>
<p>I would have expected the second value to be 7 rather than 100.</p>
<p>What am I missing?</p>
| <c++><c++11><ref> | 2016-05-08 15:08:04 | HQ |
37,101,374 | How to uninstall LLVM? | <p>I installed LLVM from source (using CMake and <code>make install</code>) but I am unable to uninstall it because there is no <code>make uninstall</code> avalaible.</p>
<p>This is LLVM version 3.5.2.</p>
<p>I use ArchLinux.</p>
<p>How can I uninstall LLVM in an automated way?</p>
| <linux><llvm> | 2016-05-08 15:13:58 | HQ |
37,101,643 | Java comparator sort in reverse order | <p>I would like to sort from highest to lowest.</p>
<p>From lowest to highest, you would normally do:</p>
<pre><code>@Override
public int compare(Person p1, Person p2) {
return (p1.getAge() - p2.getAge());
}
</code></pre>
<p>This would sort people by age from lowest to highest.</p>
<p>How do I do the reverse of this?</p>
| <java><sorting><compare><comparator> | 2016-05-08 15:39:58 | LQ_CLOSE |
37,101,800 | How to debug type-level programs | <p>I'm trying to do some hoopy type-level programming, and it just doesn't work. I'm tearing my hair out trying to figure out why the heck GHC utterly fails to infer the type signatures I want.</p>
<p>Is there some way to make GHC <em>tell me</em> what it's doing?</p>
<p>I tried <code>-ddump-tc</code>, which just prints out the final type signatures. (Yes, they're wrong. Thanks, I already knew that.)</p>
<p>I also tried <code>-ddump-tc-trace</code>, which dumps out ~70KB of unintelligible gibberish. (In particular, I can't see any user-written identifiers mentioned <em>anywhere</em>.)</p>
<p>My code is <em>so close</em> to working, but somehow an extra type variable keeps appearing. For some reason, GHC can't see that this variable should be completely determined. Indeed, if I <em>manually</em> write the five-mile type signature, GHC happily accepts it. So I'm clearly just missing a constraint somewhere... <em>but where?!?</em> >_<</p>
| <debugging><haskell><types> | 2016-05-08 15:54:54 | HQ |
37,102,676 | File Handling Calculation In C | <p>I want to calculate body mass index and write it to the file.I've tried to calculate it in a another function as you can see but output is just 0.Then I've tried different functions like int calculate returns to w/h*h but none of them give me the right answers.I couldn't find another way.</p>
<pre><code>#include <stdio.h>
struct person
{
int personId;
double height;
double weight;
double BMI;
};
void calculate (double h, double w)
{
struct person p1;
p1.BMI = w / h*h ;
}
void write () {
FILE *file;
struct person p1;
file = fopen("bmi.txt","w");
if (file == NULL)
{
printf("Error");
}
else
{
printf("Person ID: "); scanf("%d",&p1.personId);
printf("Height: "); scanf("%lf",&p1.height);
printf("Weight: "); scanf("%lf",&p1.weight);
calculate(p1.height,p1.weight);
fwrite(&p1,sizeof(p1),1,file);
}
fclose(file);
}
void read() {
FILE *file;
struct person p1;
file = fopen("bmi.txt","r");
if (file == NULL)
{
printf("Error");
}
else
{
while (!feof(file))
{
fread(&p1,sizeof(p1),1,file);
printf("Person ID: %d\n",p1.personId);
printf("Height: %f\n",p1.height);
printf("Weight: %f\n",p1.weight);
printf ("BMI: %f\n",p1.BMI);
}
}
fclose(file);
}
int main () {
write();
read();
}
</code></pre>
| <c><file><file-handling> | 2016-05-08 17:23:42 | LQ_CLOSE |
37,102,685 | Play musical notes in Swift Playground | <p>I am trying to play a short musical note sequence with a default sine wave as sound inside a Swift Playground. At a later point I'd like to replace the sound with a <em>Soundfont</em> but at the moment I'd be happy with just producing some sound. </p>
<p>I want this to be a midi like sequence with direct control over the notes, not something purely audio based. The <code>AudioToolbox</code> seems to provide what I am looking for but I have troubles fully understanding its usage. Here's what I am currently trying</p>
<pre><code>import AudioToolbox
// Creating the sequence
var sequence:MusicSequence = nil
var musicSequence = NewMusicSequence(&sequence)
// Creating a track
var track:MusicTrack = nil
var musicTrack = MusicSequenceNewTrack(sequence, &track)
// Adding notes
var time = MusicTimeStamp(1.0)
for index:UInt8 in 60...72 {
var note = MIDINoteMessage(channel: 0,
note: index,
velocity: 64,
releaseVelocity: 0,
duration: 1.0 )
musicTrack = MusicTrackNewMIDINoteEvent(track, time, &note)
time += 1
}
// Creating a player
var musicPlayer:MusicPlayer = nil
var player = NewMusicPlayer(&musicPlayer)
player = MusicPlayerSetSequence(musicPlayer, sequence)
player = MusicPlayerStart(musicPlayer)
</code></pre>
<p>As you can imagine, there's no sound playing. I appreciate any ideas on how to have that sound sequence playing aloud.</p>
| <ios><swift><audio><swift-playground><audiotoolbox> | 2016-05-08 17:24:41 | HQ |
37,102,841 | Laravel change pagination data | <p>My Laravel pagination output is like laravel pagination used to be, but I need to change the data array for each object.
My output is:</p>
<p><a href="https://i.stack.imgur.com/wokI8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wokI8.png" alt="Output"></a></p>
<p>As you can see, the data object has 2 items, which I need to change.</p>
<p>My code is:</p>
<pre><code>$items = $this->items()
->where('position', '=', null)
->paginate(15);
</code></pre>
<p>Which returns the user items with pivot table, but I don't like the way the pivot table is shown in the JSON, so I decided to change the items and organize each item with the pivot before the item.</p>
<p>For this purpose, I tried to use <code>foreach</code></p>
<pre><code>foreach ($items->data as $item)
{
}
</code></pre>
<p>which giving my an error, for a reason I don't know:</p>
<pre><code>Undefined property: Illuminate\Pagination\LengthAwarePaginator::$data"
status_code: 500
</code></pre>
<p>Any help?</p>
| <laravel> | 2016-05-08 17:38:21 | HQ |
37,102,963 | how to Read all Whatsapp Messages using Python or JAVA with the new whatsapp protocols and settings | I want to read all the whatsapp messages from the backup taken from the Windows phone and write those messages in document or in the iphone.
I have read many questions, that were limited to crypt5 only as the whatsapp has changed alot. Following the the order of my backup file.
[![enter image description here][1]][1]
How to read and write the whatsapp messages from this backup file.
[1]: http://i.stack.imgur.com/XH7Wj.png | <java><python><database><whatsapp> | 2016-05-08 17:50:25 | LQ_EDIT |
37,103,054 | Redis Installation fails when running make command | <h2>Redis installation on RHEL fails when running make command. Below is the output</h2>
<pre><code>cd src && make all
make[1]: Entering directory `/root/Downloads/redis-3.2.0/src'
CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/Downloads/redis-3.2.0/src'
make: *** [all] Error 2
</code></pre>
| <redis> | 2016-05-08 17:59:36 | HQ |
37,103,087 | How to store php blog post in mysql database with images and other html text format? | <p>I'm working on my php blog project.How can I store images from a blog post to a directory?
Blog post may contain strong, italic, web link,list, images and so on.
<br>(I'm php beginner. Thanks in advance.) </p>
| <php><mysql><regex><web><mysqli> | 2016-05-08 18:02:28 | LQ_CLOSE |
37,103,099 | swift i can't show or hide my label? | I have a HUGE problem.
What I wish for:
I wish for a label which is hidden and uneditable when the view loads or when pressing a button besides the button with the tag "15", and by pressing the button with the tag "15" is the only way for the label to show up and be editable.
my problem:
my problem is that when the view did load, it is not hidden at all and when I press the other buttons it doesn't hide either.
I have tried to set the "label.hidden = true"
inside the "weak var label : UILabel! {...}" (where I define the label) but when I then press the button with the tag "15" it doesn't show up.
btw don't worry about the other button tags, they are all included in the
"buttonAclicked" function, i have not included them because i thought it would take to much space
class TriangleViewController : UIViewController {
weak var label : UILabel! {
var label = UILabel(frame: CGRectMake(0 * view.bounds.width, 0.2 * view.bounds.height, 1 * view.bounds.width, 0.06 * view.bounds.height))
// label.center = CGPointMake(0.5 * view.bounds.width, 0.57 * view.bounds.height)
label.backgroundColor = UIColor.whiteColor()
label.textAlignment = NSTextAlignment.Right
label.font = label.font.fontWithSize(28)
label.text = "0"
label.tag = 20
self.view.addSubview(label)
return label
}
override func viewDidLoad() {
label.hidden = true
}
func buttonAclicked(sender: UIButton) {
switch sender.tag {
case 11 :
print("det virker squ")
label.hidden = true
break
//MARK: KNAPPERNE P{ TREKANTERNE CASES
case 15 :
print("button A was pressed")
label.hidden = false
label.setNeedsDisplay()
activeInput = 1
break
case 16 :
print("button B was pressed")
label.hidden = true
activeInput = 2
break
case 17 :
print("button C was pressed")
activeInput = 3
break
case 18 :
print("button Y was pressed")
label.hidden = true
activeInput = 4
break
case 19 :
print("button X was pressed")
label.hidden = true
activeInput = 5
break
default :
print("wrong button")
activeInput = 0
}
}
} | <swift><button><label><edit><show-hide> | 2016-05-08 18:03:16 | LQ_EDIT |
37,103,564 | Why aren't my onclick events working? | <p>Here is a snippet of my code on <a href="https://jsfiddle.net/dreami/jy69s6r3/2/" rel="nofollow">jsfiddle</a>.</p>
<p>I want the "+ Create Forum" button to show the form, "Cancel" button to reset the form and hide it, and if you want to see the form, delete "style="display: none".</p>
<p>I used a lot of examples out of w3schools and I have tried to use all its examples of writing a show and hide, one of the resets worked but it was a onclick="this.reset()" which wasn't what I wanted because I wanted it to hide too.</p>
<pre><code><html>
<body>
<button class="btn btn-default" type="submit" id="createform">+ Create Forum</button>
<div class="form-group" id="createForum">
<form action="forums.php" method="get" id="forumForm" style="display: none">
<label>Forum name:</label>
<input type="text" class="form-control" id="forumName">
<label>Description:</label>
<textarea class="form-control" rows="5" id="description"></textarea>
<button class="btn btn-danger" type="submit" name="create">Crear</button>
<input type="button" value="Reset Form" onclick="clearing()">
</form>
</div>
</body>
<script type="text/javascript">
$("#createform").click(function() {
$("#forumForm").show();
});
function clearing() {
document.getElementById("forumForm").reset();
}
</script>
</code></pre>
| <javascript><html> | 2016-05-08 18:48:07 | LQ_CLOSE |
37,103,814 | How does the server know when to serve an amp page | <p>I understand that there will be a version of a site with HTML designed for desktop devices and then the AMP pages.</p>
<p>Is there anything I need to do so that the site serves AMP content to mobile devices?</p>
| <redirect><amp-html> | 2016-05-08 19:11:19 | HQ |
37,103,958 | Difference between Thymeleaf include and replace? | <p>What is the difference between the two Thymeleaf attributes: <code>th:include</code> and <code>th:replace</code>?</p>
| <thymeleaf> | 2016-05-08 19:27:43 | HQ |
37,104,033 | Error: It looks like you called `mount()` without a global document being loaded | <p>I'm trying to mount a component for testing with enzyme, and get this error.</p>
| <reactjs><enzyme> | 2016-05-08 19:35:32 | HQ |
37,104,699 | AWS EB Error: Incorrect application version found on all instances | <p>I am trying to use the EB CLI to deploy an application into an environment but I seem to be getting strange errors. Is there a way to empty out previous application versions so I can upload a fresh application?</p>
<p>The message I see after I execute eb deploy.</p>
<pre><code>Update environment operation is complete, but with errors. For more information, see troubleshooting documentation.
</code></pre>
<p>I am currently getting this error:</p>
<pre><code>Incorrect application version found on all instances. Expected version [app version]
</code></pre>
<p>The logs file also seems to be getting deleted for some reason.</p>
| <ruby-on-rails><amazon-web-services><deployment><amazon-elastic-beanstalk><puma> | 2016-05-08 20:53:28 | HQ |
37,105,450 | How To insert Image to database from picturebox | **i have a picturebox and i want to save the picture of that in SQLServer Database (VarBinary)** | <c#><sql><sql-server><winforms> | 2016-05-08 22:22:00 | LQ_EDIT |
37,105,523 | What lengths code in matlab? | So I am trying to understand what length is all about. Say we have vector A = [1,2,3,4,5,6,7,8] and when we code up length(A) it spits out 8 for the # of elements.
How does the length command work.
Ive been thinking its a for loop like
A = [could be any size];
for i = A % takes each element of a
i = i+1; adds 1 for each new element thus counting the elements
end
Please help my understanding | <matlab> | 2016-05-08 22:30:02 | LQ_EDIT |
37,105,696 | How to have a set of sets in Python? | <p>In Python there's no full support for heterogeneous data structures. For example this fails:</p>
<pre><code>set(set(1,2),set(2,3))
</code></pre>
<p>What's the best way to treat sets of sets?</p>
| <python><list><python-2.7><set> | 2016-05-08 23:00:40 | HQ |
37,106,268 | Android Studio SDK Manager | I've installed Android Studio along with sdk , but in sdk manager notifies that sdk has been **partially installed** and also some of the options in sdk like **(sdk tools and sdk updates sites tab are disabled)**. Also I'm not able to add previous or other sdk versions. Sdk Manager show the updates , but its disabled and thus not able to download and install them.
Yes I've tried to run as admin , but it didn't helped | <android><android-studio><android-sdk-manager> | 2016-05-09 00:26:58 | LQ_EDIT |
37,106,411 | How to bundle video with application | <p>I have seen a lot of tutorials showing how to play a video from a URL but I want to be able to play a video that I put in my application before I build it. </p>
<p>Is it possible?</p>
<p>Also for those saying that my app will become too big, the video is only 267kb.</p>
| <android><android-videoview> | 2016-05-09 00:49:22 | LQ_CLOSE |
37,106,593 | Elixir Sleep / Wait for 1 Second | <p>How to sleep / wait for one second?</p>
<p>Best I could find was something like this (in iex):</p>
<pre><code>IO.puts "foo" ; :timer.sleep(1); IO.puts "bar"
</code></pre>
<p>But both of my puts happen with no delay.</p>
| <elixir><iex> | 2016-05-09 01:17:55 | HQ |
37,106,732 | I am trying to design a program that compares two strings for the same character in the same positions but same error keeps popping up help please | Length does not matter in this regard so for example:
string 1: "hi--there-you." "-15-389" "criminal-plan" "abc"
string 2: "12--(134)-7539" "-xy-zzy" "(206)555-1384" "9.8"
Both pairs would return True. My problem is that when I try to compile the code below I get the following error:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.charAt(Unknown Source)
at SameDashes.sameDashes(SameDashes.java:20)
at SameDashes.main(SameDashes.java:4)
public static boolean sameDashes(String a, String b){
int minlength = Math.min(a.length(), b.length());
String smallstring="";
String bigstring="";
if(a.length()== minlength){
smallstring = a;
bigstring = b;
}
else {
smallstring = b;
bigstring =a;
}
int counter = 0;
do {
if(bigstring.charAt(smallstring.indexOf('-',counter))!='-'){
return false;
}
else if(bigstring.indexOf('-',counter)!= -1){
return false;
}
counter++;
}while(counter<= bigstring.length());
return true;
} | <java><eclipse><boolean><do-while> | 2016-05-09 01:42:17 | LQ_EDIT |
37,106,879 | How do I check the last integer in the file in C? | <p>I need some help in finding the last integer in the file for my program. I have a file called "sample.txt" and I have a bunch of numbers in the file so I just want to get the last integer in the file and for example print it. Can somebody help me?</p>
| <c> | 2016-05-09 02:08:19 | LQ_CLOSE |
37,108,241 | Html isn't recognizing the tags that Angularjs spitting out | <p>Angular</p>
<pre><code> $scope.name = "<h1>John Doe</h1>"
</code></pre>
<p>HTML</p>
<pre><code> <div>{{name}}</div>
</code></pre>
<p>Outputs:</p>
<pre><code> <h1>John Doe</h1>
</code></pre>
<p>How do I make it so Html recognize the tags that I'm spitting on the page.</p>
| <javascript><html><angularjs> | 2016-05-09 05:26:18 | LQ_CLOSE |
37,108,911 | Fetech single record in a table having duplicate values using Linq | I am stuck with below issue. Kindly help
[Table structure][1]
I want to fetch records as below
[ExpectedResults][2]
So the address should follow this order
Mail
Home
Work
If Mail is present pick the record else if check if Home is present then pick the record and else if check if Work is present then pick that record.
[1]: http://i.stack.imgur.com/1MGm6.jpg
[2]: http://i.stack.imgur.com/b46Pd.jpg | <c#><linq> | 2016-05-09 06:18:29 | LQ_EDIT |
37,108,955 | PHP For Loop Working | <p>I have few lines of code that I think will work normally in any language. But this is not working in PHP. In my case I want to print numbers in ascending order. The code I have written is below:</p>
<pre><code>$i = 0;
printf("<p>Numbers in Ascending Order : ");
for (;++i <= 10;) {
printf("%3d", $i);
printf("\n\n");
}
</code></pre>
<p>But I get a syntax error which is given below:</p>
<blockquote>
<p>Parse error: syntax error, unexpected '<=' (T_IS_SMALLER_OR_EQUAL),
expecting</p>
</blockquote>
<p>Why is PHP displaying an error message like this ?</p>
| <php> | 2016-05-09 06:21:11 | LQ_CLOSE |
37,109,968 | How to convert binary fraction to decimal | <p>Javascript has the function <code>parseInt()</code> which can help convert integer in a binary form into its decimal equivalent:</p>
<pre><code>parseInt("101", 2) // 5
</code></pre>
<p>However, I need to convert binary fraction to its decimal equivalent, like:</p>
<pre><code>0.101 = 0.625
</code></pre>
<p>I can write my own function that would calculate the result like the following:</p>
<pre><code>1 * Math.pow(2, -1) + 0*Math.pow(2, -2) + 1*Math.pow(2, -3) // 0.625
</code></pre>
<p>But I'm wondering whether there is anything standard already.</p>
| <javascript><binary> | 2016-05-09 07:28:17 | HQ |
37,110,092 | Database connection failed from load runner | i am using vugen 1 version . i want to connect it to oracke 11g . could you please mention the complete process for it as i did performance of web applications earlier. Thanks. | <database><oracle><testing><vugen> | 2016-05-09 07:35:53 | LQ_EDIT |
37,110,130 | please help me with #1452 error | i am new to php coding and donn know much of it..pls help me...
Cannot delete or update a parent row: a foreign key constraint fails (`sponge`.`taxonomy`, CONSTRAINT `taxonomy_ibfk_1` FOREIGN KEY (`organism_id`) REFERENCES `organism` (`organism_id`))
i am getting this error while deleting entire record.Actually i wanted to deleted entire record from all table associated by Organism_id in spong DB.
my Organism Table is:-
CREATE TABLE IF NOT EXISTS `organism` (
`organism_id` int(11) NOT NULL AUTO_INCREMENT,
`experts_id` int(11) NOT NULL,
`literature_id` int(11) NOT NULL,
`genus` varchar(255) NOT NULL,
`species` varchar(255) NOT NULL,
`scientific_name` varchar(255) NOT NULL,
`organism_type` varchar(255) NOT NULL,
`author_org` varchar(255) NOT NULL,
`found_year` varchar(255) NOT NULL,
`curated_year` date NOT NULL,
`curated_status` varchar(10) NOT NULL,
PRIMARY KEY (`organism_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=60 ;
and Taxonomy table is:
CREATE TABLE IF NOT EXISTS `taxonomy` (
`taxonomy_id` int(11) NOT NULL AUTO_INCREMENT,
`organism_id` int(11) NOT NULL,
`kingdom` varchar(255) NOT NULL,
`phylum` varchar(255) NOT NULL,
`class` varchar(255) NOT NULL,
`order_tax` varchar(255) NOT NULL,
`family` varchar(255) NOT NULL,
PRIMARY KEY (`taxonomy_id`),
KEY `organism_id` (`organism_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=50 ;
but when i am using delete query:-
SELECT a.*,u.*,s.*,b.*,c.*,d.*,e.*,i.*,m.*
FROM organism a
JOIN taxonomy u
ON u.organism_id = a.organism_id
JOIN synonym s
ON s.organism_id = u.organism_id_id
JOIN biogeography b
ON b.organism_id = s.organism_id_id
JOIN common_name c
ON c.organism_id = b.organism_id_id
JOIN description d
ON d.organism_id = c.organism_id_id
JOIN ecology e
ON e.organism_id = d.organism_id_id
JOIN economic_importance i
ON i.organism_id = e.organism_id_id
JOIN images m
ON m.organism_id = i.organism_id_id
WHERE m.organism_id = 59
i am getting above error...
please help to write delete query and how to remove above #1452 error...
please help me... | <mysql> | 2016-05-09 07:38:00 | LQ_EDIT |
37,110,394 | How can I create Instagram like profile page in Swift | <p>I'm currently creating iOS app and having a problem with the usage of UICollectionView.
When you create Instagram-like profile page, the simple way of doing is, I guess, having a UIView on top of VC which contains user data and having a collectionView below that. But in my case, problem comes up when I scroll down collectionView. it doesn't scroll all of VC but only collectionView area scrolls down. And I have no idea how can I implement the scroll action correctly.
Thanks for your help!!</p>
| <swift><uicollectionview> | 2016-05-09 07:54:31 | LQ_CLOSE |
37,110,651 | How to check anaconda's version on mac? | <p>I installed <code>anaconda</code> a while ago, and I want to know if I need to re-install it to catch up the new updates.</p>
<p>However, i don't know how to check the current version of <code>anaconda</code></p>
<p>In command line, I type <code>anaconda -V</code> it gives</p>
<pre><code>anaconda Command line client (version 1.2.2)
</code></pre>
<p>For <code>anaconda -v</code> it returns</p>
<pre><code>anaconda: error: too few arguments
</code></pre>
| <python><anaconda> | 2016-05-09 08:10:02 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.