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 |
|---|---|---|---|---|---|
36,975,553 | MATLAB programming to detect data is Bimodal or Trimodal distribution | <p>I have a time series data having values randomly between 0 & 1. I want to detect the automatically through MATLAB programming whether the distribution of data is Bimodal or Trimodal distribution.</p>
| <matlab><matlab-guide> | 2016-05-02 05:32:47 | LQ_CLOSE |
36,975,599 | i want to do something when i close console VB window is that possible? | <p>I want to call function or execute some code when i <code>close</code> the window in console vb is that possible?</p>
<p>thanks in advance </p>
| <.net><vb.net><console> | 2016-05-02 05:38:41 | LQ_CLOSE |
36,976,266 | How to get data from an array inside an object in javascript? | <p>My data structure is as follows</p>
<pre><code>var processArray = [];
for(i = 0;i < someProcess.length;i++){
processArray.push({
id: i,
processName: someProcess[i],
processType: someType[i]
});
}
//someProcess and someType are arrays from database.
</code></pre>
<p>I use this processArray to populate a HTML list. After some operations by the user (eg:- adding more data or deleting some), I need to extract all processName from processArray and store them in another array, lets say newProcessList. How can I do it?</p>
| <javascript> | 2016-05-02 06:34:26 | LQ_CLOSE |
36,976,312 | API to extract text from a image for andoird mobile | I am trying to extract text from the picture taken in andoird mobile through some API .will that google Vision helps me ?Used OCR too but i felt that the output is not accurate. any suggestions? | <android><eclipse> | 2016-05-02 06:36:51 | LQ_EDIT |
36,977,396 | I has some wrong about insert data to SQLite. Please help me | I'm try to insert data to SQLite. But something are wrong in AddActivity.java.
My concept is insert data to SQLite.
After read data from data show list.
When click list on data list it will be show detail of this list.
[Click here to see a picture.][1]
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
Cannot resolve method 'Insertdata(java.lang.String,java.lang.String,java.lang.String)'
<!-- end snippet -->
Please help me. And sorry for my bad English.
myDBClass.java
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
package com.example.puen.projectdemo;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
public class myDBClass extends SQLiteOpenHelper {
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "mydatabase";
// Table Name
private static final String TABLE_MEMBER = "members";
public myDBClass(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
// Create Table Name
db.execSQL("CREATE TABLE " + TABLE_MEMBER +
"(MemberID INTEGER PRIMARY KEY AUTOINCREMENT," +
" Name TEXT(100)," +
" Tel TEXT(100));");
Log.d("CREATE TABLE", "Create Table Successfully.");
}
// Select Data
public String[] SelectData(String strMemberID) {
// TODO Auto-generated method stub
try {
String arrData[] = null;
SQLiteDatabase db;
db = this.getReadableDatabase(); // Read Data
Cursor cursor = db.query(TABLE_MEMBER, new String[]{"*"},
"MemberID=?",
new String[]{String.valueOf(strMemberID)}, null, null, null, null);
if(cursor != null)
{
if (cursor.moveToFirst()) {
arrData = new String[cursor.getColumnCount()];
/***
* 0 = MemberID
* 1 = Name
* 2 = Tel
*/
arrData[0] = cursor.getString(0);
arrData[1] = cursor.getString(1);
arrData[2] = cursor.getString(2);
}
}
cursor.close();
db.close();
return arrData;
} catch (Exception e) {
return null;
}
}
// Show All Data
public ArrayList<HashMap<String, String>> SelectAllData() {
// TODO Auto-generated method stub
try {
ArrayList<HashMap<String, String>> MyArrList = new ArrayList<>();
HashMap<String, String> map;
SQLiteDatabase db;
db = this.getReadableDatabase(); // Read Data
String strSQL = "SELECT * FROM " + TABLE_MEMBER;
Cursor cursor = db.rawQuery(strSQL, null);
if(cursor != null)
{
if (cursor.moveToFirst()) {
do {
map = new HashMap<>();
map.put("MemberID", cursor.getString(0));
map.put("Name", cursor.getString(1));
map.put("Tel", cursor.getString(2));
MyArrList.add(map);
} while (cursor.moveToNext());
}
}
cursor.close();
db.close();
return MyArrList;
} catch (Exception e) {
return null;
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXISTS " + TABLE_MEMBER);
// Re Create on method onCreate
onCreate(db);
}
}
<!-- end snippet -->
AddActivity.java
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
package com.example.puen.projectdemo;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class AddActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
// btnSave (Save)
final Button save = (Button) findViewById(R.id.btnSave);
save.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// If Save Complete
if(SaveData())
{
// Open Form Main
Intent newActivity = new Intent(AddActivity.this,MainActivity.class);
startActivity(newActivity);
}
}
});
// btnCancel (Cancel)
final Button cancel = (Button) findViewById(R.id.btnCancel);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Open Form Main
Intent newActivity = new Intent(AddActivity.this,MainActivity.class);
startActivity(newActivity);
}
});
}
public boolean SaveData()
{
// txtMemberID, txtName, txtTel
final EditText tMemberID = (EditText) findViewById(R.id.txtMemberID);
final EditText tName = (EditText) findViewById(R.id.txtName);
final EditText tTel = (EditText) findViewById(R.id.txtTel);
// Dialog
final AlertDialog.Builder adb = new AlertDialog.Builder(this);
AlertDialog ad = adb.create();
// Check MemberID
if(tMemberID.getText().length() == 0)
{
ad.setMessage("Please input [MemberID] ");
ad.show();
tMemberID.requestFocus();
return false;
}
// Check Name
if(tName.getText().length() == 0)
{
ad.setMessage("Please input [Name] ");
ad.show();
tName.requestFocus();
return false;
}
// Check Tel
if(tTel.getText().length() == 0)
{
ad.setMessage("Please input [Tel] ");
ad.show();
tTel.requestFocus();
return false;
}
// new Class DB
final myDBClass myDb = new myDBClass(this);
// Check Data (MemberID exists)
String arrData[] = myDb.SelectData(tMemberID.getText().toString());
if(arrData != null)
{
ad.setMessage("MemberID already exists! ");
ad.show();
tMemberID.requestFocus();
return false;
}
// Save Data
long saveStatus = myDb.InsertData(tMemberID.getText().toString(),
tName.getText().toString(),
tTel.getText().toString());
if(saveStatus <= 0)
{
ad.setMessage("Error!! ");
ad.show();
return false;
}
Toast.makeText(AddActivity.this,"Add Data Successfully. ",
Toast.LENGTH_SHORT).show();
return true;
}
}
<!-- end snippet -->
DetialActivity.java
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
package com.example.puen.projectdemo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class DetailActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
// Read var from Intent
Intent intent= getIntent();
String MemID = intent.getStringExtra("MemID");
// Show Data
ShowData(MemID);
// btnCancel (Cancel)
final Button cancel = (Button) findViewById(R.id.btnCancel);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Open Form Show
Intent newActivity = new Intent(DetailActivity.this,ShowActivity.class);
startActivity(newActivity);
}
});
}
public void ShowData(String MemID)
{
// txtMemberID, txtName, txtTel
final TextView tMemberID = (TextView) findViewById(R.id.txtMemberID);
final TextView tName = (TextView) findViewById(R.id.txtName);
final TextView tTel = (TextView) findViewById(R.id.txtTel);
// new Class DB
final myDBClass myDb = new myDBClass(this);
// Show Data
String arrData[] = myDb.SelectData(MemID);
if(arrData != null)
{
tMemberID.setText(arrData[0]);
tName.setText(arrData[1]);
tTel.setText(arrData[2]);
}
}
}
<!-- end snippet -->
ShowActivity.java
<!-- begin snippet: js hide: false -->
<!-- language: lang-css -->
package com.example.puen.projectdemo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
import java.util.HashMap;
public class ShowActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show);
final myDBClass myDb = new myDBClass(this);
final ArrayList<HashMap<String, String>> MebmerList = myDb.SelectAllData();
// listView1
ListView lisView1 = (ListView)findViewById(R.id.listView1);
SimpleAdapter sAdap;
sAdap = new SimpleAdapter(ShowActivity.this, MebmerList, R.layout.activity_column,
new String[] {"MemberID", "Name", "Tel"}, new int[] {R.id.ColMemberID, R.id.ColName, R.id.ColTel});
lisView1.setAdapter(sAdap);
lisView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> myAdapter, View myView, int position, long mylng) {
// Show on new activity
Intent newActivity = new Intent(ShowActivity.this,DetailActivity.class);
newActivity.putExtra("MemID", MebmerList.get(position).get("MemberID").toString());
startActivity(newActivity);
}
});
// btnCancel (Cancel)
final Button cancel = (Button) findViewById(R.id.btnCancel);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Open Form Main
Intent newActivity = new Intent(ShowActivity.this,MainActivity.class);
startActivity(newActivity);
}
});
}
}
<!-- end snippet -->
[1]: http://i.stack.imgur.com/MkwBY.png | <android><sqlite><android-studio><crud><lang> | 2016-05-02 07:42:03 | LQ_EDIT |
36,979,298 | Searching List <dvd> C # | I have a DVD Rental application. And in my Store.cs (class) i need to search the Dvd.cs (class) for un rented dvds and save the film from the Movie.cs class in results in a list (getAvailableDVD).
Movie.cs has properties set & a List<dvd> & in my Dvd.cs i have an enum for availability {Available,Rented,Not Available}
im quite new to this idea, but im wanting to search the list for each Availability.Available and return its corresponding film(movie.cs)
anyone have ideas on how to approach a search method in my Store.cs? | <c#><list><search><methods><enums> | 2016-05-02 09:38:36 | LQ_EDIT |
36,979,536 | isset($_SESSION['id']) is not working properly | <p>I am trying to use the condition:</p>
<blockquote>
<p>isset($_SESSION['id'])</p>
</blockquote>
<p>So i just tried </p>
<blockquote>
<p>echo isset($_SESSION['id']); and echo $_SESSION['id'];</p>
</blockquote>
<p>But this gives output different. In fact true result gives by </p>
<blockquote>
<p>echo $_SESSION['id'];</p>
</blockquote>
<p>Any one have idea why this is happening?
<br /><strong>Note:</strong> I use <code>session_start();</code> at the beginning of page.</p>
| <php><session> | 2016-05-02 09:51:13 | LQ_CLOSE |
36,979,988 | sorry my english bad, I want to add localstorage for count up timer to if refresh, it still running | [Here is JS Fiddle Demo you can see][1]
[1]: https://jsfiddle.net/o5s4y2L7/ | <javascript><php><timer><local-storage> | 2016-05-02 10:13:11 | LQ_EDIT |
36,980,523 | Write a recursive function called rev, which reverses the order of elements in an array | <p>Im new in this coding platform.</p>
<p>So i have a work to do which is reversing the order of elementsin an array recursively.</p>
<p>So here is what i did:</p>
<pre><code>A= [4,2,7,3,9,1]
def rev(A):
if (len(A)==1):
return A[0]
else:
return A[-1],pri(A[:-1])
print (rev(A))
</code></pre>
<blockquote>
<p>Output:</p>
<p>(1, (4, (2, (7, (3, 9)))))</p>
</blockquote>
<p>so i dont understand what i did wrongly,and if you can do it i want to do the output with ; instead of () things.
I have to do the program in python 3.0 or later versions.</p>
<p>Thank you.</p>
| <python> | 2016-05-02 10:42:29 | LQ_CLOSE |
36,981,109 | how to solve this error Access denied for user ''@'localhost' to database 'kishan' in php | <pre><code><html>
<body>
<?php
$servername="localhost";
$username="STARK-PC";
$password="YES";
$dbname="kishan";
$conn=new mysqli("localhost","STARK-PC","YES","kishan");
</code></pre>
<p></p>
<p>my database not select so what i can do for select my database ?</p>
| <javascript><php> | 2016-05-02 11:15:08 | LQ_CLOSE |
36,982,325 | How to share a list between two files | <p>So I have two .py files that need to share a list, but I can't get it to work as it always creates a second list in place of using the first that was created.</p>
| <python> | 2016-05-02 12:21:06 | LQ_CLOSE |
36,982,598 | result of creating purchline with not existing purch order | While importing purchline through data import export framework with a purchase order that does not exist, will the Standard AX creates the purchase header or through an error stating that purchase id does not exist??? | <axapta><data-import><dynamics-ax-2012-r3> | 2016-05-02 12:34:18 | LQ_EDIT |
36,983,015 | "already defined in .obj error" or "function template has already been define" | I have this header file:
**Utility.h:**
#pragma once
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <Windows.h>
using namespace std;
template<std::size_t> struct int_ {};
void writeToCSV(string fileName, string value);
struct Timer {
public:
Timer();
void start();
double getMilliSec();
private:
LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER t1, t2; // ticks
};
//...
#include "Utility.cpp"
And this implementation file:
**Utility.cpp:**
#include "Utility.h"
void writeToCSV(string fileName, string value) {
//...
}
Timer::Timer() {
// get ticks per second
QueryPerformanceFrequency(&frequency);
}
void Timer::start() {
QueryPerformanceCounter(&t1);
}
double Timer::getMilliSec() {
QueryPerformanceCounter(&t2);
return (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
}
Which returns this error:
error C2084: function 'void writeToCSV(std::string,std::string)' already has a body
The problem is not about guards (as suggested in [this][1] question) since I use `#pragma once`
I`ve read about of [implementing .tpp files][2] for template class implementation, but I find it an horrible solution, since Visual Studio will format nothing from this file.
[1]: http://stackoverflow.com/questions/4988593/function-already-has-a-body
[2]: http://stackoverflow.com/a/495056/4480180 | <c++><templates><header-files> | 2016-05-02 12:56:10 | LQ_EDIT |
36,983,422 | How to convert an image into a matrix in opencv | <p>As it is said in the title, i want to convert an image into a matrix to be able to do some calculation i have used this declaration but it show me an error : no matching function for call to c::Mat::Mat(IplImage*&)</p>
<pre><code>IplImage* image1 = cvLoadImage("C://images//PolarImage300915163358.bmp", 1);
Mat mtx(image1); // convert IplImage* -> Mat
</code></pre>
<p>is there something wrong with this declaration </p>
| <c++><image><opencv><matrix> | 2016-05-02 13:17:14 | LQ_CLOSE |
36,984,342 | converto c# private string to vb.net function | I have this private string in c# make with linq that return a value found in a xml file.
I need to convet this in a vb.net function.
I tried with c# converter but doesn't work
Can You help me please?
this is the code.
private string ImportoXML(string PercorsoXML, string ID)
{
XElement xdoc = XElement.Load(PercorsoXML, LoadOptions.PreserveWhitespace);
string ns = xdoc.Name.Namespace.NamespaceName;
var elements = xdoc.Elements(XName.Get("PmtInf", ns)).Elements(XName.Get("DrctDbtTxInf", ns));
var ElencoValori = from lv2 in elements
select new
{
PmtId = lv2.Element(XName.Get("DrctDbtTx", ns))
.Element(XName.Get("MndtRltdInf", ns))
.Element(XName.Get("MndtId", ns)).Value,
InstdAmt = lv2.Element(XName.Get("InstdAmt", ns)).Value
};
return ElencoValori.Where(c => c.PmtId.EndsWith(ID)).FirstOrDefault().InstdAmt.ToString();
}
| <c#><asp.net><xml><vb.net><linq> | 2016-05-02 14:01:47 | LQ_EDIT |
36,986,056 | Why +[] or +"" equal to 0 in javascript | <p>I know in javascript, <code>Array</code> does not support <code>+</code> operation, so <code>+[]</code> would be convert to <code>+ [].toString()</code>, but I can't figure out why <code>+""</code> is equal to zero.</p>
| <javascript> | 2016-05-02 15:25:16 | LQ_CLOSE |
36,986,391 | Is there an equivalent Matlab dec2bin function in fortran? | I would like to find a similar function as dec2bin(d,n) in Matlab, which produces a binary representation with at least n bits, for fortran. Online I found the following code:
https://fr.scribd.com/doc/207122116/Program-to-Do-Decimal-to-Binary-Conversion-in-Fortran
It converts decimal to binary but we don't decide the number of bits and it asks for the user to decide whether its a positive integer or a positive real number so not very handy.
Thank you in advance for your help, I am new to fortran. | <matlab><binary><fortran><decimal> | 2016-05-02 15:42:43 | LQ_EDIT |
36,986,945 | How do you in C++ of returning a default type for a class | <p>I have a class which contains a variable (apple). How can i configure the class so by default the return type if (const char *), any suggestions please?</p>
<pre><code>class myClass {
public char *apple;
}
int main()
{
myClass c;
printf("%s\r\n",c);
}
</code></pre>
| <c++> | 2016-05-02 16:15:50 | LQ_CLOSE |
36,988,673 | Generate random activation code in PHP | <p>How to generate random activation code based on current datetime and username in PHP.</p>
<p>The return value should be like this, i.e: </p>
<p>201605021955Username</p>
<pre><code>function getActivationCode($username){
$activationCode = "";
....
return activationCode;
}
</code></pre>
| <php><random><activation-codes> | 2016-05-02 17:59:25 | LQ_CLOSE |
36,988,746 | Modify a line by adding and deleting few coloumns using perl script inline | I am writing a perl script where i know which columns are to be removed and and where it needs to be added. e,g I have a array called `deleteColumn` which contains a which number column is to be deleted.Similarly i have array called `AddColumn` which contains information about at which location something needs to be inserted.
Things is i have a line where columns are separated by comma (,). An e.g of this would be
1,2,3,5,9,7,8,12
Now value in array deleteColumn is say [4,7] which means i have to
delete element 9 and 12 .And value in array AddColumn is say [3,5]
these addColoumn indicates an empty addition i.e ','. So after deletion
and addition finally the output should look like 1,2,3,,5,,7,8.
How can i achieve this inline as i would need to read around GB's of
files ( combined size ) and operate on them . Can this be done inline ?
I am reading file line by line. | <regex><perl> | 2016-05-02 18:03:52 | LQ_EDIT |
36,990,010 | How to send hidden info to database | <p>so I have a Dropbox and I have 3 selections. </p>
<pre><code>car
boat
plane
</code></pre>
<p>The value of each one is an image which sends to the database, and reads correctly, by displaying the image of their choice on my page. However, I would like to insert into the database the name of each one too, this will also display under the image. I have a separate column on the table for the hidden info to be input, but am unsure of how to do this that will correspond with the choice they made. Is it possible to do such a thing?</p>
| <php><html><mysql> | 2016-05-02 19:19:27 | LQ_CLOSE |
36,990,789 | C program please explain with answer | #include <stdio.h>
struct test
{
unsigned int x;
long int y;
unsigned int z;
};
int main()
{
struct test t;
unsigned int *ptr1 = &t.x;
unsigned int *ptr2 = &t.z;
printf("%d", ptr2 - ptr1);
return 0;
}
So this is the c code in which i'm stuck at so please anyone tell me the answer with the proper explanation.Thank you. | <c><struct> | 2016-05-02 20:06:51 | LQ_EDIT |
36,992,441 | RegEX help (working but need an exclusion) | I am need of some regex help.
I have a list like so:
/hours_3203
/hours_3204
/hours_3205
/hours_3206
/hours_3207
/hours_3208
/hours_3309
/hours_3310
/hours_3211
I am using this regex to find all entries that start with 32 or 33
/hours_3[23]/
and this is working...
however I was thrown a curve ball when I was told.. I need to EXCLUDE 'hours_3211' from matching in this list..
How can I adjust my regex to match on all 'hours_3[23]' but NOT match on /hours_3211?
Alternately....
when I have a list like this:
/hours_3412
/hours_3413
/hours_3414
/hours_3415
/hours_3516
/hours_3517
/hours_3518
/hours_3519
I have been using a regex of:
/hours_3[45]/
to find all 'hours_34x & /hours_35x
how I can adjust this:
/hours_3[45]/
to find the above but ALSO find/match on /hours_3211??
thanks! | <regex><inclusion> | 2016-05-02 22:12:06 | LQ_EDIT |
36,993,833 | make a batch file that adds iteself to startup and (windows 10) | so I was wondering is there a way to make a batch file that adds itself to startup
without getting the error: access is denied. 0 file moved
here is my bat code:
move "C:\Users\Deathblade\Desktop\Startup bat\funtime.bat" "C:\Documents and Settings\Administrator\Start Menu\Programs\Startup"
move "C:\Users\Deathblade\Desktop\Startup bat\funtime.bat" "C:\Documents and Settings\All Users\Start Menu\Programs\Startup"
pause
That's the end of it so yeah all elp appreciated, even .vbs script or anything
accepted | <windows><batch-file><cmd> | 2016-05-03 00:42:35 | LQ_EDIT |
36,994,918 | Passing objects in routing | <p>I have a component in Angular2 hosting the table of users (userTableComponnent) and another component of userDetails. Upon clicking on a row in users table, I want to route to the userDetails. One implementation is to pass the userId only, so in userDetails, I fetch the details of the user with another http get. However, this is redundant, as I grab all the user info in userTableComponent. So what I really need is to pass the User object from userTableComponent to userDetails. Any idea how to achieve it through routing? </p>
| <angular><angular2-routing> | 2016-05-03 03:05:26 | HQ |
36,994,928 | how to access key values in a json files dictionaries with python | i have a script that pulls json data from an api, and i want it to then after pulling said data, decode and pick which tags to store into a db. right now i just need to get the script to return specific called upon values. this is what the script looks like, before me trying to decode it.
import requests
def call():
payload = {'apikey':'945e8e8499474b7e8d2bc17d87191bce', 'zip' : '47120'}
bas_url = 'http://congress.api.sunlightfoundation.com/legislators/locate'
r = requests.get(bas_url, params = payload)
grab = r.json()
return grab
'results': [{'twitter_id': 'RepToddYoung', 'ocd_id': 'ocd-division/country:us/state:in/cd:9', 'oc_email': 'Rep.Toddyoung@opencongress.org', 'middle_name': 'C.', 'votesmart_id': 120345, 'first_name': 'Todd', 'youtube_id': 'RepToddYoung', 'last_name': 'Young', 'bioguide_id': 'Y000064', 'district': 9, 'nickname': None, 'office': '1007 Longworth House Office Building', 'term_start': '2015-01-06', 'thomas_id': '02019', 'party': 'R', 'in_office': True, 'title': 'Rep', 'govtrack_id': '412428', 'crp_id': 'N00030670', 'term_end': '2017-01-03', 'chamber': 'house', 'state_name': 'Indiana', 'fax': '202-226-6866', 'phone': '202-225-5315', 'gender': 'M', 'fec_ids': ['H0IN09070'], 'state': 'IN', 'website': 'http://toddyoung.house.gov', 'name_suffix': None, 'icpsr_id': 21133, 'facebook_id': '186203844738421', 'contact_form': 'https://toddyoungforms.house.gov/give-me-your-opinion', 'birthday': '1972-08-24'}, {'twitter_id': 'SenDonnelly', 'ocd_id': 'ocd-division/country:us/state:in', 'oc_email': 'Sen.Donnelly@opencongress.org', 'middle_name': None, 'lis_id': 'S356', 'first_name': 'Joe', 'youtube_id': 'sendonnelly', 'last_name': 'Donnelly', 'bioguide_id': 'D000607', 'district': None, 'nickname': None, 'office': '720 Hart Senate Office Building', 'state_rank': 'junior', 'thomas_id': '01850', 'term_start': '2013-01-03', 'party': 'D', 'in_office': True, 'title': 'Sen', 'govtrack_id': '412205', 'crp_id': 'N00026586', 'term_end': '2019-01-03', 'chamber': 'senate', 'state_name': 'Indiana', 'fax': '202-225-6798', 'phone': '202-224-4814', 'gender': 'M', 'senate_class': 1, 'fec_ids': ['H4IN02101', 'S2IN00091'], 'state': 'IN', 'votesmart_id': 34212, 'website': 'http://www.donnelly.senate.gov', 'name_suffix': None, 'icpsr_id': 20717, 'facebook_id': '168059529893610', 'contact_form': 'http://www.donnelly.senate.gov/contact/email-joe', 'birthday': '1955-09-28'}, {'twitter_id': 'SenDanCoats', 'ocd_id': 'ocd-division/country:us/state:in', 'oc_email': 'Sen.Coats@opencongress.org', 'middle_name': 'Ray', 'lis_id': 'S212', 'first_name': 'Daniel', 'youtube_id': 'SenatorCoats', 'last_name': 'Coats', 'bioguide_id': 'C000542', 'district': None, 'nickname': None, 'office': '493 Russell Senate Office Building', 'state_rank': 'senior', 'thomas_id': '00209', 'term_start': '2011-01-05', 'party': 'R', 'in_office': True, 'title': 'Sen', 'govtrack_id': '402675', 'crp_id': 'N00003845', 'term_end': '2017-01-03', 'chamber': 'senate', 'state_name': 'Indiana', 'fax': '202-228-1820', 'phone': '202-224-5623', 'gender': 'M', 'senate_class': 3, 'fec_ids': ['S0IN00053'], 'state': 'IN', 'votesmart_id': 53291, 'website': 'http://www.coats.senate.gov', 'name_suffix': None, 'icpsr_id': 14806, 'facebook_id': '180671148633644', 'contact_form': 'http://www.coats.senate.gov/contact/', 'birthday': '1943-05-16'}]}
thats the json data returned, i want to specifically call upon IE {'twitter_id': 'RepToddYoung', or 'first_name': 'Todd'
instead of my script returning the entire json file that it retrieves
| <python><json><decode> | 2016-05-03 03:06:32 | LQ_EDIT |
36,995,142 | Get the size of the window in Shiny | <p>I Would like to determine the size of the browser window in Shiny to help me layout my plot divs better. Specifically I would like to determine the aspect ratio of the window to see how many divs I should spread across the screen and it still look nice. My initial thought would be that the number of plots would be <code>floor(width/(height-navbar_height))</code>. </p>
<p>I did some looking for this and I am currently unable to locate a possible solution and am currently lead to believe that this feature is simply not present in the clientData structure. Any thoughts?</p>
| <r><shiny> | 2016-05-03 03:34:21 | HQ |
36,995,398 | How to run multiple mix tasks in one command | <p>I have multiple <code>mix</code> tasks to run in succession. With other build tools, it is possible to run the tasks with a single statement, which saves any startup overhead after the first task. How can this be done with Elixir's <code>mix</code> command?</p>
| <elixir> | 2016-05-03 04:03:25 | HQ |
36,997,619 | sklearn stratified sampling based on a column | <p>I have a fairly large CSV file containing amazon review data which I read into a pandas data frame. I want to split the data 80-20(train-test) but while doing so I want to ensure that the split data is proportionally representing the values of one column (Categories), i.e all the different category of reviews are present both in train and test data proportionally.</p>
<p>The data looks like this:</p>
<pre><code>**ReviewerID** **ReviewText** **Categories** **ProductId**
1212 good product Mobile 14444425
1233 will buy again drugs 324532
5432 not recomended dvd 789654123
</code></pre>
<p>Im using the following code to do so:</p>
<pre><code>import pandas as pd
Meta = pd.read_csv('C:\\Users\\xyz\\Desktop\\WM Project\\Joined.csv')
import numpy as np
from sklearn.cross_validation import train_test_split
train, test = train_test_split(Meta.categories, test_size = 0.2, stratify=y)
</code></pre>
<p>it gives the following error</p>
<pre><code>NameError: name 'y' is not defined
</code></pre>
<p>As I'm relatively new to python I cant figure out what I'm doing wrong or whether this code will stratify based on column categories. It seems to work fine when i remove the stratify option as well as the categories column from train-test split.</p>
<p>Any help will be appreciated.</p>
| <python><pandas><scikit-learn><sklearn-pandas> | 2016-05-03 06:56:17 | HQ |
36,997,625 | Angular 2 - communication of typescript functions with external js libraries | <p>Using <a href="https://philogb.github.io/jit/" rel="noreferrer">Javascript Infovis Toolkit</a> as an external library for drawing graph and trees. I need to manipulate the onClick method of nodes in order to asynchronously sending an HTTP GET request to the server and assign the data that comes from server to the properties and variables of an Angular service class. By Using webpack for packing all the compiled typescripts to a single js file, the output file is confusing and unreadable. so calling a function which is in the compiled js file from an external js library, is not the best solution clearly.</p>
<p>I try the following solution inside my Angular service so I can access to the properties of this service without any trouble:</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>document.addEventListener('DOMContentLoaded', function () {
var nodes = document.querySelectorAll(".nodes"); // nodes = []
for (var i = 0; i < nodes.length; i++) { // nodes.length = 0
nodes[i].addEventListener("click", function () {
// asynchronously sending GET request to the server
// and assing receiving data to the properties of this Angular service
});
}
});</code></pre>
</div>
</div>
</p>
<p>However, this solution doesn't work because in Javascript Infovis Toolkit the nodes are drawn after finishing rendering of DOM and also after <code>window.onload</code> event. This library has some lifecycle methods such as onAfterCompute() which is called after drawing tree is completed. How can I trigger a global event to inform the Angular service that the drawing of tree is completed and it can query all of the nodes?</p>
| <javascript><typescript><angular><webpack><angular2-services> | 2016-05-03 06:56:27 | HQ |
36,997,845 | adb.exe start server failed android studio | <ol>
<li>i type adb nodaemon server
error: could not install <em>smartsocket</em> listener: cannot bind to 127.0.0.1:5037: Only one u
sage of each socket address (protocol/network address/port) is normally permitted. (10048)</li>
<li>netstat -ano | findstr 5037
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 5652
TCP 127.0.0.1:5037 127.0.0.1:55726 ESTABLISHED 5652
TCP 127.0.0.1:5037 127.0.0.1:55770 ESTABLISHED 5652
TCP 127.0.0.1:55726 127.0.0.1:5037 ESTABLISHED 1620
TCP 127.0.0.1:55770 127.0.0.1:5037 ESTABLISHED 6488
So i could not find any error .I dont knw wny showing adb.exe start server failed.So what to do please help to resolve </li>
</ol>
| <android><sockets><tcp> | 2016-05-03 07:08:57 | HQ |
36,997,884 | ow to create DOM model in IPHONE SDK | How to create DOM model in IPHONE SDK to update changes in html file.I am making a project so where i have html file to convert PDF format so first i am create html file and then programmatically update dynamic data in html file.
So how i'm use DOM model in objective c IOS to change HTMl file data. | <html><ios><dom> | 2016-05-03 07:10:59 | LQ_EDIT |
36,998,214 | Leverage browser caching for external files | <p>i'm trying to get my google page speed insights rating to be decent, but there are some external files that i would want to be cached aswell, anyone knows what would be the best way to deal with this?</p>
<pre><code>https://s.swiftypecdn.com/cc.js (5 minutes)
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js (60 minutes)
https://pagead2.googlesyndication.com/pagead/osd.js (60 minutes)
https://www.google-analytics.com/plugins/ua/linkid.js (60 minutes)
https://hey.hellobar.com/…d5837892514411fd16abbb3f71f0d400607f8f0b (2 hours)
https://www.google-analytics.com/analytics.js (2 hours)
</code></pre>
| <browser-cache><google-pagespeed> | 2016-05-03 07:30:33 | HQ |
36,998,260 | Prepend element to numpy array | <p>I have the following numpy array</p>
<pre><code>import numpy as np
X = np.array([[5.], [4.], [3.], [2.], [1.]])
</code></pre>
<p>I want to insert <code>[6.]</code> at the beginning.
I've tried:</p>
<pre><code>X = X.insert(X, 0)
</code></pre>
<p>how do I insert into X?</p>
| <python><numpy><insert> | 2016-05-03 07:33:14 | HQ |
36,998,632 | Survey in Mysql | <p>I really need some help with this survey. I want to insert it into phpmyadmin. I'm studying and i need this for a project. </p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css" type="text/css"/>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div>
<form action="action.php" method="get">
<h1>KÆLEDYR</h1>
<h3>Oplysninger om dig</h3>
Navn:<br>
<input type="text" name="name" value="Navn"><br><br>
Email:<br>
<input type="email" name="email" value="navn@gmail.com"><br><br>
Køn:<br>
<input type="radio" name="gender" value="male" checked> Mand<br>
<input type="radio" name="gender" value="female"> Kvinde<br>
<input type="radio" name="gender" value="other"> Ved ikke<br><br>
Alder:
<input type="number" name="age" value="ex.20"><br><br>
<h3>Har du kæledyr?</h3>
Har du kæledyr?:<br>
<input type="radio" name="yes" value="yes" checked>Ja<br>
<input type="radio" name="no" value="no">Nej<br><br>
Hvis ja, hvor mange har du?:
<input type="number" name="pet-number" value="ex.20"><br><br>
Hvilke kældedyr har du?:
<br>
<input type="checkbox" name="animal1" value="Hund">Hund
<br>
<input type="checkbox" name="animal2" value="Kat">Kat
<br>
<input type="checkbox" name="animal3" value="Reptil">Reptil
<br>
<input type="checkbox" name="animal4" value="Fugl">Fugl
<br>
<input type="checkbox" name="animal5" value="Fisk">Fisk
<br>
<input type="checkbox" name="animal6" value="Hest">Hest
<br>
<input type="checkbox" name="animal6" value="andet">Andet
<br><br>
Kældedyrs quiz:
<br>
En dalmatiner er stribet?:
<br>
<input type="radio" name="true" value="true" checked>Sandt<br>
<input type="radio" name="false" value="false">Falsk<br><br>
<br>
En hest har 5 ben:
<br>
<input type="radio" name="true" value="true" checked>Sandt<br>
<input type="radio" name="false" value="false">Falsk<br><br>
<input type="submit">
</form>
</div>
</body>
</html>
</code></pre>
<p>My action.php looks like this.</p>
<pre><code><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
/*
File: action.php
Purpose: INSERT INTO ...
*/
$mysqli = new mysqli("localhost", "root", "","survey"); // creates the object
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; // if error messages
}
echo "You're connected to the database via: "
. $mysqli->host_info
. "\n";
if($_GET) {
/*
$fn = $_GET['firstName'];
$ln = $_GET['lastName'];
// format the sql
$sql = "INSERT INTO `sakila`.`actor` (`actor_id`, `first_name`, `last_name`, `last_update`) VALUES (NULL, '"
. $fn
. "', '"
. $ln
. "', CURRENT_TIMESTAMP);";
*/
// INSERT
$sql = "INSERT INTO `person` (`name`, '".$_GET['name']."')";
echo $_GET["name"];
$insert = $mysqli->query($sql);
echo "<p>et svar her ....</p>";
echo $sql;
}
else {
echo "<p>Error: Use the form please. No GET got.</p>";
}
?>
</body>
</html>
</code></pre>
<p>How do i proceed and get my survey into the database?</p>
| <php><mysql><survey> | 2016-05-03 07:55:57 | LQ_CLOSE |
36,999,017 | Symfony 3 createForm with construct parameters | <p>Since Symfony 2.8, you can only pass the FQCN into the controller createForm method. So, my question is, how do I pass construct parameters into the form class construct when I create the form in the controller?</p>
<p>< Symfony 2.8 I could do (MyController.php):</p>
<pre><code>$this->createForm(new MyForm($arg1, $arg2));
</code></pre>
<p>Symfony 2.8+ I can only do (MyController.php):</p>
<pre><code>$this->createForm(MyForm::class);
</code></pre>
<p>So how can I pass in my construct arguments? These arguments are provided in the controller actions so I can't use the "Forms as services" method...</p>
| <php><symfony> | 2016-05-03 08:17:39 | HQ |
36,999,406 | Allowed memory size of 134217728 bytes exhausted (tried to allocate 42 bytes) | <p>I am retrieving record from mysql table which return more than 0.2m number of rows per query, which obviously take lot of memory. in my case i have 8 GBs installed RAM on my system with SSD 256 GBs.
When i execute my page it returns the following error:</p>
<pre><code>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 42 bytes) in D:\xampp\htdocs\classes\CRUD.php on line 84
</code></pre>
<p>I think i should need to use threading instead of php loops over table rows?
Maybe i am wrong. Any suggestion/help will be appreciated. </p>
| <php><mysql><loops> | 2016-05-03 08:38:37 | HQ |
36,999,461 | How to install only "devDependencies" using npm | <p>I am trying to install ONLY the "devDependencies" listed in my package.json file. But none of the following commands work as I expect. All of the following commands install the production dependencies also which I do not want.</p>
<pre><code>npm install --dev
npm install --only=dev
npm install --only-dev
</code></pre>
<p>I cannot think of any more ways of telling the npm to install the devDependencies alone. :( </p>
| <node.js><npm><npm-install><package.json> | 2016-05-03 08:41:43 | HQ |
36,999,489 | SUM AND GROUPING JSON OUTPOUT | I have a json output on php like:
[{"Title":"Message","count":"180","Number":"200"},{"Title":"Message","count":"200","Number":"400"}]
how can obtain result like:
[{"Title":"Message","count":"380","Number":"600"}]
thank you very much | <php><json> | 2016-05-03 08:43:00 | LQ_EDIT |
36,999,611 | using list.files() in R to find files that start with a specific string | <p>I am using <code>list.files()</code> in r to read in files. However, the <code>pattern=</code> input will scan all files that contain that special string I am scanning for...</p>
<p>Ex. </p>
<p><code>MASTERLIST =list.files("/Volumes/3TB/",pattern="CL")</code></p>
<p>will call in the following files: </p>
<pre><code>[1] "CLF16" "CLF17" "CLF18" "CLF19" "CLG16" "CLG17" "CLG18" "CLH16" "CLH17" "CLJ16" "CLJ17" "CLK16" "CLK17" "CLK18" "CLM16" "CLM17"
[17] "CLM18" "CLM19" "CLN16" "CLN17" "CLQ16" "CLQ17" "CLU15" "CLU16" "CLU17" "CLV15" "CLV16" "CLV17" "CLX15" "CLX16" "CLX17" "CLZ15"
[33] "CLZ16" "CLZ17" "CLZ18" "CLZ19" "CLZ20" "MCLH16" "MCLM16" "MCLU16" "MCLZ16"
</code></pre>
<p>But I only want those files that begin with <code>CL</code> and not every file that contains <code>CL</code> like files 38 through 41 </p>
<p>How do I get it to call only those files that begin that pattern?</p>
| <r><list><file> | 2016-05-03 08:49:25 | HQ |
36,999,770 | Code Igniter authentication library | <p>I just learn new Code Igniter, look for login with register and authentication so I could get user group role like admin and member and other. </p>
<p>I would like to know what is the best Code Igniter authentication library which fits my requirements. </p>
<p>Anyone could help me with this?</p>
<p>Thanks</p>
| <php><html><codeigniter> | 2016-05-03 08:56:37 | LQ_CLOSE |
36,999,785 | SQL : this is query is taking too much of time |
SQL : this is query is taking too much of time for 12 records, event indexes also created.
SELECT p.AnchorDate
,'Active' StatusDefinition
,count(1) PatientCount
,6 AS SNO
FROM (
SELECT DISTINCT pp.PatientID
,ad.AnchorDate
FROM PatientProgram pp WITH (NOLOCK)
INNER JOIN #tblMonth ad ON ad.AnchorDate = CASE
WHEN ad.AnchorDate BETWEEN DATEADD(dd, - (DAY(pp.EnrollmentStartDate) - 1), pp.EnrollmentStartDate)
AND EOMONTH (ISNULL(pp.EnrollmentEndDate, '9999-12-31'))
THEN ad.AnchorDate
ELSE NULL
END
WHERE NOT EXISTS (
SELECT 1
FROM #ManagedPopulation m
WHERE m.tKeyId = pp.ProgramID
)
AND pp.ProgramID != 4331
) p
GROUP BY p.AnchorDate; | <sql><sql-server> | 2016-05-03 08:57:23 | LQ_EDIT |
36,999,798 | Accessing 32-bit DLLs from 64-bit code exe sample | <p>I want access 32 bit dll from 64 bit code .. can you please provide me sample or idea.</p>
| <mfc><com> | 2016-05-03 08:57:47 | LQ_CLOSE |
37,000,213 | how to check an ip address is local | <p>Here is code:</p>
<pre><code>def isSrsInternal(srcip):
here i want to write code to check that srcip is local source to thet network or not
if srcip is local than it will return true
else return false
</code></pre>
<p>1 Can anyone give me the idea to writing that function</p>
| <python><python-2.7> | 2016-05-03 09:18:09 | LQ_CLOSE |
37,000,385 | Multiple svg with same IDs | <p>Can i put multiple svgs in a html page and use the same IDs in all of them?</p>
<pre><code><div>
<svg height="0" width="0">
<clipPath id="svgPath"> ........
</svg>
<svg height="0" width="0">
<clipPath id="svgPath"> ........
</svg>
<svg height="0" width="0">
<clipPath id="svgPath"> ........
</svg>
</div>
</code></pre>
| <javascript><html><css><svg> | 2016-05-03 09:27:09 | HQ |
37,000,606 | How to do to display "Times New Roman font" in pdf using iTextSharp? | I want to change the font of the content to TIMES NEW roman
iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(textSharpDocument);
#pragma warning restore 612, 618
String[] content = letterContent.Split(new string[] { AppUtil.GetAppSettings(AppConfigKey.ReceiptLetterPDFSeparator) }, StringSplitOptions.None);
//Add Content to File
if (content.Length > AppConstants.DEFAULT_PARAMETER_ZERO)
{
string imageFolderPath = AppUtil.GetAppSettings(AppConfigKey.UploadedImageFolderPath);
for (int counter = 0; counter < content.Length - 1; counter++)
{
textSharpDocument.Add(new Paragraph());
if (!String.IsNullOrEmpty(imageUrlList[counter]))
{
string imageURL = imageFolderPath + imageUrlList[counter];
textSharpDocument.Add(new Paragraph());
string imagePath = AppUtil.GetAppSettings(AppConfigKey.ParticipantCommunicationFilePhysicalPath) + imageUrlList[counter];
imagePath = imagePath.Replace(@"\", "/");
if (File.Exists(imagePath))
{
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(imageURL);
imageLocationIDs[counter] = imageLocationIDs[counter] != null ? AppUtil.ConvertToInt(imageLocationIDs[counter], AppConstants.DEFAULT_PARAMETER_ONE) : AppUtil.ConvertEnumToInt(AppImageLocation.Left);
if (imageLocationIDs[counter] == AppUtil.ConvertEnumToInt(AppImageLocation.Left))
png.Alignment = iTextSharp.text.Image.ALIGN_LEFT;
if (imageLocationIDs[counter] == AppUtil.ConvertEnumToInt(AppImageLocation.Right))
png.Alignment = iTextSharp.text.Image.ALIGN_RIGHT;
if (imageLocationIDs[counter] == AppUtil.ConvertEnumToInt(AppImageLocation.Center))
png.Alignment = iTextSharp.text.Image.ALIGN_CENTER;
textSharpDocument.Add(png);
}
}
hw.Parse(new StringReader(content[counter]));
hw.EndElement("</html>");
hw.Parse(new StringReader(AppUtil.GetAppSettings(AppConfigKey.ReceiptLetterPDFSeparator)));
}
} | <c#><itextsharp> | 2016-05-03 09:37:08 | LQ_EDIT |
37,000,701 | adb touchscreen swipe fail in a call | <p>I'm trying to simulate a auto video call with adb using touches and swipes.
The scenario: </p>
<p>Device1 audio calls Device2, Device2 answers, Device1 asks for video call(bidirectional), Device2 tries to answer and fails.
The wired thing is that sometimes it works but most of the it fails on that point when the device2 trying to answer via adb swipe.</p>
<p>here is the code:</p>
<pre><code>@Test(timeout = 60000000)
/**
*
*/
@TestProperties(name = "Video call / Normal video call")
public void VT111_0011() throws InterruptedException, IOException, AWTException {
initTestVariable("Normal_Video_Call_Test_VT111_0011");
sleep(idleBeforeTest);
System.out.println("Starting normal video test");
Android.adbCommand(secondDevice.getDevice1(), "adb -s " + secondDevice.getDeviceID() + " shell input touchscreen swipe 355 858 590 858");
for(int i=0; i<Iteration; i++) {
moveMouse();
Jsystem.broadCastMessage("\nIteration " + i, globalVar.nameForLogFile);
cleanLogs();
firstDevice.call(secondDevice);
Thread.sleep(2000);
if(secondDevice.isRinging())
secondDevice.answerCall(1000);
else{
ringingFail();
}
// Start video by gui
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 650 380");
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 420 470");
Thread.sleep(1000);
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 197 780"); // 197 920 Video bidirectional
Thread.sleep(5500);
// Device2 answers video
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 355 858"); // 197 920 Video bidirectional
Android.adbCommand(secondDevice.getDevice1(), "adb -s " + secondDevice.getDeviceID() + " shell input touchscreen swipe 355 858 590 858");
Thread.sleep(200);
Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 60 372");
Android.adbCommand(secondDevice.getDevice1(),"adb -s " + secondDevice.getDeviceID() + " shell input tap 60 372");
/* Thread.sleep(5000);
if((!firstDevice.isInCall()) || (!secondDevice.isInCall())){
inCallFail();
continue;
} */
int failsCounter = 0;
VerifyVideo verifyVideo = new VerifyVideo();
for(int j = 8; j<10; j++){
if(verifyVideo.verrfiyVideo(firstDevice, secondDevice) == false)
failsCounter++;
}
if(failsCounter>2) {
Jsystem.broadCastMessage("****** TEST FAILED, VIDEO DOSENT WORK GOOD ENOUGH ****** " , globalVar.nameForLogFile);
System.out.println("Number of fails: " + failsCounter);
comparePhototsFail();
}
firstDevice.endCall();
secondDevice.endCall();
sleep(TimeBetweenIteration);
}
}
</code></pre>
<p>Any ideas?
Thanks.</p>
| <java><android><automation><adb> | 2016-05-03 09:41:16 | HQ |
37,001,694 | How to handle backslash character in PowerShell -replace string operations? | <p>I am using -replace to change a path from source to destination. However I am not sure how to handle the \ character. For example:</p>
<pre><code>$source = "\\somedir"
$dest = "\\anotherdir"
$test = "\\somedir\somefile"
$destfile = $test -replace $source, $dest
</code></pre>
<p>After this operation, $destfile is set to </p>
<pre><code>"\\\anotherdir\somefile"
</code></pre>
<p>What is the correct way to do this to avoid the triple backslash in the result?</p>
| <powershell><replace><backslash> | 2016-05-03 10:29:21 | HQ |
37,002,005 | Vacation calculator in Excel | I post my question in the following screenshot. Any reply and alternative suggestion is welcome.
With so thanks,
Dio
[The Question Screenshot][1]
[1]: http://i.stack.imgur.com/25oEG.jpg | <excel><excel-formula><vba> | 2016-05-03 10:44:35 | LQ_EDIT |
37,002,229 | how to remove whitespace between 2 paragraphs in IOS using swift? | [enter image description here][1]
[1]: http://i.stack.imgur.com/mRkZz.png
I am getting data from Html to the text.
Now please tell me how to avoid the space between two paragraphs ? | <html><ios><iphone><json><swift> | 2016-05-03 10:57:01 | LQ_EDIT |
37,002,233 | rotate animation in jquery or css | <p>I want to create a rotating wheel luck game. I know that jquery has some features like fadein, fadeout etc. I was just wondering if there is also a rotating effect in jquery? if not then how can i do this effect?
thanks</p>
| <javascript><jquery><css><animation> | 2016-05-03 10:57:14 | LQ_CLOSE |
37,003,316 | How to make the emitter listener in android work when the internet goes off and comes back on? | <p>I have implemented a provision for chat in my app.The chat works using socket.io .I am trying to resolve the issue of the emitter listeners working properly when internet goes off and comes back on.Currently , the socket gets re-connected on the internet but listeners don't work at all once the internet is connected back.Please help guys!</p>
| <java><android><c><node.js> | 2016-05-03 11:48:12 | LQ_CLOSE |
37,003,379 | "image/png;base64?" what does it do? | <p>I have a question about this piece of code:</p>
<p><code>redirectUrl</code>: <code>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="</code></p>
<p>When I include this piece of code, all pictures on a website dont get loaded. But what does this encoder do? </p>
<p>Does it block pictures, hides them or just isn't loading them?</p>
| <javascript><google-chrome-extension> | 2016-05-03 11:51:25 | LQ_CLOSE |
37,003,469 | Laravel migrations change default value of column | <p>I have a table with a default value already assigned. For an example we can look at the following:</p>
<pre><code>Schema::create('users', function (Blueprint $table) {
$table->increments('id')->unsigned();
$table->integer('active')->default(1);
});
</code></pre>
<p>I now want to change my default value on the active field. I am expecting to do something like this:</p>
<pre><code>if (Schema::hasTable('users')) {
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'active')) {
$table->integer('active')->default(0);
}
});
}
</code></pre>
<p>But of course it tells me the column is already there. How can I simply update the default value of column x without dropping the column?</p>
| <php><laravel><migration><artisan> | 2016-05-03 11:55:32 | HQ |
37,003,481 | How to resolve "Warning: debug info can be unavailable. Please close other application using ADB: Restart ADB integration and try again" | <p>I am having a slight issue when trying to debug and android app via usb to external device. I keep getting the error "Warning: debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
Restart ADB integration and try again
Waiting for process:"</p>
<p>I have tried stopping adb.exe in task manager , closing android studio and restarting , taking out the cable and putting it back and going to tools => android uncheck adb intergration then recheck it . All to no avail </p>
| <android><debugging><android-studio><runtime> | 2016-05-03 11:56:09 | HQ |
37,004,249 | Please help me on this C++ program on array of objects? | #include<iostream.h>
#include<conio.h>
class XIIB
{
char name[30];
int age;
int roll;
float marks;
public:
void getdata(char a[30],int i,int j,float k)
{
name[30]=a[30];
age=i;
roll=j;
marks=k;
}
void putdata(void)
{
cout<<"Name:"<<name<<endl;
cout<<"Age:"<<age<<endl;
cout<<"Roll:"<<roll<<endl;
cout<<"Marks:"<<marks<<endl;
}
};
const int size=5;
XIIB student[size];
void main()
{
char x[30];
int ag;
int rno;
float mrks;
for(int p=0;p<size;p++)
{
cout<<"Enter Name,Age,Roll and Marks of Student"<<p+1<<endl;
cin>>x>>ag>>rno>>mrks;
student[p].getdata(x,ag,rno,mrks);
}
for(p=0;p<size;p++)
{
cout<<"Student"<<p+1<<endl;
student[p].putdata();
}
getch();
}
This program compiles without any error.Also takes the input for Name,Roll No,Age and Marks as expected but it is unable to display the name of the Students.I seem to have made some error in the getdata or putdata functions.Please help me in producing the output as expected.Thanks | <c++><arrays><class><object> | 2016-05-03 12:32:09 | LQ_EDIT |
37,004,345 | How to exclude classes from the coverage calculation in EclEmma without actually excluding them from the coverage itself | <p>I am using EclEmma to test the coverage of my scenario tests and use case tests on my project.
I have a Base package which contains the most general classes and the use case tests. The coverage looks like this:</p>
<p><a href="https://i.stack.imgur.com/U1mJI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U1mJI.png" alt="Code coverage in our project"></a></p>
<p>What I want is to exclude the use case tests (e.g. BugReportTest) from the coverage calculation. But I do want the tests inside it to be considered. I know how to exclude the entire class from the coverage but if I do that, my coverage % drops because the actual tests that check which lines of my code are tested are forgotten. These use case tests do need to stay in the Base package because of privacy reasons.</p>
| <java><eclipse><unit-testing><code-coverage><eclemma> | 2016-05-03 12:35:59 | HQ |
37,004,559 | How to Edit a File Text in Perl | <p>I have a file now in that i want to update the value of variable.How can we do this .
<strong>File Content:</strong></p>
<pre><code><Config>
NUM1 = 8
AMV1 = 8
AMV2 = 8
DEF2 = 8
DGF = 8
</Config>
</code></pre>
<p>Now in this i want to change the value of <code>NUM1</code> how can we do this in Perl.</p>
| <perl> | 2016-05-03 12:45:36 | LQ_CLOSE |
37,004,737 | What's the character code for exclamation mark in circle? | <p>What's the Unicode or Segoe UI Symbols (or other font) code for exclamation mark in circle?</p>
<p><a href="https://i.stack.imgur.com/cquC6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cquC6.png" alt="enter image description here"></a></p>
| <unicode><character><symbols><non-ascii-characters> | 2016-05-03 12:52:48 | HQ |
37,004,771 | how to store last character of the world from the string into an array without using any predefine php function | I have a string like -
$str = "Hello how are you";
and i want to store last character in an array then the result look like below-
array(0=>o,1=>w,2=>e,3=>u)
how It can be achieve without the using of php redefine function | <php><arrays><string> | 2016-05-03 12:54:24 | LQ_EDIT |
37,005,566 | I'm supposed to be reading data from a file and dumping part of it into another text file. But I'm having an error | <p>//the code below is constantly giving me errors since its not reading the file
public static void main(String[]args) throws IOException{</p>
<pre><code> String file="marc21.txt";
String a;
BufferedReader br=new BufferedReader(new FileReader(file));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("marc22.txt")));
while(br.readLine()!=null){
//obtaining first five characters of file
file.substring(0, 4);
//saving substring to value
a=file.substring(0, 4);
//converting a to integer
int x=Integer.parseInt(a);
System.out.println("x is "+x);
//taking record to marc21 to another file marc22
bw.write(file.substring(0, x));
bw.write("\n");
bw.close();
}
</code></pre>
| <java> | 2016-05-03 13:28:53 | LQ_CLOSE |
37,006,087 | Can we turn off "chatty" in logcat? | <p>So I'm trying to find an elusive bug in a large codebase. As such, I've put a lot of logging into my app. I'm lucky enough to have multiple testers working on this. However, I've found that a lot of my logcat logs are missing. They're hidden as 'chatty'. For example</p>
<p><code>1799 12017 I logd: uid=10007 chatty comm=Binder_B, expire 4 lines</code></p>
<p>I've found some mention of using the adb command</p>
<p><code>adb logcat -p</code></p>
<p>but I can't find any documentation for the -p. I've also found that with a lot of devices (possibly all devices on Marshmallow) this is not supported.</p>
<p>Other than having the device plugged into Android Studio / Eclipse, is there a way to stop 'chatty' from hiding my logs?</p>
| <android><logcat><android-logcat> | 2016-05-03 13:48:53 | HQ |
37,006,365 | Run multiple android app instances like parallel space | <p>I want to know how parallel space
<a href="https://play.google.com/store/apps/details?id=com.lbe.parallel.intl&hl=en">https://play.google.com/store/apps/details?id=com.lbe.parallel.intl&hl=en</a> is working. It is an app for logging in with another facebook, whatsapp etc account. You can find the detailed description in the play store link.</p>
<p>I have looked at the folders that parallel space is creating using ES Explorer. They have created the following folder parallel_intl/0/</p>
<p>In this folder they have DCIM, Pictures etc folder. I logged in another whatsapp account using parallel space and they created the whatsapp folder at the following location parallel_intl/0/Whatsapp </p>
<p>Is it possible to achieve the same thing with Android For Work Container???</p>
<p>Are they some how creating a separate space where Whatsapp etc will run???</p>
<p>Kindly provide some guideline explaining how this can be achieved.</p>
<p>Thanks.</p>
| <android><virtualization><whatsapp><multiple-accounts><android-for-work> | 2016-05-03 14:00:32 | HQ |
37,006,954 | Art: Verification of X took Y ms | <p>I've got a warning in my logcat:</p>
<pre><code>W/art: Verification of void com.myapp.LoginFragment$override.lambda$logIn$5(com.myapp.LoginFragment, java.lang.Throwable) took 217.578ms
</code></pre>
<p>Here's the code:</p>
<pre><code>subscription = viewModel.logIn()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::showStudioSelection,
error -> {
ErrorResponse errorResponse = ErrorResponseFactory.create(error);
if (errorResponse.code() == ApiResult.BAD_REQUEST) {
Snackbar.make(getView(), R.string.login_bad_credentials, Snackbar.LENGTH_LONG)
.setAction(android.R.string.ok, v -> {})
.show();
} else {
Snackbar.make(getView(), "Unknown error " + errorResponse.code(), Snackbar.LENGTH_LONG)
.setAction(android.R.string.ok, v -> {})
.show();
}
viewModel.updateLoginButtonState();
}
);
</code></pre>
<p>220ms is quite a lot (and I feel like I'm noticing a lag on startup of that Fragment). </p>
<p>I'm using RxJava and retrolambda, but this is not the only spot where this message pops up so I don't think it's directly related.</p>
<p><strong>How can I influence the verification time?</strong> Is it even worth it?</p>
<p>It seems like it has something to do with cyclomatic complexity, since I could get rid of the waring by removing the <code>Snackbar.make</code> calls in the <code>if</code> with some more <em>dry</em> code:</p>
<pre><code>String errorMessage;
if (errorResponse.code() == ApiResult.BAD_REQUEST) {
errorMessage = getString(R.string.login_bad_credentials);
} else {
errorMessage = "Unknown error " + errorResponse.code();
}
</code></pre>
| <android><performance><android-runtime> | 2016-05-03 14:27:50 | HQ |
37,007,109 | Django 1.9 - JSONField in Models | <p>I'm trying to set up a models file in Django 1.9 using the new JSONField. I have found examples using postgres but none with MySql. In the examples with postgres they do a </p>
<pre><code>from django.contrib.postgres.fields import JSONField
</code></pre>
<p>How do I go about importing it for MySql?
Thanks</p>
| <django> | 2016-05-03 14:35:25 | HQ |
37,007,322 | Open, remove text, and save a text file C# | I want to edit some text files automatically but I don't know what to used to do it.
I want to open a file, check all lines, if one line begins with a 'C', I remove first 39-characters, etc .. then save all the file with an other name.
I already have a portion of code :
var car = ligne[0];
if(car != 'C') { continue; }
ligne.Remove(0, 39);
I use StreamReader to read, but what is the simple way to read and save in another file ? | <c#><text-files><read-write><system.io.file> | 2016-05-03 14:45:21 | LQ_EDIT |
37,007,994 | Android MVP, where check internet connection | <p>I'm implementing MVP pattern on an Andorid App and I have a doubt about where is the <strong>best place</strong> for <strong>checking the internet connection.</strong>
I usually check if there is internet connection before doing any network call. </p>
<p>So, where should I check it in the <strong>Activity</strong> or in the <strong>Presenter</strong>?
I think the Presenter would be a nice place, so it decides what to do, however I'm not 100% sure If I should place it in the activity and avoid doing a call to the Presenter. </p>
| <android><mvp> | 2016-05-03 15:15:26 | HQ |
37,008,089 | HtmlDocument does not contain a constructore that takes 1 arguments | I cant seem to understand why this wont work. I keep getting an error that says HtmlDocument does not contain a constructor that takes 1 arguments any help would be greatly appreciated
//Create the Browser Window
BrowserWindow broWin = new BrowserWindow();
broWin.SearchProperties[UITestControl.PropertyNames.Name] = "Execute Automation";
HtmlDocument doc = new HtmlDocument(broWin); | <c#><visual-studio> | 2016-05-03 15:19:56 | LQ_EDIT |
37,008,713 | Rails 5.1 Routes: dynamic :action parameters | <p>Rails 5.0.0.beta4 introduced a deprecation warning on routes containing dynamic :action and :controller segments: </p>
<pre><code>DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and will be removed in Rails 5.1.
</code></pre>
<p><a href="https://github.com/rails/rails/pull/23980">The commit message from this PR</a> states: </p>
<blockquote>
<p>Allowing :controller and :action values to be specified via the path
in config/routes.rb has been an underlying cause of a number of issues
in Rails that have resulted in security releases. In light of this
it's better that controllers and actions are explicitly whitelisted
rather than trying to blacklist or sanitize 'bad' values.</p>
</blockquote>
<p>How would you go about "whitelisting" a set of action parameters? I have the following in my routes file, which are raising the deprecation warning: </p>
<pre><code>namespace :integrations do
get 'stripe(/:action)', controller: 'stripe', as: "stripe"
post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
end
</code></pre>
| <ruby-on-rails-5> | 2016-05-03 15:48:36 | HQ |
37,008,848 | basic pyodbc bulk insert | <p>In a python script, I need to run a query on one datasource and insert each row from that query into a table on a different datasource. I'd normally do this with a single insert/select statement with a tsql linked server join but I don't have a linked server connection to this particular datasource.</p>
<p>I'm having trouble finding a simple pyodbc example of this. Here's how I'd do it but I'm guessing executing an insert statement inside a loop is pretty slow.</p>
<pre><code>result = ds1Cursor.execute(selectSql)
for row in result:
insertSql = "insert into TableName (Col1, Col2, Col3) values (?, ?, ?)"
ds2Cursor.execute(insertSql, row[0], row[1], row[2])
ds2Cursor.commit()
</code></pre>
<p>Is there a better bulk way to insert records with pyodbc? Or is this a relatively efficient way to do this anyways. I'm using SqlServer 2012, and the latest pyodbc and python versions.</p>
| <python><sql-server><pyodbc> | 2016-05-03 15:55:13 | HQ |
37,009,441 | "error: expected primary-expression before '<' token." What am I missing? | <p>I've done a very similar code in C without such errors.</p>
<p>I'm assuming that I got all the header files I need? </p>
<pre><code>#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(){
double percentage;
cout << "enter percentage" << endl;
cin >> percentage;
string letter;
if (percentage >= 98)
letter = "A+";
</code></pre>
<p>This is where the error starts to appear on every condition line. I deleted the rest of the grades in this sample to avoid redundancy. </p>
<pre><code>else if (percentage >= 92 && < 98) //"error: expected primary-expression before '<' token."
{
letter = "A";
}
else if (percentage >= 90 && < 92) //"error: expected primary-expression before '<' token."
{
letter = "A-";
}
else if (percentage >= 88 && < 90) //"error: expected primary-expression before '<' token."
{
letter = "B+";
}
</code></pre>
<p>This is where it stops</p>
<pre><code>else {letter = "F";}
cout << "Grade: " << letter << endl;
return 0;
}
</code></pre>
| <c++> | 2016-05-03 16:26:53 | LQ_CLOSE |
37,009,498 | Are monitors deadlock free? | <p>If you are using monitors in your concurrent system design, is this sufficient to prevent deadlock? I know that in Java there are many ways to cause deadlock, but few of these examples are actually to do with monitors (most use mutexes).</p>
| <java><concurrency> | 2016-05-03 16:29:49 | LQ_CLOSE |
37,009,844 | Combine certain tuples in a list | I have this list with multiple tuples:
['ASA', 'TD', 'UDP', '255.255.255.255', '/80', 'to', '255.255.255', '/88']
How can I get this as the final result:
['ASA', 'TD', 'UDP', '255.255.255.255/80', 'to', '255.255.255/88']
| <python> | 2016-05-03 16:47:45 | LQ_EDIT |
37,010,507 | How to bubble up angular2 custom event | <p>Parent template:</p>
<pre><code><ul>
<tree-item [model]="tree" (addChild)="addChild($event)"></tree-item>
</ul>
</code></pre>
<p>Tree item template:</p>
<pre><code><li>
<div>{{model.name}}
<span [hidden]="!isFolder" (click)="addChild.emit(model)">Add Child</span>
</div>
<ul *ngFor="let m of model.children">
<tree-item [model]="m"></tree-item>
</ul>
</li>
</code></pre>
<p>For above example, parent receives addChild event only from the root tree-item (immediate child). Is it possible to bubble up addChild event from any tree-item?
I am using angular 2.0.0-rc.0.</p>
| <typescript><angular> | 2016-05-03 17:22:13 | HQ |
37,010,535 | How does git flow handle hotfix to older release or point release of older release | <p>How does git flow handle a hotfix after master has move far beyond that release?</p>
<p><strong>Scenario</strong></p>
<ol>
<li>Work for 1.0 performed on develop, stabilized on releases/v1.0 release branch and pushed to master in fast-forward merge with tag v1.0 pointing to tip of master and tip of stabilization branch</li>
<li>Releases 1.1 - 3.2 take place in much the same fashion.</li>
<li><p>We need to hotfix a bug in 1.0</p>
<ul>
<li>branch from v1.0 tag</li>
<li>perform fix</li>
<li>merge to where? </li>
</ul></li>
</ol>
<p>Master is far in the future and any merge wouldn't be a fast forward and for fun, let's say would conflict.</p>
<p>Would I merge to release stabilization branch and make new tag? Is that what subsequent hotfixes would use as their starting point?</p>
<p><a href="https://i.stack.imgur.com/kF7Uf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kF7Uf.png" alt="Git Flow Example"></a></p>
| <git><git-flow> | 2016-05-03 17:23:30 | HQ |
37,011,291 | python wand.image is not recognized | <p>I installed Imagemagic (both 32 and 64 bits versions were tried) and then used pip to install wand, I also set the Magick_Home env. variable to imagemagic address but when I run </p>
<blockquote>
<p><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Anaconda2\lib\site-packages\wand\image.py", line 20, in <module>
from .api import MagickPixelPacket, libc, libmagick, library
File "c:\Anaconda2\lib\site-packages\wand\api.py", line 205, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows</code></p>
</blockquote>
| <python-2.7><imagemagick><wand><magickwand> | 2016-05-03 18:04:51 | HQ |
37,011,409 | How do I sum across certain columns? | <p>I have a data frame called <code>df</code> that looks like this:</p>
<pre><code>name score1 score2 score3
Joe 1 NA 3
Jane NA 2 3
</code></pre>
<p>How do I make a column named <code>sum</code> that sums non-empty cells in <code>score1</code>, <code>score2</code> and <code>score3</code>?</p>
| <r> | 2016-05-03 18:11:12 | LQ_CLOSE |
37,011,894 | Circe instances for encoding/decoding sealed trait instances of arity 0? | <p>I'm using sealed traits as enums for exhaustive pattern matching. In cases where I have case objects instead of case classes extending my trait, I'd like to encode and decode (via <a href="http://circe.io">Circe</a>) as just a plain string. </p>
<p>For example:</p>
<pre><code>sealed trait State
case object On extends State
case object Off extends State
val a: State = State.Off
a.asJson.noSpaces // trying for "Off"
decode[State]("On") // should be State.On
</code></pre>
<p>I understand that this will be configurable in 0.5.0, but can anyone help me write something to tide me over until that's released?</p>
| <scala><circe> | 2016-05-03 18:38:11 | HQ |
37,012,053 | jQuery Select Failed To Change Input Value | <p>I have this jquery inside PHP code :</p>
<pre><code>echo '<select id="state" name="state" onchange="document.getElementById(\'state_text_content\').value=this.options[this.selectedIndex].text>
'.$list_state.'
</select>
<input type="hidden" name="state_text" id="state_text_content" value="" />';
</code></pre>
<p>why onchange function doesn't update <code>#state_text_content</code> value? thank you.</p>
| <php><jquery> | 2016-05-03 18:46:10 | LQ_CLOSE |
37,012,082 | CursorIndexOutOfBoundsException SQLITE ERROR | Please provide me a possible solution for this error.
Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 2
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:460)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
at com.freedomkitchen.sonali.freedomkitchenAndroidApp.DB_Access.GetRecipes(DB_Access.java:241)
at com.freedomkitchen.sonali.freedomkitchenAndroidApp.User_Ingredients_Input.ViewRecipes(User_Ingredients_Input.java:227)
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
public ArrayList<String> GetRecipes(String meal_cat_selected) {
SQLiteDatabase db = this.getReadableDatabase();
// Cursor cursor_recipes = db.rawQuery("SELECT " + RECIPE_NAME + " FROM " + RECIPES_TABLE_NAME + " where " + MEAL_CATEGORY+"=?", new String[]{meal_cat_selected});
Cursor cursor_recipes = db.rawQuery("SELECT " + RECIPE_NAME + " FROM " + RECIPES_TABLE_NAME + " where " + MEAL_CATEGORY+"= '"+meal_cat_selected+"'", null);
ArrayList<String> array_list_recipes = new ArrayList<String>();
while (cursor_recipes.isAfterLast() == false) {
array_list_recipes.add(cursor_recipes.getString(cursor_recipes.getColumnIndex(RECIPE_NAME)));
cursor_recipes.moveToNext();
Log.i("reci_based_on_meal_cat", cursor_recipes.getString(cursor_recipes.getColumnIndex(RECIPE_NAME)));
}
db.close();
return array_list_recipes;
}
| <android><sqlite><android-sqlite> | 2016-05-03 18:46:56 | LQ_EDIT |
37,012,454 | How do i order a column in sql server in following manner? | I am trying to order by sql column which have a data type of nvarchar. My column data looks like this.
9 AM - 11 AM
1 PM - 3 PM
11 AM - 1 PM
3 PM - 5 PM
5 PM - 7 PM
And i want to order by my column in this manner
9 AM - 11 AM
11 AM - 1 PM
1 PM - 3 PM
3 PM - 5 PM
5 PM - 7 PM
How can i do this? | <sql-server> | 2016-05-03 19:08:19 | LQ_EDIT |
37,012,958 | Can anyone explain this code to me in plain english? Thanks | - the output is
- 1
- 2
- 3
int i, j, ans;
for (i = 1; i <= 3; i++)
{
for (j = i; j > 0; j--)
{
ans = i * j;
System.out.print(ans);
}
System.out.println();
}
| <java> | 2016-05-03 19:37:45 | LQ_EDIT |
37,013,151 | Why does Arrays.asList return a fixed-size List? | <p><code>Arrays.asList</code> is a useful and convenient method, but it returns a <code>List</code> whose size is fixed, such that no elements can be added or removed with <code>add</code> or <code>remove</code> (<code>UnsupportedOperationException</code> is thrown). </p>
<p>Is there a good reason for that? It looks like an odd restriction to me. </p>
<p>The <a href="https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#asList(T...)" rel="noreferrer">documentation</a> does not explain the reason behind it: </p>
<blockquote>
<p>Returns a fixed-size list backed by the specified array.</p>
</blockquote>
| <java><list> | 2016-05-03 19:49:52 | HQ |
37,013,726 | not get mysql db data .... into html page with php (stumped) | I am working on an assignment, and it requires me to select a "slip_id" from the 3aStudent_Slip.html and pass it to the next html 4aservice_request.html and populate a table that is being built in the php code. I have NOT had any php classes so I am really struggling with why it's NOT getting any database from the "ProgrammingDatabase" on the server.
using the following code ...
<?php
require_once('auth.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Service Requests</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="innerWrapper">
<h1>Service request by <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1>
<a href="index.php">Login Page</a> |
<a href="amenu.php">Menu Page</a> |
<a href="logout.php">Logout</a>
<?php
$slip_id = strtoupper($_POST['slip_id']);
echo("<h2>Services for Slip ID $slip_id</h2>");
//Verify Password
$vlogin=$_SESSION['vlogin'];
$vpassword=$_SESSION['vpasswd'];
//Connection String
$con=mysql_connect("localhost", $vlogin, $vpasswd);
if(!$con)
{
die("Could not connect".mysql_error());
}
//Select Database
mysql_select_db("ProgrammingDatabase", $con);
//The actual SQL code goes below into the structured variable $result
$result=mysql_query("SELECT * FROM service_request");
//Constructing the table and column names
echo "<table border='1'>
<tr>
<th>Service ID</th>
<th>Description</th>
</tr>";
//Looping until there are no more records from $result
//If there are records, print the column for that row
//do the while loop below with the variables from $result
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['service_id']."</td>";
echo "<td>".$row['description']."</td>";
echo "</tr>";
}
echo "</table>";
//Close the SQL connection string
mysql_close($con);
?>
<br />
<form action="a4Services_Student.php " method="post">
<br />
</form>
</div>
</body>
</html> | <php><mysql><html-table> | 2016-05-03 20:25:19 | LQ_EDIT |
37,013,784 | Javascript to jquery convertion | So I'm trying to convert this javascript DOM into jquery, and my code isn't running for some reason. This is the DOM I am using.
document.getElementById("forma").onsubmit = function () {
var ime = document.getElementById("ime").value;
var priimek = document.getElementById("priimek").value;
var stranka = document.getElementById("stranka").value;
try {
var kandidat = Kandidat(ime, priimek, stranka);
DodajKandidataNaPolje(kandidat);
document.getElementById("seznam").innerHTML = OblikujIzpis(PridobiPolje());
document.getElementById("obvestila").innerHTML = "Uspešen Vnos!";
document.getElementById("obvestila").className = "bg-success";
}
catch (napaka) {
document.getElementById("obvestila").innerHTML = napaka.message;
document.getElementById("obvestila").className = "bg-danger";
}
document.getElementById("forma").reset();
}
document.getElementById("forma_isci").onsubmit = function () {
var iskani_niz = document.getElementById("iskalniNiz").value;
document.getElementById("seznam").innerHTML = OblikujIzpis(Isci(iskani_niz));
document.getElementById("obvestila").innerHTML = "Rezultat iskanja po iskalnem nizu " + iskani_niz;
document.getElementById("obvestila").className = "bg-info";
}
document.getElementById("pobrisi").onclick = function () {
IzbrisiPolje();
document.getElementById("obvestila").innerHTML = "Polje je bilo izbrisano!";
document.getElementById("obvestila").className = "bg-success";
document.getElementById("seznam").innerHTML = "";
document.getElementById("forma").reset();
}
This is what I tried writing in jquery.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("forma").submit(function(){
var ime=$("ime").val();
var priimek=$("priimek").val();
var stranka=$("stranka").val();
try{
var kandidat= Kandidat(ime, priimek, stranka);
DodajKandidataNaPolje(kandidat);
$("seznam").html(OblikujIzpis(PridobiPolje());
$("obvestila").html("Uspešen Vnos!");
$("obvestila").addClass("bg-success");
}
catch(napaka){
$("obvestila").html(napaka.message);
$("obvestila").addClass("bg-danger");
}
$("forma").reset();
$("forma_isci").submit=function(){
var iskani_niz=$("iskaniNiz").val();
$("seznam").html(OblikujIzpis(iskani_niz));
$("obvestila").html("Rezultat iskanja po iskalnem nizu " + iskani_niz);
$("obvestila").addClass("bg-info");
}
$("pobrisi".click=function(){
IzbrisiPolje();
$("obvestila").html("Polje je bilo izbrisano!");
$("obvestila").addClass("bg-success");
$("seznam").html("");
$("forma").reset();
}
}
});
});
</script>
here is my HTML file
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<script src="funkcije.js"></script>
<script src="dom.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>JavaScript - DOM</title>
</head>
<body>
<div class="container">
<h1>Seznam predsedniških kandidatov!</h1>
<form action="#" id="forma_isci" class="form-inline">
<div class="form-group">
<input type="text" class="form-control" id="iskalniNiz" placeholder="Iskalni niz">
</div>
<button type="submit" class="btn btn-info">Išči</button>
</form>
<br />
<br />
<h3>Vnos novih kandidatov</h3>
<form action="#" id="forma" class="form-group">
<table class="table">
<tr>
<td>Ime:</td>
<td>
<input type="text" id="ime" placeholder="Ime kandidata" class="form-control" />
</td>
</tr>
<tr>
<td>Priimek:</td>
<td>
<input type="text" id="priimek" placeholder="Priimek kandidata" class="form-control" />
</td>
</tr>
<tr>
<td>Stranka:</td>
<td>
<select id="stranka" class="form-control" >
<option>Demokratska</option>
<option>Republikanska</option>
<option>Neodvisna</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Dodaj" class="btn btn-info" />
</td>
<td>
<input type="reset" value="Ponastavi" class="btn btn-info" />
</td>
</tr>
</table>
</form>
<br />
<br />
<p id="obvestila"></p>
<br />
<br />
<h3>Seznam obstoječih kandidatov</h3>
<ul id="seznam" class="list"></ul>
<button class="btn" id="pobrisi">Pobriši seznam</button>
</div>
</body>
</html>
So anyway, I'm not going to post the functions here since they're not needed to be seen here.
The javascript code works, the site works then and the elements get added normally. But I would like to have the same effect but written in Jquery. I think some of the issues are in .className, which I replaced with .Addclass from jquery and .innerHTML where I write .html(function). If someone could convert this for me it would be great, since I am kinda new to jquery I'm having some issues. | <javascript><jquery> | 2016-05-03 20:29:16 | LQ_EDIT |
37,014,221 | Logback: SizeAndTimeBasedRollingPolicy not honoring totalSizeCap | <p>I'm trying to manage my logging in a way in which my oldest archived logfiles are deleted once they've either reached the total cumulative size limit or reached their maximum history limit. When using the <code>SizeAndTimeBasedRollingPolicy</code>in Logback 1.1.7, the rolling file appender will keep creating new archives in spite of exceeding the <code>totalSizeCap</code> set. </p>
<p>Here's my logback.xml file for reference:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="file"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${USERPROFILE}/testlogs/test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${USERPROFILE}/testlogs/%d{yyyy-MM-dd_HH}/test%i.log.zip
</fileNamePattern>
<maxHistory>7</maxHistory>
<maxFileSize>50KB</maxFileSize>
<totalSizeCap>200KB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p - %m%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="file" />
</root>
</configuration>
</code></pre>
<p>Is this a bug in logback or am I not configuring the rolling file appender correctly?</p>
| <java><logging><logback> | 2016-05-03 20:57:14 | HQ |
37,014,313 | ScalaTest DeferredAbortedSuite error when running simple tests. | <p>My original code had a lot more going on, which distracted me from the true cause of the problem.
This captures the essential problem.</p>
<pre><code>import org.scalatest.AsyncFlatSpec
import scala.concurrent.Future
class AsyncFlatSpecSpec extends AsyncFlatSpec
{
it should "parse an XML file" in {
// ... Parsing ...
Future.successful(succeed)
}
it should "parse an XML file" in {
// ... Serializing ...
Future.successful(succeed)
}
}
</code></pre>
<p>This produced these errors:</p>
<pre><code>[info] DeferredAbortedSuite:
[error] Uncaught exception when running AsyncFlatSpecSpec: java.lang.ArrayIndexOutOfBoundsException: 17
[trace] Stack trace suppressed: run last test:testOnly for the full output.
</code></pre>
<p>There is no array access happening anywhere in my code. What's going on?</p>
<p>Running "last test:testOnly" wasn't much help:</p>
<pre><code>[info] DeferredAbortedSuite:
[error] Uncaught exception when running AsyncFlatSpecSpec: java.lang.ArrayIndexOutOfBoundsException: 17
sbt.ForkMain$ForkError: java.lang.ArrayIndexOutOfBoundsException: 17
at org.scalatest.exceptions.StackDepth$class.stackTraceElement(StackDepth.scala:63)
at org.scalatest.exceptions.StackDepth$class.failedCodeFileName(StackDepth.scala:77)
at org.scalatest.exceptions.StackDepthException.failedCodeFileName(StackDepthException.scala:36)
at org.scalatest.exceptions.StackDepth$class.failedCodeFileNameAndLineNumberString(StackDepth.scala:59)
at org.scalatest.exceptions.StackDepthException.failedCodeFileNameAndLineNumberString(StackDepthException.scala:36)
at org.scalatest.tools.StringReporter$.withPossibleLineNumber(StringReporter.scala:442)
at org.scalatest.tools.StringReporter$.stringsToPrintOnError(StringReporter.scala:916)
at org.scalatest.tools.StringReporter$.fragmentsForEvent(StringReporter.scala:747)
at org.scalatest.tools.Framework$SbtLogInfoReporter.apply(Framework.scala:622)
at org.scalatest.tools.FilterReporter.apply(FilterReporter.scala:41)
at org.scalatest.tools.SbtDispatchReporter$$anonfun$apply$1.apply(SbtDispatchReporter.scala:23)
at org.scalatest.tools.SbtDispatchReporter$$anonfun$apply$1.apply(SbtDispatchReporter.scala:23)
at scala.collection.Iterator$class.foreach(Iterator.scala:893)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at org.scalatest.tools.SbtDispatchReporter.apply(SbtDispatchReporter.scala:23)
at org.scalatest.tools.Framework$SbtReporter.apply(Framework.scala:1119)
at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:387)
at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:506)
at sbt.ForkMain$Run$2.call(ForkMain.java:296)
at sbt.ForkMain$Run$2.call(ForkMain.java:286)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code></pre>
<p>Confused, I retreated to the non-Async version, to see if that fared any
better.</p>
<pre><code>import org.scalatest.FlatSpec
class FlatSpecSpec extends FlatSpec {
it should "parse an XML file" in {
// ... Parsing ...
succeed
}
it should "parse an XML file" in {
// ... Serializing ...
succeed
}
}
</code></pre>
<p>It produced this different, but still cryptic error message:</p>
<pre><code>[info] DeferredAbortedSuite:
[info] Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite *** ABORTED *** (20 milliseconds)
[info] Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite (AsyncFlatSpecSpec.scala:32)
[info] ScalaTest
</code></pre>
<p>For completeness, here are the related portions of my build.sbt:</p>
<pre><code>scalaVersion := "2.11.8"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0-M15" % "test"
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0-M15"
</code></pre>
<p>This was ultimately a trivial mistake on my part, but I wanted to post this for the sake of anyone else Googling these errors.</p>
| <scala><unit-testing><scalatest> | 2016-05-03 21:03:50 | HQ |
37,014,795 | Calculate time difference in word VBA | I would like to calculate the time difference between 2 cells and the result showing in the 3rd cell.
For instance, cell D2 showing 2pm and D1 showing 1pm and the difference in cell B2
Sub DetermineDuration()
Dim doc As Document
Dim rng As Range
Dim dtDuration As Date
dtDuration = DateDiff("h:mm:ss", D2, D1)
Range("B2").dtDuration
End Sub
| <vba><ms-word> | 2016-05-03 21:36:22 | LQ_EDIT |
37,015,827 | Difference between In-Memory cache and In-Memory Database | <p>I was wondering if I could get an explanation between the differences between In-Memory cache(redis, memcached), In-Memory data grids (gemfire) and In-Memory database (VoltDB). I'm having a hard time distinguishing the key characteristics between the 3. </p>
| <caching><redis><memcached><in-memory-database><voltdb> | 2016-05-03 23:04:49 | HQ |
37,016,654 | I can start my video but can't play it | <p>I have this video:</p>
<pre><code><video src='videos/StressedOut.mp4' class='prize_video' controls></video>
</code></pre>
<p>I've <em>checked</em>, the URL is working. <code>.prize_video</code> doesn't affect the function of the video, only the style:</p>
<pre><code>.prize_video {
width: 800px;
height: 480px;
position: relative;
left: 22px;
}
</code></pre>
<p><strong>I can click play, but the video won't start...</strong></p>
| <html><video> | 2016-05-04 00:46:11 | LQ_CLOSE |
37,017,192 | Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:" While fetching whether | <p>I am using jQuery simple whether plugin to get the whether and trying to create a chrome widget.</p>
<p>While loading the file as a chrome extensions, I am getting error, after looking all the help provided by google and here it self, still I am not able to resolve this issue.</p>
<p>Below is the error for yahoo whether </p>
<pre><code>> jquery-2.1.3.min.js:4 Refused to load the script
> 'https://query.yahooapis.com/v1/public/yql?format=json&rnd=2016437&diagnosti…ces(1)%20where%20text=%22New%20Delhi%22)%20and%20u=%22c%22&_=1462326587463'
> because it violates the following Content Security Policy directive:
> "script-src 'self' blob: filesystem: chrome-extension-resource:".
</code></pre>
<p>Another error which is for font,</p>
<pre><code>> Refused to load the font
> 'data:application/octet-stream;base64,AAEAAAAPAIAAAwBwR1NVQrD+s+0AAAD8AAAAQk…GIUViwQIhYsQNkRLEmAYhRWLoIgAABBECIY1RYsQMARFlZWVmzDAIBDCq4Af+FsASNsQIARAAA'
> because it violates the following Content Security Policy directive:
> "default-src *". Note that 'font-src' was not explicitly set, so
> 'default-src' is used as a fallback.
</code></pre>
<p>Used manifest code are </p>
<pre><code>"content_security_policy": "script-src 'self'; object-src 'self' https://query.yahooapis.com/",
"permissions": [
"tabs", "<all_urls", "http://localhost/",
"http://*/*", "https://*/*", "https://query.yahooapis.com/*"
],
"content_scripts":
[{
"css": [
"css/component.css",
"css/tooltip-line.css",
"css/modal.css"
],
"js": [
"js/modernizr.custom.js",
"js/jquery-2.1.3.min.js",
"js/jquery.simpleWeather.min.js",
"js/handlebars-v4.0.5.js",
"js/moment.min.js",
"js/background.js"
],
"matches": [ "http://*/*", "https://*/*"]
}]
</code></pre>
<p>Also In my html file i am using this meta tag </p>
<pre><code><meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
</code></pre>
<p>Can some one please help me to how i can solve this.</p>
| <javascript><jquery><html><google-chrome><google-chrome-extension> | 2016-05-04 01:59:59 | HQ |
37,017,244 | Uploading a file to a S3 bucket with a prefix using Boto3 | <p>I am attempting to upload a file into a S3 bucket, but I don't have access to the root level of the bucket and I need to upload it to a certain prefix instead. The following code:</p>
<pre><code>import boto3
s3 = boto3.resource('s3')
open('/tmp/hello.txt', 'w+').write('Hello, world!')
s3_client.upload_file('/tmp/hello.txt', bucket_name, prefix+'hello-remote.txt')
</code></pre>
<p>Gives me an error:</p>
<p><code>An error occurred (AccessDenied) when calling the PutObject operation: Access Denied: ClientError Traceback (most recent call last): File "/var/task/tracker.py", line 1009, in testHandler s3_client.upload_file('/tmp/hello.txt', bucket_name, prefix+'hello-remote.txt') File "/var/runtime/boto3/s3/inject.py", line 71, in upload_file extra_args=ExtraArgs, callback=Callback) File "/var/runtime/boto3/s3/transfer.py", line 641, in upload_file self._put_object(filename, bucket, key, callback, extra_args) File "/var/runtime/boto3/s3/transfer.py", line 651, in _put_object **extra_args) File "/var/runtime/botocore/client.py", line 228, in _api_call return self._make_api_call(operation_name, kwargs) File "/var/runtime/botocore/client.py", line 492, in _make_api_call raise ClientError(parsed_response, operation_name) ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
</code></p>
<p><code>bucket_name</code> is in the format <code>abcd</code> while <code>prefix</code> is in the format <code>a/b/c/d/</code>. I'm not sure if the error is due to the slashes being wrong or if there's some way you can specify the prefix elsewhere, or if I don't have write permissions (although I supposedly do).</p>
<p>This code executes without any errors:</p>
<pre><code>for object in output_bucket.objects.filter(Prefix=prefix):
print(object.key)
</code></pre>
<p>Although there is no output as the bucket is empty. </p>
| <python><amazon-s3><boto3> | 2016-05-04 02:06:12 | HQ |
37,017,351 | Multiple Datasets in One SSRS | <p>I cannot use First() because I have multiple data to return.</p>
<p>I cannot use Lookup() because I don't know what data to look for.</p>
<p>Any other workaround? or the only way is I have to change my query?</p>
| <c#><oracle><reporting-services><rdlc> | 2016-05-04 02:20:05 | LQ_CLOSE |
37,017,407 | Where can I upload a JSON file and get JSONP support? | <p>I'm looking for a server where I can upload a JSON file and use it via JSONP afterwards. I'd usually use my work server for this type of stuff, but it doesn't support JSONP unfortunately. </p>
| <json><upload><jsonp> | 2016-05-04 02:26:07 | LQ_CLOSE |
37,018,085 | Python dictionary doesn't have all the keys assigned, or items | <p>I created the following dictionary</p>
<pre><code>exDict = {True: 0, False: 1, 1: 'a', 2: 'b'}
</code></pre>
<p>and when I print <code>exDict.keys()</code>, well, it gives me a generator. Ok, so I coerce it to a list, and it gives me </p>
<pre><code>[False, True, 2]
</code></pre>
<p>Why isn't 1 there? When I print <code>exDict.items()</code> it gives me</p>
<pre><code>[(False, 1), (True, 'a'), (2, 'b')]
</code></pre>
<p>Anyone have a guess about what's going on here? I'm stumped.</p>
| <python><dictionary> | 2016-05-04 03:50:06 | HQ |
37,018,469 | Why does 1ul << 64 return 1 instead of 0? | <p>Consider the following piece of code:</p>
<pre><code>// Simply loop over until 64 is hit.
unsigned long x = 0;
for (int i = 0; i <= 64; i++) {
if (i == 64) {
x = 1ul << i;
printf("x: %d\n", x);
}
}
</code></pre>
<p>We know that unsigned long is 64-bit wide, and left shifting 1 by 64 positions would become 1000...000 (64 zeros behind one), and would have been truncated to 0. However, the actual printout gives:</p>
<pre><code>x: 1
</code></pre>
<p>The strange thing is, if we just do </p>
<pre><code>printf("x: %d\n", (1ul << 64));
</code></pre>
<p>It would print 0. </p>
<p>Can anyone explain why this is happening? Why in the first case, the program mistakenly produces 1 instead of 0, but in the second case it's correct? </p>
| <c><math><gcc><long-integer><unsigned> | 2016-05-04 04:27:01 | LQ_CLOSE |
37,018,567 | Why my gradle projects creates separated modules for main and test in Intellij Idea | <p>Recently, I found all my gradle projects in Idea import separated modules for main and test. The modules look like this:</p>
<p><a href="https://i.stack.imgur.com/386GG.png"><img src="https://i.stack.imgur.com/386GG.png" alt="enter image description here"></a></p>
<p>As you can see, there is a "main" module which content root is the src/main and includes only main classes and resources, and there is a "test" module as well. The modules just don't look right. Is this an expected behavior?</p>
<p>The Idea is <code>Intellij Idea 2016.1.1</code> and the gradle is <code>2.11</code></p>
<p>Here is the content of build.gradle</p>
<pre><code>apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: "jacoco"
version = getVersion()
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
test {
resources {
srcDir 'src/test/data'
}
compileClasspath += configurations.provided
}
}
processResources {
filter { String line -> line.replace("{version}", getVersion()) }
}
processTestResources {
filter { String line -> line.replace("{version}", getVersion()) }
}
idea {
module {
scopes.PROVIDED.plus += [configurations.provided]
}
}
repositories {
mavenCentral()
}
</code></pre>
| <intellij-idea><gradle> | 2016-05-04 04:35:12 | HQ |
37,020,418 | create zip file in .net with password | <p>I'm working on a project that I need to create zip with password protected from file content in c#.</p>
<p>Before I've use System.IO.Compression.GZipStream for creating gzip content.
Does .net have any functionality for create zip or rar password protected file?</p>
| <c#><.net><passwords><zip> | 2016-05-04 06:48:30 | HQ |
37,021,438 | How to generate sitemap with react router | <p>I'm trying to figure out how to dynamically generate sitemap in reactJS server side (express) web app. I'm using react router. </p>
| <reactjs><server-side><react-router><react-router-component> | 2016-05-04 07:42:02 | HQ |
37,021,899 | Division by zero error in a code | <pre><code>public function convert($value, $from, $to) {
if ($from == $to) {
return $value;
}
if (isset($this->lengths[$from])) {
$from = $this->lengths[$from]['value'];
} else {
$from = 0;
}
if (isset($this->lengths[$to])) {
$to = $this->lengths[$to]['value'];
} else {
$to = 0;
}
return $value * ($to / $from);
}
</code></pre>
<p>This code is giving division by zero error on the line "return $value * ($to/$from)" . Can any one debug this . </p>
| <php><opencart> | 2016-05-04 08:04:55 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.