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 |
|---|---|---|---|---|---|
34,683,653 | google maps your timeline api | <p>google maps' new feature your timeline <a href="https://www.google.com/maps/timeline">https://www.google.com/maps/timeline</a> seems to be useful to retrieve location history for a given user, my question is
how to use google maps to retrieve this timeline ?
it is possible ?
sorry am new to google world and i have looked for this information on their site but no news.</p>
<p>Thanks !</p>
| <javascript><google-maps> | 2016-01-08 18:25:35 | HQ |
34,683,793 | How to generate random number that must contains predefined characters? | <p>In my application i need to generate random numbers that should contain certain character like capital letter, a number and of certain length.
It will be an honor if you guys help me out.</p>
| <php> | 2016-01-08 18:34:52 | LQ_CLOSE |
34,684,376 | Psycopg2 Python SSL Support is not compiled in | <p>I am trying to connect to my postgres database using psycopg2 with sslmode='required' param; however, I get the following error</p>
<pre><code>psycopg2.OperationalError: sslmode value "require" invalid when SSL support is not compiled in
</code></pre>
<p>Heres a couple details about my system</p>
<ul>
<li>Mac OS X El Capitan</li>
<li>Python 2.7</li>
<li>Installed psycopg2 via pip</li>
<li>Installed python via homebrew</li>
</ul>
<p>Here is what I tried to do to fix the problem</p>
<ul>
<li><code>brew uninstall python</code></li>
<li><code>which python</code> still shows python living in <code>/usr/local/bin/python</code>, tried to uninstall this but couldnt. And heard that this is the python that the OS uses and should not be uninstalled anyways</li>
<li><code>brew install python --with-brewed-openssl --build-from-source</code></li>
<li><code>pip uninstall psycopg2</code></li>
<li><code>pip install psycopg2</code></li>
</ul>
<p>After doing all of this, the exception still happens. I am running this python script via <code>#!/usr/bin/env python</code> Not sure if it matters, but that is a different directory than the one that <code>which python</code> shows</p>
| <python><postgresql><python-2.7><ssl><psycopg2> | 2016-01-08 19:13:16 | HQ |
34,684,796 | Understanding Arraylist is not Thread safe through a java example | I am trying to understand how Arraylist is not thread safe through a java program.Attached is my program.
import java.util.ArrayList;
import java.util.List;
public class class1
{
static List ar=new ArrayList(1);
public static void main(String[] args) throws InstantiationException,
IllegalAccessException, ClassNotFoundException, InterruptedException
{
Thread t1= new Thread()
{
public void run() {
while(true)
{
ar.add(new Object());
}
}
};
Thread t2=new Thread()
{
public void run()
{
while(true)
{
ar=new ArrayList(1);
ar.add(new Object());
ar.add(new Object());
}
}
};
t1.start();
Thread.sleep(100);
t2.start();
}
}
The error i got is:
Exception in thread "Thread-0" java.lang.ArrayIndexOutOfBoundsException: 2
at java.util.ArrayList.add(Unknown Source)
at class1$1.run(class1.java:22)
I understand that the exception is caused by a thread.However,I am not getting a broader picture on how it is actually functioning.Any help would be highly appreciated.
| <java><multithreading><arraylist><collections> | 2016-01-08 19:39:37 | LQ_EDIT |
34,684,846 | how to Detect if Keyboard is shown in Xcode UI test | <p>I am writing a UI text in swift under the new Xcode 7 UI test framework.
the requirement is to test whether the system keyboard is shown in an app.
can someone give me a clue on how to do that? thanks</p>
| <ios><iphone><xcode><swift><uitest> | 2016-01-08 19:43:31 | HQ |
34,685,072 | react / redux-form: how to return promise from onSubmit? | <p>I'm trying to wrap my head around <a href="http://rackt.org/redux/" rel="noreferrer">redux</a>, <a href="http://rackt.org/redux/docs/basics/UsageWithReact.html" rel="noreferrer">react-redux</a> and <a href="http://erikras.github.io/redux-form/" rel="noreferrer">redux-form</a>.</p>
<p>I have setup a store and added the reducer from redux-form. My form component looks like this:</p>
<p><strong>LoginForm</strong></p>
<pre><code>import React, {Component, PropTypes} from 'react'
import { reduxForm } from 'redux-form'
import { login } from '../../actions/authActions'
const fields = ['username', 'password'];
class LoginForm extends Component {
onSubmit (formData, dispatch) {
dispatch(login(formData))
}
render() {
const {
fields: { username, password },
handleSubmit,
submitting
} = this.props;
return (
<form onSubmit={handleSubmit(this.onSubmit)}>
<input type="username" placeholder="Username / Email address" {...username} />
<input type="password" placeholder="Password" {...password} />
<input type="submit" disabled={submitting} value="Login" />
</form>
)
}
}
LoginForm.propTypes = {
fields: PropTypes.object.isRequired,
handleSubmit: PropTypes.func.isRequired,
submitting: PropTypes.bool.isRequired
}
export default reduxForm({
form: 'login',
fields
})(LoginForm)
</code></pre>
<p>This works as expected, in <a href="https://github.com/gaearon/redux-devtools" rel="noreferrer">redux DevTools</a> I can see how the store is updated on form input and on submitting the form the <code>login</code> action creator dispatches the login actions.</p>
<p>I added the <a href="https://github.com/gaearon/redux-thunk" rel="noreferrer">redux-thunk</a> middleware to the store and setup the action creator(s) for logging in as described in the <a href="http://rackt.org/redux/docs/advanced/AsyncActions.html" rel="noreferrer">redux docs for Async Actions</a>:</p>
<p><strong>authActions.js</strong></p>
<pre><code>import ApiClient from '../apiClient'
const apiClient = new ApiClient()
export const LOGIN_REQUEST = 'LOGIN_REQUEST'
function requestLogin(credentials) {
return {
type: LOGIN_REQUEST,
credentials
}
}
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'
function loginSuccess(authToken) {
return {
type: LOGIN_SUCCESS,
authToken
}
}
export const LOGIN_FAILURE = 'LOGIN_FAILURE'
function loginFailure(error) {
return {
type: LOGIN_FAILURE,
error
}
}
// thunk action creator returns a function
export function login(credentials) {
return dispatch => {
// update app state: requesting login
dispatch(requestLogin(credentials))
// try to log in
apiClient.login(credentials)
.then(authToken => dispatch(loginSuccess(authToken)))
.catch(error => dispatch(loginFailure(error)))
}
}
</code></pre>
<p>Again, in redux DevTools I can see that this works as expected. When <code>dispatch(login(formData))</code> is called in <code>onSubmit</code> in the LoginForm, first the <code>LOGIN_REQUEST</code> action is dispatched, followed by <code>LOGIN_SUCCESS</code> or <code>LOGIN_FAILURE</code>. <code>LOGIN_REQUEST</code> will add a property <code>state.auth.pending = true</code> to the store, <code>LOGIN_SUCCESS</code> and <code>LOGIN_FAILURE</code> will remove this property. (I know this might me something to use <a href="https://github.com/rackt/reselect" rel="noreferrer">reselect</a> for, but for now I want to keep it simple.</p>
<p>Now, in the redux-form docs I read that I can return a promise from <code>onSubmit</code> to update the form state (<code>submitting</code>, <code>error</code>). But I'm not sure what's the correct way to do this. <code>dispatch(login(formData))</code> returns <code>undefined</code>.</p>
<p>I could exchange the <code>state.auth.pending</code> flag in the store with a variable like <code>state.auth.status</code> with the values <em>requested</em>, <em>success</em> and <em>failure</em> (and again, I could probably use reselect or something alike for this).</p>
<p>I could then subscribe to the store in <code>onSubmit</code> and handle changes to <code>state.auth.status</code> like this:</p>
<pre><code>// ...
class LoginForm extends Component {
constructor (props) {
super(props)
this.onSubmit = this.onSubmit.bind(this)
}
onSubmit (formData, dispatch) {
const { store } = this.context
return new Promise((resolve, reject) => {
const unsubscribe = store.subscribe(() => {
const state = store.getState()
const status = state.auth.status
if (status === 'success' || status === 'failure') {
unsubscribe()
status === 'success' ? resolve() : reject(state.auth.error)
}
})
dispatch(login(formData))
}).bind(this)
}
// ...
}
// ...
LoginForm.contextTypes = {
store: PropTypes.object.isRequired
}
// ...
</code></pre>
<p>However, this solution doesn't feel good and I'm not sure if it will always work as expected when the app grows and more actions might be dispatched from other sources.</p>
<p>Another solution I have seen is moving the api call (which returns a promise) to <code>onSubmit</code>, but I would like to keep it seperated from the React component.</p>
<p>Any advice on this?</p>
| <javascript><forms><reactjs><redux><redux-form> | 2016-01-08 19:56:59 | HQ |
34,685,099 | Python A part of code is not being exicuted | Hi I have this class which gives me output of "I am in level 1" but doesn't out "i am in level 2" so i assume get_full_name(self) part isn't being executed any help ?
class UserTest(TestCase):
user = UserFactory()
def test_user_login_client(self):
self.client.login(username=self.user.email, password=self.user.password)
print "i am in level 1"
def get_full_name(self):
print "i am in level 2"
full_name = user.full_name()
return full_name
| <python><testcase> | 2016-01-08 19:58:48 | LQ_EDIT |
34,685,210 | Can I delete an item using DynamoDB Mapper without loading it first? | <p>I am using DynamoDB mapper for deleting an item but have to make sure it exists before deleting it?</p>
<p>So I'm currently doing</p>
<pre><code>public void delete(final String hashKey, final Long rangeKey) {
final Object obj = mapper.load(Object.class, hashKey, rangeKey);
if (obj != null) {
mapper.delete(obj);
}
}
</code></pre>
<p>If there a way to delete an item without loading it first? I want it to silently return if the item was not found</p>
| <amazon-dynamodb> | 2016-01-08 20:06:02 | HQ |
34,685,928 | Token null Sign-in Google Account | <p>I am following the example of google to get the token but without success.
Always fails to acquire the token.
This is latest way Google displays on your page developers
I believe the error is not in my code</p>
<pre><code> private String CLIENTE_ID = "...apps.googleusercontent.com";
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(CLIENTE_ID)
.requestEmail()
.build();
// Build GoogleAPIClient with the Google Sign-In API and the above options.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
imgBGoogle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, 9002);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == 9002) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result, data);
}
if (requestCode == 9002) {
// [START get_id_token]
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Log.d(TAG, "onActivityResult:GET_TOKEN:success:" + result.getStatus().isSuccess());
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
// Show signed-in UI.
Log.d(TAG, "idToken:" + idToken);
Log.d(TAG, "\n ");
// TODO(user): send token to server and validate server-side
} else {
// Show signed-out UI.
Log.d(TAG, "idToken: fail");
}
// [END get_id_token]
}
}
private void handleSignInResult(GoogleSignInResult result, Intent data) {
getToken1(data);
getToken2(result);
String BOOKS_API_SCOPE = "https://www.googleapis.com/auth/books";
String GPLUS_SCOPE = "https://www.googleapis.com/auth/plus.login";
String mScopes = "oauth2:" + BOOKS_API_SCOPE + " " + GPLUS_SCOPE;
}
void getToken1(Intent data){
GoogleSignInResult a = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (a.isSuccess()) {
Log.d(TAG, "TOKEN 1: " + a.getSignInAccount().getIdToken());
Log.d(TAG, "DISPLAY NAME 1: " +a.getSignInAccount().getDisplayName());
Log.d(TAG, "ID 1: " + a.getSignInAccount().getId()+"\n ");
}else{
Log.d(TAG, "ID 1: falhou"+"\n ");
}
}
void getToken2(GoogleSignInResult result){
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
Log.d(TAG, "TOKEN 2: " + acct.getIdToken());
Log.d(TAG, "DISPLAY NAME 2: " + acct.getDisplayName());
Log.d(TAG, "ID 2: " + acct.getId()+"\n ");
}else{
Log.d(TAG, "ID 2: falhou"+"\n ");
}
}
</code></pre>
<p><strong>how can I get the token?
can anyone help me?</strong></p>
<p><a href="https://i.stack.imgur.com/Uj0LO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Uj0LO.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/6keg0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6keg0.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/csq4D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/csq4D.png" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/p2zSX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/p2zSX.png" alt="enter image description here"></a></p>
| <android><google-signin><googlesigninaccount> | 2016-01-08 20:57:20 | HQ |
34,685,947 | Adjust Single Value within Tensor -- TensorFlow | <p>I feel embarrassed asking this, but how do you adjust a single value within a tensor? Suppose you want to add '1' to only one value within your tensor?</p>
<p>Doing it by indexing doesn't work:</p>
<pre><code>TypeError: 'Tensor' object does not support item assignment
</code></pre>
<p>One approach would be to build an identically shaped tensor of 0's. And then adjusting a 1 at the position you want. Then you would add the two tensors together. Again this runs into the same problem as before.</p>
<p>I've read through the API docs several times and can't seem to figure out how to do this. Thanks in advance! </p>
| <indexing><addition><tensorflow> | 2016-01-08 20:58:51 | HQ |
34,686,287 | Automating CSV file merging and cleaning preferably by using Batch or Powershell | I'm not a code guy and have spent whole day trying to get this done without success, hoping I can get some help from the experts.
I have a folder called Vehicles, within which are two sub-folders - Automobiles and Trucks. Each of sub-folders contain two CSV files which have identical (to that sub-folder) headers/structure.
What I'm trying to accomplish:
1. Take the two CSV files in Automobiles folder merge them without duplicating headers and name the merged file as Automobiles.csv
2. Delete all rows in Automobiles.csv where 6th column (header is Fuel_Type) is "Diesel" (without the quotes) then move the file from sub-folder to main Vehicles folder.
3. Take the two CSV files in Trucks folder merge them without duplicating headers and name merge file as Trucks.csv
3. For merged file in trucks folder remove all rows where 6th column (header is "Fuel_Type") is "Diesel" (without the quotes) then move the file from sub-folder to main Vehicles folder.
Obviously if someone can help with 1 and 2 I can manipulate it for 3 and 4.
5. BONUS POINTS :) take the Automobiles.csv and Trucks.csv files and create Vehicles.xls file with Automobiles and Trucks tabs.
Few details - files are pretty large, each CSV can up to 350 thousand rows x 150 columns and be 200 MB in size each. All the Batch scripts that I tried to put together removing headers seemed to freeze with larger files.
Due to user permissions on work computers would strongly prefer to use something that is native to Windows7/8 and doesn't require additional software, but would consider other options if nothing native is available.
Thanks in advance!
| <csv><powershell><batch-file><merge> | 2016-01-08 21:22:04 | LQ_EDIT |
34,686,411 | C language, How can I Convert Number to String? | <p>if I've a large number stored in 10 bytes of memory, how can I convert this number to string? like How do C %d converts number to string?</p>
<p>I'm not looking for some library or function, I wan't to know how to convert large byte numbers to string, that is what i need to know.</p>
| <c><string><numbers> | 2016-01-08 21:30:28 | LQ_CLOSE |
34,687,645 | can you assign initial value to global static variable in C? | <p>I have a global variable "count". All I want to do is increment it each time the loop runs. Is there a potential problem with initializing static count as 0? How is this works in C?</p>
<pre><code>static unsigned short count = 0;
while(1)
{
count++;
// do something
}
</code></pre>
| <c> | 2016-01-08 23:14:43 | LQ_CLOSE |
34,687,762 | Why does my Android string display in all caps in my app? | <p>I want to display Vo for initial velocity, and it displays fine in MOST places, but on all of my circle buttons, it displays in all caps, so it looks like "VO" instead of "Vo". </p>
<p>Is there a way to fix this? Is it a weird button interaction?</p>
<p>Thanks!</p>
| <java><android><xml><android-layout> | 2016-01-08 23:24:39 | LQ_CLOSE |
34,688,239 | C# - How to shorten a string | <p>I have a piece of code and I need to shorten a string that I have in a variable. I was wondering how could I do this. My code is below.</p>
<pre><code>string test = Console.ReadLine();
if(string.Length > 5)
{
//shorten string
}
Console.WriteLine(test);
Console.ReadLine();
</code></pre>
| <c#><string> | 2016-01-09 00:17:28 | LQ_CLOSE |
34,688,399 | Can someone provide an example for this statement in java "a collection is eagerly constructed "? | <p>Collection is constructed when we add elements to it. Isn't it ?</p>
| <java><java-8> | 2016-01-09 00:37:32 | LQ_CLOSE |
34,689,254 | what's the difference between factory and service? | <p>I am trying play with Angular factory and service. Anyone could tell me the difference between those two?</p>
<p>Does factory always returns a singleton, but service an instance?</p>
| <angularjs> | 2016-01-09 02:59:19 | LQ_CLOSE |
34,689,559 | Perl: select elements of array using array of integers | Is it possible to select specifics elements of an array using an array of integers(indexes). I know that this can be done easily with a loop but was hoping for a one line solution.
Example/attempts
@arr = qw(a b c d e f);
@arr2 = qw( 0 2 4);
Rather than
@arr3 = @arr[0,2,4];
use @arr2 as set of integers that you wan't selected
@arr3 = @arr[@arr2]; #won't work as "@arr2" returns number of elements
@arr3 = @arr[join(','@arr2)] #won't work as join returns a string
| <arrays><perl><subset> | 2016-01-09 04:08:24 | LQ_EDIT |
34,691,353 | why text file created is blank? | My code is
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
struct info
{
char product_name[100], Seller_Name[100], DOP[30];
int price;
}data;
void main()
{
ofstream fout("code.txt",ios::out);
fout<< "ofstream fout(\"data.dat\",ios::binary|ios::out);\n" ;
while(1){
cout << "Enter Product Name: ";
gets(data.product_name);
cout<<"Enter Seller Name: ";
gets(data.Seller_Name);
cout<<"Enter Date of Purchase: " ;
gets(data.DOP);
cout<<"Enter Price:" ;
cin>>data.price;
fout<<"strcpy(data.product_name,"<<data.product_name<<");";
fout<<"\nstrcpy(data.Seller_Name,"<<data.Seller_Name<<");";
fout<<"\nstrcpy(data.DOP,"<<data.DOP<<");";
fout<<"\nstrcpy(data.price,"<<data.price<<");";
fout<<"fout.write((char*)&data,sizeof(info));\n";
}}
I am developing a software and am making sample data for it. So I made this application so I just have to copy statements and need not have to write it again. It worked the first time but now it is not working... Thankyou...
| <c++><file-handling> | 2016-01-09 08:28:40 | LQ_EDIT |
34,692,506 | Dispalying ads on browsers protected by Adblock | <p>I understand that people don't want to see ads but as a developer I would like to make money from ads on my site.
How to add an ads to my site so Adblock will not block my content ?</p>
| <javascript><html><browser><adblock> | 2016-01-09 10:47:03 | LQ_CLOSE |
34,692,843 | difference between "->" and "." operator in C language (struct) | <p>I' just got started in learning struct in c language.
i Thought "->" and "." were equivalent but i get the following error when using "->" instead of ".":
<em>invalid type argument of '->' (have 'struct item')</em></p>
| <c><struct> | 2016-01-09 11:23:11 | LQ_CLOSE |
34,693,023 | Binary file output for fixed fixed length string vb.net | I am trying to write a binary file which also has a string which i want to have as fixed length in vb.net. I tried lset, padleft in debug, the value returned is correct but in the output file, the first character before the string is the fixed length i specified. why does the binary writer write the additional char ? | <vb.net><binaryfiles> | 2016-01-09 11:43:38 | LQ_EDIT |
34,695,130 | <input type="date" name="purchasedDate" id="purchasedDate"> not working in Internet Explorer | <p>I am getting issue with the input tag. It works fine in all major browsers except Internet Explorer.</p>
<p>My version of IE is 8.</p>
<pre><code><input type="date" name="purchasedDate" id="purchasedDate">
</code></pre>
<p>I have tried some scripts too like polyfills but still the issue is not solved.</p>
| <javascript><jquery><html><cross-browser> | 2016-01-09 15:10:21 | LQ_CLOSE |
34,695,134 | js pass object to callback function | <p>I would like to reference the item object in the geocoder callback function.
Item always refers to the state of the last $each iteration, if I use the code below. I assume this is because the callback is run after the $each loop finishes. I would therefore need to pass the item object to the geocoder. How can I do that?</p>
<pre><code> $.each(results.data, function(index) {
var item = results.data[index];
geocoder.geocode( { 'address': address}, function(results, status) {
item.lat = results[0].geometry.location.lat();
item.lng = results[0].geometry.location.lng();
});
});
</code></pre>
| <javascript><callback> | 2016-01-09 15:10:48 | LQ_CLOSE |
34,695,303 | Free() bifore return 0; | What happen if I end the execution by passing return 0; after using a malloc and without freeing the part of memory allocated?
int * var;
var = (int *)malloc(sizeof(int)) ;
free(var) ;
return 0; | <c> | 2016-01-09 15:24:43 | LQ_EDIT |
34,695,544 | is there a way to make a custom window? not box like but custom shape [python] | <p><a href="http://i.stack.imgur.com/HrfwH.jpg" rel="nofollow">like this</a></p>
<p>the green lady on the screen. that's how i want to make my program look like. how do i make that happen in python? just so you know i am new to python and i know only the basics of it.and i would love an explaining of how i make text appear next to her and stuff like that. would appreciate step by step + explaining.i have looked a bit on the internet but i couldn't find nothing like this question before. thanks</p>
| <python><graphics> | 2016-01-09 15:49:57 | LQ_CLOSE |
34,695,999 | why <li> is kept open without a </li> html nested lists | <p>I posted a question and everyone said things that i was not really asking
I will try to be more clear next time.</p>
<p>I was told that when nesting lists you must leave a <code><li></code> without a <code></li></code></p>
<p>The <<<<<<<<<<<< point to the tags.</p>
<p>That is what i need someone to explain... I was told this is necessary and i can't find a resource that tells me why.</p>
<pre><code><ul>
<li> Louis </li>
<li> Louis <<<<<<<<<<<<<
<ol>
<li> Louis </li>
<li> Louis </li>
<ul>
<li> Louis </li>
<li> Louis </li>
<ol>
<li> Louis </li>
<li> Louis </li>
</ol>
</ul>
</ol>
</li> <<<<<<<<<<
</ul>
</code></pre>
| <html> | 2016-01-09 16:33:06 | LQ_CLOSE |
34,696,301 | How did a vector became a matrix? | So i found this code on the internet but as i'm not that familiar with C++ i found difficult to understand this: how does a vector suddenly becomes a matrix?
thanks! :)
int main(){
int n;
string v[MAX];
cin >> n;
for(int i=0;i<n;i++)
cin >> v[i];
for(int i=0;i<n-1;i++){
int y1,y2;
y1=v[i].size();
y2=v[i+1].size();
for(int j=0; j<y1 && j<y2 ;j++)
if(v[i][j]!=v[i+1][j]){ // here <-
int x1,x2;
x1=(int) v[i][j]-'A';
x2=(int) v[i+1][j] - 'A';
m[x1][0]=true;
m[x2][0]=true;
m[x1][x2+1]=true;
break;
}
} | <c++> | 2016-01-09 16:59:40 | LQ_EDIT |
34,698,074 | Securing a PHP Server from a Hijacker | <p><strong>BACKGROUND:</strong> I'm implementing a PHP Server without HTTPS/SSL. On it, I want to authenticate that the user making calls to server is valid assuming that the communication between the app and the server is being watched by a hijacker (hacker with a network sniffer). I further assume that the hijacker is an app owner trying to figure out how the app communicates with the server in order to hack my system. I will have no control on who is an app owner.</p>
<p>What I have implemented so far is that the app needs to start a session before they can any work against the server. To do this the app first sends a request to the server with a randomly generated code, and an authorization number, and the server responds with a security token. The authorization number is based on the code and some other secret information in the app. On subsequent calls the app regenerates the code and uses the token plus other secret information recalculate an authorization number (it never retransmits the token to the server either). This is how each call is validated.</p>
<p>It's set up so that the calling parameters of one call cannot be reused the next time, so that if a hijacker can see the message used within a session, they cannot do anything with it. Using them simply indicates that the call is "not authorized". I'm 99% sure I've plugged all the related holes to the session communication, such that the hijacker cannot invade my environment.</p>
<p><strong>PROBLEM:</strong> The hijacker will see the original session request, reuse those parameters to get a new session and use them to eventually figure out how the session calls the work. </p>
<p><strong>QUESTION:</strong> What strategy would you employ to validate that it is only my app talking to the server during the initial session request and not a hijacker impersonating my app in order to start a session? </p>
<p>Note: Saving the session start parameters is unrealistic. One idea I have is to embed the "GMT time + N seconds" into the randomly generated code then test to see if the server's GMT < app's GMT+N; this way the randomly generated code become invalid within N seconds.</p>
| <php><security><session> | 2016-01-09 19:41:31 | LQ_CLOSE |
34,698,755 | How to write text file in a specific path in android device | I am using visual studio to crate cordova mobile application (Cordova-plugin-file).
How to write text file in a specific path in android device,
to be able get it from a fixed location. | <android><file><cordova><mobile> | 2016-01-09 20:48:32 | LQ_EDIT |
34,698,767 | Why i cannot use background-image: url("omg/1.jpg"); to using local images? | The code is like below. I have already put the image "1.jpg" into that file
name "img". But in my website, this image doesn't show up. However, i found
that if i use the images from Internet, it will show up. Could someone
figure out the problem? Thanks.
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
#banner
{
background-image: url("img/1.jpg");
}
<!-- end snippet -->
| <css> | 2016-01-09 20:50:23 | LQ_EDIT |
34,698,833 | output of the functions based on nodes | im new at coding cpp and i dont undertstand how we can get the following outputs about the nodes subject? can anyone help thanks in advance :)
the output of the following program is
10 3 22 33
5 7 6
3 22 33
2 4 6
here is the code:
void display(Node *head){
if(head == NULL)
cout<<"head is NULL"<<endl;
for(Node *tmp=head; tmp!=NULL; tmp = tmp->next )
cout<<" "<<tmp->data;
cout<<endl;
}
Node *func1(int value1, int value2, int value3){
Node *head = new Node;
head->next = new Node;
head->next->next = new Node;
head->next->next->next = NULL;
head->data = value1;
head->next->data = value2;
head->next->next->data = value3;
return head;
}
void func2(Node *head1, Node *head2, Node *head3){
head1->next = head3;
head1->next->data =3;
head1= head2;
head1->data = 5;
head1->next->data = 7;
head2 = head1;
head3 = head1;
}
void func3(Node *head){
for(; head!= NULL; head = head->next)
head->data *=2;
}
int main(){
Node *head1 = func1(10,20,30);
Node *head2 = func1(2,4,6);
Node *head3 = func1(11,22,33);
func2(head1, head2, head3);
display(head1);
display(head2);
display(head3);
head1 = func1(1,2,3);
func3(head1);
display(head1);
return 0;
}
| <c++><output><nodes> | 2016-01-09 20:56:02 | LQ_EDIT |
34,699,186 | uniq -u -i -d command implement in linux | I tried something but Resus mainly not know how to read the file line by line to compare lines between them, I get the error segmentation fault ( core dumped ).
This is my function for uniq -u command
void uniq_u()
{
// strcpy(file_name1,params[2]);
FILE *file = fopen ( file_name1, "r" );
if ( file != NULL )
{
fgets(prev, sizeof prev,file);
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
if(!strcmp(line, prev))
printf("%s", prev);
else
strcpy(prev,line);
}
fclose ( file );
}
}
Thanks! | <c><linux><uniq> | 2016-01-09 21:33:08 | LQ_EDIT |
34,699,953 | I need help programming a Fahrenheit to Celsius Converter | I don't know what I'm doing wrong. ive looked but I cant find the answer. im trying to have a text box, and a button next to it. When you click the button, I want it to convert it to fahrenheit or celsius and display it in another text box. I only have the fahrenheit to celsius done and I can just copy the code over when Im done
<!DOCTYPE html>
<html>
<head>
<center>
<h1> Fahrenheit to Celsius Converter</h1>
<font size="+1" >
<p> Fahrenheit to Celsius</p>
<input type="text" name="ftc" id="ftc"/> <button type="button" onclick="fahrenheitCelsius()" /> Click to Convert </button>
<p>Celsius to Fahrenheit </p>
<input type="text" name="ctf" id="ctf" /> <button type="button" onclick="celsiusFahrenheit()" /> Click to Convert </button>
<p> Answer </p>
<input type="text" name="answer box" id="answer/>
<script>
function fahrenheitCelsius() {
var fsc = parseFloat(document.getElementById('ftc').value);
var cfc = (fsc-32) * (5/9);
document.getElementById('answer box').value = cfc;
return false;
document.writeIn(<input type="text" name="answer box" id="answer"/>)
}
</script>
</font>
</head>
</html> | <javascript> | 2016-01-09 23:02:51 | LQ_EDIT |
34,700,150 | Stadard "veiw contact" icon | I'm developing a texting app and would like to create a view contact button. Anyone know what the standard menu icon for such an action is? | <android><icons><contacts> | 2016-01-09 23:25:37 | LQ_EDIT |
34,700,207 | Adding variables to dictionary | <p>I have a empty dictionary</p>
<pre><code>d = {}
</code></pre>
<p>I have these variables:</p>
<pre><code>key = "foo"
value = 1
</code></pre>
<p>I want to add them to dictionary as <code>key</code> and <code>value</code> variables because they can be change in a for loop. What should be the proper syntax?</p>
| <python> | 2016-01-09 23:32:47 | LQ_CLOSE |
34,701,564 | Input string was not in a correct format when converting value from database into integer C# | I have a problem in converting string from database to integer. When I look at Locals, that variable show the value but notification still says that there is something wrong. Anyone can help me, please ?
OleDbConnection kon = new OleDbConnection(koneksi);
OleDbCommand command1 = kon.CreateCommand();
kon.Open();
string selectkoordgaris = "select * from koordinatgaris where namakamera = '" + PilihKameraComboBox.Text + "'";
command1.CommandText = selectkoordgaris;
OleDbDataReader bacakoordgaris = command1.ExecuteReader();
while (bacakoordgaris.Read())
{
var templateGaris = Directory.GetFiles(@"D:\Dokumen\Alfon\TA Alfon\CobaFitur\Template\Garis\" + bacakoord["namakamera"].ToString());
foreach (var fileGaris in templateGaris)
{
counterbanyakgaris++;
Image<Bgr, byte> garis = new Image<Bgr, byte>(fileGaris);
for (cntgaris = 0; cntgaris < banyakgaris; cntgaris++)
{
int x1garis = int.Parse(bacakoordgaris["x" + ((cntgaris * 4) + 1) + "garis"].ToString()); //here the error. It says Input string was not in a correct format
int x2garis = int.Parse(bacakoordgaris["x" + ((cntgaris * 4) + 2) + "garis"].ToString());
int y1garis = int.Parse(bacakoordgaris["y" + ((cntgaris * 4) + 1) + "garis"].ToString());
int y2garis = int.Parse(bacakoordgaris["y" + ((cntgaris * 4) + 2) + "garis"].ToString());
int y3garis = int.Parse(bacakoordgaris["y" + ((cntgaris * 4) + 3) + "garis"].ToString());
int gariswidth = x2garis - x1garis;
int garisheight = y3garis - y2garis;
}
}
} | <c#><.net> | 2016-01-10 02:59:33 | LQ_EDIT |
34,701,855 | ArrayList project at college, some questions | So hey guys I have some things to ask,
I have to program my first, call it project, in my first semester. It's about programming an appointment calendar (don't really know how it's called in english, like a scheduleish thing :P). Until now we've learned the major stuff (for, if, etc.), how to connect classes, create a constructor and about objects. So we have to program this schedule pretty easily with ArrayList and it should delete, edit, create, list the entries. You have to just type in a date and an entry,
f. e.: 10.01.16 "example".
It doesn't even have to sort it after the date, but I'm really struggling at some points.
1. I listened to some dudes in my class and one said, he would have
wrote 9 classes. I couldn't even think of that, why so many?
2. Also how do I save the entries? Just with examplelist.add and it
just saves like that?
3. Why do I need a getter and setter, if I could just wrote that stuff
in my constructor?
4. How do I make it look nice, just a println/printf("\n") in a loop
after each entry?
First of all, thanks for reading this and spending time for helping a lowbie, I appreciate everything you have to offer. I will go to bed now, spending my whole day tomorrow to write that. Most likely I will have some more questions.
| <java><oop><arraylist> | 2016-01-10 03:48:58 | LQ_EDIT |
34,701,944 | triangle.java Uses or overrides a deprecated API | Finding area and perimeter of triangle of a triangle using stream in java:
On Compiling the below program shows
Note: triangle.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Please find what error in this program!
import java.io.*;
class triangle
{
double s,h,area,perimeter;
void get()throws IOException
{
System.out.println("Enter value of side of an equilateral triangle");
DataInputStream dis=new DataInputStream(System.in);
s=Double.parseDouble(dis.readLine());
System.out.println("Enter height");
h=Double.parseDouble(dis.readLine());
}
void area()
{
area=0.5*s*h;
}
void perimeter()
{
perimeter=3*s;
}
void display()
{
System.out.println("Area="+area);
System.out.println("Perimeter="+perimeter);
}
public static void main(String args[])throws IOException
{
triangle t=new triangle();
t.get();
t.area();
t.perimeter();
t.display();
}
} | <java> | 2016-01-10 04:05:31 | LQ_EDIT |
34,702,092 | Simple algorithms that can be implemented on a FPGA | <p>I am new to FPGA programming and was planning on implementing several algorithms that may become useful in future to me when I am doing my projects. So, I wanted to ask for suggestions on things I could implement on FPGA (specially some interesting algorithms) ordered in difficulty level. Thank you!</p>
| <algorithm><fpga> | 2016-01-10 04:34:01 | LQ_CLOSE |
34,703,349 | merge sort infinite recursion | I'm learning Ruby and algorithms at the current moment an would like some guidance in solving this issue that has arise. I haven't started the merge process yet. So far I've only focused on dividing the array over and over again until only 1 number is left in the array. Below is my code showing how I implemented this so far. My problem is the loop will not break and I'm unsure why. I'm hoping someone can point me in the right direction as to what I'm missing. I'm also open to resources to help me solve this problem better.
def mergesort(list)
mid = list.length / 2
left = list[0, mid]
right = list[mid, list.size]
until left.size <= 1 || right.size <= 1 do
test(mergesort(left), mergesort(right))
end
print left
print right
def test(left, right)
sorted = []
left.length / 2
right.length / 2
# print sorted
end
end | <ruby><algorithm><mergesort> | 2016-01-10 08:02:06 | LQ_EDIT |
34,703,609 | How to find difference in hours between dates in R | <p>I have the following dataframe (DF1):</p>
<pre><code>Date Value
29/12/2014 8:00 24.940
29/12/2014 9:00 24.960
29/12/2014 11:00 25.020
</code></pre>
<p>I would like to add a new column for DF1$DIFF, where it contains the difference in values between each line's Date (including hours) to its above Date. So that the required results will be:</p>
<pre><code>Date Value Diff
29/12/2014 8:00 24.940
29/12/2014 9:00 24.960 1
29/12/2014 11:00 25.020 2
</code></pre>
<p>I tried to use the as.date function, however, I get the difference in dates only: </p>
<pre><code>> as.Date("2009-10-01 10:00")- as.Date("2009-10-01 9:00")
Time difference of 0 days
</code></pre>
| <r><as.date> | 2016-01-10 08:42:06 | LQ_CLOSE |
34,704,739 | I need help in understanding the following kernel module written in C | <p>As an assignment I need to complete the following C code in order to produce a kernel module able to act as a memory, but from how it's written I can't understand how it works and why many variables are not used but just declared. I have already tried looking on the teaching material they gave me, and it's even more confusing, plus I can't find on the web a good site where to find documentation about these functions. </p>
<p>The code is the following:</p>
<pre><code>#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#define DEVICE_NAME "my_device"
#define MAJOR_DEVICE_NUMBER 60
#define MINOR_DEVICE_NUMBER 0
#define BUF_LEN 1024
static char msg[BUF_LEN];
static char *msg_ptr; // I'm pretty sure this should become msg_reading_offset
static int major;
MODULE_AUTHOR("<YOUR NAME>");
MODULE_LICENSE("GPL");
static ssize_t my_read (
struct file *filp, char __user *buf,
size_t length, loff_t *offset);
static ssize_t my_write (
struct file *filp, const char __user *buf,
size_t length, loff_t *offset);
static int my_open (struct inode *inode,
struct file *filp);
static int my_close (struct inode *inode,
struct file *filp);
static int __init my_init (void);
static void __exit my_cleanup (void);
static struct file_operations fops = {
.read = my_read,
.write = my_write,
.open = my_open,
.release = my_close,
};
// I need to implement this function
static int my_open (struct inode *inode,
struct file *filp)
{
return 0;
}
// and this function
static int my_close (struct inode *inode,
struct file *filp)
{
return 0;
}
static ssize_t my_read (
struct file *filp, char __user *buf,
size_t length, loff_t *offset)
{
int nc = 0;
// if no more "valid" bytes can be read, stop
if (*msg_reading_offset == 0) return 0;
// no-negative values allowed
if (length < 0)
return -EINVAL;
// read the whole msg, nothing more
if (length > strlen(msg)) {
length = strlen(msg);
}
nc = copy_to_user(buf, msg_reading_offset, length);
/*
updates the current reading offset pointer so that a
recursive call due to not original
full length will get a 0 (nothing to read)
*/
msg_reading_offset += sizeof(char) * (length-nc);
// returns the number of REAL bytes read.
return length - nc;
}
static ssize_t my_write (
struct file *filp, const char __user *buf,
size_t length, loff_t *offset)
{
int nc = 0;
if (length > BUF_LEN)
return BUF_LEN-length;
nc = copy_from_user(msg,buf,length);
msg_ptr = msg;
return length - nc;
}
static int __init my_init (void)
{
register_chrdev (MAJOR_DEVICE_NUMBER,
DEVICE_NAME,
&fops);
}
module_init(my_init);
static void __exit my_cleanup (void)
{
unregister_chrdev (major, DEVICE_NAME);
}
module_exit(my_cleanup);
</code></pre>
<p>At the moment these are my biggest problems:</p>
<ul>
<li>Where are all the *inode, *filp variables going? Am I supposed to use them?</li>
<li>How is this program even working? I know I need to compile it with a makefile I've been give, but then how am I supposed to access these functions? </li>
<li>Is this supposed to be a real program executed by the kernel or is it just a collections of functions I should use in another C program?</li>
</ul>
<p>I'm sorry if the questions may seem stupid, but I am at a loss to know how the hell I'm supposed to approach this.</p>
| <c><linux><kernel> | 2016-01-10 11:16:25 | LQ_CLOSE |
34,704,869 | How can I make user not allow to resize textarea? | <p>I have textarea in my website and i want to make user not allow to resize this textarea.
But I use this languages only :
php - html - jquery - javascript</p>
| <javascript><php><jquery><html> | 2016-01-10 11:31:58 | LQ_CLOSE |
34,705,397 | bson 4.0.0 gem error | <p>I got this error while installing bson gem: (ruby 2.2.2, ubuntu 14.04 clean)</p>
<pre><code>ubuntu:/var/apps/real-fetcher$ gem install bson -v '4.0.0'
Building native extensions. This could take a while...
ERROR: Error installing bson:
ERROR: Failed to build gem native extension.
/home/ubuntu/.rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20160110-7126-18thkio.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling native.c
In file included from native.c:21:0:
native-endian.h:113:17: warning: '__bson_uint32_swap_slow' defined but not used [-Wunused-function]
static uint32_t __bson_uint32_swap_slow(uint32_t v)
^
native-endian.h:137:17: warning: '__bson_uint64_swap_slow' defined but not used [-Wunused-function]
static uint64_t __bson_uint64_swap_slow(uint64_t v)
^
native-endian.h:164:15: warning: '__bson_double_swap_slow' defined but not used [-Wunused-function]
static double __bson_double_swap_slow(double v)
^
linking shared-object native.so
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
make: *** [native.so] Error 1
make failed, exit code 2
Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-2.2.2/gems/bson-4.0.0 for inspection.
Results logged to /home/ubuntu/.rvm/gems/ruby-2.2.2/extensions/x86_64-linux/2.2.0/bson-4.0.0/gem_make.out
</code></pre>
<p>Can't find anything related on my searches.</p>
<p>I haven't tried anything yet and I'm not sure what to try.</p>
| <ruby><ubuntu><rubygems><bson> | 2016-01-10 12:33:50 | LQ_CLOSE |
34,705,405 | C: Functions with custom type in header | I've written a program that uses three functions to which I pass a custom type defined as:
typedef struct w
{
char *wd;
long position;
struct w *next;
}W;
typedef W *word;
When I try to put the functions in a header file like this:
void find(char *s,word *T);
void seek(char *s,word p);
void look(word p);
and try to compile di file I get
> error: unknown type name ‘word’
How do I fix it? | <c><function><types> | 2016-01-10 12:34:53 | LQ_EDIT |
34,705,585 | Regex No Work , Regex between 2 String | please help me : I have a strange error with Regex:
Remove the dot's on span :)
Const AG = "<.span>$(.*)<./span>"
Dim x As String = "<.span>$1</span.>"
Dim lel As Regex = New Regex(AG)
Dim lol As Match = lel.Match(x)
The following code no work , i don't know why please help me :/ | <regex><vb.net> | 2016-01-10 12:53:25 | LQ_EDIT |
34,705,628 | Undefined variable | <p>I still get this error for some I guess stupid reason. I was following Laracast fundamentals tutorials then I decided to create my own app and it's the same. Probably I've messed something up and can't see it.</p>
<p>Here's the error:</p>
<blockquote>
<p>Undefined variable: movies (View: C:\Users\username\PhpstormProjects\movie_app\resources\views\movies\show.blade.php)</p>
</blockquote>
<p>This is my controller:</p>
<pre><code>public function show($id)
{
$movie = Movie::findOrFail($id);
return view('movies.show', compact('movie'));
}
</code></pre>
<p>View:</p>
<pre><code>@extends('layouts.app')
@section('content')
@foreach($movies as $movie)
<h4>{{$movie->name}}</h4>
@endforeach
@endsection
</code></pre>
| <php><laravel><laravel-5> | 2016-01-10 12:58:08 | LQ_CLOSE |
34,706,960 | 1.#QNAN000000000000 interrupts the loop | This is my problem: I am simulating a particle random walking ((my full codes are long)) in a spherical region (of radius 0.5, with a reflective boundary outside) with absorbing boundary at radius r = 0.05. It starts at r = 0.25 and the loop will stop when it hits the absorbing boundary. However, the loops are always interrupted by value 1.#QNAN000000000000. For example, I am writting the distance to the origin in a file:
... ... (a lot of numbers omitted)
0.20613005432153597
0.20623630547871444
0.20638287597603161
0.20639479244526721
0.20632936118972162
0.20624097359751253
0.20634346836172857
0.20662686334789271
0.20662651327072232
0.20661986008216310
0.20662358691463298
0.20661462509258177
0.20649145569824909
0.20651885241720047
0.20652145059961324
0.20651490447436160
0.20646925001041655
0.20645889385120675
0.20629285654651422
0.20633769635178317
0.20635757642249095
0.20645451482187596
0.20654217470043859
1.#QNAN000000000000
Here the problem arises, the particle is not yet absorbed, but 1.#QNAN000000000000 interrupts the loop. I vaguely know that this might be due to issues in arithmetric operations of floats, but I am paying considerable attention to this. Therefore, I am wondering what I should probably do to avoid these kind of things? Thanks a lot! | <c> | 2016-01-10 15:08:06 | LQ_EDIT |
34,707,071 | List append comes out wrong | <p>I have the following piece of code as a problem.</p>
<pre><code>list = [ [ ] ] * 5
print list
list[0].append(1)
print list
</code></pre>
<p>The first line prints <code>[[][][][][]]</code> which is what it should print
but the second print gives</p>
<p><code>[[1][1][1][1][1]]</code></p>
<p>why does this happen? it is supposed to append only to the first list. </p>
| <python> | 2016-01-10 15:19:02 | LQ_CLOSE |
34,707,859 | [Beginner]Inserting a function into main part - c++ | I'm a beginner and I have a little problem about calling a function into the main part of the program.
#include <iostream>
#include<cmath>
int getAbsProd(int a, int b)
{
cout<<"Insert integer: "<<endl;
cin>>a;
cout<<"Insert another integer: "<<endl;
cin>>b;
cout<<"The absolute value of the multiplication is: "<<abs(a*b)<<endl;
return abs(a*b);
}
int main()
{
cout<<getAbsProd();
return 0;
}
I'm using codeblocks, couldn't call <math.h>, somewhere it was suggested to call <cmath>, I'm just beginning to code, so go easy :)
| <c++><function> | 2016-01-10 16:27:37 | LQ_EDIT |
34,708,181 | My script is not functioning like it had before. why? | My code was working fine until today(what it does now is nothing) and I didn't edit it at all today any idea what might have happened?
my code is this:
loop
{
Send {1}
Send {2}
Numpad0::
ExitApp
Return
} | <autohotkey> | 2016-01-10 16:55:25 | LQ_EDIT |
34,708,381 | Combining one webpage section into other webpage | <p>I have downloaded a several nulled website templates for testing purposes.
I was wondering if I could combine them into one webpage?</p>
<p>For example, take category page layout from one webpage and implement it to other webpage. Is it possible to create webpage using php and html files combined, lets say index.html and contact.php?</p>
<p>Thank You in advance.</p>
| <php><html><css> | 2016-01-10 17:14:32 | LQ_CLOSE |
34,710,117 | SQL Server: Displaying result in Java Textfield | <p>I use MS SQL Server and Java with JDBC to connect.
I don't know how to display the result of my simple SQL queries in a Java Texfield. Displaying my data in a JTable is no problem with the external JAR <strong>rs2xml</strong>.</p>
<p>That works and prints my table in the panel.</p>
<pre><code>String MaxQuery = "SELECT * FROM Employees";
PreparedStatement pst=con.prepareStatement(MaxQuery);
ResultSet rs=pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
</code></pre>
<p><strong>But</strong> when i want to display a simple query like "<em>SELECT AVG(budget) FROM Employees</em>" with 1 result, i want to print this <strong>in a textfield</strong>. </p>
<p>The method setModel doesn't work with Textfields. So i have tried something like that:</p>
<pre><code>String AVGQuery = "SELECT AVG(budget) FROM Employees";
PreparedStatement pst=con.prepareStatement(AVGQuery);
ResultSet rs=pst.executeQuery();
textFieldAns.setText(rs.toString());
</code></pre>
<p>But that prints me "SQLServerResultSet:1". I want the result, and not the number of results. Hope u can help me by my little problem :). </p>
| <java><sql><sql-server><database><swing> | 2016-01-10 19:55:48 | LQ_CLOSE |
34,712,056 | How to find percentage value from a table column | <p>I am trying to find the a percentage value of every numeric value with the same id in my table. For example, if my table consists of this:</p>
<pre><code>id answer points
1 answer 1 3
1 answer 2 1
1 answer 3 10
1 answer 4 5
1 answer 5 6
1 answer 6 10
1 answer 7 10
1 answer 8 2
</code></pre>
<p>If max points are 80, how can I display the current result (point) from database in percentage form?</p>
| <php><mysql><percentage> | 2016-01-10 23:30:54 | LQ_CLOSE |
34,712,224 | How is CSS pixel movement same in every monitor resolution | <p>Lets says I have the following CSS:</p>
<pre><code>#div-1 {
position:relative;
top:20px;
left:-40px;
}
</code></pre>
<p>If load it on Monitor A and drag my browser to monitor B with a different resolution, HTML div will be at the same spot, although pixel numbers are different in monitors. How does that work?</p>
| <html><css> | 2016-01-10 23:53:38 | LQ_CLOSE |
34,713,799 | Why does AngularJS show me that a scope variable is undefined in directive when it is clearly defined? | I have an angularJS directive that I call like this:
<rpt-closing closing-begin-ts="'None'" closing-begin-ts="'2014-11-25 23:59:59'"></rpt-closing>
Here is what the directive code looks like:
.directive('rptClosing',function(){
return {
restrict:'E',
scope: {
closingBeginTs: '=',
closingEndTs: '='
},
link: function(scope, element, attrs) {
console.log('*******************************************');
console.log('scope = ', scope);
console.log('scope.closingBeginTs = ', scope.closingBeginTs);
console.log('scope.closingEndTs = ', scope.closingEndTs);
console.log('*******************************************');
},
template: '<div>BLAH BLAH BLAH</div>'
};
}
)
This code works perfectly fine in [this jsFiddle][1]. I can see the values of `scope.closingBeginTs` and `scope.closingEndTs` in the console output.
However, when I run the same codebase on my machine, it doesn't work! I can see that those two values are properly attached to the `scope`. But when I try to log them to the console, it shows `undefined`. Why? You can see what I mean in the screenshot below. Very weird indeed.
[![enter image description here][2]][2]
[1]: https://jsfiddle.net/xgxwqxun/
[2]: http://i.stack.imgur.com/aLkue.png | <javascript><angularjs><angularjs-directive><angularjs-scope> | 2016-01-11 03:31:59 | LQ_EDIT |
34,714,833 | ReferenceError: getElementsById is not defined why? | <p>I am trying to set a variable. </p>
<pre><code>var fname = getElementsById(fname);
</code></pre>
<p>A function will then reference this variable on body load</p>
<p>But the console returns ReferenceError: getElementsById is not defined</p>
<p>Why?</p>
| <javascript><variables> | 2016-01-11 05:38:27 | LQ_CLOSE |
34,715,320 | Key keeps getting replaced in dictionary C++ | <p>I'm trying to create a dictionary type of class for fun in C++, similar to the one seen in Python where you can designate a key and a value (which may be of any type in this case, including custom classes).</p>
<pre><code>for (unsigned int x = 0; x < word.length(); x++) {
if (!map.has_key(word[x])) {
std::cout << "CREATING " << word[x] << std::endl;
map[word[x]] = ics::ArraySet<char>();
map[word[x]].insert(word[x]);
}
for (int y = 0; y < dist; y++) {
std::cout << "HELLO!" << std::endl;
if ((x + y) < word.length())
std::cout << "ADDING " << word[x+y] << std::endl;
map[word[x]].insert(word[(x + y)]);
if ((x - y) >= 0)
map[word[x]].insert(word[(x - y)]);
}
}
</code></pre>
<p>The issue that occurs is that my key keeps being replaced. I'm trying to find letters that are within "x" range of the current letter I'm on. I append these nearby keys into a set, which is the value of my dictionary in this scenario.</p>
<p>For an example: <strong>nearby(racecar,2)</strong></p>
<p>Should return a dictionary with values like this ...</p>
<p>dictionary('r' -> {r,a,c}, 'a' -> {r,c,e}, ...)</p>
<p>However, what happens is that the </p>
<pre><code>if (!map.has_key(word[x]))
</code></pre>
<p>keeps failing and my keys keep being recreated each and every time along with the sets.</p>
| <c++><dictionary> | 2016-01-11 06:22:22 | LQ_CLOSE |
34,715,375 | i set tabs but it dint navigate other tabs in angular | this is my code
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#sectionA">Section A</a></li>
<li><a data-toggle="tab" href="#sectionB">Section B</a></li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#dropdown1">Dropdown 1</a></li>
<li><a data-toggle="tab" href="#dropdown2">Dropdown 2</a></li>
</ul>
</li>
</ul>
<div class="tab-content">
<div id="sectionA" class="tab-pane fade in active">
<p>Section A content…</p>
</div>
<div id="sectionB" class="tab-pane fade">
<p>Section B content…</p>
</div>
<div id="dropdown1" class="tab-pane fade">
<p>Dropdown 1 content…</p>
</div>
<div id="dropdown2" class="tab-pane fade">
<p>Dropdown 2 content…</p>
</div>
</div>
| <javascript><angularjs> | 2016-01-11 06:27:26 | LQ_EDIT |
34,718,641 | How to create asossiative array in wrapping class | I have made a array associative like this , and i know how to take get value from a dict with index 10
var dict = new Dictionary<int, Dictionary<string, int[]>>
{
{
10, new Dictionary<string, int[]>
{
{"first", new[] {57, 57, 5, 0}},
{"second", new[] {42, 58, 13, 8}}
}
},
{
40, new Dictionary<string, int[]>
{
{"first", new[] {4, 24, 5, 0}},
{"second", new[] {42, 58, 23, 8}}
}
}
};
foreach (var item in dict[10])
{
foreach (var test in item.Value)
{
Console.WriteLine(test); //This will show value with key 10
}
}`
after that i want to change this code to make my code more elegant and maintainable by wrapping the dict in class
first class
class DataContainer
{
public DataContainer()
{
}
public int index { get; set; }
public DataValue DataValue { get; set; }
}
Second class
class DataValue
{
public DataValue()
{
IntegerValues = new List<int>();
}
public string name { get; set; }
public List<int> IntegerValues { get; set; }
}
after that i want to fill my data like i inserted in dict dictionary
but i confuse how to make it
i have tried with this below code
public List<DataContainer> harakatSininilMabsutoh = new List<DataContainer>(){
new DataContainer{index = 10 , DataValue = new List<DataValue>()
{
new DataValue{name = "first",IntegerValues = {9,55,18,11}},
new DataValue{name = "second" ,IntegerValues = {5,54,18,11}},
}
}
}
But i got the error error result
after that i want to try to show a integervalue which has index = 10
But i got an error
| <c#> | 2016-01-11 10:01:48 | LQ_EDIT |
34,719,253 | C - Binary to Decimal segmentation error | I am using a pointer in place of an array, I'm aware that a pointer needs to be freed unlike an array. Why is it that using a pointer in place of an array gives me a segmentation memory error.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
void bin(void){
char *input;
int choice;
int x = 0;
printf("Enter Decimal Code:\n");
scanf("%s",&input);
int leng = strlen(input);
for(int i = 0; i <= leng ; ++i){
if(input[i] == '1'){
x += pow(2,i);
}
else if(input[i] == '0'){
input[i] = 0;
}
free(input);
}
printf("Binary-Dec: %d\n",x);
}
int main()
{
bin();
}
| <c><pointers><scanf> | 2016-01-11 10:31:41 | LQ_EDIT |
34,720,406 | Symfony 2 : Best practice | <p>I have two questions and I hope somebody can answer them clearly.</p>
<p>Q1 : Is it recommended to use the same symfony envelop for different projects (each project would be a bundle). In any case, can you explain why it has to be done or not.</p>
<p>Q2 : is it recommended (and possible) to move the vendor folder outside the project envelop to be used by different projects. So just one vendor for different projects.</p>
<p>Thank you for answering those questions.</p>
| <symfony> | 2016-01-11 11:29:07 | LQ_CLOSE |
34,720,553 | Only Enable the last Remove Element Button of a ListBox | <p>In my ListBox.ItemTemplate i have a TextBlock and a Remove button, the button must be enabled only if it's the last element o the listbox.</p>
| <c#><wpf><listbox> | 2016-01-11 11:36:47 | LQ_CLOSE |
34,721,247 | How to auto delete wordpress comments older then x days | Everybody
I have my site in WordPress and in my site i am using forum for user discussion by using WordPress default comment system. In my forum page users continuously post comments, now i want to automatically delete comments that are older then 15 days.
is it possible to auto delete WordPress comments on any page after the interval of some days.
can anybody help me in order to do my task. | <php><wordpress><comments> | 2016-01-11 12:09:34 | LQ_EDIT |
34,721,852 | Getting Index -1 requested, with a size of 1 error while fetching data android | <p>I am using following code to get version of content </p>
<pre><code>public String getNotificationVersion(String rootContentId) {
String strVersion = "";
try {
database.open();
Cursor cur = database.query(Database.DOWNLOAD_TABLE,
new String[] { Database.KEY_VERSION },
Database.KEY_ROOT_CONTENT_ID + " = ?",
new String[] { rootContentId }, null, null, null);
Log.v("NOTIFICATION PRESENT IN DOWNLOAD GETTING DOWNLOAD", "TRUE");
strVersion = cur.getString(0);
cur.close();
database.close();
} catch (Exception e) {
Log.v("NOTIFICATION PRESENT IN DOWNLOAD GETTING DOWNLOAD", e.getMessage());
// TODO: handle exception
}
return strVersion;
}
</code></pre>
<p>and at "strVersion = cur.getString(0);" line I am getting Index -1 requested, with a size of 1 error.
I have checked database and there is value for this column. Where I am doing wrong?</p>
<p>Thanks in Advance</p>
| <android><android-sqlite> | 2016-01-11 12:42:03 | LQ_CLOSE |
34,722,257 | Get selected form data using jQuery | <p>I have a scenario where a page have multiple forms and I am trying to get the form data which is being submitted.</p>
<p>HTML</p>
<pre><code><form name="form1">
<input type="text">
<input type="button" value="Submit">
<form>
<form name="form2">
<input type="text">
<input type="button" value="Submit">
<form>
</code></pre>
<p>jQuery</p>
<pre><code>$('[type="button"]').click(function(e){
e.preventDefault();
console.log($(this).parent().attr('name'));
});
</code></pre>
<p>I always get form1 in console. I also tried <code>jQuery('form')</code> in console and it is also returning only the first form. I don't know what I am doing wrong or it is browser feature.</p>
| <jquery><html><forms> | 2016-01-11 13:03:03 | LQ_CLOSE |
34,723,261 | Which typeface in Intellij IDEA for MAC OS X | I have Windows but I want this typeface.
[PIC][1]
[1]: http://i.stack.imgur.com/FPEec.png | <macos><intellij-idea><fonts><typeface><jetbrains-ide> | 2016-01-11 13:55:30 | LQ_EDIT |
34,726,096 | How to get an array values in the dropdown in perl cgi html template | Please suggest how to get array values in the dropdown list using html template.
open (FL, "<file.txt");
file.txt values are
count1
count2
count3
count4
count5
my @TOTAL = <FL>;
foreach $count(@TOTAL)
{
$template->param( COUNT => [{name => $count}]); # here I am getting only one value (count1 only)
}
I am expecting the values like below , so the dropdown will list all the values.
$template->param(COUNT => [{name => $count1}, {name => $count2}, {name => $count3}, {name => $count4}]);
print $template->output, "\n"; | <perl> | 2016-01-11 16:09:54 | LQ_EDIT |
34,727,085 | I couldn't change color of diagonal line in 16*16 label matrix. What's my false in here? | 16*16 matrix is coming to my screen when i start the program. But when i click diagonal button, diagonal line isn't red. that is not change.
my codes :
Public Class Form1
Dim etk As New Label 'i define the matrix as etk
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 0 To 15
For j = 0 To 15
Dim etk As New Label
Me.Panel.Controls.Add(etk)
etk.Name = i
etk.Tag = j
etk.Size = New Size(26, 26)
etk.BackColor = Color.Black
etk.Location = New Point(30 * i + 10, 30 * j + 10)
Next
Next
End Sub
Private Sub diagonal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Timer1.Enabled = True
For i = 0 To 15
For j = 0 To 15
etk.Name = i
etk.Tag = j
If i = j Then
etk.BackColor = Color.Red
End If
Next
Next
End Sub
End Class
thanks for your interests.. | <vb.net><matrix> | 2016-01-11 17:01:41 | LQ_EDIT |
34,727,183 | In Java, if one boolean true then all others become false | <p>I was wondering if it was possible in Java to have a series of booleans such as:</p>
<pre><code> boolean boo1, boo2, boo3, boo4, boo5;
</code></pre>
<p>I want to make it so that if one of these booleans become true than all others become false. I know this can be done with a series of long if statements but is there a simpler way to achieve this.</p>
<p>Thanks!</p>
| <java> | 2016-01-11 17:06:25 | LQ_CLOSE |
34,730,270 | redefinition of int main() c++ | <p>Compiler constantly give the error redefine of int main(). I don't know where is the problem. There is also problem with MAX_CHAR. It's writtend MAX_CHARS’ was not declared in this scope. Any suggeston, comment ?? </p>
<pre><code>#include <iostream> // cin cout endl
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <stdlib.h> //exit
#include "insertionSort.h"
#include <vector>
#include <climits>
using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;
const int MAX_CHAR = 500; // max length of each line to read from the input file
template<class T>
void readSortOutput( char* typeName, vector<T> v, ifstream &inStream );
int main()
{
cout << "Insertion sort algorithm driver program" << endl;
ifstream inStream("/home/Downloads/input.txt");
if( inStream.fail( ) )
{
cerr << "Input file opening failed.\n";
exit(1);
}
vector<int> intVector;
readSortOutput( (char*)"int", intVector, inStream );
vector<double> dblVector;
readSortOutput( (char*)"double", dblVector, inStream );
inStream.close( );
return 0;
}
template<class T>
void insertionSort(vector<T>& data)
{
for (size_t i = 0; i < data.size( ); i++)
for (size_t j = i; j < data.size( ); j++)
if (data[ j ] < data[ i ])
{ // swap values
T temp = data[ j ];
data[ j ] = data[ i ];
data[ i ] = temp;
}
return;
}
template<class T>
void readSortOutput( char* typeName, vector<T> v, ifstream &inStream )
{
char fileLine[MAX_CHARS];
std::stringstream ss;
inStream.getline(fileLine, MAX_CHARS);
ss << fileLine;
T elem;
while (ss >> elem) {
v.push_back( elem );
}
cout << endl << typeName << " vector before insertion sort: " << endl;
for (int i = 0; i < v.size( ); i++)
cout << v[i] << " ";
cout << endl;
insertionSort( v ); // the sort itself
cout << typeName << " vector after insertion sort: " << endl;
for (int i = 0; i < v.size( ); i++)
cout << v[i] << " ";
cout << endl;
return;
}
</code></pre>
<p>InsertionSort.h</p>
<pre><code>#ifndef INSERTIONSORT_H
#define INSERTIONSORT_H
#include <iostream>
#include <iostream> // cin cout endl
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <stdlib.h> //exit
#include "insertionSort.h"
#include <vector>
#include <climits>
using namespace std;
int main()
{
int sizee=10;
int v[sizee];
for (int i=0;i<sizee;i++){
cout<<"Sorting array: ";
cin>>v[i];
}
int i,j,val;
for (i=1; i<sizee; i++) {
val=v[i];
j = i-1;
while (j>=0 && v[j]>val) {
v[j+1] = v[j];
j--;
}
v[j+1] = val;
}
for (int i=0;i<sizee;i++){
cout<<"v["<<i<<"]="<<v[i]<<endl;
}
return 0;
}
</code></pre>
| <c++><redefinition> | 2016-01-11 20:15:52 | LQ_CLOSE |
34,730,352 | Routing between 2 LAN | <p>I have Mikrotik router with Wifi connected to:</p>
<ul>
<li>WAN/internet on port ether1.</li>
<li>Other ports are for LAN 10.0.1.*.</li>
<li>Only port ether8 is connected to another simple POE switch. Four IP cameras with static IP are connected. This is LAN2 192.168.50.*. Port is not included in bridge or switch.</li>
</ul>
<p><strong>From main LAN I can access internet and other PC on same LAN, but can't access IP cameras on LAN2.</strong> </p>
<p>So, what is wrong/missing in my Mikrotik configuration:</p>
<pre><code>/ip address
add address=10.0.1.1/24 comment="default configuration" interface= ether2-master-local network=10.0.1.0
add address=10.0.0.18/30 interface=ether1-gateway network=10.0.0.16
add address=192.168.50.253/24 interface=ether8-master-local-SUBNET network=
192.168.50.0
/ip route
add distance=2 gateway=10.0.0.17
</code></pre>
<p>No ping or trace route can reach LAN2 from main LAN.
If I connect to POE switch with my laptop and configure static IP in range 192.168.50.* than I can access all cameras OK.</p>
<p>If try ping IP camera directly from Mikrotik via ether8 than I get random mix of timeouts and success which is really strange.</p>
<p>Any help is appreciated.</p>
| <networking><routing><ip><mikrotik> | 2016-01-11 20:20:26 | LQ_CLOSE |
34,730,910 | How to make string accessible to all forms | I have a form called "AddFile" and I have a textbox "tbPassword" and button "btnOkay" in it. What Im trying to do is (on a click of a button) make the text of this textbox a string so i can use it across all Forms and add it in ListView, so it displays the text written in "tbPassword" in ListView. | <c#><string><listview><global> | 2016-01-11 20:56:09 | LQ_EDIT |
34,731,625 | PHP For Loop in code | <p>I am having trouble getting my for loop to work in php. I am trying to make my code loop the time ten times with my css formating</p>
<pre><code><html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="clockloop.css">
</head>
<body>
<div id="bodycontainer">
<h1> Clock Loop </h1><hr>
<?php for($i=0;$i<=10;$i++){
<div id="border">
<span id = "font">
<?php
echo date("G:i:s")
?>
</span>
</div>
<h3> Today is
<?php
echo date("F,j,Y")
?>
</h3>
}
?>
</div>
</body>
</html>
</code></pre>
| <php> | 2016-01-11 21:39:34 | LQ_CLOSE |
34,732,032 | Stop IEnumerable from enumerating through all elements | <p>How do I stop <code>IEnumberable</code> from enumerating through all the elements in the variable in question.
I have a function which I pass an <code>IEnumerable</code> list to, and it will always have only two elements. I however, need the function to only run for the first element, no more, no less. How do I get it to only go through the first element?</p>
<p>Note: Since there are only two elements, I've tried passing them in separately (e.g <code>double</code> <code>double</code>), but it still runs through both.</p>
| <c#><ienumerable> | 2016-01-11 22:08:14 | LQ_CLOSE |
34,734,108 | Can you use http POST from a web page? | I am trying to use Jira to REST API to submit issues.
This answer gives a POST method to submit issues
http://stackoverflow.com/questions/5884960/how-to-create-an-issue-in-jira-via-rest-api
Is there a way to integrate POST with html so you could submit things from a webpage?
As you can probably tell I know very little about POST so simple would be better :)
Thank you! | <html><http><jira> | 2016-01-12 01:25:28 | LQ_EDIT |
34,734,299 | liste chainées C | i dunno how to formulate a question when i dunno what's the problem at all, since i'm still new at the linked list stuff in C, anyhow this is my code
#include <stdio.h>
#include <stdlib.h>
typedef struct Element{
int val;
struct Element* suivant;
}Element;
Element* initialiserListe(Element* L){
L = NULL;
return L;
}
Element* nouveau;
Element* insererEnTete(Element* L){
nouveau = (Element*)malloc(sizeof(Element));
if(L == NULL) printf("initialisation : ");
printf("donner une valeur : ");
scanf("%d", &nouveau->val);
nouveau->suivant = L;
return nouveau;
}
int listeVide(Element* L){
return L == NULL;
}
void affichageListe(Element* L){
if(listeVide(L)) printf("liste vide");
else{
Element* temp = L;
while(temp != NULL){
printf("%d", temp->val);
temp = temp->suivant;
}
}
}
int main()
{
printf("Hello world!\n");
Element *L = NULL;
initialiserListe(L);
insererEnTete(L);
affichageListe(L);
return 0;
}
all i wanna know is why does it print "liste vide" when it should print the vals from the list | <c><linked-list> | 2016-01-12 01:48:32 | LQ_EDIT |
34,736,800 | how to get output of count variable ? | <?php
$count=0;
class My extends Thread
{
private $myid;
// ini_set('max_execution_time', 0);
//echo date("Y-m-d H:i:s")."<br/>";
public function __construct($id)
{
$this->myid = $id;
}
public function run()
{
for($t=0;$j+$t<=100;$t+=10){ //future buy
for($k=0;$j+$t+$k<=100;$k+=10){//future sell
for($l=1;$l<=14;$l++){ // strike
for($m=0;$j+$k+$m<=300;$m+=10){ //put buy
for($n=1;$n<=14;$n++){ // strike
for($o=0;$o<=300;$o+=10){ // call buy
for($p=1;$p<=14;$p++){ //strike
if($p==$l)
continue;
for($q=0;$q<=300;$q+=10){ // put sell
for($r=1;$r<=14;$r++){ // strike
if($r==$n)
continue;
for($s=0;$s<=300;$s+=10){ // call buy
$count ++;
}
}
}
}
}
}
}
}
}
}
}
}
echo date("Y-m-d H:i:s")."<br/>";
$mycalls = [];
for($i=0;$i<=100;$i+=10)
{
$mycalls[$i]= new My($i);
$mycalls[$i]->start();
$mycalls[$i]->join();
}
echo date("Y-m-d H:i:s")."<br/>";
echo "<br>";
echo $count;
?> | <php> | 2016-01-12 06:19:48 | LQ_EDIT |
34,737,089 | J query height and java script height gets 0 . Why? | I have a visible div on screen but when i gets its height, it returns always 0. How it is possible? I have tried many j query and JavaScript methods to get hight but it returns 0. This is my div:
<div class="option-content">
<div class="row">
<div class="col-sm-12">
<div class="dropDownStyling" id="filterDropdowns">
</div>
</div>
</div>
//Other contents
</div>
I have tried following methods to get height:
var $element = $("#filterDropdowns");
$element.css("height")
$element.height()
$element.innerHeight()
$element.outerHeight()
Also tried javascript:
document.getElementById('filterDropdowns').offsetHeight
document.getElementById('filterDropdowns').clientHeight
But in all cases, it returns 0,While it returns the width value.Then why height value gets 0? | <javascript><jquery><html><css> | 2016-01-12 06:40:30 | LQ_EDIT |
34,737,219 | Chagne text box border color in login page as in gmail | I am developing a login page having input filed functionality similar to gmail input field i.e. in focus mode input field should be blue and when validation fails it changes into red, please help.
Many-Many Thanks in advance… | <javascript><jquery><html><asp.net> | 2016-01-12 06:50:31 | LQ_EDIT |
34,737,289 | Chagne the width of the dropdownlist | Goal:
Change the width of the select dropdownlist that use bootstrap v2.
Problem:
I don't know how to change the width of it in relation to bootstrap.
Info:
Please remember that I have three dropdownlist in the same page and it is one of them that I want to change the width.
http://jsbin.com/roriyododa/edit?html,css,output
Thanks!
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
<select style="display: none;" class="selectpicker" id="fromContent" name="From"><option value="122344">122344</option>
<option value="46731233320">46731233320</option>
<option value="abbb">abbb</option>
<option value="asd">asd</option>
<option value="d">d</option>
<option value="test">test</option>
<option value="testtest">testtest</option>
<option value="11">11</option>
<option value="24">24</option>
<option value="ddd">ddd</option>
<option value="gd">gd</option>
<option value="hn2">hn2</option>
<option value="jippo">jippo</option>
<option value="sdf">sdf</option>
<option value="sdfsdf">sdfsdf</option>
</select>
<div class="btn-group bootstrap-select"><button title="122344" data-id="fromContent" type="button" class="btn dropdown-toggle form-control selectpicker btn-default" data-toggle="dropdown"><span class="filter-option pull-left">122344</span> <span class="caret"></span></button><div class="dropdown-menu open"><ul class="dropdown-menu inner selectpicker" role="menu"><li class="selected" data-original-index="0"><a tabindex="0" class="" data-normalized-text="<span class="text">122344</span>"><span class="text">122344</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="1"><a tabindex="0" class="" data-normalized-text="<span class="text">46731233320</span>"><span class="text">46731233320</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="2"><a tabindex="0" class="" data-normalized-text="<span class="text">abbb</span>"><span class="text">abbb</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="3"><a tabindex="0" class="" data-normalized-text="<span class="text">asd</span>"><span class="text">asd</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="4"><a tabindex="0" class="" data-normalized-text="<span class="text">Feedex</span>"><span class="text">Feedex</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="5"><a tabindex="0" class="" data-normalized-text="<span class="text">test</span>"><span class="text">test</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="6"><a tabindex="0" class="" data-normalized-text="<span class="text">testtest</span>"><span class="text">testtest</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="7"><a tabindex="0" class="" data-normalized-text="<span class="text">11</span>"><span class="text">11</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="8"><a tabindex="0" class="" data-normalized-text="<span class="text">24</span>"><span class="text">24</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="9"><a tabindex="0" class="" data-normalized-text="<span class="text">ddd</span>"><span class="text">ddd</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="10"><a tabindex="0" class="" data-normalized-text="<span class="text">gd</span>"><span class="text">gd</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="11"><a tabindex="0" class="" data-normalized-text="<span class="text">hn2</span>"><span class="text">hn2</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="12"><a tabindex="0" class="" data-normalized-text="<span class="text">jippo</span>"><span class="text">jippo</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="13"><a tabindex="0" class="" data-normalized-text="<span class="text">sdf</span>"><span class="text">sdf</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li><li data-original-index="14"><a tabindex="0" class="" data-normalized-text="<span class="text">sdfsdf</span>"><span class="text">sdfsdf</span><span class="glyphicon glyphicon-ok check-mark"></span></a></li></ul></div></div>
<!-- end snippet -->
| <javascript><jquery><html><css><twitter-bootstrap> | 2016-01-12 06:55:14 | LQ_EDIT |
34,737,316 | This code is not running properly. | I tried to run the following code but after one input, the rest of the input is initialized to zero and is displayed on the screen automatically. where did I go wrong?
#include<iostream>
#define N 50
using namespace std;
struct movies_t
{
char title[60];
int year;
}user[N];
void printmovie(movies_t);
int main()
{
for(int i = 0; i < N; i++)
{
cout << "Enter title: ";
cin.get(user[i].title, 60);
cout << "Enter year: ";
cin >> user[i].year;
}
cout << "\nYou have entered these movie: \n";
for(int i = 0; i < N; i++)
printmovie(user[i]);
return 0;
}
void printmovie(movies_t m)
{
cout << m.title;
cout << " (" << m.year << ")\n";
} | <c++> | 2016-01-12 06:57:11 | LQ_EDIT |
34,738,807 | How to join 2 tables but same data's? | Is it possible to join to tables like in the picture,[example picture][1]
there are no foreign key in svotes but there are the same records.
In the select option tag I putted the school_year and the option are `2015-2016,2016-2017`. If I click the 2016 it should that the other table svotes can display the year of 2016 can it be possible? and How?
Here's my code:
<script type="text/javascript">
function getyr(str) {
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
//this part will be handle
xmlhttp.open("GET","get_winner.php?no="+str,true);
xmlhttp.send();
}
</script>
<select style="margin-left:-313px;" name="sy_no" onchange="getyr(this.value)">
<option></option>
<?php
include('../connect.php');
$sql2 = mysql_query("SELECT * FROM school_year");
while ($row1=mysql_fetch_array($sql2)){
echo "<option value=".$row1['syearid'].">".$row1['from_year'].'-'.$row1['to_year']."</option>";
}
?>
</select>
get_winner.php
<?php
include('../connect.php');
$no = $_GET['no'];
//this is where I get the year
$stud = mysql_query("SELECT * FROM studentvotes,school_year WHERE school_year.from_year = studentvotes.year AND studentvotes.year = '$no' ") or die(mysql_error());
echo"<center>";
echo "<form action='' method='POST' enctype='multipart/form-data' >";
echo " <table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
echo "<tr>";
echo "<th>IDno</th>";
echo "<th>Action</th>";
echo "</tr>";
while ($row=mysql_fetch_array($stud)){
$result = mysql_query("SELECT * FROM studenvotes,school_year WHERE studenvotes.year = school_year.from_year") or die(mysql_error());
$r1 = mysql_fetch_assoc($result);
?>
<tr class="headings">
<td><?php echo $row['idno']; ?></td>
<td> <a href="editcandidate.php?candid=<?php echo $row['candid']; ?> "style="border:1px solid grey; background:grey; border-radius:10%; padding:5px 14px; color:white; text-decoration:none; "> Edit </a></td>
<?php
}
?>
[1]: http://i.stack.imgur.com/bg4e8.png | <php> | 2016-01-12 08:31:34 | LQ_EDIT |
34,739,366 | If statement wont work | First i run this first function,
it sets paikka3.src to "sapeli.png".
But then when i run the second function, the if statement wont work/run.
Why is this? I have no clue...
code:
var sapeliMäärä = 1;
function tavarat() {
if(sapeliMäärä == 1) {
document.lomake.paikka3.src = "sapeli.png";
}
}
function käytäTavaraa3() {
if(document.lomake.paikka3.src == "sapeli.png") {
OmaHp += 5;
document.lomake.poksi.value = "Söit lohen joka paransi 5 HP";
document.lomake.paikka3.src = "";
lohiMäärä -= 1;
}
} | <javascript> | 2016-01-12 09:05:47 | LQ_EDIT |
34,739,634 | Delete SSH key without SSH access | <p>My sshd is refusing to restart because of the following error:</p>
<p><code>@ WARNING: UNPROTECTED PRIVATE KEY FILE! @</code></p>
<p>However, i cant figure out how to delete the unsafe ssh keys without having the ssh access. What to do?</p>
| <ssh><sshd> | 2016-01-12 09:18:58 | LQ_CLOSE |
34,739,819 | selenium with C# on IE | <p>Switching multiple windows in IE. </p>
<p>First page has LOGIN button which on clicked goes to second window. </p>
<p>Second window takes credentials and has a NEXT button which on clicked goes to third window.</p>
<p>Third window has a button which on clicking moves to the fourth window. </p>
<p>How do I navigate mutiple windows using Selenium with C#.My website runs on IE only.</p>
| <c#><internet-explorer><selenium> | 2016-01-12 09:27:59 | LQ_CLOSE |
34,740,488 | reuse twig templates in symfony2 with inheritance | <p>I have a symfony2 project which will be the base for a bundle of domains. Most configuration differences for those domains are done via the database. Like e.g. are the contents randomized, how many are shown on the start page etc.
But for some domains I want to use a different twig template for certain views depending on a categorization I do via the db.</p>
<p>Question 1: Is it possible to set it up like "if you find no template in place A use the default template from place B"? If yes how?</p>
<p>Question 2: Where would I place those templates in relation to the default templates?</p>
| <symfony><templates><twig> | 2016-01-12 09:59:03 | LQ_CLOSE |
34,741,347 | Randomly select multiple items from an array | <p>I want to have an array with different words and phrases and randomly generate around five of these on page refresh. How would I go about doing this in javascript?</p>
| <javascript><arrays><string><random> | 2016-01-12 10:37:03 | LQ_CLOSE |
34,742,124 | Is it possible to append another value to existing variable in sass / scss? | <p>I have this defined in an external file of a framework I am using:</p>
<pre><code>$font-family-sans-serif: "Helvetica Neue", "Roboto", "Segoe UI", sans-serif !default;
</code></pre>
<p>I want to prepand my own font (in a different file , e.g, without altering the FW variables file).</p>
<pre><code>$font-family-sans-serif: 'MyFont', $font-family-sans-serif;
</code></pre>
<p>So, is it possible? The above is not working.</p>
<pre><code>Error: Undefined variable: "$font-family-sans-serif".
on line 3 of scss/variables.scss
on line 3 of scss/variables.scss
>> $font-family-sans-serif: 'MyFont', $font-family-sans-serif;
</code></pre>
| <css><sass> | 2016-01-12 11:12:16 | LQ_CLOSE |
34,743,075 | Find subnet mask from ip | In my lan i've two subnet:
- 255.255.255.0
- 255.255.255.128
Is there a method to scan all lan's IP to know in wich subnet mask are? | <networking><ip><lan><subnet> | 2016-01-12 11:57:29 | LQ_EDIT |
34,743,669 | Site is not loading .htaccess rewrite rule error. How to fix this ? | The site does not load anymore and in error log file I can see. This happened suddenly after attempting to load files such as video and img.
EROOR messages are :
RewriteRule: cannot compile regular expression '^([0-9]+)\\/([^\\d\\/]+)([0-9]+).**\\/[0-9]+,[0-9]+\\)\\).*\\/*![0-9]+.**\\/\\)``\\)``\\)\\)$'
[Tue Jan 12 00:26:31 2016] [alert] [client 77.221.147.16] [host schweitzerlambarene.org] /homez.133/schweitzo/www/.htaccess: RewriteRule: cannot compile regular expression '^([0-9]+)\\/([^\\d\\/]+)([0-9]+).**\\/[0-9]+,[0-9]+\\)\\).*\\/*![0-9]+.**\\/\\)``\\)``\\)\\)$', referer: http://schweitzerlambarene.org/index.php?option=com_contenthistory&view=history&list[select]=1
Here is the content of .htaccess
> SetEnv PHP_VER 5_3 SetEnv MAGIC_QUOTES 0
> ##
> # @package Joomla
> # @copyright Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
> # @license GNU General Public License version 2 or later; see LICENSE.txt
> ##
> ##
> # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
> #
> # The line just below this section: 'Options +FollowSymLinks' may cause problems
> # with some server configurations. It is required for use of mod_rewrite, but may already
> # be set by your server administrator in a way that dissallows changing it in
> # your .htaccess file. If using it causes your server to error out, comment it out (add # to
> # beginning of line), reload your site in your browser and test your sef url's. If they work,
> # it has been set by your server administrator and you do not need it set here.
> ##
> ## Can be commented out if causes errors, see notes above. Options +FollowSymLinks
> ## Mod_rewrite in use. RewriteEngine On
> ## Begin - Rewrite rules to block out some common exploits.
> # If you experience problems on your site block out the operations listed below
> # This attempts to block the most common type of exploit `attempts` to Joomla!
> #
> # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
> # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
> # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
> # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
> # Return 403 Forbidden header and show the content of the root homepage RewriteRule .* index.php [F]
> #
> ## End - Rewrite rules to block out some common exploits.
> ## Begin - Custom redirects
> #
> # If you need to redirect some pages, or set a canonical non-www to
> # www redirect (or vice versa), place that code here. Ensure those
> # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
> #
> ## End - Custom redirects
> ##
> # Uncomment following line if your webserver's URL
> # is not directly related to physical file paths.
> # Update Your Joomla! Directory (just / for root).
> ##
> # RewriteBase /
> # RewriteRule ^/?([\w+\s-]+)$ ?x=$1 [QSA,L] ?$2$1=$3&%{QUERY_STRING}[L] RewriteRule
> ^([0-9]+)\/([^\d\/]+)([0-9]+).**\/[0-9]+,[0-9]+\)\).*\/*![0-9]+.**\/\)``\)``\)\)$
> ?$2$1=$3&%{QUERY_STRING}[L]
> # RewriteRule ^([0-9]+)\/([^\d\/]+)([0-9]+)-[0-9]+\/.*..*$ ?$2$1=$3&%{QUERY_STRING}[L]
> ## Begin - Joomla! core SEF Section.
> # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
> #
> # If the requested path and file is not /index.php and the request
> # has not already been internally rewritten to the index.php script RewriteCond %{REQUEST_URI} !^/index\.php
> # and the request is for something within the component folder,
> # or for the site root, or for an extensionless URL, or the
> # requested URL ends with one of the listed extensions RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$
> [NC]
> # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f
> # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d
> # internally rewrite the request to the index.php script RewriteRule .* index.php [L]
> #
> ## End - Joomla! core SEF Section. | <.htaccess><joomla> | 2016-01-12 12:26:02 | LQ_EDIT |
34,743,937 | how to use mysql one fiel AND | My simple question about mysql
This is my code
`SELECT
t_id_tags.id_post,
t_id_tags.id_tag
FROM
t_id_tags
WHERE
id_tag IN (860, 945)`
I'm like this
`SELECT
t_id_tags.id_post,
t_id_tags.id_tag
FROM
t_id_tags
WHERE
id_tag = 860
AND id_tag = 945`
is possible ?
tnx
| <mysql> | 2016-01-12 12:38:55 | LQ_EDIT |
34,744,190 | Android Material Design support for ecipse | Is it possible to work on material design in eclipse IDE.
when i run the app i'm getting issue to change the app theme to appcomact instead of android:Theme.Material | <android> | 2016-01-12 12:50:11 | LQ_EDIT |
34,744,742 | Should I make my code dependent on external libraries? | <p>Tl;dr: Stick to the bold text.</p>
<p><strong>Libraries</strong> provided by others can <strong>save</strong> a lot of <strong>programming time</strong>, because one does not have to solve problems that others already did. Furthermore, they often perform certain tasks much <strong>more efficient</strong> than one could ever achieve by oneself.</p>
<p>On the downside one adds a <strong>dependency</strong> to the program which can cause <strong>problems with licensing, compiling</strong> on other machines and so on. Also developments in the libraries may interfere with developments in ones own code. In extreme cases one is after some time <strong>restricted</strong> to the <strong>functionalities</strong> the library provides meaning that even a small extension might require the programmer to rewrite half of the library. In such a case one may rather want to <strong>exchange the library</strong> with a different one.</p>
<p>At this point one can be in big <strong>trouble</strong> if the whole code is cluttered with calls to the library. To prevent problems like this one can right from the start write a <strong>wrapper</strong> around the external library so that a library change reduces to changing the wrapper and no other code needs to be touched - in theory.</p>
<p>In practice, however, the <strong>interfaces</strong> through which the wrapper is called may <strong>not</strong> be <strong>compatible</strong> with the "new" library. Also a library might use <strong>data structures</strong> that are <strong>not</strong> directly <strong>compatible</strong> with the data types in ones own program. Then data needs to be reorganized and probably a lot of copying happens which was not necessary before.</p>
<p><strong>Questions:</strong></p>
<ul>
<li><strong>How can I avoid trouble with changing libraries?</strong></li>
<li><strong>Should I always wrap the functions external libraries provide?</strong></li>
<li><strong>Should I wrap data objects of external libraries as well?</strong></li>
<li><strong>Or should I instead completely decide for a library and stick with it?</strong></li>
</ul>
<p><strong>Example:</strong></p>
<p>I work on a huge program in which problems of linear algebra are ubiquitous. Recently, we started to switch to Eigen, an efficient library with broad linear algebra functionalities. Eigen comes with its own data objects. Now there are tons of <code>std::vector<double></code> objects present in the code which would need to be replaced with Eigen's <code>VectorXd</code> to be able to nicely work with Eigen. It would be a hell of a work to do all these replacements. However, it would probably be even more work to undo these changes if Eigen at some points turns out to be not the ideal solution. Now I'm not sure whether writing an own vector class which just wraps the Eigen data type would actually reduce the effort if the library will be exchanged someday, or whether I will just produce more problems that way.</p>
| <c++><external><eigen> | 2016-01-12 13:16:22 | LQ_CLOSE |
34,744,788 | Can't call function Python | <p>Here is my code that calls the <code>__init__</code> of <code>Game_Events</code> class:</p>
<pre><code>class Game_Events(object):
def __init__(self, DoSetup):
if DoSetup == "yes":
print "Done"
GE = Game_Events()
GE.__init__("no")
</code></pre>
<p>But when ever I run the code I get:</p>
<pre><code>TypeError: __init__() takes exactly 2 arguments (1 given)
</code></pre>
<p>How can I fix this?</p>
| <python><function> | 2016-01-12 13:18:11 | LQ_CLOSE |
34,744,959 | alright this is my most rescent code |
highest = {}
def reader():
myfile = open("scores.txt","r")
pre = myfile.readlines()
print(pre)
for line in pre :
print(line)
x = line.split(",")
a = x[0]
b = x[1]
c = len(b)-1
b = b[0:c]
highest[a] = b
and this is the Traceback error message in full
Traceback (most recent call last):
File "C:/Python34/my boto snaky/snaky.py", line 568, in gameLoop
reader()
File "C:/Python34/my boto snaky/snaky.py", line 531, in reader
b = x[1]
IndexError: list index out of range
| <python> | 2016-01-12 13:26:23 | LQ_EDIT |
34,746,224 | pre tag text not coming in innerText | <p>I was just testing something and noticed that text inside <code>pre</code> tag does not appear if you access it using <code>parent</code> element. </p>
<p>Following is the code example: </p>
<p><a href="https://jsfiddle.net/RajeshDixit/2wkvvapn/" rel="nofollow">JSFiddle</a></p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>(function() {
var _innerText = document.getElementById("content").innerText;
var _innerHTML = document.getElementById("content").innerHTML;
var _textContent = document.getElementById("content").textContent;
console.log(_innerText, _innerHTML, _textContent)
console.log($("#content").text());
})()</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<p id="content">
p text
<pre>Pre text</pre>
<small>small text</small>
</p></code></pre>
</div>
</div>
</p>
<p>I also noticed that anything after it is also not fetched. If you move <code>small</code> before <code>pre</code>, text appears. What could be the reason for it?</p>
| <javascript><jquery><html> | 2016-01-12 14:25:36 | LQ_CLOSE |
34,746,726 | loading fonts ttf crashes , error loading with libgdx | i have the problem with load the ttf file, my code:
Label migliaLabel;
migliaLabel = new Label("label", new Label.LabelStyle(new BitmapFont(Gdx.files.internal("Kalam-Regular.ttf")), Color.MAGENTA));
the file Kalam-Regular.ttf is in the folder assets/Kalam-Regular.ttf
but when i run the game, android studio get in error:
> FATAL EXCEPTION: GLThread 125
> com.badlogic.gdx.utils.GdxRuntimeException: Error loading font file:
> Kalam-Regular.ttf
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.load(BitmapFont.java:665)
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(BitmapFont.java:475)
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:114)
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:107)
> at com.surfsurvivor.game.GameClass.show(GameClass.java:181)
> at com.badlogic.gdx.Game.setScreen(Game.java:61)
> at com.surfsurvivor.game.SurfClass.create(SurfClass.java:26)
> at
> com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:254)
> at
> android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
> at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
> Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Invalid
> padding.
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.load(BitmapFont.java:488)
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(BitmapFont.java:475)
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:114)
> at
> com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:107)
> at com.surfsurvivor.game.GameClass.show(GameClass.java:181)
> at com.badlogic.gdx.Game.setScreen(Game.java:61)
> at com.surfsurvivor.game.SurfClass.create(SurfClass.java:26)
> at
> com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:254)
> at
> android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
> at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
how can solve ?
Thanks | <android-studio><fonts><libgdx><load> | 2016-01-12 14:48:27 | LQ_EDIT |
34,746,778 | Why is my HTML test report always one XML file behind? | <p>This code in my <code>protractor</code> config file works perfectly... except that the <code>html</code> file creation in onComplete always uses the junitresults <code>xml</code> file from the <em>previous</em> test run, instead of the xml file created in the same config file's onPrepare function. So the html page is always showing test results one run behind what the timestamp displayed on the html page claims.</p>
<p>A simple illustration is that if I start with no xml file from a previous test in the test-results folder, the html generator finds <em>no</em> xml file at all to build an html file from, and therefore generates no html file. But the <em>new</em> xml file does show still get created, dropped into the folder, and totally ignored... until the next test run.</p>
<p>Can you help me get my test to generate an xml file and then use <em>that</em> xml file to generate the html file? </p>
<p>Thanks!</p>
<pre><code>onPrepare: function() {
var capsPromise = browser.getCapabilities();
capsPromise.then(function(caps) {
browser.browserName = caps.caps_.browserName.replace(/ /g,"-");
browser.browserVersion = caps.caps_.version;
browserName = browser.browserName;
browser.reportPath = 'c:/QA/test-results/' + browser.browserName + '/';
}). then(function(caps) {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'c:/QA/test-results/' + browser.browserName + '/',
filePrefix: 'junitresults'
}));
});
return browser.browserName, browser.browserVersion, browser.reportPath;
},
onComplete: function() {
var HTMLReport = require('jasmine-xml2html-converter');
// Call custom report for html output
testConfig = {
reportTitle: 'Test Execution Report',
outputPath: browser.reportPath,
seleniumServer: 'default',
applicationUrl: browser.baseUrl,
testBrowser: browser.browserName + ' v.' + browser.browserVersion
};
new HTMLReport().from(browser.reportPath + 'junitresults.xml', testConfig);
console.log("... aaaannnnd... done.");
},
</code></pre>
| <angularjs><jasmine><automated-tests><protractor><jasmine2.0> | 2016-01-12 14:51:18 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.