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 |
|---|---|---|---|---|---|
38,257,231 | How can I upload multiple files to a model field? | <p>I want to upload multiple files through a ModelForm,with all files to be assigned to a <code>file</code> field of the Model.I have gone through the docs and I saw an example on it and I ve implemented it here but I can only get my form to pick multiple files but only one get saved and assigned to <code>files</code>field.Below are my codes</p>
<p>models.py</p>
<pre><code>class Feed(models.Model):
user=models.ForeignKey(User,on_delete=models.CASCADE,related_name='feeds')
text=models.TextField(blank=False,max_length=500)
files = models.FileField(upload_to="files/%Y/%m/%d")
</code></pre>
<p>forms.py</p>
<pre><code>class FeedForm(ModelForm):
class Meta:
model=Feed
fields=('text','auth','files')
widgets={"files":forms.FileInput(attrs={'id':'files','required':True,'multiple':True})}
</code></pre>
<p>and views.py</p>
<pre><code>def post_feed(request):
form_class = FeedForm
if request.method == 'POST':
form = form_class(request.POST,request.FILES)
if form.is_valid():
feed = form.save(commit=False)
feed.user = User.objects.get(pk=1)
feed.pub_date=timezone.now()
#instance = Feed(files=request.FILES['files'])
# feed.files=request.FILES['files']
feed.save()
return redirect('home')
else:
form = form_class()
return render(request, 'post_feed.html', {'form': form,})
from django.views.generic.edit import FormView
from .forms import FeedForm
class FileFieldView(FormView):
form_class=FeedForm
template_name='post_feed.html'
'''success_url=??? #I dont know what to write here.I thought of putting this
render(request, 'post_feed.html', {'form': form,}) because I just want
to reload the page but it gave an error,so I removed it entirely.'''
def post_feed(self,request,*args,**kwargs):
form_class=self.get_form_class()
form=self.get_form(form_class)
filez=request.FILES.getlist('files')
if form.is_valid():
for f in filez:
f.save()
return self.form_valid(form)
else:
return self.form_invalid(form)
</code></pre>
<p>Kindly help me out,Thanks in advance.</p>
| <django> | 2016-07-08 00:20:32 | HQ |
38,257,499 | What is the difference between cpan and cpanm? | <p>What is the difference between the <code>cpan</code> and <code>cpanm</code> commands?</p>
<p>They both seem to install <code>perl</code> modules, so what is the difference?</p>
| <perl><cpan><cpanm> | 2016-07-08 01:03:57 | HQ |
38,258,206 | Email validation has odd bug | Ok, so I needed an email validator with Javascript. So, I used the code from this [StackOverflow answer][1]. The problem involves putting a space *after* your email address. If I enter `example@gmail.com`, nothing wrong happens. If I enter `example@gmail.com `, notice the added space at the end, the email address is proved invalid. People make mistakes and an added space shouldn't deem an email address invalid. How do I fix this...
<!-- begin snippet: js hide: false console: true -->
<!-- language: lang-js -->
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validate() {
$("#result").text("");
var email = $("#email").val();
if (validateEmail(email)) {
$("#result").text(email + " is valid :)");
$("#result").css("color", "green");
} else {
$("#result").text(email + " is not valid :(");
$("#result").css("color", "red");
}
return false;
}
$("form").bind("submit", validate);
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<p>Enter an email address:</p>
<input id='email'>
<button type='submit' id='validate'>Validate!</button>
</form>
<h2 id='result'></h2>
<!-- end snippet -->
[1]: http://stackoverflow.com/a/46181/6540373 | <javascript><email> | 2016-07-08 02:46:44 | LQ_EDIT |
38,258,306 | how does the value of variable get changed through swap function? | <p>Here I have two swap functions</p>
<pre><code>void kswap(int* a, int* b)
{
int* temp = a;
a = b;
b = temp;
}
void kswap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
</code></pre>
<p>The value only changed inside of the first function,
<br>and the second function change the value permanently..</p>
<p>Can anyone tell me the different between two functions?
I thought as both functions take pointer type through parameter, the value would be changed through both functions..</p>
| <c++><pointers><swap> | 2016-07-08 03:01:05 | LQ_CLOSE |
38,258,935 | Hello i"ve trying to build a simple login page for my project | **My view**
def login(request):
c = {}
c.update(csrf(request))
return render_to_response(request,
'login.html', c)
def auth_view(request):
username = request.POST.get
('username', '')
password = request.POST.get
('password', '')
user = auth.authenticate
(username = username, password =
password)
if user is not None:
auth.login(request,user)
if request.method == 'POST':
return HttpResponseRedirect('accounts/loggedin/')
else:
Retun HttpResponseRedirect('accounts/invalid/')
Error occurs that fuction auth_view return nothing.. i'm stuck
| <python><django> | 2016-07-08 04:30:17 | LQ_EDIT |
38,259,658 | Can anyone pls clarify this code? | I have a doubt in the very basics of C .
- I have written the following code.Here in the function add(), i m not returning anything and so I expected that the output will be some junk value or something, but it didn't happen like that.Can anyone explain me why was it happening like that.? Please excuse me if I have written something wrong in the code.To my understanding,
- I thought the memory for ***variable*** ***add1*** will be from stack and hence once the **add ()** is done , all the memory allocated will be freed and hence some junk value will be displayed.
Code sample
=======
main()
{
int x=4,sum;
int n;
printf(" enter a number \n");
scanf("%d",&n);
sum = add(x,n);
printf(" total sum = %d\n",sum);
}
add(int x,int n)
{
int add1=0;
add1 = x+n;
//return(add1);
}
| <c><function><memory><stack> | 2016-07-08 05:46:38 | LQ_EDIT |
38,259,976 | Time delays without using Thread.sleep() | <p>I wrote a client application where I am using two threads other than the main thread.The Background thread is used to receive data through TCP IP,while after receiving I am calling another thread that will show the received data continuously using a for loop.But after every iteration the for loop needs to wait for 30 seconds.I have used Thread.sleep(30000) but the dont know why its not working,sometimes it wakes up from sleep mode before 30 seconds.I am using dot net framework 4.Please suggest some other alternatives.</p>
<pre><code> for(n=0;n<=m;n++)
{
//show data;
//wait for 30 seconds
}
</code></pre>
| <c#><.net><multithreading><multidimensional-array> | 2016-07-08 06:09:58 | LQ_CLOSE |
38,260,105 | How to convert each character in a character array to integer ? | I have tried the standard methods but still I get error in my answer.
For eg, with this code:
int main()
{
int val;
char str[]={'1','45','0'};
val = str[1]-'0';
printf("Int value = %d\n",val);
return(0);
}
I am getting ans as 5 instead of 45.
How do I solve this issue? Plz help. | <c><initialization><literals> | 2016-07-08 06:20:27 | LQ_EDIT |
38,260,725 | Add prefix to all Spring Boot actuator endpoints | <p>Is there an easy way to add a prefix to all the Actuator endpoints? </p>
<pre><code>/env -> /secure/env
/health -> /secure/health
/info -> /secure/info
...
</code></pre>
| <spring><spring-boot><spring-boot-actuator> | 2016-07-08 07:02:47 | HQ |
38,260,874 | How to provide login credentials to an automated android test? | <p>I'm looking for a way to "provide a login" to my app so an automated test "is logged in" and can test the entire app. Currently it's of course blocked by the login-screen.</p>
<p>Because I'm using SmartLock for Passwords, this might be a chance to provide some credentials for the test - but I don't know how.</p>
<hr>
<p>Is there some best-practice to provide credentials to / skip the login during a test? I could think of a special buildType / -flavor which is mocking the login but this way it can't be used to test a release build.</p>
<p>It would be great when I could test a final release build which can be uploaded to the store when the test succeeds. This way, I could use the embedded pre-launch-reports in the PlayStore as well (which would be really nice).</p>
| <android><login><automated-tests><google-smartlockpasswords><firebase-test-lab> | 2016-07-08 07:12:19 | HQ |
38,261,299 | Twig: Include external Code from an SVG file | <p>Is it possible to inlcude code from a svg file directly into a twig template file?</p>
<p>Something like:</p>
<pre><code>{% include 'my.svg' %}
</code></pre>
<p>that will result in:</p>
<pre><code><svg viewbox=".... />
</code></pre>
| <svg><twig><inline><templating> | 2016-07-08 07:38:19 | HQ |
38,261,505 | Getting total number of registered users | <p>In my app I have login/registration system and need to count the total number of registered users. For example I have 2 registered users.</p>
<pre><code>----------------------------------------------------
|id| email |use_name|user_pass|confirm_pass|
----------------------------------------------------
|7 | theo@gmail.com| theo | my pass | my pass |
----------------------------------------------------
|8 | test@gmail.com| test | my pass | my pass |
----------------------------------------------------
</code></pre>
<p>The is a function in mysql called SUM,but it adds ints.In my case though the id is incrementing from the last deleted user. </p>
<p>Thanks,</p>
<p>Theo.</p>
| <php><mysql><database> | 2016-07-08 07:49:42 | LQ_CLOSE |
38,262,526 | Assert Statement for ternary operator in Rhino mocks? | <pre><code>x(string)= y(string) != ? y : string.empty
</code></pre>
<p>How to get 100% code coverage for above line using Assert statement</p>
<p>We've tried using:
Assert.AreEqual(Actualvalue,ExpectedValue);
but we are missing code coverage somewhere</p>
| <c#><code-coverage><rhino-mocks> | 2016-07-08 08:49:23 | LQ_CLOSE |
38,262,803 | How are large codebase for a large software written? | <p>i was trying to solve some bugs (easyhacks) for libreoffice , but i had problem understanding the code . It may be because of the way i have learnt programming and never working with a large codebase before.<br>
Below is how coding looks in my textbook and school..<br></p>
<pre><code>#include<header1>
#include<header2>
using some namespace
class MyClass1{
.....
.....
};
class MyClass2 : public MyClass1{
.....
.....
};
int main() //entry point
{
int a , b ;
string str ; //use basic data types
MyClass1 Ca
.....
.....
}
</code></pre>
<p>This is roughly what programs look like even if something complex is to be learnt.<br>
Now the bug i was looking at had specific code pointers to it , so i looked into it , this is how it looked like to me</p>
<pre><code>//mediaItem.hxx --> represents embedded media object
#include<several_headers.hxx>
class RANDOM_MACRO MediaItem : public SomeOtherClass{
public :
const sal_uint& some_var ;
const OUString& some_str ; \\never before seen data types
virtual void someFoo ;
Virtual OUString getURL() ; \\function i am supposed to look into
private :
struct Impl ;
...
};
</code></pre>
<p>and then there is a .cxx file defining the functions. <br>
so i have a few questions</p>
<ol>
<li>Why aren't basic data types like int , string ever used in writing such programs?</li>
<li>Where is the entry point for such large programs , i.e there is always a main() when i write a program. </li>
<li>What are terms like pImpl , Impl that i frequently come across inside classes .
<br></li>
</ol>
<p>P.S. perhaps this should be a seperate question , but people have advised me to understand large codebases using debugger , now again i have used debugger before to understand small programs but i dont understand how i can use it over here especially without knowing an entry point . Thank you.... </p>
| <c++><libreoffice> | 2016-07-08 09:04:43 | LQ_CLOSE |
38,263,086 | How to see few fields in the view but later clicking on the record should show all fields | My HANA table consists of 20 fields but I want my view to display only 5 fields for each record in my browser through an xml view.But again, when I click on the particular row on browser, I should be able to see all 20 field for that record.How will that be possible? Please help | <sapui5><hana> | 2016-07-08 09:19:08 | LQ_EDIT |
38,263,682 | make pip ignore an existing wheel | <p>If a <code>.whl</code> is available online, <code>pip</code> always installs it rather than compiling from source. However, for some specific module, the wheel happened to be compiled for the next processor generation and doesn't run on a specific machine.</p>
<p>If I command it to just download the package, then it still downloads the wheel rather than source. Does <code>pip</code> have some mechanism to override this preference?</p>
| <python><pip><python-wheel> | 2016-07-08 09:51:29 | HQ |
38,263,817 | can't get a:hover function in css/php to work | for some reason my browser with xampp (PHP) isn't giving a response to the hover command in this piece of code. how can i solve this to get my font to get a little color while hovering over with my mouse?
.headermenu a{
font-size: 18px;
color: #ffffff;
display: inline-block 5px;
background-color: #7f2048;
box-shadow: 0px 0px 50px #888888;
border-radius: 5px;
vertical-align: middle;
padding-bottom: 5px;
padding-top: 5px;
padding-left: 24px;
padding-right: 24px;
margin-bottom: 10px;
text-decoration: none;
font-family:
.headermenu a: hover{
color: #5b5a64;
}
-------------------
im using `<div class"headermenu">` and a end-div to get it to work.
in sublime the text hover from headermenu a:hover{ is white so means not functioning or something i guess.
thnx for helping me out in advise!!! btw im new here.
| <html><css><hover> | 2016-07-08 09:58:42 | LQ_EDIT |
38,264,091 | two progress bars with same styles (default) look different in android | In my android application i am using an open source library. This library has an activity which creates a progress bar (no style) using below code . say it progressBar1 .
private void createProgressBar() {
LayoutParams params = new LayoutParams(-1, -2); // match_parent , wrap_content
params.addRule(13); //center in parent
ProgressBar = new ProgressBar(this);
ProgressBar.setLayoutParams(params);
RootLayout.addView(ProgressBar);
ProgressBar.setVisibility(8); //View.GONE
}
I am also creating a progress bar in my app using exact same code above , Say ProgressBar2.
But the two progress bars look different . I donot know whats the reason .
I want both the progress bars to look same .
I also tried changing the progressBar2 by adding it in xml and using from there using below code:
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate= "true"
android:visibility="gone"/>
using it in java as:
progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.setVisibility(View.VISIBLE);
still the progressBar2 Looks the same and both progressBar1 and progressBar2 look different ... do not know why?
| <android><android-progressbar> | 2016-07-08 10:10:06 | LQ_EDIT |
38,264,685 | show static rows one by one using java script | I have the following table
<table class="hTab">
<tr class="hTr"> </tr>
<tr class="hTr"> </tr>
<tr class="hTr"> </tr>
</table>
<tr> <input type=button value="Show 1 more" id="onemore" /></tr>
I have used following Jquery code to show the rows one by one ( I have declared 10 rows in the table
var currentrow = 0;
$('#hTab #hTr').hide();
$('#hTab #tr:eq(0)').show();
$("#onemore").click(function () {
currentrow++;
$('#hTab #hTr:eq(' + currentrow + ')').show();
});
but at the moment it's not working. if anyone could show the error in my code will be very helpful | <javascript><jquery> | 2016-07-08 10:42:28 | LQ_EDIT |
38,264,715 | How to pass context down to the Enzyme mount method to test component which includes Material UI component? | <p>I am trying to use <code>mount</code> from Enzyme to test my component in which a several Material UI component are nested. I get this error when running the test:</p>
<p><code>TypeError: Cannot read property 'prepareStyles' of undefined</code></p>
<p>After some digging, <a href="https://github.com/callemall/material-ui/issues/4021">I did found that a theme needs to be passed down in a context</a>. I am doing that in the test but still get this error. </p>
<p>My test:</p>
<pre><code>import expect from 'expect';
import React, {PropTypes} from 'react';
import {mount} from 'enzyme';
import SearchBar from './SearchBar';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
function setup() {
const muiTheme = getMuiTheme();
const props = {
closeSearchBar: () => {},
fetchSearchData: () => {},
data: [],
searching: false
};
return mount(<SearchBar {...props} />, {context: {muiTheme}});
}
describe('SearchBar Component', ()=> {
it('Renders search toolbar properly', () => {
const wrapper = setup();
expect(wrapper.find('.toolbar').length).toBe(1);
expect(wrapper.find('button').length).toBe(1);
});
});
</code></pre>
<p>My searchbar component is a stateless component, so I am not pulling in any context. But even when I am, I still get the same error. </p>
<p>What am I doing wrong?</p>
| <material-ui><enzyme> | 2016-07-08 10:44:16 | HQ |
38,264,720 | Swift : expected type after as , Xcode 8-Beta, Swift 3 | This this code Where I'm getting the error..
This this code Where I'm getting the error..
This this code Where I'm getting the error..
This this code Where I'm getting the error..
This this code Where I'm getting the error..
[![private class func doRequest(_ urlString: String, params: \[String: String\], success: (NSDictionary) -> ()) {
if let url = URL(string: "\(urlString)?\(query(params))"){
let request = NSMutableURLRequest(
url:url
)
let session = URLSession.shared()
let task = session.dataTask(with: request) { data, response, error in
self.handleResponse(data, response: response as?, error: error, success: success)
}
task.resume()
}
}][1]][1]
[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/PDezO.png | <ios><swift><swift3> | 2016-07-08 10:44:34 | LQ_EDIT |
38,264,772 | Using IIS Server instead of IIS Express in Visual Studio 2015 | <p>How can we configure our already developed ASP.Net website to use IIS Server instead of using IIS Express in VS2015?</p>
<p>IIS Express is the default server in Visual Studio 2015. My website runs fine with ASP.NET web Development server in Visual studio 2012 but when i run it in VS2015 , it does not loads the css and images .</p>
<p>So, i want to run it with IIS Server and not IIS Express in VS2015. Can anyone help me out ?</p>
| <asp.net><visual-studio><iis> | 2016-07-08 10:47:52 | HQ |
38,265,590 | LISTVIEW WITH CHECKBOX USING CUSTOM ADAPTER CLASS IN ANDROID | I was creating app like e-commerce with listview that containing images, textbox and one checkbox. Now my question is that i want choose(click) max 3 item from listview and checked item pass to next activity on OnClick on button. After going to next activity it will hold that checked item for filling the user info. After filling user info she/he pressed button, onto the button click it select all checked item and user info and send it to send my database which is located at server side. I will posted this question on stack overflow also but answer is not getting their. Please help me solve this issue. or provide some link which are used info as like this.:( And one more main thing is that my listview data will retrieves from server using json and php. and i want send again back it to server after selecting item from listview. Thank You
Here is my code of lisview
public class Hotels extends Activity
{
// Declare Variables
JSONArray jsonarray = null;
SQLiteDatabase sqLite;
public static final String TAG_NAME = "name";
public static final String TAG_LOCATION = "location";
public static final String TAG_DESC = "description";
String name,arrival_date,departure_date,image,location,description,adult,kids;
ProgressDialog loading;
ListView list;
Button booknow;
ListViewAdapter adapter;
private ArrayList<Product> itemlist;
Product product;
static String Array = "MyHotels";
View view;
CheckBox click;
ArrayList<String> checked = new ArrayList<String>();
String hotel = "http://app.goholidays.info/getHotelData.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.all_item_layout);
itemlist = new ArrayList<Product>();
new ReadJSON().execute();
click = (CheckBox) findViewById(R.id.mycheckbox);
booknow = (Button) findViewById(R.id.bookhotel);
product = new Product();
list = (ListView) findViewById(R.id.myimagelist);
booknow.setOnClickListener(new MyPersonalClickListener("book_hotel",product,getApplicationContext()));
}
class ReadJSON extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(Hotels.this,"Fetching Data","Please wait...",false,false);
}
@Override
protected String doInBackground(String... args) {
Product tempMenu;
try {
JSONObject jsonobject = JSONfunctions.getJSONfromURL(hotel);
jsonarray = jsonobject.optJSONArray(Array);
//parse date for dateList
for (int i = 0; i < jsonarray.length(); i++) {
tempMenu = new Product();
jsonobject = jsonarray.getJSONObject(i);
tempMenu.setName(jsonobject.getString("name"));
tempMenu.setLocation(jsonobject.getString("location"));
tempMenu.setImage_path(jsonobject.getString("image_name"));
tempMenu.setDescription(jsonobject.getString("description"));
tempMenu.setFacility1(jsonobject.getString("facility1"));
tempMenu.setFacility2(jsonobject.getString("facility2"));
tempMenu.setFacility3(jsonobject.getString("facility3"));
tempMenu.setFacility4(jsonobject.getString("facility4"));
tempMenu.setStar(jsonobject.getString("star"));
itemlist.add(tempMenu);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
adapter = new ListViewAdapter(Hotels.this, itemlist);
list.setAdapter(adapter);
loading.dismiss();
}
}
private class MyPersonalClickListener implements View.OnClickListener {
String book_hotel;
Product name;
Context context;
public MyPersonalClickListener(String book_hotel, Product product, Context context) {
this.book_hotel = book_hotel;
this.name = product;
this.context = context;
}
@Override
public void onClick(View v){
if (click.isChecked()) {
startActivity(new Intent(Hotels.this, BookHotel.class));
}
else
{
Toast.makeText(context, "Please Select Hotel", Toast.LENGTH_SHORT).show();
}
}
}
}
Adapter class of listview
public class ListViewAdapter extends BaseAdapter {
Context context;
LayoutInflater inflater;
ArrayList<Product> AllMenu = new ArrayList<>();
ImageLoader imageLoader;
int checkCounter = 0;
public ListViewAdapter(Context context, ArrayList<Product> itemlist) {
this.context=context;
AllMenu = itemlist;
imageLoader = new ImageLoader(context);
checkCounter = 0;
}
public int getCount() {
return AllMenu.size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(final int position, final View convertView, ViewGroup parent) {
// Declare Variables
final Product tempMenu = AllMenu.get(position);
final CheckBox c;
final ImageView image_path,facility1,facility_1;
ImageView facility2,facility_2;
ImageView facility3,facility_3;
ImageView facility4,facility_4;
ImageView star1,star2,star3,star4,star5;
TextView name,location,desc;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View view = inflater.inflate(R.layout.viewpage, parent, false);
// Get the position
c = (CheckBox) view.findViewById(R.id.mycheckbox);
name = (TextView) view.findViewById(R.id.fh_name);
location = (TextView) view.findViewById(R.id.fh_loc);
desc = (TextView) view.findViewById(R.id.fh_desc);
facility1 = (ImageView) view.findViewById(R.id.fh_fc1);
facility_1 = (ImageView) view.findViewById(R.id.fh_fc11);
facility2 = (ImageView) view.findViewById(R.id.fh_fc2);
facility_2 = (ImageView) view.findViewById(R.id.fh_fc22);
facility3 = (ImageView) view.findViewById(R.id.fh_fc3);
facility_3 = (ImageView) view.findViewById(R.id.fh_fc33);
facility4 = (ImageView) view.findViewById(R.id.fh_fc4);
facility_4 = (ImageView) view.findViewById(R.id.fh_fc44);
star1 = (ImageView) view.findViewById(R.id.fh_s1);
star2 = (ImageView) view.findViewById(R.id.fh_s2);
star3 = (ImageView) view.findViewById(R.id.fh_s3);
star4 = (ImageView) view.findViewById(R.id.fh_s4);
star5 = (ImageView) view.findViewById(R.id.fh_s5);
image_path = (ImageView) view.findViewById(R.id.image_all_main);
c.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
if(c.isChecked() && checkCounter >=3) {
AllMenu.get(position).setSelected(false);
c.setChecked(false);
Toast.makeText(context, "You can select max 3 hotels!!", Toast.LENGTH_SHORT).show();
}
else {
Product p = (AllMenu).get(position);
p.setSelected(c.isChecked());
if(c.isChecked()) {
checkCounter++;
}
else {
checkCounter--;
}
}
StringBuffer responseText = new StringBuffer();
responseText.append("The following were selected...");
ArrayList<Product> p = AllMenu;
for(int i=0;i<p.size();i++){
Product pp = p.get(i);
if(pp.isSelected()){
responseText.append("\n" + pp.getName() + "\t");
responseText.append("\t" + pp.getLocation());
}
}
Toast.makeText(context,
responseText, Toast.LENGTH_SHORT).show();
}
});
c.setTag(tempMenu);
c.setChecked(tempMenu.isSelected());
name.setText(tempMenu.getName());
location.setText(tempMenu.getLocation());
desc.setText(tempMenu.getDescription());
imageLoader.DisplayImage(tempMenu.getImage_path(),image_path);
if(tempMenu.getFacility1().equals("Pool")) {
facility1.setVisibility(view.VISIBLE);
facility_1.setVisibility(view.INVISIBLE);
}else {
facility_1.setVisibility(view.VISIBLE);
facility1.setVisibility(view.INVISIBLE);
}
if(tempMenu.getFacility2().equals("Bar")) {
facility2.setVisibility(view.VISIBLE);
facility_2.setVisibility(view.INVISIBLE);
}else {
facility_2.setVisibility(view.VISIBLE);
facility2.setVisibility(view.INVISIBLE);
}
if(tempMenu.getFacility3().equals("Gym")) {
facility3.setVisibility(view.VISIBLE);
facility_3.setVisibility(view.INVISIBLE);
}else {
facility_3.setVisibility(view.VISIBLE);
facility3.setVisibility(view.INVISIBLE);
}
if(tempMenu.getFacility4().equals("Theater")) {
facility4.setVisibility(view.VISIBLE);
facility_4.setVisibility(view.INVISIBLE);
}else {
facility_4.setVisibility(view.VISIBLE);
facility4.setVisibility(view.INVISIBLE);
}
if(tempMenu.getStar().equals("1")) {
star1.setVisibility(view.VISIBLE);
star2.setVisibility(view.INVISIBLE);
star3.setVisibility(view.INVISIBLE);
star4.setVisibility(view.INVISIBLE);
star5.setVisibility(view.INVISIBLE);
}else if(tempMenu.getStar().equals("2")) {
star1.setVisibility(view.VISIBLE);
star2.setVisibility(view.VISIBLE);
star3.setVisibility(view.INVISIBLE);
star4.setVisibility(view.INVISIBLE);
star5.setVisibility(view.INVISIBLE);
}else if(tempMenu.getStar().equals("3")) {
star1.setVisibility(view.VISIBLE);
star2.setVisibility(view.VISIBLE);
star3.setVisibility(view.VISIBLE);
star4.setVisibility(view.INVISIBLE);
star5.setVisibility(view.INVISIBLE);
}else if(tempMenu.getStar().equals("4")) {
star1.setVisibility(view.VISIBLE);
star2.setVisibility(view.VISIBLE);
star3.setVisibility(view.VISIBLE);
star4.setVisibility(view.VISIBLE);
star5.setVisibility(view.INVISIBLE);
}else if(tempMenu.getStar().equals("5")) {
star1.setVisibility(view.VISIBLE);
star2.setVisibility(view.VISIBLE);
star3.setVisibility(view.VISIBLE);
star4.setVisibility(view.VISIBLE);
star5.setVisibility(view.VISIBLE);
}
else {
star1.setVisibility(view.INVISIBLE);
star2.setVisibility(view.INVISIBLE);
star3.setVisibility(view.INVISIBLE);
star4.setVisibility(view.INVISIBLE);
star5.setVisibility(view.INVISIBLE);
}
return view;
}
}
After selecting item from list it will come on this activity.
public class BookHotel extends AppCompatActivity {
EditText arrival,departure;
Calendar myCalendar;
Button booknow;
final String[] qtyValues = {"0","1","2","3","4"};
Spinner adult,children;
String chkin,chkout,persons,kids;
CheckBox checkbox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.book_hotel);
booknow = (Button) findViewById(R.id.bookmyhotel);
arrival = (EditText) findViewById(R.id.arrival_date);
departure = (EditText) findViewById(R.id.departure_date);
myCalendar = Calendar.getInstance();
adult = (Spinner) findViewById(R.id.adults);
children = (Spinner) findViewById(R.id.childrens);
booknow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(arrival.getText().length() <= 0){
arrival.setError("Please fill the field.!!");
}else if(departure.getText().length() <= 0){
departure.setError("Please fill the field.!!");
}else {
chkin = arrival.getText().toString();
chkout = departure.getText().toString();
persons = adult.getSelectedItem().toString();
kids = children.getSelectedItem().toString();
//Submit(chkin, chkout, persons, kids);
}
}
});
ArrayAdapter<String> aa=new ArrayAdapter<String>(getApplicationContext(),R.layout.qty_spinner_item,qtyValues);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adult.setAdapter(aa);
children.setAdapter(aa);
final DatePickerDialog.OnDateSetListener adate = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateArrival();
}
};
final DatePickerDialog.OnDateSetListener ddate = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateDeparture();
}
};
arrival.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DatePickerDialog(BookHotel.this, adate, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
departure.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DatePickerDialog(BookHotel.this, ddate, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
}
private void updateArrival() {
String myFormat = " MM/dd/yy "; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
arrival.setText(sdf.format(myCalendar.getTime()));
//departure.setText(sdf.format(myCalendar.getTime()));
}
private void updateDeparture() {
String myFormat = " MM/dd/yy "; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
//arrival.setText(sdf.format(myCalendar.getTime()));
departure.setText(sdf.format(myCalendar.getTime()));
}
}
I don't know how i can pass those selecting item and this info to server on onClickListener please help me solve this problem. Thank You
And here is another problem i will posted on it is [this][1]
[1]: http://stackoverflow.com/questions/38142573/how-to-retrieve-particular-user-information-from-server-when-user-get-logged-in | <android><json><listview><checkbox> | 2016-07-08 11:32:50 | LQ_EDIT |
38,265,921 | How to use Meteor | <p>I am a newbie to meteor, so can anyone help me out , how to use <code>meteor</code> for mobile application development. I am not getting relevant tutorials for it. I am currently working on Ubuntu 14.0 LTS</p>
<p>Thanks in advance!!</p>
| <javascript><meteor> | 2016-07-08 11:52:26 | LQ_CLOSE |
38,266,038 | HTML reserve space for scrollbar | <p>I have a div that may overflow as content is added or removed.</p>
<p>However the UI designer does not want a visible, but inactive scrollbar (as with <code>overflow: scroll</code>), and they don't want the content layout to change when one is added and remove (as with <code>overflow: auto</code>).</p>
<p>Is there a means to get this behavior, and considering the different scrollbars on different platforms and browsers.</p>
<p><a href="https://i.stack.imgur.com/MQi3P.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MQi3P.png" alt="enter image description here"></a>
<a href="https://jsfiddle.net/qy9a2r00/1/" rel="noreferrer">https://jsfiddle.net/qy9a2r00/1/</a> </p>
| <html><css> | 2016-07-08 11:57:47 | HQ |
38,266,296 | Laravel authentication without global scope | <p>In my Laravel app users can disable (not delete) their account to disappear from the website. However, if they try to login again their account should be activated automatically and they should log in successfully.</p>
<p>This is done with "active" column in the users table and a global scope in User model:</p>
<pre><code>protected static function boot() {
parent::boot();
static::addGlobalScope('active', function(Builder $builder) {
$builder->where('active', 1);
});
}
</code></pre>
<p>The problem now is that those inactive accounts can't log in again, since AuthController does not find them (out of scope).</p>
<p>What I need to achieve:</p>
<ol>
<li>Make AuthController ignore global scope "active".</li>
<li>If username and password are correct then change the "active" column value to "1".</li>
</ol>
<p>The idea I have now is to locate the user using withoutGlobalScope, validate the password manually, change column "active" to 1, and then proceed the regular login.</p>
<p>In my AuthController in postLogin method:</p>
<pre><code>$user = User::withoutGlobalScope('active')
->where('username', $request->username)
->first();
if($user != null) {
if (Hash::check($request->username, $user->password))
{
// Set active column to 1
}
}
return $this->login($request);
</code></pre>
<p>So the question is how to make AuthController ignore global scope without altering Laravel main code, so it will remain with update?</p>
<p>Thanks.</p>
| <laravel><authentication> | 2016-07-08 12:10:28 | HQ |
38,266,848 | How to sort ArrayList<String> in Java in decreasing order? | <p>I am new in java i am trying to sort a list of install app in device according to their data use. i want like highest at the top.i use code to find install package are:</p>
<pre><code> List<ApplicationItem> mApplicationItemList = new ArrayList<ApplicationItem>();
PackageManager p = getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo packageInfo : apps) {
ApplicationItem item = new ApplicationItem();
if (packageInfo.requestedPermissions == null)
continue;
if (Arrays.asList(packageInfo.requestedPermissions).contains(android.Manifest.permission.INTERNET) &&
!Utility.isSystemApp(packageInfo.packageName) &&
(p.getLaunchIntentForPackage(packageInfo.packageName) != null)) {
item.setPkgName(packageInfo.packageName);
mApplicationItemList.add(item);
}
}
and find data usage by this code:
public static long getTotalDataByUid(String pkgName) {
long totalData = 0;
try {
ApplicationInfo appInfo = getApplicationContext().getPackageManager().getApplicationInfo(pkgName, 0);
//TODO Handle UNSUPPORTED
long tx = TrafficStats.getUidTxBytes(appInfo.uid);
long rx = TrafficStats.getUidRxBytes(appInfo.uid);
totalData = tx + rx;
if (totalData < 0) {
totalData = 0;
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
totalData = 0;
}
return totalData;
}
</code></pre>
| <android> | 2016-07-08 12:35:14 | LQ_CLOSE |
38,268,175 | Is it possible to use OAuth 2.0 without a redirect server? | <p>I'm trying to create a local Java-based client that interacts with the SurveyMonkey API.</p>
<p>SurveyMonkey requires a long-lived access token using OAuth 2.0, which I'm not very familiar with.</p>
<p>I've been googling this for hours, and I think the answer is no, but I just want to be sure:</p>
<p>Is it possible for me to write a simple Java client that interacts with the SurveyMonkey, <strong>without setting up my own redirect server in some cloud</strong>?</p>
<p>I feel like having my own online service is mandatory to be able to receive the bearer tokens generated by OAuth 2.0. Is it possible that I can't have SurveyMonkey send bearer tokens directly to my client?</p>
<p>And if I were to set up my own custom Servlet somewhere, and use it as a redirect_uri, then the correct flow would be as follows:</p>
<ol>
<li>Java-client request bearer token from SurveyMonkey, with
redirect_uri being my own custom servlet URL. </li>
<li>SurveyMonkey sends token to my custom servlet URL. </li>
<li>Java-client polls custom servlet URL until a token is available?</li>
</ol>
<p>Is this correct?</p>
| <java><oauth-2.0><surveymonkey> | 2016-07-08 13:41:15 | HQ |
38,268,334 | String decimal conversion in c# | <p>Please how do I convert a string from 2 decimal places to 5 decimal places in c#?</p>
<p>For example; I'm trying to convert 12.14 to 12.14000 using C#</p>
| <c#> | 2016-07-08 13:48:34 | LQ_CLOSE |
38,268,773 | export double value with comma | <p>i need to generate excel that display double values with a comma as grouping symbol.
example :100000000.00 ------> 100,000,000.00 </p>
<p>the comma symbol for group and the Dot symbol for decimal separator
thanks,</p>
| <java><excel><apache-poi> | 2016-07-08 14:10:16 | LQ_CLOSE |
38,268,776 | Why does Typescript ignore my tsconfig.json inside Visual Studio Code? | <p>I got my project setup like this</p>
<pre><code>project/
|
+---src/
| |
| +---app/
| |
| sample.ts
|
+---typings/
+---tsconfig.json
</code></pre>
<p>and here's my <code>tsconfig.json</code></p>
<pre><code>{
"compilerOptions": {
"rootDir": "src",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"sourceMap": true,
"noImplicitAny": false,
"outDir": "dist"
},
"exclude": [
"node_modules",
"src/assets",
"src/lib"
]
}
</code></pre>
<p>What I'm wondering is, why does VSC indicate errors such as</p>
<p><a href="https://i.stack.imgur.com/m10Sk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m10Sk.png" alt="Error Highlighting in VSC"></a></p>
<p>when clearly there is no error at all (<code>"experimentalDecorators": true</code> is set in <code>tsconfig.json</code>), and the app transpiles just fine? And it's not just decorators, <code>Promise</code> and the like is highlighted as well (I made sure to have <code>tsconfig.json</code> in the same folder as <code>typings</code> and I got the typings for <code>es6-shim</code> installed).</p>
<p>Not sure if it matters, but I'm on <code>typescript@2.0.0-dev.20160707</code> at the moment. </p>
| <typescript><visual-studio-code> | 2016-07-08 14:10:23 | HQ |
38,268,929 | @RunWith(PowerMockRunner.class) vs @RunWith(MockitoJUnitRunner.class) | <p>In the usual mocking with <code>@Mock</code> and <code>@InjectMocks</code> annotations, the class under testing should be run with <code>@RunWith(MockitoJUnitRunner.class)</code>. </p>
<pre><code>@RunWith(MockitoJUnitRunner.class)
public class ReportServiceImplTestMockito {
@Mock
private TaskService mockTaskService;
@InjectMocks
private ReportServiceImpl service;
// Some tests
}
</code></pre>
<p>but in some example I am seeing <code>@RunWith(PowerMockRunner.class)</code> being used:</p>
<pre><code>@RunWith(PowerMockRunner.class)
public class Tests {
@Mock
private ISomething mockedSomething;
@Test
public void test1() {
// Is the value of mockedSomething here
}
@Test
public void test2() {
// Is a new value of mockedSomething here
}
}
</code></pre>
<p>could someone point it out whats the difference and when I want to use one instead of another?</p>
| <java><mocking><mockito><powermockito> | 2016-07-08 14:17:41 | HQ |
38,269,478 | Prevent "use strict" in typescript? | <p>When trying to load my app on an iOS device I get the following error;</p>
<p><code>VMundefined bundle.js:1722 SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.</code></p>
<p>This error occurred on iPhone 5s/6s + a couple of different iPad's I tried (can't remember which). It also did not work on the HTC one. This error did not occur on any samsung/windows phones I tried. It also worked on desktops. (I have not tried to run it on a mac yet). </p>
<p>Here is that line of code from the bundle.js;</p>
<pre><code>{}],12:[function(require,module,exports){
"use strict";
const guage_1 = require("./charts/kpi/guage");
const stacked_1 = require("./charts/area/stacked");
const barChart_1 = require("./charts/compare/barChart");
</code></pre>
<p>When I remove the "use strict" from the bundle.js it works fine on all devices. Just wondering if there is a way to make sure typescript does not compile with "use strict" or a fix for the problem with iOS devices?</p>
<p>Here is my gulpfile for compiling (followed the guide published on typescripts <a href="https://www.typescriptlang.org/docs/handbook/gulp.html" rel="noreferrer">website</a>)</p>
<pre><code>var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
source = require('vinyl-source-stream'),
tsify = require('tsify'),
browserSync = require('browser-sync'),
postcss = require('gulp-postcss'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
watchify = require("watchify"),
browserify = require('browserify'),
gutil = require("gulp-util"),
buffer = require('vinyl-buffer'),
processorArray = [
...
],
watchedBrowserify = watchify(browserify({
basedir: '.',
debug: true,
entries: ['src/main.ts'],
cache: {},
packageCache: {}
}).plugin(tsify)),
devPlugin = './src/plugins/';
function bundle() {
return watchedBrowserify
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest("dist"));
}
gulp.task('default', ['styles', 'browser-sync', 'watch'], bundle, function() {
return browserify({
basedir: '.',
debug: true,
entries: ['src/main.ts'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.transform("babelify")
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'))
});
watchedBrowserify.on("update", bundle);
watchedBrowserify.on("log", gutil.log);
</code></pre>
| <typescript> | 2016-07-08 14:44:49 | HQ |
38,269,630 | Is it possible to use dependencies without module-info.class in a Java 9 module | <p>I created two small projects <em>de.app1</em> and <em>de.app2</em>, where <code>App</code> from <em>de.app1</em> uses <code>Test</code> from <em>de.app2</em>.</p>
<pre><code>├── de.app1
│ ├── de
│ │ └── app
│ │ └── App.java
│ └── module-info.java
└── de.app2
└── de
└── test
└── Test.java
</code></pre>
<p><em>module-info.java</em> in the first project just contains <code>module de.app1 {}</code></p>
<p>I compiled the second project and created a jar file:</p>
<pre><code>javac de/test/Test.java
jar cf app2.jar de/test/Test.class
</code></pre>
<p>and then tried to compile the first project like this:</p>
<pre><code>javac -cp ../de.app2/app2.jar de/app/App.java module-info.java
</code></pre>
<p>which failed because <code>Test</code> could not be found. When I compile the project without <em>module-info.java</em>, everything is working as usual.</p>
<p>Is it somehow possible to use classes from a jar that is not a Java 9 module <em>within</em> a Java 9 module? Especially for projects that depend on 3rd-party projects (e.g. apache-commons,...), I think something like this would be required.</p>
| <java><java-9><java-platform-module-system> | 2016-07-08 14:51:39 | HQ |
38,269,883 | set value of input on form to a $_GET array | <p>I have a page that is receiving an array from $_GET. Lets say it has 3 values in $_GET['types'] containing: 'good', 'bad', and 'ugly'. Now on this page I am setting up a form and I need to pass this array into the form through an input. Maybe this short piece of code can help demonstrate what I'm trying to do</p>
<pre><code><form action="dosomething.php" method="get">
<input name="types[]" value="<?php echo $_GET['types']; ?>" />
</form>
</code></pre>
<p>How can I accomplish this?</p>
| <php><arrays><forms><input> | 2016-07-08 15:04:00 | LQ_CLOSE |
38,272,393 | ListView is null, why? | <p>In a fragment I am trying to set up a list view. In <code>onCreateView()</code> :</p>
<pre><code>mFindFriendsOptionsListView = (ListView) view.findViewById(R.id.find_friends_list_view);
mFindFriendsOptionsAdapter = new FindFriendsOptionsAdapter(mFindFriendOptionIconIds, mFindFriendOptionTitles, mFindFriendOptionDescription);
mFindFriendsOptionsListView.setAdapter(mFindFriendsOptionsAdapter);
</code></pre>
<p>Here is the xml for the list view:</p>
<pre><code><ListView
android:id="@+id/find_friends_options_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="32dp"
android:layout_alignParentTop="true"
android:divider="#999999"
android:dividerHeight="1dp"/>
</code></pre>
<p>Here is the list element xml file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="@+id/option_icon_image_view"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/option_title_text_view"
tools:text="Contacts"
android:textSize="18sp"
android:layout_marginBottom="6dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/option_description_text_view"
tools:text="Upload contacts to be your friends"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="@+id/arrow_image_view"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp" />
</RelativeLayout>
</code></pre>
<p>Here is the stacktrace:</p>
<pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at com.hb.birthpay.fragment.FindFriendFragment.onCreateView(FindFriendFragment.java:66)
</code></pre>
<p>I have debugged and the field <code>mFindFriendOptionsListView</code> is <code>null</code> even though I set it using <code>findViewById()</code>. Why is the ListView field null and how do I fix this so that I no longer get a <code>java.lang.NullPointerException</code>?</p>
| <java><android><listview><nullpointerexception><findviewbyid> | 2016-07-08 17:29:07 | LQ_CLOSE |
38,272,444 | Chart.js axes label font size | <p>In chart.js how can I set the set the font size for just the x axis labels without touching global config?</p>
<p>I've already tried setting the 'scaleFontSize' option my options object.
I've also tried setting:</p>
<pre><code>{
...
scales: {
xAxes: [{
scaleFontSize: 40
...
}]
}
}
</code></pre>
| <javascript><chart.js> | 2016-07-08 17:33:30 | HQ |
38,273,434 | PHP: put_file_content not working | <p>I have a php-script which saves a pdf from a eclipse birt report to pdf.
I'm using get file content as imput.
The birt report pdf takes some time to create.</p>
<p>I think this is the problem. </p>
<p>In the following, the script:</p>
<pre><code><?php
$rname = 'reportname';
$wname = $rname . '_' . date('d.m.Y') . '.pdf';
$pdf = file_get_contents("http://xxx.xxx.xxx.x:8080/Birt/run?__report=" . $rname . ".rptdesign&sample=my+parameter&__format=pdf");
file_put_contents('/tmp/report' . $wname, $pdf);
?>
</code></pre>
<p>What is the problem?</p>
<p>Thanks for your help :)</p>
| <php><pdf><birt> | 2016-07-08 18:42:02 | LQ_CLOSE |
38,273,904 | Linked list in c displayed with same values | <p>I have a CSV file containing lines separated by ','</p>
<p>The file looks like this:</p>
<pre><code>FIRST,00-92-93,1,0,1
SECOND,53-12-53,5,1,5
THIRD,12-33-51,5,0,51
</code></pre>
<p>Linked list looks like this:</p>
<pre><code>struct Data{
char *dat;
char *uname;
bool war_dep;
int edu_period;
bool dorms;
};
struct llist{
Data d;
llist *next;
};
</code></pre>
<p>I have a function that itterates over this file, separating each line into chunks and
adding them to a structure. </p>
<p>Here's my programm:</p>
<pre><code>void showi(llist *u){
while(u){
printf("Name: %s\t Date: %s\n", u->d.dat, u->d.uname);
u=u->next;
}
}
void inserti(llist **head, char *line){
char *tok;
llist *p=new llist;
int i=0;
tok = strtok(line, ",");
while(tok!=NULL){
switch(i){
case 0:
p->d.dat=tok;
break;
case 1:
p->d.uname=tok;
break;
case 2:
p->d.war_dep=atoi(tok);
break;
case 3:
p->d.edu_period=atoi(tok);
break;
case 4:
p->d.dorms=atoi(tok);
break;
}
i++;
tok=strtok(NULL, ",");
}
p->next=NULL;
if(*head!=NULL)
p->next=*head;
*head=p;
printf("Callback: %s\n", p->d.dat);
}
int main()
{
FILE *fp;
char line[128], *tok;
llist *head;
head = NULL;
int i=0;
fp=fopen("data.txt", "r");
while(fgets(line, sizeof(line), fp))
{
inserti(&head, line);
}
fclose(fp);
showi(head);
return 0;
}
</code></pre>
<p>When above code is executed I get callbacks from <strong>inserti</strong> (just to make sure each line is processed properly), however when I try to display my list I got only the last value (in this case I get 3 <strong>THIRD</strong>). I don't know why it happens, maybe something wrong with this piece of code in <strong>inserti</strong></p>
<pre><code>p->next=NULL;
if(*head!=NULL)
p->next=*head;
*head=p;
</code></pre>
| <c><structure> | 2016-07-08 19:16:25 | LQ_CLOSE |
38,274,160 | I'm android Problems to convert a full name of a android.widget.EditText@410e5a58 edittextview | <p>I'm android Problems to convert a full name of a android.widget.EditText@410e5a58 edittextview is the string representation of your EditText object (ie , calling the toString your EditText object will return this string) I know it's simple but , as I followed here Tips site and not getting hit.</p>
<p>coding page1 send to page2</p>
<pre><code>TextView codigo1 = (TextView)findViewById(R.id.textView1);
TextView codigo2 = (TextView)findViewById(R.id.textView2);
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("codigo1",""+codigo1 );
intent.putExtra("codigo2",""+codigo2 );
startActivity(intent);
</code></pre>
<p>XML page1</p>
<pre><code><EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Código Monitorado:"
android:textAppearance="?android:attr/textAppearanceLarge" />
</code></pre>
<p>coding page2 recive </p>
<pre><code> setContentView(R.layout.main);
String codigo1 = getIntent().getStringExtra("codigo1");
String codigo2 = getIntent().getStringExtra("codigo2");
TextView codMonitorTV = (TextView)findViewById(R.id.textViewCod1);
TextView codMonitoradoTV = (TextView)findViewById(R.id.textViewCod2);
codMonitorTV.setText(codigomonitor);
codMonitoradoTV.setText(codigomonitorado);
</code></pre>
<p>XML page2</p>
<pre><code><TextView
android:id="@+id/textViewCodMonitor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/retrieve_location_button"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textViewCodMonitorado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewCodMonitor"
android:layout_toRightOf="@+id/retrieve_location_button"
android:textAppearance="?android:attr/textAppearanceSmall" />
</code></pre>
<p>I type in 1234 and get android.widget.EditText@410e5a58</p>
| <java><android> | 2016-07-08 19:34:41 | LQ_CLOSE |
38,274,206 | Using regex with notepad++ to get specific words only | <p>I'm trying to get export the following format into normal wording format</p>
<pre><code>#EXTINF:0 tvg-id="ChannelName" tvg-name="ChannelName" group-title="CATEGORY" tvg-logo="jpglink",AXN http://streamlink.m3u8
</code></pre>
<p>im able to do one at time using notepad++ with bookmarks but it can only work if i search for m3u8 or jpg but i can't get the tv-id or tv-name neither group-title name so the export of above format should look like this</p>
<p>ChannelName ChannelName CATEGORY jpglink <a href="http://streamlink.m3u8" rel="nofollow">http://streamlink.m3u8</a></p>
<p>any help will be appreciated thanks</p>
| <regex><notepad++> | 2016-07-08 19:37:17 | LQ_CLOSE |
38,274,493 | compare 2 string arraylist and get same value in console | I have 2 below string array list.
ArrayList<String> sourceArray = [bg, zh_cn, cs, da, en_us];
ArrayList<String> targetArray = [bg, pt, ru, sg, da, en_us];
I want to write the code in java, where I will compare this two arraylist get the same value in output, like below.
If sourceArray equalis to targetArray then it should print below
System.out.println("bg is similar in both array");
Can anybody tell me how can I proceed with this..
My output should be as below:
**bg is similar in both array
da is similar in both array
en_us is similar in both array** | <java><arraylist> | 2016-07-08 19:58:13 | LQ_EDIT |
38,274,496 | String builder underline text | <p>How can I underline text in a string builder ?</p>
<pre><code>strBody.Append("be a minimum of 8 characters")
</code></pre>
<p>I can't use HTML tags </p>
<pre><code>be a minimum of <u>8 characters</u>
</code></pre>
| <c#><vb.net> | 2016-07-08 19:58:27 | LQ_CLOSE |
38,274,821 | SQL Server - How to get list of tables that needs tuning | I have a database with tables that grow every day and i cannot predict which table is going to grow and which will not as I'm not the one who is filling the data into them.
Is there a way to find tables that needs indexes at a particular period of time?
Is there a way in SQL Server to notify me that after a period of time when database grows it needs tuning on certain tables which is slow to load?
Note:As per my understanding we must not create indexes on an empty table as it can affect the performance. So i cannot create indexes while installing databases when the tables are having less rows or even empty. | <sql><sql-server><performance><sql-server-2008> | 2016-07-08 20:21:56 | LQ_EDIT |
38,275,302 | Regex use in Notepad++, searching | <p>I have a bunch of JSON key-value pairs. Most of them are empty, like this </p>
<pre><code>"object": []
</code></pre>
<p>However, some of them aren't. I want to use Notepad++'s regex search to find every "object" that has something between the []. I know this is a very basic question, but I don't know anything about regexes except that they could probably be used to solve this problem. If someone can take a few seconds to answer my question it'd save me a lot of searching. Thanks!</p>
| <regex><notepad++> | 2016-07-08 20:57:18 | LQ_CLOSE |
38,275,348 | Update a filter in a SQL select code | <p>I want to update the a filter in the following code I wrote. I am confused how to put.</p>
<p>Code is:</p>
<pre><code>$query = "SELECT P.`Building_info` as `name`,P.`Area` as `area`,
avg(
CASE
WHEN P.`Bedroom`='4'
THEN P.`$price`
ELSE NULL
END
) AS 'Beds_4',
avg(
CASE
WHEN P.`Bedroom`='5'
THEN P.`$price`
ELSE NULL
END
) AS 'Beds_5'
FROM All_Rent P
WHERE P.Building_info<>''
AND Sale_Rent='$accom'
AND converted_date > '$min_date'
GROUP BY P.`Building_info`";
</code></pre>
<p>I want to add a filter where <code>Area = "Euston Road"</code> i.e. select only the areas with the name "Euston Road"</p>
<p>Can anyone help? </p>
| <php><mysql><sql><subquery> | 2016-07-08 21:02:26 | LQ_CLOSE |
38,275,467 | Send table as an email body (not attachment ) in Python | <p>My input file is a CSV file and by running some python script which consists of the python Tabulate module, I have created a table that looks like this below:-</p>
<p><a href="http://i.stack.imgur.com/Lmjt1.png" rel="noreferrer">tabulate_output</a>
or </p>
<pre><code>| Attenuation | Avg Ping RTT in ms | TCP UP |
|---------------:|---------------------:|---------:|
| 60 | 2.31 | 106.143 |
| 70 | 2.315 | 103.624 |
</code></pre>
<p>I would like to send the this table in the email body and <strong>not as an</strong> <strong>attachment</strong> using python.</p>
<p>I have created a sendMail function and will be expecting to send the table in the mail_body.
<code>sendMail([to_addr], from_addr, mail_subject, mail_body, [file_name])
</code></p>
| <python><email><html-email> | 2016-07-08 21:13:11 | HQ |
38,275,583 | create version.txt file in project dir via build.gradle task | <p>Apologies in advance for my ignorance. I'm very new to gradle.</p>
<p>My is goal is to have some task in my build.gradle file, wherein a file 'version.txt' is created in my project directory whenever I run the <code>gradle</code> terminal command in my project root. This 'version.txt' file needs to contain version metadata of the build, such as:</p>
<p><code>Version: 1.0
Revision: 1z7g30jFHYjl42L9fh0pqzmsQkF
Buildtime: 2016-06-14 07:16:37 EST
Application-name: foobarbaz app</code></p>
<p>(^Revision would be the git commit hash of the HEAD)</p>
<p>I've tried to reuse snippets from the following resources, but to no avail, possibly because these resources are out of date:
<a href="http://mrhaki.blogspot.com/2015/04/gradle-goodness-use-git-commit-id-in.html" rel="noreferrer">http://mrhaki.blogspot.com/2015/04/gradle-goodness-use-git-commit-id-in.html</a>
<a href="http://mrhaki.blogspot.com/2010/10/gradle-goodness-add-incremental-build.html" rel="noreferrer">http://mrhaki.blogspot.com/2010/10/gradle-goodness-add-incremental-build.html</a></p>
<p>I'm using gradle version 2.14 (which is the latest version).</p>
<p>Any help and/or insight would be very much appreciated. Thanks!</p>
| <git><file><gradle><build.gradle><versioning> | 2016-07-08 21:22:52 | HQ |
38,275,880 | Charles proxy shows IP addresses instead of domain names | <p>Charles for me shows IP addresses instead of domain names. Has anyone else seen this problem. See the attached screenshot.</p>
<p><a href="https://i.stack.imgur.com/PXG06.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PXG06.png" alt="Charles screenshot"></a></p>
| <charles-proxy> | 2016-07-08 21:52:14 | HQ |
38,276,007 | how to define dynamic nested loop python function | <pre><code>a = [1]
b = [2,3]
c = [4,5,6]
d = [a,b,c]
for x0 in d[0]:
for x1 in d[1]:
for x2 in d[2]:
print(x0,x1,x2)
</code></pre>
<p>Result:</p>
<pre><code>1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
</code></pre>
<p>Perfect, now my question is how to define this to function, considering ofcourse there could be more lists with values. The idea is to get function, which would dynamicaly produce same result.</p>
<p>Is there a way to explain to python: "do 8 nested loops for example"?</p>
| <function><loops><dynamic><nested><python-3.5> | 2016-07-08 22:04:22 | HQ |
38,276,209 | Setting up Flashlight on Heroku for ElasticSearch with new Firebase | <p>My goal is to connect Firebase with ElasticSearch for indexing so that I can implement "like" queries when searching usernames in my iOS app. From what I've read this is the best solution, and I want to tackle it this way early in order to be scalable instead of brute-forcing it.</p>
<p>To achieve this, I'm trying to deploy the <a href="https://github.com/firebase/flashlight" rel="noreferrer">flashlight</a> app that Firebase developers have provided for us onto a Heroku, but I'm confused on how to go about doing it. Please correct me where I'm wrong, I'm fairly new to the Heroku ecosystem, ElasticSearch, and nodejs.</p>
<p>I currently have a Heroku account, and have the toolbelt and nodejs/npm installed on my computer (Mac). I've run the following commands:</p>
<pre><code>git clone https://github.com/firebase/flashlight
cd flashlight
heroku login
heroku create
heroku addons:add bonsai
heroku config
</code></pre>
<p>(I was able to get my bonsai url successfully with the heroku config command)</p>
<p>The next step is</p>
<pre><code>heroku config:set FB_NAME=<instance> FB_TOKEN="<token>"
</code></pre>
<p>But I don't really understand what FB_NAME (my guess is Firebase app name, but is that the name of my app? or with the letters/numbers following it due to the new Firebase setup where it's no longer <code>app_name.firebaseio.com</code> but <code>app_name-abc123.firebaseio.com</code>) and what is FB_TOKEN? (is it a key or something in my plist I download?)</p>
| <ios><node.js><heroku><elasticsearch><firebase> | 2016-07-08 22:25:44 | HQ |
38,276,584 | How to learn android development efficiently? | <p>It's been around 1 month that I have started to work on Android to create an app, I understood the basics (Views, widgets, intent ...) and I use a lot developer.android.com to ancknowledge new things but when I try to do complex things, such as creating a camera preview inside my app, I feel like I am Ctrl+C and Ctrl+V the code that is provided without really understanding it. And most of the time my app crashes.</p>
<p>So, do you have any tips for me to make things easier ? </p>
| <android> | 2016-07-08 23:10:12 | LQ_CLOSE |
38,276,695 | Does Firebase still support Mac OS X - July 2016 | <p>I have an iOS App that uses the Firebase Realtime Database that I would like to create for Mac OS X. Does Firebase still support Mac OS X in the latest update as the Firebase console only shows the option to Add Firebase to an iOS, Android or web app.</p>
<p>If so, where can I find it?</p>
<p>Thank you</p>
| <ios><macos><firebase><firebase-realtime-database> | 2016-07-08 23:25:51 | HQ |
38,276,742 | Global const char pointer array in C/C++ | I have defined a const char pointer array in header file. Array contains multiple strings. Now I have to find a string at particular index. I don't know how should I access this array from another files. Please see my code:
common.h
extern const char *lookup_str[] = {"test Str0", "test Str1", "test Str2", "test Str3"};
file1.c
int ret = 3;
std::string r = lookup_str[ret];
Can I use this way in all my C files? Any suggestion/help is much appreciated. Thank you in advance !
| <c++><arrays><pointers> | 2016-07-08 23:32:24 | LQ_EDIT |
38,276,960 | What is the recommended directory structure for a Rust project? | <p>Where should one put the sources, examples, documentation, unit tests, integration tests, license, benchmarks <em>etc</em>?</p>
| <rust> | 2016-07-09 00:03:51 | HQ |
38,277,165 | how to select element text with react+enzyme | <p>Just what it says. Some example code:</p>
<pre><code>let wrapper = shallow(<div><button class='btn btn-primary'>OK</button></div>);
const b = wrapper.find('.btn');
expect(b.text()).to.be.eql('OK'); // fails,
</code></pre>
<p>Also the <code>html</code> method returns the contents of the element but also the element itself plus all the attributes, e.g. it gives <code><button class='btn btn-primary'>OK</button></code>. So I guess, worst case, I can call <code>html</code> and regex it, but...</p>
<p>Is there a way to just get the contents of the element, so I can assert on it. </p>
| <reactjs><enzyme> | 2016-07-09 00:43:12 | HQ |
38,278,361 | How to take input from text file for adjacency matrix in c language | <p>Here is the inline input for my code.</p>
<pre><code>int graph[V][V] = {{0, 2, 0, 6, 0},
{2, 0, 3, 8, 5},
{0, 3, 0, 0, 7},
{6, 8, 0, 0, 9},
{0, 5, 7, 9, 0},
};
</code></pre>
<p>I want to take this graph input from the text file to the graph array.</p>
| <c> | 2016-07-09 04:32:56 | LQ_CLOSE |
38,278,403 | Java Multiple Input in a Single row | <p>Enter any number of integer values in a single row separated by space and the calculate and print the sum to next line.</p>
<p>EX: input: 1 2 3 4
output: 10</p>
| <java><input><row> | 2016-07-09 04:41:15 | LQ_CLOSE |
38,279,169 | False Iterations in Tparallel.for | I have a problem with number of iterations in Tparallel.for.
i have 100 folder and in each folder exist a file to be run (run.bat).
After run the out.txt file is created in folder.when i use Tparalle.for with 100 iterations, i recieve randomly 90 to 98 out.txt while it be 100.
my code is as below (Delphi XE7):
Tparallel.for(1,100.procedure(i:integer)
begin
setcurrentdir(path+'\test\'+inttostr(i));
winexec32andwait(pchar('run.bat'),0);
end);
can you help me?
| <delphi><delphi-xe7> | 2016-07-09 06:47:00 | LQ_EDIT |
38,279,477 | how to start the second activity from the first, directly, not through a button | All the textbooks/guides start the second activity via click a button.
I thought I can start it directly by just removing the button codes.
Obvious I was wrong. Below code reports "Unfortunately, the xxxx has stopped".
So, my question: ow to start the second activity from the first?
(I can't believe I am the only newbies need to seek help on this while others figured it out by themselves for I can not google the similar question)
Thanks.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent iCodes = new Intent(this, OtherActivity.class);
startActivity(iCodes);
} | <android> | 2016-07-09 07:32:14 | LQ_EDIT |
38,280,584 | Python: parse all files in a folder | <p>I am trying to parse allthe files in a folder with help of a python loop and then store it as a dataframe, I am using following script </p>
<pre><code>path='C:\\Users\\manusharma\\Training'
for filename in os.listdir(path):
tree = ET.parse(filename)
a = ET.tostring(tree.getroot(), encoding='utf-8', method='text')
c = a.replace('\n', '')
df = df.append({'text': c, 'type': 'abc'}, ignore_index=True)
</code></pre>
<p>and my path file has following files </p>
<pre><code>abc1.xml
abc2.xml
abc3.xml
abc4.xml
abc5.xml
</code></pre>
<p>every time, I ran my code it show me an error </p>
<pre><code>IOError: [Errno 2] No such file or directory: 'abc1'
</code></pre>
<p>though it is there, where am I making an error? Appreciate every help</p>
| <python><xml><pandas><for-loop> | 2016-07-09 09:58:01 | LQ_CLOSE |
38,281,687 | How to create screen sharing application C# | <p>I have recently tried to make a screen sharing application, but it does not work. It works to share my own screen for myself, but not with my friend. Does the other user need to be connected to the same internet? I would really appreciate some help! :)</p>
| <c#><ip><port><screensharing> | 2016-07-09 12:11:03 | LQ_CLOSE |
38,281,748 | how to do average in R or xcel | I have a big data set something like this below
image length angle
DSC_0001.JPG 13 22.619865
DSC_0001.JPG 21.470911 27.758541
DSC_0001.JPG 10.198039 11.309933
DSC_0001.JPG 115.97414 60.561512
DSC_0001.JPG 16.27882 79.38035
DSC_0001.JPG 22.803509 15.255118
DSC_0001.JPG 22.825424 28.810793
DSC_0001.JPG 151.0298 1.138177
DSC_0001.JPG 13.038404 85.601295
DSC_0001.JPG 16.124516 7.125016
DSC_0001.JPG 18.027756 3.17983
DSC_0001.JPG 10.198039 11.309933
DSC_0001.JPG 26.832815 26.565052
DSC_0001.JPG 17 61.927513
DSC_0001.JPG 12.165525 80.53768
DSC_0001.JPG 12.206555 55.00798
DSC_0001.JPG 12.727922 45
DSC_0001.JPG 76.02631 63.434948
DSC_0001.JPG 18.248287 9.462322
DSC_0002.JPG 17.492855 59.036243
DSC_0002.JPG 28.160255 6.115504
DSC_0002.JPG 10.049875 84.289406
DSC_0002.JPG 33.970577 42.614056
DSC_0002.JPG 10.440307 16.699244
DSC_0002.JPG 15.231546 66.80141
DSC_0002.JPG 19.723083 30.465546
DSC_0002.JPG 75.802376 53.583622
DSC_0002.JPG 5.8309517 30.963757
I want to do average of "Length" and "angles" for each set(DSC_001 is one set, DSC_002 is another and so on)
I can do it manually in excel but taking huge time when it around 4000 data point.
I like to know how I do it in R or in excel in much smarter way?
| <r><excel-formula> | 2016-07-09 12:21:01 | LQ_EDIT |
38,281,760 | Using retryWhen to update tokens based on http error code | <p>I found this example on <a href="http://sapandiwakar.in/refresh-oauth-tokens-using-moya-rxswift/" rel="noreferrer">How to refresh oauth token using moya and rxswift</a> which I had to alter slightly to get to compile. This code works 80% for my scenario. The problem with it is that it will run for all http errors, and not just 401 errors. What I want is to have all my other http errors passed on as errors, so that I can handle them else where and not swallow them here.</p>
<p>With this code, if I get a <code>HttpStatus 500</code>, it will run the authentication code 3 times which is obviously not what I want.</p>
<p>Ive tried to alter this code to handle only handle <code>401</code> errors, but it seem that no matter what I do I can't get the code to compile. It's always complaining about wrong return type, <code>"Cannot convert return expression of type Observable<Response> to return type Observable<Response>"</code> which makes no sense to me..</p>
<p>What I want: handle 401, but stop on all other errors</p>
<pre><code>import RxSwift
import KeychainAccess
import Moya
public extension ObservableType where E == Response {
/// Tries to refresh auth token on 401 errors and retry the request.
/// If the refresh fails, the signal errors.
public func retryWithAuthIfNeeded() -> Observable<E> {
return self.retryWhen {
(e: Observable<ErrorType>) in
return Observable.zip(e, Observable.range(start: 1, count: 3), resultSelector: { $1 })
.flatMap { i in
return AuthProvider.sharedInstance.request(
.LoginFacebookUser(
accessToken: AuthenticationManager.defaultInstance().getLoginTokenFromKeyChain(),
useFaceBookLogin: AuthenticationManager.defaultInstance().isFacebookLogin())
)
.filterSuccessfulStatusCodes()
.mapObject(Accesstoken.self)
.catchError {
error in
log.debug("ReAuth error: \(error)")
if case Error.StatusCode(let response) = error {
if response.statusCode == 401 {
// Force logout after failed attempt
log.debug("401:, force user logout")
NSNotificationCenter.defaultCenter().postNotificationName(Constants.Notifications.userNotAuthenticated, object: nil, userInfo: nil)
}
}
return Observable.error(error)
}.flatMapLatest({
token -> Observable<Accesstoken> in
AuthenticationManager.defaultInstance().storeServiceTokenInKeychain(token)
return Observable.just(token)
})
}
}
}
}
</code></pre>
| <ios><swift><alamofire><rx-swift><moya> | 2016-07-09 12:22:27 | HQ |
38,281,883 | Check whether cell at indexPath is visible on screen UICollectionView | <p>I have a <code>CollectionView</code> which displays images to the user. I download these in the background, and when the download is complete I call the following func to update the <code>collectionViewCell</code> and display the image. </p>
<pre><code>func handlePhotoDownloadCompletion(notification : NSNotification) {
let userInfo:Dictionary<String,String!> = notification.userInfo as! Dictionary<String,String!>
let id = userInfo["id"]
let index = users_cities.indexOf({$0.id == id})
if index != nil {
let indexPath = NSIndexPath(forRow: index!, inSection: 0)
let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
if (users_cities[index!].image != nil) {
cell.backgroundImageView.image = users_cities[index!].image!
}
}
}
</code></pre>
<p>This works great if the cell is currently visible on screen, however if it is not I get a
<code>fatal error: unexpectedly found nil while unwrapping an Optional value</code> error on the following line : </p>
<pre><code> let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
</code></pre>
<p>Now this function does not even need to be called if the collectionViewCell is not yet visible, because in this case the image will be set in the <code>cellForItemAtIndexPath</code> method anyway.</p>
<p>Hence my question, how can I alter this function to check whether the cell we are dealing with is currently visible or not. I know of the <code>collectionView.visibleCells()</code> however, I am not sure how to apply it here. </p>
| <ios><swift><uicollectionview><uicollectionviewcell><nsindexpath> | 2016-07-09 12:38:45 | HQ |
38,282,206 | How to generate a random sequence of numbers in python? | <p>I need to create a short unique ID which is a random sequence of numbers in python. So i need to allocate the short sequence to a user and also store it in a text file</p>
<p>Can some one please help me with this and give me an example??</p>
| <python><random><numbers><unique> | 2016-07-09 13:15:27 | LQ_CLOSE |
38,282,799 | I don't understand why all the data gets printed in the arrange method correctly but does not get printed in the print method. | In tree class there is a method called arrange().When i print any node value within the arrange ()method the value comes to be accurate but when i use the method print() in tree class i get a null pointer exception, please help!!
public class Node {
Node lnode;
Node rnode;
int data;
public Node(String d)
{
data=Integer.parseInt(d);
this.rnode=null;
this.lnode=null;
}
}
public class tree {
public void arrange(String s[],int n,Node r)
{
Node root=new Node(s[0]);
for(int i=1;i<n;i++)
{
r=root;
if(Integer.parseInt(s[i])>root.data&&root.rnode==null)
{
root.rnode=new Node(s[i]);
}
else if(Integer.parseInt(s[i])<root.data&&root.lnode==null)
root.lnode=new Node(s[i]);
while(!(r.rnode==null)&&(Integer.parseInt(s[i]))>r.data)
{
r=r.rnode;
if(Integer.parseInt(s[i])>r.data&&r.rnode==null)
r.rnode=new Node(s[i]);
else if(Integer.parseInt(s[i])<r.data&&r.lnode==null)
r.lnode=new Node(s[i]);
}
while(!(r.lnode==null)&&(Integer.parseInt(s[i]))<r.data)
{
r=r.lnode;
if(Integer.parseInt(s[i])>r.data&&r.rnode==null)
r.rnode=new Node(s[i]);
else if(Integer.parseInt(s[i])<r.data&&r.lnode==null)
r.lnode=new Node(s[i]);
}
}
**System.out.println(root.rnode.data);**
}
public void print(Node r)
{
System.out.println(r.rnode.data);
}
} | <java><binary-search-tree> | 2016-07-09 14:24:02 | LQ_EDIT |
38,282,973 | Difference between "public" and "void" | <p>I am learning java programming from <a href="http://courses.caveofprogramming.com/courses/java-for-complete-beginners/lectures/38443" rel="nofollow">http://courses.caveofprogramming.com/courses/java-for-complete-beginners/lectures/38443</a></p>
<p>This guy, till now have been using the <code>void</code> keyword before declaring any method but once he reached to the <em>passing parameters in methods</em> part, he starting using the <code>public</code> keyword instead of the void keyword. Why did he start using <code>public</code> instead of <code>void</code>?</p>
<p>I have a vague understanding of both the keyword but it would be better if you could explain these keywords to me too.</p>
| <java> | 2016-07-09 14:43:46 | LQ_CLOSE |
38,283,287 | How to get a length of object in array of objects based on key | I have array with six objects,i want to get a object length based on key value(if it is repeated means,i want to get the length of ii as 2).This is my array of object structure.
[
{
"name":"aaa",
"id":"2100",
"designation":"developer"
},
{
"name":"bbb",
"id":"8888",
"designation":"team lead"
},
{
"name":"ccc",
"id":"6745",
"designation":"manager"
},
{
"name":"aaa",
"id":"9899",
"designation":"sw"
}
]
Any help would be appreciated... | <javascript> | 2016-07-09 15:19:33 | LQ_EDIT |
38,283,630 | Traversing,Insertion and Deletion in LinkedList data structure in java | <p>I am new to data structures. I am very curious to learn data structures, but i didnt find any healthy tutorial for that so I am posting it here thinking someone would help me. I know theory of linked list but m totally blank while implementation. If Someone can make me understand how it works that would be really helpful for me.Like, how to traverse through Linked List ,insert and delete. Please provide me a running code so that its easy for me to understand.
<strong>I KNOW there are lot of peoples who will think to mark this question as a duplicate and downvote this. Rather than finding mistakes if you guys provide me a good solution that would be really Helpful. Thanks.</strong> </p>
| <java><arrays><data-structures><linked-list> | 2016-07-09 15:56:21 | LQ_CLOSE |
38,284,094 | How do you use Python to clean API results to get say just the headlines of the news articles? | I am very new to programming using Python and have been having trouble finding a way to pull out specific text info from the Guardian API for my dissertation. I have managed to get all my text onto Python but how do you then clean it to get say, just the headlines of the news articles?
This is a snippet of the API result that I want to pull out info from:
{"response":{"status":"ok","userTier":"developer","total":1869990,"startIndex":1,"pageSize":10,"currentPage":1,"pages":186999,"orderBy":"newest","results":[{"id":"sport/live/2016/jul/09/tour-de-france-2016-stage-eight-live","type":"liveblog","sectionId":"sport","sectionName":"Sport","webPublicationDate":"2016-07-09T13:21:36Z","webTitle":"Tour de France 2016: stage eight – live!","webUrl":"https://www.theguardian.com/sport/live/2016/jul/09/tour-de-france-2016-stage-eight-live","apiUrl":"https://content.guardianapis.com/sport/live/2016/jul/09/tour-de-france-2016-stage-eight-live","isHosted":false},{"id":"sport/live/2016/jul/09/serena-williams-v-angelique-kerber-wimbledon-womens-final-live","type":"liveblog","sectionId":"sport","sectionName":"Sport","webPublicationDate":"2016-07-09T13:21:02Z","webTitle":"Serena Williams v Angelique Kerber: Wimbledon women's final –
Any help would be greatly appreciated! Many thanks!
I am also more familiar with R so if anyone knows of any easier way there let me know. Otherwise I would like to know the Python way as well. | <python><api> | 2016-07-09 16:50:42 | LQ_EDIT |
38,284,344 | Given three numbers, two are guaranteed equal, find the different number. | <p>For example: A = 2, B = 4 & C = 2 then output should be uniqueNumber(A, B, C) = 4</p>
| <php> | 2016-07-09 17:19:20 | LQ_CLOSE |
38,284,413 | assignment makes integer from pointer without a cast c[a0][4]="YES"; i cant get it what is wrong int it integer t is already decleared | <p>warning: assignment makes integer from pointer without a cast
c[a0][4]="YES"; i cant get it what is wrong int it integer t is already decleared </p>
<pre><code>char c[t][4];
for(int a0 = 0; a0 < t; a0++)
{
int n;
int k;
scanf("%d %d",&n,&k);
int a[n];
for(int a_i = 0; a_i < n; a_i++)
{
scanf("%d",&a[a_i]);
if(a[a_i]<=0)
{
count++;
}
}
if(count>=k)
c[a0][4]="NO";
else
c[a0][4]="YES";
count=0;
}
for(int p=0;p<t;p++)
printf("%c \n",c[p][4]);
</code></pre>
| <c><string> | 2016-07-09 17:26:24 | LQ_CLOSE |
38,284,518 | Firebase dynamic link support custom parameters? | <p>I am writing a App for a Open Source Conference.</p>
<p>Originally each attendees will receive different link via email or SMS like</p>
<p><a href="https://example.com/?token=fccfc8bfa07643a1ca8015cbe74f5f17" rel="noreferrer">https://example.com/?token=fccfc8bfa07643a1ca8015cbe74f5f17</a></p>
<p>then use this link to open app, we can know the user is which attendee by the token.</p>
<p>Firebase release a new feature Dynamic Links in I/O 2016, it provide better experience for users.</p>
<p>I had try that, but I can't find any way to pass the custom parameters (the token) in dynamic links, how to use the same link with different parameters to my users?</p>
<p>Thanks.</p>
| <firebase><firebase-dynamic-links> | 2016-07-09 17:38:42 | HQ |
38,284,908 | how to split string taken as input and i want to separate it with comas in c | char exp[50];
// printf("Enter the postfix expression :");
// scanf("%s", exp);
my desired output is when 567+* as input
5,newline
5,6,newline
5,6,7,newline......
| <c> | 2016-07-09 18:20:01 | LQ_EDIT |
38,285,005 | Why I am getting the below error? I interchanged the class names and there was no error. | [enter image description here][1]
[1]: http://i.stack.imgur.com/IbCWi.png
I am executing this in java 8. I tried interchanging the class name. While i did that, I also shuffled the main method. I was getting no errors. It is the only scenario where i am getting an error. I am not getting why. Please help. | <java><inheritance><main> | 2016-07-09 18:30:33 | LQ_EDIT |
38,285,282 | Where is the certificates folder for Docker Beta for Mac | <p>I can't find any certificate files created by <code>Docker Beta for Mac</code>. I need it for my IDE connection to Docker.</p>
| <docker> | 2016-07-09 18:59:14 | HQ |
38,286,704 | How can I share config file like appsettings.json across multiple ASP.NET CORE projects in one solution in Visual Studio 2015? | <p>I have 3 ASP.NET CORE projects in one solution and I want to share connection string information in one config file like appsettings.json across these projects.</p>
<p>How can I do this in Visual Studio 2015 ?</p>
| <asp.net><json><asp.net-mvc><visual-studio><asp.net-core> | 2016-07-09 21:57:12 | HQ |
38,286,717 | TensorFlow - regularization with L2 loss, how to apply to all weights, not just last one? | <p>I am playing with a ANN which is part of Udacity DeepLearning course.</p>
<p>I have an assignment which involves introducing generalization to the network with one hidden ReLU layer using L2 loss. I wonder how to properly introduce it so that ALL weights are penalized, not only weights of the output layer.</p>
<p>Code for network <em>without</em> generalization is at the bottom of the post (code to actually run the training is out of the scope of the question).</p>
<p>Obvious way of introducing the L2 is to replace the loss calculation with something like this (if beta is 0.01):</p>
<pre><code>loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(out_layer, tf_train_labels) + 0.01*tf.nn.l2_loss(out_weights))
</code></pre>
<p>But in such case it will take into account values of output layer's weights. I am not sure, how do we properly penalize the weights which come INTO the hidden ReLU layer. Is it needed at all or introducing penalization of output layer will somehow keep the hidden weights in check also?</p>
<pre><code>#some importing
from __future__ import print_function
import numpy as np
import tensorflow as tf
from six.moves import cPickle as pickle
from six.moves import range
#loading data
pickle_file = '/home/maxkhk/Documents/Udacity/DeepLearningCourse/SourceCode/tensorflow/examples/udacity/notMNIST.pickle'
with open(pickle_file, 'rb') as f:
save = pickle.load(f)
train_dataset = save['train_dataset']
train_labels = save['train_labels']
valid_dataset = save['valid_dataset']
valid_labels = save['valid_labels']
test_dataset = save['test_dataset']
test_labels = save['test_labels']
del save # hint to help gc free up memory
print('Training set', train_dataset.shape, train_labels.shape)
print('Validation set', valid_dataset.shape, valid_labels.shape)
print('Test set', test_dataset.shape, test_labels.shape)
#prepare data to have right format for tensorflow
#i.e. data is flat matrix, labels are onehot
image_size = 28
num_labels = 10
def reformat(dataset, labels):
dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32)
# Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...]
labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32)
return dataset, labels
train_dataset, train_labels = reformat(train_dataset, train_labels)
valid_dataset, valid_labels = reformat(valid_dataset, valid_labels)
test_dataset, test_labels = reformat(test_dataset, test_labels)
print('Training set', train_dataset.shape, train_labels.shape)
print('Validation set', valid_dataset.shape, valid_labels.shape)
print('Test set', test_dataset.shape, test_labels.shape)
#now is the interesting part - we are building a network with
#one hidden ReLU layer and out usual output linear layer
#we are going to use SGD so here is our size of batch
batch_size = 128
#building tensorflow graph
graph = tf.Graph()
with graph.as_default():
# Input data. For the training data, we use a placeholder that will be fed
# at run time with a training minibatch.
tf_train_dataset = tf.placeholder(tf.float32,
shape=(batch_size, image_size * image_size))
tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels))
tf_valid_dataset = tf.constant(valid_dataset)
tf_test_dataset = tf.constant(test_dataset)
#now let's build our new hidden layer
#that's how many hidden neurons we want
num_hidden_neurons = 1024
#its weights
hidden_weights = tf.Variable(
tf.truncated_normal([image_size * image_size, num_hidden_neurons]))
hidden_biases = tf.Variable(tf.zeros([num_hidden_neurons]))
#now the layer itself. It multiplies data by weights, adds biases
#and takes ReLU over result
hidden_layer = tf.nn.relu(tf.matmul(tf_train_dataset, hidden_weights) + hidden_biases)
#time to go for output linear layer
#out weights connect hidden neurons to output labels
#biases are added to output labels
out_weights = tf.Variable(
tf.truncated_normal([num_hidden_neurons, num_labels]))
out_biases = tf.Variable(tf.zeros([num_labels]))
#compute output
out_layer = tf.matmul(hidden_layer,out_weights) + out_biases
#our real output is a softmax of prior result
#and we also compute its cross-entropy to get our loss
loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(out_layer, tf_train_labels))
#now we just minimize this loss to actually train the network
optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
#nice, now let's calculate the predictions on each dataset for evaluating the
#performance so far
# Predictions for the training, validation, and test data.
train_prediction = tf.nn.softmax(out_layer)
valid_relu = tf.nn.relu( tf.matmul(tf_valid_dataset, hidden_weights) + hidden_biases)
valid_prediction = tf.nn.softmax( tf.matmul(valid_relu, out_weights) + out_biases)
test_relu = tf.nn.relu( tf.matmul( tf_test_dataset, hidden_weights) + hidden_biases)
test_prediction = tf.nn.softmax(tf.matmul(test_relu, out_weights) + out_biases)
</code></pre>
| <machine-learning><neural-network><tensorflow><deep-learning><regularized> | 2016-07-09 22:00:33 | HQ |
38,287,374 | In Mongo what is the difference between $near and $nearSphere? | <p>I read the docs and its not very clear what the difference is between the two.</p>
<p>The only difference I found is that in nearSphere it explicitly says that Mongo calculates distances for $nearSphere using spherical geometry. But this is achievable using $near as well is it not?</p>
| <mongodb> | 2016-07-10 00:02:27 | HQ |
38,287,456 | Access Object in Javascript Model | <p>I fetch data from a model in Angular service , and in console log the data become like this. </p>
<pre><code>console.log(serces);
alModel {info: Object}
info: Object
ProductName:"test product al"
StartTime:"00:00:00"
StopTime:"00:00:00"
__proto__:Object
__proto__:Object
</code></pre>
<p>How do I to get the <code>ProductName</code> from there? </p>
<p>Please help, many thanks in advance. </p>
| <javascript><angularjs> | 2016-07-10 00:17:06 | LQ_CLOSE |
38,287,772 | CBOW v.s. skip-gram: why invert context and target words? | <p>In <a href="https://www.tensorflow.org/versions/r0.9/tutorials/word2vec/index.html#vector-representations-of-words" rel="noreferrer">this</a> page, it is said that: </p>
<blockquote>
<p>[...] skip-gram inverts contexts and targets, and tries to predict each context word from its target word [...]</p>
</blockquote>
<p>However, looking at the training dataset it produces, the content of the X and Y pair seems to be interexchangeable, as those two pairs of (X, Y): </p>
<blockquote>
<p><code>(quick, brown), (brown, quick)</code></p>
</blockquote>
<p>So, why distinguish that much between context and targets if it is the same thing in the end? </p>
<p>Also, doing <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/5_word2vec.ipynb" rel="noreferrer">Udacity's Deep Learning course exercise on word2vec</a>, I wonder why they seem to do the difference between those two approaches that much in this problem: </p>
<blockquote>
<p>An alternative to skip-gram is another Word2Vec model called CBOW (Continuous Bag of Words). In the CBOW model, instead of predicting a context word from a word vector, you predict a word from the sum of all the word vectors in its context. Implement and evaluate a CBOW model trained on the text8 dataset.</p>
</blockquote>
<p>Would not this yields the same results?</p>
| <nlp><tensorflow><deep-learning><word2vec><word-embedding> | 2016-07-10 01:21:34 | HQ |
38,287,910 | How can I generate NSManagedObject classes in Swift instead of Objective C in Xcode 8? | <p>I'm building a Core Data application using Swift 3 and Xcode 8 beta and when I generate the NSManagedObject subclasses Xcode gives me Objective-C files instead of Swift.</p>
<p>While I am very aware that I can simply write my own NSManagedObject subclasses in Swift I'd like to know how to switch the language of the generated code from Objective-C to Swift.</p>
<h2>Question</h2>
<p>How can I generate NSManagedObject classes in Swift instead of Objective C in Xcode 8?</p>
| <xcode><core-data><swift3><xcode8> | 2016-07-10 01:56:46 | HQ |
38,288,048 | C++ Start Process / Apllication | I have a dll source file, I want to create a function in it, which call an exe.
The exe is in the Data/Common/PPI.exe How can I start this from the c++ code?
I tryed with CreateProcess and ShellExec, can anybody create an example for me to know how to make it, with this path and with this exe name.
I dont want to add the full directory path because if its changed or something I need to rebuild the exe... so the dll is in the root folder the dll call this function and the function start the Data/common/PPI.exe, thats it all.
Thanks! | <c++> | 2016-07-10 02:30:05 | LQ_EDIT |
38,288,110 | Get value in list on python | See the code
mult = [lambda x, i=i:x*i for i in range(4)]
for v in mult:
print(v)
But my return value is:
<function <listcomp>.<lambda> at 0x7fd8b26b9d08>
<function <listcomp>.<lambda> at 0x7fd8b26b9d90>
<function <listcomp>.<lambda> at 0x7fd8b26b9ae8>
<function <listcomp>.<lambda> at 0x7fd8b26b9a60>
can i get a real value?
| <python><lambda><list-comprehension> | 2016-07-10 02:43:50 | LQ_EDIT |
38,289,101 | Boost Program Options dependent options | <p>Is there any way of making program options dependent on other options using <code>boost::program_options</code>?</p>
<p>For example, my program can accept the following sample arguments:</p>
<pre><code>wifi --scan --interface=en0
wifi --scan --interface=en0 --ssid=network
wifi --do_something_else
</code></pre>
<p>In this example, the <code>interface</code> and <code>ssid</code> arguments are only valid if they are accompanied by <code>scan</code>. They are dependent on the <code>scan</code> argument.</p>
<p>Is there any way to enforce this automatically with <code>boost::program_options</code>? It can of course be implemented manually but it seems like there must be a better way.</p>
| <c++><boost><command-line-arguments><boost-program-options> | 2016-07-10 06:02:01 | HQ |
38,289,769 | c++ std::string '==' operator and Compare method is return 1 to equal string | [the data of str1 and str2][1]
[1]: http://i.stack.imgur.com/TeVzJ.png
motion->bone_frames[0].name == model->bones[0].bone_name// return 0 . it should be 1
motion->bone_frames[0].name.Compare(model->bones[0].bone_name)// return 1 . it should be 0
wcscmp(motion->bone_frames[0].name.c_str(), model->bones[0].bone_name.c_str()) // return 0 . it should be 0
I cant understand std::string compare function why have different result to wcscmp.
Can i know why these results are different?
Is it cause of different is length?
| <c++><string><return><std> | 2016-07-10 07:44:34 | LQ_EDIT |
38,290,143 | Difference between become and become_user in Ansible | <p>Recently I started digging into Ansible and writing my own playbooks. However, I have a troubles with understanding difference between <code>become</code> and <code>become_user</code>.
As I understand it <code>become_user</code> is something similar to <code>su <username></code>, and <code>become</code> means something like <code>sudo su</code> or "perform all commands as a sudo user". But sometimes these two directives are mixed. </p>
<p>Could you explain the correct meaning of them?</p>
| <ansible><ansible-playbook><ansible-2.x> | 2016-07-10 08:42:22 | HQ |
38,290,187 | Excel c# in computers Without visual basic | <p>i made a project in c# that use excel, in my computer and other computers with visual basic the project works but in other computer when i Click the buttom Who start Work with excel i get exeption.
Am i need to install some driver or something? Tnx</p>
| <c#><excel><driver><basic> | 2016-07-10 08:48:15 | LQ_CLOSE |
38,290,419 | Spring tags instead java code | I'm looking for good example, how can I replace this java code with spring tags.
<%
Object user = (String) request.getSession().getAttribute("User");
Object role = (String) request.getSession().getAttribute("role");
if(user == null){
out.println("<a href=\"register.jsp\">Register</a> <a href=\"login.jsp\">Login</a>");
} else {
out.println(" Hello " + user +" "+"<a href=\"LogoutServlet\" >Logout</a>");
}
%>
</div>
<div class="menu">
<%
if (role != null){
if(role.equals("admin")) out.println("<a href=\"adminPanel.jsp\">Admin Panel</a></br>");
out.println("<a href=\"userOrders\">Orders</a></br>");
} else {
if(user != null) out.println("<a href=\"userOrders\">Orders</a></br></br>");
}%>
| <java><spring><jsp> | 2016-07-10 09:24:12 | LQ_EDIT |
38,291,058 | How stop keys from spamming? | <p>I'm currently struggling with the windows "Inputs".
I would like to ask if there is a way to stop keys from spamming.</p>
<p>In fact I'm using this keyword:
case WM_KEYDOWN:
// do some stuff</p>
<p>All the time I press the button it repeats firing functions
that depend on the pressing.
But I would like it to have waiting until it's released once
to be able to be firing once again.</p>
<p>Is there a keyword that checks that for me or do I have to hardcode that?
( searching on the net didn't help me out :/ )</p>
| <windows><input><onkeydown> | 2016-07-10 10:46:37 | LQ_CLOSE |
38,291,230 | Pyhton selenium drop down menu click | i want to select option from a drop down menu, for this i use that :
`br.find_element_by_xpath("//*[@id='adyen-encrypted-form']/fieldset/div[3]/div[2]/div/div/div/div/div[2]/div/ul/li[5]/span").click()`
To select option month 4 but when i do that pyhton return error message :
`selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
(Session info: chrome=51.0.2704.103)
(Driver info: chromedriver=2.22.397929 (fb72fb249a903a0b1041ea71eb4c8b3fa0d9be5a),platform=Mac OS X 10.11.5 x86_64)
`
That is the HTML code:
</div>
<div class="form-row exp-date clearfix fancyform">
<div class="formfield expired-label monthcaption">
<label>Date d'expiration <span>*</span></label>
</div>
<div class="formfield month">
<div class="value value-select">
<select class="selectbox required" id="dwfrm_adyenencrypted_expiryMonth" data-missing-error="Veuillez sélectionner le mois d'expiration" data-parse-error="Ce contenu est invalide" data-range-error="Ce contenu est trop long ou trop court" data-value-error="Cette date d'expiration est invalide" pattern="^(:?0[1-9]|1[0-2])$" required="required" >
<option class="selectoption" label="Mois" value="">Mois</option>
<option class="selectoption" label="01" value="01">01</option>
<option class="selectoption" label="02" value="02">02</option>
<option class="selectoption" label="03" value="03">03</option>
<option class="selectoption" label="04" value="04">04</option>
<option class="selectoption" label="05" value="05">05</option>
<option class="selectoption" label="06" value="06">06</option>
<option class="selectoption" label="07" value="07">07</option>
<option class="selectoption" label="08" value="08">08</option>
<option class="selectoption" label="09" value="09">09</option>
<option class="selectoption" label="10" value="10">10</option>
<option class="selectoption" label="11" value="11">11</option>
<option class="selectoption" label="12" value="12">12</option>
</select>
What is wrong ? I know selenium cant find the element but i dont know why , xpath wrong ? i need to use other method to find element ? thanks for anwsers
| <python><selenium> | 2016-07-10 11:08:09 | LQ_EDIT |
38,291,374 | Getting the ClaimsPrincipal in a logic layer in an aspnet core 1 application | <p>I'm writing an aspnet core 1 application.
Using a bearer token authentication I have the User property inside the controller with the correct identity. However I cant seem to find a way to grab with identity as I did before using the <code>ClaimPrincipal.Current</code> static.
What is the current best practice to get this data inside the BL layers with out passing the ClaimPrincipal object around?</p>
| <asp.net><.net> | 2016-07-10 11:27:51 | HQ |
38,291,567 | Killing gracefully a .NET Core daemon running on Linux | <p>I created a .NET Core console application running as a daemon on a Ubuntu 14.04 machine.</p>
<p>I want to stop the service without forcing it, being able to handle a kill event.</p>
<p>How can I achieve this?</p>
| <c#><linux><service><daemon><.net-core> | 2016-07-10 11:51:33 | HQ |
38,291,572 | Get access to all installed Apps on Iphone | I want to display all apps there was installed on the iPhone in a UITableView in my App and then I would like to display the internet usage of each apps there are installed. Is that Possible ?
Thanks for your answer and a good day :) | <ios> | 2016-07-10 11:52:16 | LQ_EDIT |
38,291,755 | Namecheap webmail setup but can't receive email | <p>I'm trying to setup incoming email for my Amazon EC2 linux box. Namecheap Private Email records for domains with third-party DNS
My domain's DNS is managed through NameCheap. They have a private email hosting service.</p>
<p><a href="https://www.namecheap.com/hosting/email.aspx" rel="nofollow">https://www.namecheap.com/hosting/email.aspx</a></p>
<p>Will this enable me to have a webmail interface where I can send / receive emails from my domain?</p>
| <email><amazon-web-services><amazon-ec2><amazon-route53><namecheap> | 2016-07-10 12:14:40 | LQ_CLOSE |
38,291,811 | SSRS 2016 - cannot see parameter | <p>I am self-learning SSRS via Microsoft SQL Server Data Tools, VS 2015. I am using tutorial from <a href="https://www.youtube.com/watch?v=nBYn1DU3VMQ&index=5&list=PL7A29088C98E92D5F" rel="noreferrer">here</a></p>
<p>I cannot see the parameter I created in preview. The visible has been selected in parameter properties. What have I missed out? Thanks in advance if anyone can help me.</p>
<p>. Microsoft SQL Server Data Tools, VS 2015</p>
<p>. Microsoft SQL Server management studio 2016</p>
<p>Design
<a href="https://i.stack.imgur.com/YmnpO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/YmnpO.jpg" alt="enter image description here"></a></p>
<p>Preview
<a href="https://i.stack.imgur.com/IaTX0.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/IaTX0.jpg" alt="enter image description here"></a></p>
<p>Parameter Properties
<a href="https://i.stack.imgur.com/vzHC6.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/vzHC6.jpg" alt="enter image description here"></a> </p>
| <sql-server><reporting-services> | 2016-07-10 12:23:20 | HQ |
38,292,180 | T_CONSTANT_ENCAPSED_STRING | <pre><code>this is my code:
<?php
functionrequire 'zMovie/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.live.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'papteste@outlook.pt'; // SMTP username
$mail->Password = 'Teresapaula1'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('papteste@outlook.pt', 'Fernando Alves'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo 'Message has been sent';
}
</code></pre>
<p>Im using php mailer to send and email throught my form but that error keep pushing my nerves.im one day to finish this project and i can't solve this!!It also said that the error is in line 2 "functionrequire 'zMovie/phpmailer/PHPMailerAutoload.php';". If you all could help me i would be mutch mutch thankfull!! :)</p>
| <php><email><ssl><outlook> | 2016-07-10 13:05:10 | LQ_CLOSE |
38,292,861 | Delete Txt file with vb.net | I create a txt file in c++ in the application folder /Common/Send/Test.txt
Than I call a vb.net application from the c++ code
the Vb.net app read the test.txt content than send it to a webserver with POST request, than delete the file.
But its not delete the file, the vb.net app crashing when it need to delete the file.
My.Computer.FileSystem.DeleteFile(".\\Common\Send\Test.txt")
I am using this to delete the file, what can be the problem? | <vb.net><filesystems> | 2016-07-10 14:18:32 | LQ_EDIT |
38,293,243 | React Native BUILD SUCCEED, but "No devices are booted." | <p>Here's my environment:</p>
<pre>
➜ AwesomeProject node --version
v6.3.0
➜ AwesomeProject npm --version
3.10.3
➜ AwesomeProject react-native --version
react-native-cli: 1.0.0
react-native: 0.29.0
➜ AwesomeProject watchman --version
3.0.0
</pre>
<p><code>Xcode version 7.3.1</code></p>
<p>I created the <code>AwesomeProject</code> described on: <a href="https://facebook.github.io/react-native/docs/getting-started.html#content">https://facebook.github.io/react-native/docs/getting-started.html#content</a></p>
<p>Then execute: <code>sudo react-native run-ios</code></p>
<p>Here's what I'm getting:</p>
<pre>
...
export SYSTEM_DEVELOPER_USR_DIR=/Applications/Xcode.app/Contents/Developer/usr
export SYSTEM_DEVELOPER_UTILITIES_DIR=/Applications/Xcode.app/Contents/Developer/Applications/Utilities
export SYSTEM_DOCUMENTATION_DIR=/Library/Documentation
export SYSTEM_KEXT_INSTALL_PATH=/System/Library/Extensions
export SYSTEM_LIBRARY_DIR=/System/Library
export TAPI_VERIFY_MODE=ErrorsOnly
export TARGETED_DEVICE_FAMILY=1
export TARGETNAME=AwesomeProject
export TARGET_BUILD_DIR=/Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Products/Debug-iphonesimulator
export TARGET_DEVICE_MODEL=iPhone7,2
export TARGET_DEVICE_OS_VERSION=9.3
export TARGET_NAME=AwesomeProject
export TARGET_TEMP_DIR=/Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Intermediates/AwesomeProject.build/Debug-iphonesimulator/AwesomeProject.build
export TEMP_DIR=/Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Intermediates/AwesomeProject.build/Debug-iphonesimulator/AwesomeProject.build
export TEMP_FILES_DIR=/Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Intermediates/AwesomeProject.build/Debug-iphonesimulator/AwesomeProject.build
export TEMP_FILE_DIR=/Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Intermediates/AwesomeProject.build/Debug-iphonesimulator/AwesomeProject.build
export TEMP_ROOT=/Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Intermediates
export TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault
export TOOLCHAIN_DIR=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
export TREAT_MISSING_BASELINES_AS_TEST_FAILURES=NO
export UID=0
export UNLOCALIZED_RESOURCES_FOLDER_PATH=AwesomeProject.app
export UNSTRIPPED_PRODUCT=NO
export USER=root
export USER_APPS_DIR=/var/root/Applications
export USER_LIBRARY_DIR=/var/root/Library
export USE_DYNAMIC_NO_PIC=YES
export USE_HEADERMAP=YES
export USE_HEADER_SYMLINKS=NO
export VALIDATE_PRODUCT=NO
export VALID_ARCHS="i386 x86_64"
export VERBOSE_PBXCP=NO
export VERSIONPLIST_PATH=AwesomeProject.app/version.plist
export VERSION_INFO_BUILDER=root
export VERSION_INFO_FILE=AwesomeProject_vers.c
export VERSION_INFO_STRING="\"@(#)PROGRAM:AwesomeProject PROJECT:AwesomeProject-\""
export WRAPPER_EXTENSION=app
export WRAPPER_NAME=AwesomeProject.app
export WRAPPER_SUFFIX=.app
export WRAP_ASSET_PACKS_IN_SEPARATE_DIRECTORIES=NO
export XCODE_APP_SUPPORT_DIR=/Applications/Xcode.app/Contents/Developer/Library/Xcode
export XCODE_PRODUCT_BUILD_VERSION=7D1014
export XCODE_VERSION_ACTUAL=0731
export XCODE_VERSION_MAJOR=0700
export XCODE_VERSION_MINOR=0730
export XPCSERVICES_FOLDER_PATH=AwesomeProject.app/XPCServices
export YACC=yacc
export arch=x86_64
export diagnostic_message_length=124
export variant=normal
/bin/sh -c /Users/glaksmono/Documents/React/AwesomeProject/ios/build/Build/Intermediates/AwesomeProject.build/Debug-iphonesimulator/AwesomeProject.build/Script-00DD1BFF1BD5951E006B06BC.sh
Skipping bundling for Simulator platform
=== BUILD TARGET AwesomeProjectTests OF PROJECT AwesomeProject WITH CONFIGURATION Debug ===
Check dependencies
** BUILD SUCCEEDED **
Installing build/Build/Products/Debug-iphonesimulator/AwesomeProject.app
No devices are booted.
Launching org.reactjs.native.example.AwesomeProject
No devices are booted.
</pre>
<p>And the iOS iPhone 6 simulator is just showing a black screen.</p>
<p>Ideas?</p>
| <react-native> | 2016-07-10 14:58:53 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.