Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
36,205,573 | Is there a way to use a macro to insert a comment in whichever cell I've selected and automatically deletes the username? | <p>The point of this is that I have a column of cells in which I'd like to put a comment in each cell (which I move up and down with sort). However I'm a bit too lazy to go through hundreds of cells and each time having to delete the username when I insert a blank comment for future use. So I thought it'd be easier, if I could select a cell and just press a shortcut key instead.</p>
| <vba><excel> | 2016-03-24 16:45:10 | LQ_CLOSE |
36,205,625 | Skip object items if the value is null | <p>I have a nested <code>for ... in</code> loop in vue js. What I'm trying to to is to skip elements if the value of the element is <code>null</code>. Here is the html code:</p>
<pre><code><ul>
<li v-for="item in items" track-by="id">
<ol>
<li v-for="child in item.children" track-by="id"></li>
</ol>
</li>
</ul>
</code></pre>
<p><code>null</code> elements may be present in both <code>item</code> and <code>item.children</code> objects.</p>
<p>For example:</p>
<pre><code>var data = {
1: {
id: 1,
title: "This should be rendered",
children: {
100: {
id: 100,
subtitle: "I am a child"
},
101: null
}
},
2: null,
3: {
id: 3,
title: "Should should be rendered as well",
children: {}
}
};
</code></pre>
<p>With this data <code>data[1].children[101]</code> should not be rendered and if <code>data[1].children[100]</code> becomes null later it should be omitted from the list.</p>
<p>P.S. I know this is probably not the best way to represent data but I'm not responsible for that :)</p>
| <vue.js> | 2016-03-24 16:48:02 | HQ |
36,205,859 | java8: method reference from another method reference | <p>I want to use a method reference based off another method reference. It's kind of hard to explain, so I'll give you an example:</p>
<p><strong>Person.java</strong></p>
<pre><code>public class Person{
Person sibling;
int age;
public Person(int age){
this.age = age;
}
public void setSibling(Person p){
this.sibling = p;
}
public Person getSibling(){
return sibling;
}
public int getAge(){
return age;
}
}
</code></pre>
<p>Given a list of <code>Person</code>s, I want to use method references to get a list of their sibling's ages. I know this can be done like this:</p>
<pre><code>roster.stream().map(p -> p.getSibling().getAge()).collect(Collectors.toList());
</code></pre>
<p>But I'm wondering if it's possible to do it more like this:</p>
<pre><code>roster.stream().map(Person::getSibling::getAge).collect(Collectors.toList());
</code></pre>
<p>It's not terribly useful in this example, I just want to know what's possible.</p>
| <java><lambda><java-8> | 2016-03-24 16:58:48 | HQ |
36,206,686 | Error: "Double colon in host identifer" | <p>I am trying to connect to a database that I have hosted at MLab. I am using the StrongLoop API. I've placed the config information for my hosted databases into my datasources.json and config.json files, but whenever I run the directory with <code>npm start</code>, I get <code>throw new Error ('double colon in host identifier';)</code> at api\node_modules\mongodb\lib\url_parser.js:45.</p>
<p>I have also made sure to install the loopback-connecter-mongodb npm package.</p>
<p>Here is a snippet of <strong>datasources.json</strong> (without the actual database details, of course):</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>{
"db": {
"name": "db",
"connector": "mongodb",
"host": "ds047355.mlab.com",
"database": "dbtest",
"username": "user",
"password": "fakepassword",
"port": 47355
}
}</code></pre>
</div>
</div>
</p>
<p>Here is the <strong>config.json</strong> file:</p>
<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>{
"restApiRoot": "/api",
"host": "ds047355.mlab.com",
"port": 47355,
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": false
}
},
"legacyExplorer": false
}</code></pre>
</div>
</div>
</p>
<p>Got any ideas?</p>
| <node.js><mongodb><strongloop> | 2016-03-24 17:44:19 | HQ |
36,206,721 | adjacency matrix sum of corresponding rows and columns | <p>What is the easiest way to sum the rows and columns, of the same index, on an adjacency matrix?</p>
<p>Here is one example:</p>
<pre><code> A B C D
A 1 0 2 1
B 3 - - -
C 0 - - -
D 1 - - -
</code></pre>
<p>where the (-) are entries. How can I sum the A column with A row, B column with B row....</p>
<p>example, for A: (1 + 0 + 2 + 1) + (1 + 3 + 0 + 1) = 9</p>
| <c> | 2016-03-24 17:46:25 | LQ_CLOSE |
36,206,768 | How do i validate data inserted from asp.net to sql server | I have a web form already connected to SQL Server, i can insert but i dont know how to do the validation to not Insert data if the table already has the same information.
How can this process be done?
using (SqlConnection con = new SqlConnection("Data Source=hans-pc;Initial Catalog=CntExp;Integrated Security=True"))
{
SqlCommand cmd = new SqlCommand("INSERT INTO PreExp1 (Expe, Usuario) values (@Expe, @Usuario)", con);
cmd.Parameters.AddWithValue("@Expe", TextBox1.Text);
cmd.Parameters.AddWithValue("@Usuario", TextBox2.Text);
//cmd.Parameters.AddWithValue("@Fecha", Datenow());
con.Open();
int insertar = cmd.ExecuteNonQuery();
Response.Write("Inserted" + insertar.ToString());
}
| <c#><sql><asp.net><sql-server><sql-server-2012> | 2016-03-24 17:49:11 | LQ_EDIT |
36,207,120 | values from dictionary in list | I have list containing dictionaries like this
[{"abc":"da123-tap","efg":"xyzf","acd":"123-brf"}, {"abc":"ab234-tap","efg":"yuvi","acd":"345-brf"}]
I want all the values of "abc" in one list1, values of "efg" in list 2 | <list><python-2.7><dictionary> | 2016-03-24 18:08:09 | LQ_EDIT |
36,207,203 | Uncaught TypeError: $(...).datepicker is not a function(anonymous function) | <p>I found few answers on stack overflow but still cant resolve my problem.
I am running on Django but I dont think it is relevant for this error.</p>
<p>I try to make work my date picker java script but I am getting the error </p>
<p>1:27 Uncaught TypeError: $(...).datepicker is not a function(anonymous function) @ 1:27fire @ jquery-1.9.1.js:1037self.fireWith @ jquery-1.9.1.js:1148jQuery.extend.ready @ jquery-1.9.1.js:433completed @ jquery-1.9.1.js:103
jquery-2.1.0.min.js:4 XHR finished loading: POST "<a href="https://localhost:26143/skypectoc/v1/pnr/parse">https://localhost:26143/skypectoc/v1/pnr/parse</a>".l.cors.a.crossDomain.send @ jquery-2.1.0.min.js:4o.extend.ajax @ jquery-2.1.0.min.js:4PNR.findNumbers @ pnr.js:43parseContent @ contentscript.js:385processMutatedElements @ contentscript.js:322</p>
<p>This is all my scripts :</p>
<pre><code><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.dateinput').datepicker({ format: "yyyy/mm/dd" });
});
</script>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<!-- Just to make our placeholder images work. Don't actually copy the next line! -->
<script src="http://getbootstrap.com/assets/js/vendor/holder.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="http://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#extra-content").hide();
$("#toggle-content").click(function(){
$("#extra-content").toggle();
});
});
</script>
</code></pre>
<p>any feedback will be very appreciated </p>
| <javascript><jquery><django><datepicker> | 2016-03-24 18:13:52 | HQ |
36,207,286 | Qualtrics Word Counter Javascript | <p>I am setting up a survey on Qualtrics. One question has a text box, in which participants shall write 100-130 words. I want to have a word counter so people can see how much they have written already. Can anyone help me out with a Javascript code for a word counter that is usable in Qualtrics? Thank you very much!</p>
| <javascript><word-count><qualtrics> | 2016-03-24 18:17:21 | LQ_CLOSE |
36,208,331 | How to use Observable.fromCallable() with a checked Exception? | <p><code>Observable.fromCallable()</code> is great for converting a single function into an Observable. But how do you handle checked exceptions that might be thrown by the function?</p>
<p>Most of the examples I've seen use lambdas and "just work". But how would you do this without lambdas? For example, see the quote below from <a href="http://artemzin.com/blog/rxjava-defer-execution-of-function-via-fromcallable/">this great article</a>:</p>
<pre><code>Observable.fromCallable(() -> downloadFileFromNetwork());
</code></pre>
<blockquote>
<p>It's a one-liner now! It deals with checked exceptions, no more weird Observable.just() and Observable.error() for such easy thing as deferring code execution!</p>
</blockquote>
<p>When I attempt to implement the above Observable without a lambda expression, based on other examples I've seen, and how Android Studio auto-completes, I get the following:</p>
<pre><code>Observable.fromCallable(new Func0<File>() {
@Override
public File call() {
return downloadFileFromNetwork();
}
}
</code></pre>
<p>But if <code>downloadFileFromNetwork()</code> throws a checked exception, I have to try-catch it and wrap it in a <code>RuntimeException</code>. There's got to be a better way! How does the above lambda support this?!?!</p>
| <java><android><rx-java><reactive-programming> | 2016-03-24 19:17:44 | HQ |
36,208,460 | hasMany vs belongsToMany in laravel 5.x | <p>I'm curious why the Eloquent relationship for <code>hasMany</code> has a different signature than for <code>belongsToMany</code>. Specifically the custom join table name-- for a system where a given <code>Comment</code> belongs to many <code>Role</code>s, and a given <code>Role</code> would have many <code>Comment</code>s, I want to store the relationship in a table called <code>my_custom_join_table</code> and have the keys set up as <code>comment_key</code> and <code>role_key</code>.</p>
<pre><code>return $this->belongsToMany('App\Role', 'my_custom_join_table', 'comment_key', 'role_key'); // works
</code></pre>
<p>But on the inverse, I can't define that custom table (at least the docs don't mention it):</p>
<pre><code>return $this->hasMany('App\Comment', 'comment_key', 'role_key');
</code></pre>
<p>If I have a <code>Role</code> object that <code>hasMany</code> <code>Comments</code>, but I use a non-standard table name to store that relationship, why can I use this non-standard table going one way but not the other?</p>
| <php><laravel><eloquent> | 2016-03-24 19:25:47 | HQ |
36,208,666 | How to know, all arrays are uniq(Equal) from multiple arrays list in RUBY | Would like to know whether all arrays are same from list of arrays.
Like == (Equalator) will be helpful to compare only 2 arrays but want know
is there any library method to know is all arrays are same.
Share your ideas. | <arrays><ruby><compare><comparison> | 2016-03-24 19:37:52 | LQ_EDIT |
36,208,705 | my first c++ program runtime is super long like 5 - 10 minutes on a fast CPU it's a very basic c++ program | <p>i just dont understand whats taking so long
its the standard hello world program you write when you first start to learn a new language and its just so un-optimized</p>
<pre><code>#include <iostream>
#include <string>
#include <vector>
#include <sstream>
int main()
{
std::string hello_world = "HELLO WORLD!";
std::string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ !";
std::vector<long> positions;
std::ostringstream oss;
for(auto l : hello_world){
int position = 0;
position = letters.find(l);
positions.push_back(position);
}
for(long t = 0; t <= 100000000000; t++){
if(t%256465445 == 0){
for(auto p : positions){
oss<<letters[p];
}
}
}
std::cout<<"Hello World!";
}
</code></pre>
| <c++><loops><optimization> | 2016-03-24 19:40:22 | LQ_CLOSE |
36,208,732 | Angular 2 http.post() is not sending the request | <p>When I make a post request the angular 2 http is not sending this request</p>
<pre><code>this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions())
</code></pre>
<p>the http post is not sent to the server but if I make the request like this </p>
<pre><code>this.http.post(this.adminUsersControllerRoute, JSON.stringify(user), this.getRequestOptions()).subscribe(r=>{});
</code></pre>
<p>Is this intended and if it is can someone explain me why ? Or it is a bug ?</p>
| <angular><angular2-http> | 2016-03-24 19:41:53 | HQ |
36,209,022 | No need for state in React components if using Redux and React-Redux? | <p><strong>Managing state with React only</strong></p>
<p>I understand that if you're creating an application using React only, you will end up managing all of your state within different React components you create.</p>
<p><strong>Managing state with React and Redux</strong></p>
<p>If you decide to use Redux in combination with React, you can then move all of the state from each of your React components into the overall Redux application state. Each component that requires a slice of the Redux application state can then hook into the state via React-Redux's <code>connect</code> function.</p>
<p><strong>Question</strong></p>
<p>Does this mean that you no longer need to write any React components that deal with React's <code>state</code> (i.e. <code>this.setState</code>) since React-Redux is <code>connect</code>ing the React components with Redux state by passing data into the <code>container</code> component as <code>props</code>?</p>
| <javascript><reactjs><redux><react-redux> | 2016-03-24 19:58:53 | HQ |
36,209,027 | C# - How can I correct string case by using HashSet<string> | <p>Given a hash set such as:</p>
<pre><code>HashSet<string> names = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"Alice",
"Bob",
"Charles",
}
</code></pre>
<p>How can I use this hash set to find the mapped value of a case insensitive string? For example, if I have a string <code>"aLICe"</code>, I want to be able to find <code>"Alice"</code>. </p>
| <c#><string><case-sensitive><case-insensitive> | 2016-03-24 19:59:11 | LQ_CLOSE |
36,209,068 | Boto3: grabbing only selected objects from the S3 resource | <p>I can grab and read all the objects in my AWS S3 bucket via </p>
<pre><code>s3 = boto3.resource('s3')
bucket = s3.Bucket('my-bucket')
all_objs = bucket.objects.all()
for obj in all_objs:
pass
#filter only the objects I need
</code></pre>
<p>and then</p>
<pre><code>obj.key
</code></pre>
<p>would give me the path within the bucket.</p>
<p>Is there a way to filter beforehand for only those files respecting a certain starting path (a directory in the bucket) so that I'd avoid looping over all the objects and filtering later?</p>
| <python><amazon-web-services><amazon-s3><boto3> | 2016-03-24 20:02:08 | HQ |
36,209,336 | In Django 1.9, what's the convention for using JSONField (native postgres jsonb)? | <p>Django <a href="https://docs.djangoproject.com/en/1.9/ref/models/fields/#null">highly suggests</a> <strong>not</strong> to use <code>null=True</code> for CharField and TextField string-based fields in order not to have two possible values for "no data" (assuming you're allowing empty strings with <code>blank=True</code>). This makes total sense to me and I do this in all my projects.</p>
<p>Django 1.9 introduces <a href="https://docs.djangoproject.com/en/1.9/ref/contrib/postgres/fields/#django.contrib.postgres.fields.JSONField">JSONField</a>, which uses the underlying Postgres <code>jsonb</code> data type. Does the suggestion above carry over to JSONField (i.e. <code>blank=True</code> should be used instead of <code>null=True</code>)? Or, should <code>null=True</code> be used instead? Or, should <code>default=dict</code> be used instead? Or, ..? Why?</p>
<p>In other words, what is the convention for the new native JSONField, when you want to allow only one "no data" value? Please support your answer because I did a lot of research and couldn't find anything official. Thanks in advance.</p>
| <python><json><django><postgresql><jsonb> | 2016-03-24 20:21:32 | HQ |
36,209,415 | display data in sepcific format using php | <p>I have following output. I want to read it using php.
Please let me know how I can do that</p>
<pre><code> ?({"ip":"104.112.115.28","country_code":"US","country_name":"United States","region_code":"CA","region_name":"California","city":"Houston","zip_code":"90013","time_zone":"America/Los_Angeles","latitude":34.0453,"longitude":-118.2413,"metro_code":803});
</code></pre>
| <php> | 2016-03-24 20:26:27 | LQ_CLOSE |
36,209,784 | Variable inside setTimeout says it is undefined, but when outside it is defined | <p>I have a class. I need to do some http work inside of a timeout. The problem I am faceing is the http variable inside the timeout keeps saying it is undefined.</p>
<pre><code>export class MyClass {
http:Http:
constructor(private http:Http) {
this.http = http;
}
sendFriendRequest(){
this.http.post( ...//http variable is defined here
setTimeout(function(){
this.http.post(... //http is not defined here
}
}
}
</code></pre>
| <javascript><angular> | 2016-03-24 20:51:05 | HQ |
36,209,819 | Please how do i get the final Url from a link in Java | This is a link generated from Google Alerts, and i would like to get the real url of the site with Java. I have checked for the response but no location header redirect.
https://www.google.com/url?rct=j&sa=t&url=http://naija247news.com/2016/03/nigerian-bond-yields-rise-after-cbns-interest-rate-hike-aimed-at-luring-investors/&ct=ga&cd=CAIyGjA3ZmJiYzk0ZDM0N2U2MjU6Y29tOmVuOlVT&usg=AFQjCNGs7HsYSodEUnECfdAatG6KgY18DA | <java><google-alerts> | 2016-03-24 20:53:19 | LQ_EDIT |
36,210,321 | Comparing Cassandra structure with Relational Databases | <p>A few days ago I read about wide-column stored type of NoSql and
exclusively Apache-Cassandra.
What I understand is that Cassandra consist of :</p>
<p>A keyspace(like database in relational databases) and supporting many column families or tables (Same as table in relational databases) and unlimited rows.</p>
<p>From Stackoverflow tags :</p>
<blockquote>
<p>A wide column store is a type of key-value database. It uses tables, rows, and columns, but unlike a relational database, the names and format of the columns can vary from row to row in the same table.</p>
</blockquote>
<p>In Cassandra all of the rows (in a table) should have a row key then each row key can have multiple columns.
I read about differences in implementation and storing data of Relational database and NoSql (Cassandra) .</p>
<p>But I don't understand the difference between structure :</p>
<p>Imagine a scenario which I have a table (or column family in Cassandra) : </p>
<p>When I execute a query (Cql) like this :</p>
<pre><code>Select * from users;
</code></pre>
<p>It gives me the result as you can see :</p>
<pre><code>lastname | age | city | email
----------+------+---------------+----------------------
Doe | 36 | Beverly Hills | janedoe@email.com
Jones | 35 | Austin | bob@example.com
Byrne | 24 | San Diego | robbyrne@email.com
Smith | 46 | Sacramento | null
Jones2 | null | Austin | bob@example.com
</code></pre>
<p>So I perform the above scenario in relational database (MsSql) with the blow query :</p>
<pre><code>select * from [users]
</code></pre>
<p>And the result is :</p>
<pre><code>lastname age city email
Doe 36 Beverly Hills janedoe@email.com
Jones 35 Austin bob@example.com
Byrne 24 San Diego robbyrne@email.com
Smith 46 Sacramento NULL
Jones2 NULL Austin bob@example.com
</code></pre>
<p>I know that Cassandra supports dynamic column and I can perform this by using sth like :</p>
<pre><code>ALTER TABLE users ADD website varchar;
</code></pre>
<p>But it is available in relational model for example in mssql the above code can be implemented too.
Sth like :</p>
<pre><code>ALTER TABLE users
ADD website varchar(MAX)
</code></pre>
<p>What I see is that the first select and second select result is the same.
In Cassandra , they just give a row key (lastname) as a standalone objet but it is same as a unique field (like ID or a text) in mssql (and all relational databases) and I see the type of column in Cassandra is static (in my example <code>varchar</code>) unlike what it describes in Stackoverflow tag.</p>
<p>So my questions is :</p>
<ol>
<li><p>Is there any misunderstanding in my imagination about Cassandra?!</p></li>
<li><p>So what is different between two structure ?! I show you the result is same.</p></li>
<li><p>Is there any special scenarios (Json like) that cannot be implemented in relational databases but Cassandra supports ?( For example I know that nested column doesn't support in Cassandra.)</p></li>
</ol>
<p>Thank you for reading.</p>
| <cassandra><wide-column-store> | 2016-03-24 21:30:24 | HQ |
36,210,977 | python numpy.savetxt header has extra character # | <p>I am using the following to save the numpy array x with a header:</p>
<pre><code>np.savetxt("foo.csv", x, delimiter=",", header="ID,AMOUNT", fmt="%i")
</code></pre>
<p>However, if I open "foo.cv", the file looks like:</p>
<pre><code># ID,AMOUNT
21,100
52,120
63,29
:
</code></pre>
<p>There is an extra <code>#</code> character in the beginning of the header. Why is that and is there a way to get rid of it?</p>
| <python><numpy><header> | 2016-03-24 22:19:47 | HQ |
36,211,228 | jump to line X in nano editor | <p>Does the Nano minimal text editor have a keyboard shortcut feature to jump to a specified line?</p>
<p>Vim provides several <a href="http://vim.wikia.com/wiki/Go_to_line" rel="noreferrer">analogs</a>.</p>
| <nano> | 2016-03-24 22:43:47 | HQ |
36,211,589 | How to treat a section of a list as one number in python? | <p>For example in x = [0, 1, 2, 3, 4, 5, 6] if I then wanted to use digits x[0, 1, 2, 3] as 0123 how would I do it?</p>
| <python><arrays><list> | 2016-03-24 23:17:59 | LQ_CLOSE |
36,212,020 | How can I convert a Bluetooth 16 bit service UUID into a 128 bit UUID? | <p>All <a href="https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx" rel="noreferrer">assigned services</a> only state the 16 bit UUID. How can I determine the 128 bit counterpart if I have to specify the service in that format?</p>
<p>From <a href="https://www.bluetooth.com/specifications/assigned-numbers/service-discovery" rel="noreferrer">Service Discovery Protocol Overview</a> I know that 128 bit UUIDs are based on a so called "BASE UUID" which is also stated there:</p>
<pre><code>00000000-0000-1000-8000-00805F9B34FB
</code></pre>
<p>But how do I create a 128 bit UUID from the 16 bit counterpart? Probably some of the 0 digits have to be replaced, but which and how?</p>
| <bluetooth><uuid> | 2016-03-25 00:01:30 | HQ |
36,212,722 | How to prevent pull-down-to-refresh of mobile chrome | <p>I want to prevent pull-down-to-refresh of mobile chrome(especially iOS chrome). My web application has vertical panning event with device-width and device-height viewport, but whenever panning down, mobile chrome refreshes itself because of browser's default function. Plus, on Safari browser, screen is rolling during panning event. I want to disable these moves.</p>
<p>Of course, I tried event.preventDefault(); and touch-action: none; But it doesn't look work. Should I add eventListner and touch-action "on body tag"? I expect useful answer with example.</p>
| <javascript><ios><css><mobile> | 2016-03-25 01:29:47 | HQ |
36,212,860 | Subscribe to single property change in store in Redux | <p>In Redux I can easily subscribe to store changes with</p>
<pre><code>store.subscribe(() => my handler goes here)
</code></pre>
<p>But what if my store is full of different objects and in a particular place in my app I want to subscribe to changes made only in a specific object in the store?</p>
| <react-native><redux><redux-framework> | 2016-03-25 01:50:23 | HQ |
36,212,905 | Python 3: Is not JSON serializable | <pre><code>TypeError: b'Pizza is a flatbread generally topped with tomato sauce and cheese and baked in an oven. It is commonly topped with a selection of meats, vegetables and condiments. The term was first recorded in the 10th century, in a Latin manuscript from Gaeta in Central Italy. The modern pizza was invented in Naples, Italy, and the dish and its variants have since become popular in many areas of the world.\nIn 2009, upon Italy\'s request, Neapolitan pizza was safeguarded in the European Union as a Traditional Speciality Guaranteed dish. The Associazione Verace Pizza Napoletana (the True Neapolitan Pizza Association) is a non-profit organization founded in 1984 with headquarters in Naples. It promotes and protects the "true Neapolitan pizza".\nPizza is sold fresh, frozen or in portions, and is a common fast food item in North America and the United Kingdom. Various types of ovens are used to cook them and many varieties exist. Several similar dishes are prepared from ingredients commonly used in pizza preparation, such as calzone and stromboli.' is not JSON serializable
</code></pre>
<p>I have a program that adds this into a JSON string, which works fine for most text strings - but not this one apparently. Can you tell why not, or how to fix it?</p>
| <python><python-3.x> | 2016-03-25 01:56:05 | HQ |
36,212,962 | What files are necessary for a Cordova app build from a Wordpress site? | <p>I am attempting to build a mobile app from my existing wordpress website. I am curious which files I need to include in the assets folder for Cordova? Any assistance would be greatly appreciated</p>
| <javascript><html><wordpress><cordova><jquery-mobile> | 2016-03-25 02:04:03 | LQ_CLOSE |
36,213,067 | How can I choose Swift compiler version | <p>I'm using Xcode 7.3 but my project is in Swift 2.1. I don't want to update my codes right now. So how can I choose or download older version of Swift compiler? Many thanks in advance!</p>
| <ios><xcode><swift> | 2016-03-25 02:21:19 | HQ |
36,213,383 | pandas DataFrame, how to apply function to a specific column? | <p>I have read the docs of <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html" rel="noreferrer">DataFrame.apply</a></p>
<blockquote>
<p>DataFrame.apply(func, axis=0, broadcast=False, raw=False, reduce=None, args=(), **kwds)¶
Applies function along input axis of DataFrame.</p>
</blockquote>
<p>So, How can I apply a function to a specific column?</p>
<pre><code>In [1]: import pandas as pd
In [2]: data = {'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]}
In [3]: df = pd.DataFrame(data)
In [4]: df
Out[4]:
A B C
0 1 4 7
1 2 5 8
2 3 6 9
In [5]: def addOne(v):
...: v += 1
...: return v
...:
In [6]: df.apply(addOne, axis=1)
Out[6]:
A B C
0 2 5 8
1 3 6 9
2 4 7 10
</code></pre>
<p>I want to addOne to every value in <code>df['A']</code>, not all columns. How can I do that with <code>DataFrame.apply</code>.</p>
<p>Thanks for help! </p>
| <python><pandas> | 2016-03-25 03:04:14 | HQ |
36,213,455 | Add startsWith in IE 11 | <p>IE 11 does not support <code>startsWith</code> with strings. (<a href="https://kangax.github.io/compat-table/es6/" rel="noreferrer">Look here</a>)</p>
<p>How do you add a prototype so that it supports the method?</p>
| <javascript><internet-explorer> | 2016-03-25 03:15:27 | HQ |
36,213,487 | App to launch the Google Map | <p>I have implemented the cordova app using angular frame work.please guide me to launch the google map or map application by passing the longitude and langtitude.</p>
| <javascript><angularjs><cordova><google-maps><phonegap-plugins> | 2016-03-25 03:19:45 | LQ_CLOSE |
36,213,640 | Angular 2 event when any [routerLink] is clicked | <p>I have a simple Loader Service that hides and shows certain loaders. I'm working on something that will be used a lot with slow connections and I need to show/hide a loader between route changes. </p>
<p>I can hide the loader when the new route is loaded with the following.</p>
<pre><code>this._Router.subscribe(() => {
this._LoaderService.hide();
})
</code></pre>
<p>I'm trying to find a way that I can call my <code>this._LoaderService.show()</code> function immediately when any [routerLink] is clicked (at the start of the route change, not the end).</p>
<p>I've had a look around and I tried <a href="https://angular.io/docs/ts/latest/api/router/Router-class.html" rel="noreferrer">https://angular.io/docs/ts/latest/api/router/Router-class.html</a> but I can't seem to figure it out.</p>
<p>Any help appreciated</p>
| <angular><angular2-routing> | 2016-03-25 03:40:54 | HQ |
36,213,989 | Getting six and six.moves modules to autocomplete in pycharm | <p>Is it possible to get imports for the six module to work in pycharm? I realize the module does some playing with imports that confuses pycharm but was hoping there was some type of workaround.</p>
<p>For example, I'd like the following to work properly in pycharm or intellij::</p>
<pre><code>from six.moves import BaseHTTPServer
</code></pre>
| <python><intellij-idea><ide><pycharm><six> | 2016-03-25 04:26:06 | HQ |
36,214,057 | How to remove elements from HTML/Change the page entirely? | <p>I am using the following tag to load my scripts and start the game I am making, but all the original elements stay from the original webpage.</p>
<pre><code><input type="image" src="Images/start.jpg" height='200' width='350' alt='Something went wrong loading the images. Update your Internet plugins and try again.' onclick='INIT_THREE(); INIT_CANNON(); UPDATE();'/>
</code></pre>
<p>Is there any way to remove the elements like the background sound and image when I press the button? I tried using href to load another html page, but I don't think that is the best way to do it, plus it didn't work. Any help appreciated, thanks!</p>
| <css><html> | 2016-03-25 04:32:32 | LQ_CLOSE |
36,214,428 | How to scan text from a file and save into an array Java | <p>I am trying to read a string in from a text file, split the string whenever there are spaces, and store each word in an array of strings:</p>
<p>eg. input <code>"Hello i am a sentence"</code></p>
<p>output <code>[Hello, i, am, a, sentence]</code></p>
<p>I currently have the following</p>
<pre><code>Scanner sc = null;
try
{
sc = new Scanner(new FileReader(args[0]));
LinkedList<String> list = new LinkedList<String>();
String str = sc.nextLine();
for(String i:str.split(" ")){
list.add(i);
}
String[] arguments = list.toArray(new String[list.size()]);
System.out.println(arguments);
}
catch (FileNotFoundException e) {}
finally
{
if (sc != null) sc.close();
}
</code></pre>
<p>But i am unable to convert the list into an array and i get the following output</p>
<pre><code>[Ljava.lang.String;@45ee12a7
</code></pre>
| <java><input><java.util.scanner> | 2016-03-25 05:15:49 | LQ_CLOSE |
36,214,711 | Coverting C script to PHP | <p>I want to study the following script in PHP, it's actually in C, how can I convert the exactly same code to PHP?</p>
<pre><code>int solution(int A[], int N) {
int equi(int arr[], int n) {
if (n==0) return -1;
long long sum = 0;
int i;
for(i=0;i<n;i++) sum+=(long long) arr[i];
long long sum_left = 0;
for(i=0;i<n;i++) {
long long sum_right = sum - sum_left - (long long) arr[i];
if (sum_left == sum_right) return i;
sum_left += (long long) arr[i];
}
return -1;
}
</code></pre>
<p>}</p>
| <php><c> | 2016-03-25 05:45:48 | LQ_CLOSE |
36,215,672 | Spark Yarn Architecture | <p><a href="https://i.stack.imgur.com/cheHp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cheHp.png" alt="enter image description here"></a></p>
<p>I had a question regarding this image in a tutorial I was following. So based on this image in a yarn based architecture does the execution of a spark application look something like this:</p>
<p>First you have a driver which is running on a client node or some data node. In this driver (similar to a driver in java?) consists of your code (written in java, python, scala, etc.) that you submit to the Spark Context. Then that spark context represents the connection to HDFS and submits your request to the Resource manager in the Hadoop ecosystem. Then the resource manager communicates with the Name node to figure out which data nodes in the cluster contain the information the client node asked for. The spark context will also put a executor on the worker node that will run the tasks. Then the node manager will start the executor which will run the tasks given to it by the Spark Context and will return back the data the client asked for from the HDFS to the driver. </p>
<p>Is the above interpretation correct?</p>
<p>Also would a driver send out three executors to each data node to retrieve the data from the HDFS, since the data in HDFS is replicated 3 times on various data nodes?</p>
| <scala><hadoop><apache-spark><hdfs> | 2016-03-25 07:18:19 | HQ |
36,216,220 | What is different of Config and ContainerConfig of docker inspect? | <p>I use <code>docker inspect</code> to get the image information. I find there are <code>Config</code> and <code>ContainerConfig</code> in the output, and most value are the same, except the <code>CMD</code>. </p>
<p>In practice, the <code>Config</code> take effect. For I must add cmd in the run command.
<code>
$ docker run -it debian bash
</code></p>
<p>I wonder what is the difference of the two items?</p>
<pre><code>$ docker inspect debian
[
{
"Id": "7abab0fd74f97b6b398a1aca68735c5be153d49922952f67e8696a2225e1d8e1",
......
"ContainerConfig": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"/bin/bash\"]"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"Config": {
"Hostname": "e5c68db50333",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/bash"
],
"Image": "d8bd0657b25f17eef81a3d52b53da5bda4de0cf5cca3dcafec277634ae4b38fb",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
......
}
]
</code></pre>
| <docker> | 2016-03-25 08:04:04 | HQ |
36,216,735 | Cannot load underlying module for 'RealmSwift' | <p>I'm trying to install Realm for Swift via Cocoapods. </p>
<p>First what I did was <strong>pod init</strong> into my project<br><br>
Then I open podfile and changed it like this:</p>
<pre><code>target 'Taskio' do
use_frameworks!
pod 'RealmSwift'
end
</code></pre>
<p>Then I closed podfile and execute command <strong>pod install</strong> <br><br></p>
<p>Everything pass good. But now when i opened workspace I'm getting error while importing RealmSwift </p>
<p>Cannot load underlying module for 'RealmSwift'</p>
<p><a href="https://i.stack.imgur.com/GAyGU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GAyGU.png" alt="Error"></a></p>
| <ios><xcode><swift><realm> | 2016-03-25 08:45:34 | HQ |
36,216,835 | how to send my object by email? | This my code after submitting a form i got a json object, i want to send this JSON object in an mail, but i am stuck
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
$(document).ready(function() {
$("#contact").submit(function () {
var data = {};
$.each($(this).serializeArray(), function (key, value) {
data[value.name] = value.value;
});
data.interest = [data.interest1, data.interest2, data.interest3];
delete data.interest1;
delete data.interest2;
delete data.interest3;
console.log(data);
$.ajax({
type: "POST",
data: JSON.stringify(data),
dataType: 'json',
url: "post.js",
success: function (data) {
$("#contact").addClass('success');
},
error: function () {
$("#contact").addClass('error');
}
});
return false;
});
});
<!-- end snippet -->
| <javascript><json><ajax><node.js><express> | 2016-03-25 08:53:08 | LQ_EDIT |
36,216,923 | akka http throws EntityStreamException: Entity stream truncation | <p>I'm writing a client for a rest API using the akka http library. The library seems very powerful, but it works very unstable for me. Quite often (not always) it throws the following exception when I try to consume an HttpResponse.entity:</p>
<blockquote>
<p>EntityStreamException: Entity stream truncation</p>
</blockquote>
<p>and after this it stops processing subsequent requests at all. Maybe it tries to deal with some back-pressure or actors just die, I don't know.</p>
<p>It doesn't matter how I send a request, using the Request-Level Client-Side API:</p>
<pre><code>def pollSearchResult(searchId: String): FutureActionResult[String, SearchResult] = {
val request = HttpRequest(GET, s"http://***/Search/$searchId")
for {
response <- Http().singleRequest(request)
entity <- Unmarshal(response.entity).to[String]
result = entity.decodeEither[SearchResult]
} yield result
}
</code></pre>
<p>or using the Connection-Level Client-Side API:</p>
<pre><code>val client = Http(actorSystem).outgoingConnection("***")
def pollSearchResult(searchId: String): FutureActionResult[String, SearchResult] = {
val request = HttpRequest(GET, s"Search/$searchId")
for {
response <- Source.single(request).via(client).runWith(Sink.head)
entity <- Unmarshal(response.entity).to[String]
result = entity.decodeEither[SearchResult]
} yield result
}
</code></pre>
<p>It doesn't metter whether I consume the entity using unmarshaller or manually using the getDataBytes, the result is the same - the above exception.</p>
<p>The http status of the response is 200 OK, headers are ok, it is a "Default" entity (so, no chunking), content length is about 500-2000 Kb (increasing akka.http.parsing.max-content-length doesn't help, although the default value should be enough). The server is also ok - other http libraries on other platforms work with this API just fine.</p>
<p>Is it a bug or I am doing something wrong? What is the best non blocking, asycnhonous http library for scala?</p>
| <scala><akka-http> | 2016-03-25 08:59:06 | HQ |
36,217,250 | Cannot install uwsgi on Alpine | <p>I'm trying to install uwsgi using <code>pip install uwsgi</code> in my Alpine docker image but unfortunately it keeps failing weird no real error message to me:</p>
<pre><code>Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-mEZegv/uwsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-c7XA_e-record/install-record.txt --single-version-externally-managed --compile:
running install
using profile: buildconf/default.ini
detected include path: ['/usr/include/fortify', '/usr/include', '/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/include']
Patching "bin_name" to properly install_scripts dir
detected CPU cores: 1
configured CFLAGS: -O2 -I. -Wall -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_HAS_IFADDRS -DUWSGI_ZLIB -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION="\"2.0.12\"" -DUWSGI_VERSION_BASE="2" -DUWSGI_VERSION_MAJOR="0" -DUWSGI_VERSION_MINOR="12" -DUWSGI_VERSION_REVISION="0" -DUWSGI_VERSION_CUSTOM="\"\"" -DUWSGI_YAML -DUWSGI_PLUGIN_DIR="\".\"" -DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(ugreen);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);" -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(ugreen);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);"core/utils.c: In function 'uwsgi_as_root':
core/utils.c:344:7: error: implicit declaration of function 'unshare' [-Werror=implicit-function-declaration]
if (unshare(uwsgi.unshare)) {
^
core/utils.c:564:5: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
sigfillset(&smask);
^
core/utils.c:565:5: error: implicit declaration of function 'sigprocmask' [-Werror=implicit-function-declaration]
sigprocmask(SIG_BLOCK, &smask, NULL);
^
core/utils.c:565:17: error: 'SIG_BLOCK' undeclared (first use in this function)
sigprocmask(SIG_BLOCK, &smask, NULL);
^
core/utils.c:565:17: note: each undeclared identifier is reported only once for each function it appears in
core/utils.c:586:7: error: implicit declaration of function 'chroot' [-Werror=implicit-function-declaration]
if (chroot(uwsgi.chroot)) {
^
core/utils.c:791:5: error: unknown type name 'ushort'
ushort *array;
^
core/utils.c:833:8: error: implicit declaration of function 'setgroups' [-Werror=implicit-function-declaration]
if (setgroups(0, NULL)) {
^
core/utils.c:848:8: error: implicit declaration of function 'initgroups' [-Werror=implicit-function-declaration]
if (initgroups(uidname, uwsgi.gid)) {
^
core/utils.c: In function 'uwsgi_close_request':
core/utils.c:1145:18: error: 'WAIT_ANY' undeclared (first use in this function)
while (waitpid(WAIT_ANY, &waitpid_status, WNOHANG) > 0);
^
core/utils.c: In function 'uwsgi_resolve_ip':
core/utils.c:1802:7: error: implicit declaration of function 'gethostbyname' [-Werror=implicit-function-declaration]
he = gethostbyname(domain);
^
core/utils.c:1802:5: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
he = gethostbyname(domain);
^
core/utils.c: In function 'uwsgi_unix_signal':
core/utils.c:1936:19: error: storage size of 'sa' isn't known
struct sigaction sa;
^
core/utils.c:1938:24: error: invalid application of 'sizeof' to incomplete type 'struct sigaction'
memset(&sa, 0, sizeof(struct sigaction));
^
core/utils.c:1942:2: error: implicit declaration of function 'sigemptyset' [-Werror=implicit-function-declaration]
sigemptyset(&sa.sa_mask);
^
core/utils.c:1944:6: error: implicit declaration of function 'sigaction' [-Werror=implicit-function-declaration]
if (sigaction(signum, &sa, NULL) < 0) {
^
core/utils.c:1936:19: error: unused variable 'sa' [-Werror=unused-variable]
struct sigaction sa;
^
In file included from core/utils.c:1:0:
core/utils.c: In function 'uwsgi_list_has_num':
./uwsgi.h:140:47: error: implicit declaration of function 'strtok_r' [-Werror=implicit-function-declaration]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:1953:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list2, ",", p, ctx) {
^
./uwsgi.h:140:46: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:1953:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list2, ",", p, ctx) {
^
./uwsgi.h:140:70: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:1953:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list2, ",", p, ctx) {
^
core/utils.c: In function 'uwsgi_list_has_str':
./uwsgi.h:140:46: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:1968:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list2, " ", p, ctx) {
^
./uwsgi.h:140:70: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:1968:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list2, " ", p, ctx) {
^
core/utils.c:1969:8: error: implicit declaration of function 'strcasecmp' [-Werror=implicit-function-declaration]
if (!strcasecmp(p, str)) {
^
core/utils.c: In function 'uwsgi_sig_pause':
core/utils.c:2361:2: error: implicit declaration of function 'sigsuspend' [-Werror=implicit-function-declaration]
sigsuspend(&mask);
^
core/utils.c: In function 'uwsgi_run_command_putenv_and_wait':
core/utils.c:2453:7: error: implicit declaration of function 'putenv' [-Werror=implicit-function-declaration]
if (putenv(envs[i])) {
^
In file included from core/utils.c:1:0:
core/utils.c: In function 'uwsgi_build_unshare':
./uwsgi.h:140:46: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:2855:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list, ",", p, ctx) {
^
./uwsgi.h:140:70: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
^
core/utils.c:2855:2: note: in expansion of macro 'uwsgi_foreach_token'
uwsgi_foreach_token(list, ",", p, ctx) {
^
core/utils.c: In function 'uwsgi_tmpfd':
core/utils.c:3533:7: error: implicit declaration of function 'mkstemp' [-Werror=implicit-function-declaration]
fd = mkstemp(template);
^
core/utils.c: In function 'uwsgi_expand_path':
core/utils.c:3615:7: error: implicit declaration of function 'realpath' [-Werror=implicit-function-declaration]
if (!realpath(src, dst)) {
^
core/utils.c: In function 'uwsgi_set_cpu_affinity':
core/utils.c:3641:3: error: unknown type name 'cpu_set_t'
cpu_set_t cpuset;
^
core/utils.c:3646:3: error: implicit declaration of function 'CPU_ZERO' [-Werror=implicit-function-declaration]
CPU_ZERO(&cpuset);
^
core/utils.c:3651:4: error: implicit declaration of function 'CPU_SET' [-Werror=implicit-function-declaration]
CPU_SET(base_cpu, &cpuset);
^
core/utils.c:3662:7: error: implicit declaration of function 'sched_setaffinity' [-Werror=implicit-function-declaration]
if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {
^
core/utils.c:3662:35: error: 'cpu_set_t' undeclared (first use in this function)
if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {
^
core/utils.c: In function 'uwsgi_thread_run':
core/utils.c:3782:2: error: implicit declaration of function 'pthread_sigmask' [-Werror=implicit-function-declaration]
pthread_sigmask(SIG_BLOCK, &smask, NULL);
^
core/utils.c:3782:18: error: 'SIG_BLOCK' undeclared (first use in this function)
pthread_sigmask(SIG_BLOCK, &smask, NULL);
^
core/utils.c: In function 'uwsgi_envdir':
core/utils.c:4349:8: error: implicit declaration of function 'unsetenv' [-Werror=implicit-function-declaration]
if (unsetenv(de->d_name)) {
^
core/utils.c:4380:7: error: implicit declaration of function 'setenv' [-Werror=implicit-function-declaration]
if (setenv(de->d_name, content, 1)) {
^
cc1: all warnings being treated as errors
*** uWSGI compiling server core ***
</code></pre>
<p>Any idea what could cause this? I'm installing the following dependencies beforehand:</p>
<pre><code>RUN apk --update add \
bash \
python \
python-dev \
py-pip \
gcc \
zlib-dev \
git \
linux-headers \
build-base \
musl \
musl-dev \
memcached \
libmemcached-dev
</code></pre>
| <docker><uwsgi><alpine> | 2016-03-25 09:24:27 | HQ |
36,217,317 | Time schedule algorithm | <p>I have been trying for some time solve a scheduling problem for an App that I used to work at. This problem is as follows...</p>
<p>First time the list gets populated:</p>
<ul>
<li>will look at all contacts that a user has made “Active” in the Contacts list.</li>
<li>For each, it should look at their selected contact frequency (e.g. x days, x weeks, x months.) </li>
<li>will compare their “last contact date” with today’s date. For any contact where the difference between these dates is greater than their assigned contact frequency, the person is a candidate to be added to the Agent list.</li>
</ul>
<p>The order of how people will appear on the Agent list should adhere to the following rules:</p>
<ul>
<li>Contacts with longest gap between last contact are higher on the list</li>
<li>Contacts marked as Favorite go to the top of the list</li>
<li>isApp users take priority</li>
</ul>
<p>From this list of “candidates”, the algorithm should then also review contact history for each. For contacts with the following assigned contact frequency, follow these rules </p>
<ul>
<li>Every x Days – Do not take history into account. Just add when they’re past due </li>
<li>Every x Weeks – if contact already within the last 3 days, do not show, and skip to the next time they will be up for contacting. </li>
<li>Every x Months – if contact already within the last 7 days, do not show, and skip to the next time they will be up for contacting.</li>
<li>Every x Year – if contacted in the last month, do not show, and skip to the next time they will be up for contacting.</li>
</ul>
| <node.js><algorithm> | 2016-03-25 09:29:54 | LQ_CLOSE |
36,217,755 | Set the file name and open blob pdf type in new tab | <p>I am trying to open the blob byte streams in the new tab of the browser. It is works, but I am not sure how to set the file name so that each of the documents will have the unique name when downloaded. Now, the document was defaulted to 'document.pdf' when saved. </p>
<pre><code>var blob = new Blob([response.data], { type: "application/pdf" });
if (blob) {
var fileURL = window.URL.createObjectURL(blob);
window.open(fileURL);
}
</code></pre>
| <javascript><pdf> | 2016-03-25 09:58:58 | HQ |
36,218,203 | Continuous WebJob with timer trigger | <p>I have written following functions in continuous web job :</p>
<pre><code>public static void fun1([TimerTrigger("24:00:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timerInfo, TextWriter log)
{//Code}
public static void fun2([TimerTrigger("00:01:00", RunOnStartup = true, UseMonitor = true)] TimerInfo timerInfo, TextWriter log)
{//code}
</code></pre>
<p>where, fun1 is not getting called again (only once, after starting web job)
and fun2 is getting called with 1 min trigger after every process gets completed.</p>
<p>can anyone please explain why?
Am I doing anything wrong?</p>
| <azure><azure-webjobs> | 2016-03-25 10:29:00 | HQ |
36,218,494 | C# Return XML Attribute Value from String to Label | <p>I need to return the values for ID="3" and ID="4" to Labels</p>
<p>The xml string is stored in the database column exactly like this:</p>
<pre><code><Attributes><CheckoutAttribute ID="3"><CheckoutAttributeValue><Value>dear jason, wishing you a happy easter</Value></CheckoutAttributeValue></CheckoutAttribute><CheckoutAttribute ID="4"><CheckoutAttributeValue><Value>Thursday, 31-03-2016</Value></CheckoutAttributeValue></CheckoutAttribute></Attributes>
</code></pre>
<p>I'm looking to get the output as follows.</p>
<p>Label1.Text = "dear jason, wishing you a happy easter";</p>
<p>Label2.Text = "Thursday, 31-03-2016";</p>
<p>Label1 will always be for ID="3"
Label2 will always be for ID="4"</p>
<p>Thanks</p>
| <c#><asp.net><xml> | 2016-03-25 10:48:00 | LQ_CLOSE |
36,218,565 | how we add array values to another array in php |
**below is my $array1 and $array2.
And I want to add $array2 values in the first indexes of the $array1**
$array1 = Array
(
[0] => Array
(
[0] => 2
[1] => 6
[2] => 15
[3] => 6
)
[1] => Array
(
[0] => 5
[1] => 8
[2] => 6
[3] => 12
)
[2] => Array
(
[0] => 2
[1] => 5
[2] => 5
[3] => 5
)
)
**below is $array2.
i want to pick this array values and put this values to above $array1**
$array2 = Array
(
[0] => Outlook
[1] => Temp
[2] => Humidity
)
**Aspect-ed output is below where added value i show in single quotes**
$array1 = Array
(
[0] => Array
(
[0] => 'Outlook'
[1] => 2
[2] => 6
[3] => 15
[4] => 6
)
[1] => Array
(
[0] => 'Temp'
[1] => 5
[2] => 8
[3] => 6
[4] => 12
)
[2] => Array
(
[0] => 'Humidity'
[1] => 2
[2] => 5
[3] => 5
[4] => 5
)
) | <php><arrays> | 2016-03-25 10:52:31 | LQ_EDIT |
36,219,080 | undefined method `toggle!' for #:ActiveRecord_AssociationRelation: | I've just got this problem in my controller ,and I don't understand what's going on.
It returns me undefined method `toggle!' for Like::ActiveRecord_AssociationRelation: Or for my create action every thing works but not with the update action.
This is a basic like controller to like and unlike an event,someone and so one.
class LikesController < ApplicationController
before_action :authenticate_user!
def create
@project=Project.find(params[:project_id])
@like= @project.likes.where(user:current_user).first_or_initialize( name:current_user.first_name)
@like.toggle(:heart)
@like.save
Notification.create(user:current_user, user_name: current_user.first_name, action:'like', recipient:@project.subject)
redirect_to project_path(@project)
end
def update
@project=Project.find(params[:project_id])
@like= @project.likes.where(user:current_user)
@like.toggle(:heart)
@like.save
Notification.create(user:current_user, user_name: current_user.first_name, action:'Unlike', recipient:@project.subject)
redirect_to project_path(@project)
end
end
| <ruby-on-rails> | 2016-03-25 11:29:00 | LQ_EDIT |
36,219,269 | Python module workday() | The python module workday() has an inconvenient input format:
workday(date(year=2009,month=12,day=28),10,[date(year=2009,month=12,day=29)])
I would prefer to input the dates as 2009,12,28.
My holiday.xlsx list is read in as entries with: datetime.datetime(2016, 5, 1, 0, 0).
Thus I am trying to figure out how to align this format to work with the workday()
Any advice would be well received. | <python><datetime> | 2016-03-25 11:42:34 | LQ_EDIT |
36,220,708 | How to remove text from String | <p>I have string as </p>
<p>------=_Part_0_rtkakab</p>
<p>Hello Testing1.
------=_Part_0_rtkakab</p>
<p>I want to change to
<strong>Hello Testing1.</strong> </p>
<p>What is the best way to do this.</p>
| <java><string><stringbuilder> | 2016-03-25 13:17:26 | LQ_CLOSE |
36,222,111 | Android: Could not find com.android.support:support-v4:23.2.1 | <p>I add this library in my gradle file:</p>
<pre><code>compile 'com.appeaser.sublimepickerlibrary:sublimepickerlibrary:2.0.0'
</code></pre>
<p>I've already these dependencies:</p>
<pre><code>dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:design:23.+"
compile 'com.android.support:support-v4:23.+'
compile 'com.android.support:support-v13:23.+'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:cardview-v7:23.+'
compile 'com.android.support:recyclerview-v7:23.+'
</code></pre>
<p>Since, I've added SublimePicker library, I add this error:</p>
<p>Error:Could not find com.android.support:support-v4:23.2.1.
Required by:
Android:app:unspecified</p>
<p>Could you help me guys ?</p>
| <android><gradle> | 2016-03-25 14:43:08 | HQ |
36,222,224 | Equivalent of "@section" in ASP.NET Core MVC? | <p>In the default <code>_Layout.cshtml</code> file, scripts are defined in "environment"s like so:</p>
<pre><code><environment names="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
</code></pre>
<p>And below that is <code>@RenderSection("scripts", required: false)</code></p>
<p>I can't seem to implement a section (in this case "scripts") in any separate .cshtml file since it looks like they got rid of "<code>@section</code>" in Core</p>
<p>I would like to add specific scripts for specific views. What is the new way to go about this? Do I just dump everything in <code>_Layout</code> now?</p>
| <asp.net><asp.net-mvc><razor><asp.net-core><asp.net-core-mvc> | 2016-03-25 14:50:25 | HQ |
36,222,805 | Is there a way to write an `if case` statement as an expression? | <p>Consider this code:</p>
<pre><code>enum Type {
case Foo(Int)
case Bar(Int)
var isBar: Bool {
if case .Bar = self {
return true
} else {
return false
}
}
}
</code></pre>
<p>That's gross. I would like to write something like this instead:</p>
<pre><code>enum Type {
case Foo(Int)
case Bar(Int)
var isBar: Bool {
return case .Bar = self
}
}
</code></pre>
<p>But such a construct does not seem to exist in Swift, or I cannot find it.</p>
<p>Since there's data associated with each case, I don't think it's possible to implement the <code>~=</code> operator (or any other helper) in a way that's equivalent to the above expression. And in any case, <code>if case</code> statements exist for free for all enums, and don't need to be manually implemented.</p>
<p>Thus my question: is there any more concise/declarative/clean/idiomatic way to implement <code>isBar</code> than what I have above? Or, more directly, is there any way to express <code>if case</code> <em>statements</em> as Swift <em>expressions</em>?</p>
| <swift> | 2016-03-25 15:26:14 | HQ |
36,223,157 | Set weight and bias tensors of tensorflow conv2d operation | <p>I have been given a trained neural network in torch and I need to rebuild it exactly in tensorflow. I believe I have correctly defined the network's architecture in tensorflow but I am having trouble transferring the weight and bias tensors. Using a third party package, I converted all the weight and bias tensors from the torch network to numpy arrays then wrote them to disk. I can load them back into my python program but I cannot figure out a way to assign them to the corresponding layers in my tensorflow network. </p>
<p>For instance, I have a convolution layer defined in tensorflow as</p>
<pre><code>kernel_1 = tf.Variable(tf.truncated_normal([11,11,3,64], stddev=0.1))
conv_kernel_1 = tf.nn.conv2d(input, kernel_1, [1,4,4,1], padding='SAME')
biases_1 = tf.Variable(tf.zeros[64])
bias_layer_1 = tf.nn_add(conv_kernel_1, biases_1)
</code></pre>
<p>According to the tensorflow documentation, the tf.nn.conv2d operation uses the shape defined in the kernel_1 variable to construct the weight tensor. However, I cannot figure out how to access that weight tensor to set it to the weight array I have loaded from file. </p>
<p><strong>Is it possible to explicitly set the weight tensor? And if so, how?</strong> </p>
<p>(The same question applies to bias tensor.)</p>
| <python><numpy><tensorflow> | 2016-03-25 15:45:42 | HQ |
36,224,066 | Average of a numpy array returns NaN | <p>I have an np.array with over 330,000 rows. I simply try to take the average of it and it returns NaN. Even if I try to filter out any potential NaN values in my array (there shouldn't be any anyways), average returns NaN. Am I doing something totally wacky? </p>
<p>My code is here: </p>
<pre><code>average(ngma_heat_daily)
Out[70]: nan
average(ngma_heat_daily[ngma_heat_daily != nan])
Out[71]: nan
</code></pre>
| <python><arrays><numpy> | 2016-03-25 16:38:05 | HQ |
36,224,276 | Angular2 - adding [_ngcontent-mav-x] to styles | <p>I'm setting up a basic angular app, and I'm trying to inject some css to my views. This is an example of one of my components:</p>
<pre><code>import { Component } from 'angular2/core';
import { ROUTER_PROVIDERS, ROUTER_DIRECTIVES, RouteConfig } from 'angular2/router';
import { LandingComponent } from './landing.component';
import { PortfolioComponent } from './portfolio.component';
@Component({
selector: 'portfolio-app',
templateUrl: '/app/views/template.html',
styleUrls: ['../app/styles/template.css'],
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS]
})
@RouteConfig([
{ path: '/landing', name: 'Landing', component: LandingComponent, useAsDefault: true },
{ path: '/portfolio', name: 'Portfolio', component: PortfolioComponent }
])
export class AppComponent { }
</code></pre>
<p>Now the .css file is requested from my server, and when I inspect the page source, I can see it was added to the head. But something weird is happening: </p>
<pre><code><style>@media (min-width: 768px) {
.outer[_ngcontent-mav-3] {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
.mainContainer[_ngcontent-mav-3] {
display: table-cell;
vertical-align: middle;
}
.appContainer[_ngcontent-mav-3] {
width: 95%;
border-radius: 50%;
}
.heightElement[_ngcontent-mav-3] {
height: 0;
padding-bottom: 100%;
}
}</style>
</code></pre>
<p>gets generated from this file:</p>
<pre><code>/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {
/* center the mainContainer */
.outer {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
.mainContainer {
display: table-cell;
vertical-align: middle;
}
.appContainer {
width: 95%;
border-radius: 50%;
}
.heightElement {
height: 0;
padding-bottom: 100%;
}
}
</code></pre>
<p>Can somebody please explain where the _ngcontent-mav tag comes from, what does it stand for and how to get rid of it?</p>
<p>I think this is the reason why my style is not getting applied to my templates.</p>
<p>If you need more info about the app structure, please checkout my <a href="https://github.com/Shooshte/PortfolioV3">gitRepo</a>, or ask and I'll add the code to the question.</p>
<p>Thanks for the help.</p>
| <css><typescript><angular> | 2016-03-25 16:52:09 | HQ |
36,224,300 | Anti-Forgery Token was meant for a different claims-based user | <p>I am working on a logout feature in the application we are using ASP.NET Identity login. I can login successfully but when I logout and then try to login again I get the following message: </p>
<pre><code>The provided anti-forgery token was meant for a different claims-based user than the current user.
</code></pre>
<p>Here is my logout code: </p>
<pre><code> public ActionResult Logout()
{
SignInManager.Logout();
return View("Index");
}
**SignInManager.cs**
public void Logout()
{
AuthenticationManager.SignOut();
}
</code></pre>
<p>After the user press the logout button he is taken to the login screen. The url still says "<a href="http://localhost:8544/Login/Logout" rel="noreferrer">http://localhost:8544/Login/Logout</a>". Since we are on the login screen maybe it should just say "<a href="http://localhost:8544/Login" rel="noreferrer">http://localhost:8544/Login</a>". </p>
| <asp.net><asp.net-mvc> | 2016-03-25 16:53:19 | HQ |
36,227,118 | Print a student grade, list, and letter grade | <p>I'm trying to get Python to print a specific set of names, grades, and the letter grade but I'm coming up short for how to do it after asking "the user" to input the number and the name. What I have to do is make sure that it says it with a name, numeric grade, and letter grade in a list so
Name Grade Letter
Joe 98 A
Bob 56 F
and so on...</p>
<p>Here is what I have already...</p>
<pre><code>A_score = 90
B_score = 80
C_score = 70
D_score = 60
F_score = 50
score1 = int(input('Enter score: '))
name1 = input('Enter name: ')
score = int(input('Enter score: '))
name = input('Enter name: ')
score = int(input('Enter score: '))
name = input('Enter name: ')
score = int(input('Enter score: '))
name = input('Enter name: ')
score = float(input('Enter score: '))
name = input('Enter name: ')
# Print the table headings
print('Name\tNumeric grade\tLetter grade')
print('---------------------------------')
#Print the names and grades
for score in range(A_score, B_score, C_score):
print(name1, '\t', score1)
</code></pre>
| <python><list><names> | 2016-03-25 19:59:20 | LQ_CLOSE |
36,227,130 | R: as.POSIXct timezone and scale_x_datetime issues in my dataset | <p>I spent some time trying to figure out why the hour ticks were shifted when scale_x_datetime was applied. I've tried to give the timezone when the Date/Time column was created. I used ggplot and scale_x_datetime() from the package scales. The hour ticks were wrong, which datapoint did not match the time in their Date/Time column.</p>
<p>Here is some procedures to deal with my dataset. </p>
<pre><code> DF$DateTime<-as.POSIXct(DF$timestamp,format="%m/%d/%y %H:%M", tz="America/Toronto")
DF$Date<-as.Date(DF$DateTime)
lims <- as.POSIXct(strptime(c("2015-07-21 00:00","2015-07-23 00:00"), format = "%Y-%m-%d %H:%M"), tz="America/Toronto")
ggplot(DF) + geom_line(aes(x=DateTime, y=-Diff,group=Date)) + scale_x_datetime(limits =lims, breaks=date_breaks("2 hour"), labels=date_format("%m/%d %H:%M"))
</code></pre>
<p>Do I miss anything here?? Please help me to figure it out.
Many thanks!</p>
| <r><ggplot2><posixct> | 2016-03-25 19:59:55 | HQ |
36,227,194 | Data binding: set property if it isn't null | <p>Cannot understand... How to set some property of view only if variable field isn't null?
<br>For example</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="item"
type="com.test.app.Item" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_margin="16dp"
android:src="@{item.getDrawable()}"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:layout_marginLeft="72dp"
android:layout_marginRight="16dp"
android:layout_marginStart="72dp"
android:layout_toLeftOf="@id/action"
android:layout_toStartOf="@id/action"
android:orientation="vertical">
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/black_87"
android:textSize="16sp"
android:text="@{item.getTitle()}"/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web|email"
android:linksClickable="false"
android:singleLine="true"
android:textColor="@color/black_54"
android:textSize="14sp"
android:text="@{item.getSubtitle()}"/>
</LinearLayout>
</RelativeLayout>
</layout>
</code></pre>
<p>Some field of Item can be null and I won't call methods of layout views unnecessarily. And I won't get <code>NullPointerException</code>. How can I set property only if it isn't null?
<br>P.S. Sorry for English.</p>
| <android><android-databinding> | 2016-03-25 20:04:56 | HQ |
36,227,705 | Why casting division by zero to integer primitives gives different results? | <pre><code> System.out.println((byte) (1.0/0));
System.out.println((short) (1.0/0));
System.out.println((int) (1.0/0));
System.out.println((long) (1.0/0));
</code></pre>
<p>The result is:</p>
<pre><code> -1
-1
2147483647
9223372036854775807
</code></pre>
<p>In binary format:</p>
<pre><code> 1111 1111
1111 1111 1111 1111
0111 1111 1111 1111 1111 1111 1111 1111
0111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111
</code></pre>
<p>Why casting infinity to int and long integers keeps sign bit as "0", while sets sign bit to "1" for byte and short integers?</p>
| <java><casting><binary><primitive-types> | 2016-03-25 20:42:35 | HQ |
36,227,897 | Bulk files rename | <p>I have 10000 files (php, html, css, and png). They are interconnected, in other words that the site engine. How do I can to do a bulk rename files so that the website worked properly? I understand that in addition to rename files and folders, I need to rename the paths inside the files. But how to do it bulk?</p>
| <javascript><php><html><css> | 2016-03-25 20:56:39 | LQ_CLOSE |
36,228,681 | What does => do and what is it called in the context below? | <p>What does (a=>) do in the context below?</p>
<pre><code>function findOutlier(int){
var even = int.filter(a=>a%2==0);
var odd = int.filter(a=>a%2!==0);
return even.length==1? even[0] : odd[0];
}
</code></pre>
| <javascript> | 2016-03-25 21:55:38 | LQ_CLOSE |
36,228,836 | Syntax error or access violation: 1055 Expression #8 of SELECT list is not in GROUP BY clause and contains nonaggregated column | <p>i tried the CakePHP 3.x "Bookmaker Tutorial" and i followed the instruction step by step. Unfortunately, at the end of the first chapter i get the attached error:</p>
<pre><code>Error: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #8 of SELECT list
is not in GROUP BY clause and contains nonaggregated column 'wis.Tags.id' which is not
functionally dependent on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_by
</code></pre>
<p>Furthermore, i get the information to check my "BookmarksTags" table but i do not have to creat one before. I little bit confused.</p>
<pre><code>Please try correcting the issue for the following table aliases:
BookmarksTags
</code></pre>
<p>I already google my problem and i found information to update the "my.cnf" with a extra line. i already try but nothing happed. I also check the spelling and downloaded the "bookmarker-tutorial" from github but i still get this error above.</p>
<p>I use MySQL 5.7.11 and PHP 5.6.14. </p>
| <mysql><apache><cakephp> | 2016-03-25 22:08:57 | HQ |
36,229,621 | respondsToSelector can't recognize Selector with more than one parameters in Swift | <p>I have a <code>protocol</code> with some <code>optional</code> functions. My goal is to check if a delegate function is implemented by the delegate object, if yes execute it, otherwise do some default stuff.</p>
<p>I am using <code>respondsToSelector</code> for this purpose, it works fine for functions that with none or only one parameters, but doesn't work for two parameters.</p>
<p>Could anyone help? Thanks in advance.</p>
<p>Note that all the functions have been implemented by the delegate object, here is my code:</p>
<pre><code>@objc protocol ViewControllerDelegate: NSObjectProtocol {
optional func doSomethingWithoutParams()
optional func doSomethingWithOneParam(controller: ViewController)
optional func doSomethingWithTwoParams(controller: ViewController, secondParam: String)
}
class ViewController: UIViewController {
weak var delegate: ViewControllerDelegate?
@IBAction func onButtonClicked(sender: AnyObject){
if (delegate != nil && delegate!.respondsToSelector(Selector("doSomethingWithoutParams"))) {
// Entered here
}
else{
NSLog("doSomethingWithoutParams is not implemented")
}
if (delegate != nil && delegate!.respondsToSelector(Selector("doSomethingWithOneParam:"))) {
// Entered here
}
else{
NSLog("doSomethingWithOneParam is not implemented")
}
if (delegate != nil && delegate!.respondsToSelector(Selector("doSomethingWithTwoParams::"))) {
NSLog("doSomethingWithTwoParams is implemented")
}
else{
// Entered here
NSLog("doSomethingWithTwoParams is not implemented")
}
}
}
</code></pre>
| <ios><swift> | 2016-03-25 23:19:08 | LQ_CLOSE |
36,230,782 | Rust external library macro | I have a project tree like this:
main.rs:
external crate lib;
mod a;
fn main() {
a::some_func();
}
a.rs:
use lib;
fn some_func() {
lib::func();
}
this works ok.
but when i try to use a macro from 'lib', it gives me an error of macro undefined.
I tried putting #[macro_use] in front of the 'external crate lib', then i get a lot of unresolved errors inside of the external crate. And i have already looked inside of the external crate, there is nothing wrong. Also, the fact that i can use functions from the library kinda proves (to me, im a rust noob) that the library is ok, and i'm doing something wrong. | <macros><rust> | 2016-03-26 01:59:28 | LQ_EDIT |
36,231,375 | C ampersand operator from command line | I need to develop a client and server program with using sockets. My program should get port number from the command line. I saw an example which says "myprogram 2454 &"
I wonder what that & means there.
Thanks | <shell><unix> | 2016-03-26 03:41:20 | LQ_EDIT |
36,231,492 | How to optimize this simple algorithm further? | <p><i>Note: this is a programming challenge</i>
<hr>
This challenge requires usage of <code>std::set</code>.</p>
<p><b>Input</b></p>
<ul>
<li>A number <code>n</code></li>
<li><code>n</code> lines with each <code>j</code> and <code>k</code></li>
</ul>
<p>Sample input:</p>
<pre><code>5
1 4
2 1
1 6
3 4
1 2
</code></pre>
<p><code>j</code> is for the operation: <code>1</code> to insert <code>k</code>, <code>2</code> to delete <code>k</code> (if there is a <code>k</code>), <code>3</code> find <code>k</code></p>
<p>For <code>j == 3</code>, output <code>Yes</code> or <code>No</code> if <code>k</code> is in the <code>std::set</code>.
<hr>
I made different versions of the algorithm, but all are way too slow. I tried different <code>std</code> functions, but <code>std::find</code> seems the fastest one, but is still too slow. Implementing my own would be even worse, so maybe I missed a function from the library. I really have no idea how to optimize it further. Currently I have this:</p>
<pre><code>int main()
{
std::set<int> set{};
int Q = 0;
std::cin >> Q;
int type = 0;
int x = 0;
for (int i = 0; i < Q; ++i)
{
std::cin >> type;
std::cin >> x;
if (type == 1)
set.insert(x);
else if (type == 2)
set.erase(x);
else if (type == 3)
std::cout << (std::find(std::begin(set), std::end(set), x) != std::end(set) ? "Yes" : "No") << '\n';
//Condition may be std::find, std::count or std::binary_search
}
return 0;
}
</code></pre>
<p><hr>
The challenge requires it to run under 2 seconds. Here are the results of mine:</p>
<pre><code>Function Time % over
std::find -> 7.410s 370.50%
std::count -> 7.881s 394.05%
std::binary_search -> 14.050s 702.50%
</code></pre>
<p>As you can see my algorithm is 3x slower than the required algorithm. The bottlenecks are clearly those functions:</p>
<pre><code>Function % of total time
std::find -> 77.61%
std::count -> 80.80%
std::binary_search -> 87.59%
</code></pre>
<p>But currently I have no better idea than to use <code>std::find</code> or similar functions. Does someone have a way/idea to optimize my code further? Or are there some obvious bottlenecks that I'm missing?</p>
| <c++><algorithm><performance><c++11><optimization> | 2016-03-26 04:04:18 | HQ |
36,231,820 | How can I write an optimal Swap ( T a, T b ) algorithm in C#? | My mission for this lonely Friday night is to write a C# swap algorithm
public void Swap<T> ( ref T a, ref T b )
{
// ...
}
that works on any class or data type `T` and is as efficient as possibe. Help critique the method I've built up so far. First of all, is it correct? How can I make it Skeet-certified?
public void Swap<T> ( ref T a, ref T b )
{
// Not sure yet if T is a data or value type.
// Will handle swapping algorithm differently depending on each case.
Type type = T.GetTyle();
if ( type.IsPrimitive() || type == typeof(Decimal) )
{
// this means the we can XOR a and b, the fastest way of swapping them
a ^= b ^= a ^= b;
}
else if ( type.IsValueType() )
{
// plain old swap in this case
T temp = a;
a = b;
b = temp;
}
else // is class type
{
// plain old swap???
}
}
Other questions:
- What the overhead of the type checking cancel out any performance benefits of the XOR swap?
- Would the way this is handled be any different for a value type versus a class type if I wanted to optimize the performance of each case?
- Is there a better way to check whether two elements are XORable?
- Let's say I wanted a version of this method that takes value types, like
public void Swap<T> ( ref T a, ref T b ) where T : struct
{
//
}
obviously I don't want to make copies of the entire structs in case they're very big. So I want to do the equivalent of what is in C++
template <typename T>
void PointerSwap<T> ( T * a, T * b )
{
T * temp = a;
a = b;
b = temp;
}
Now, I know that in C# you can get in the structs by ***boxing*** them into a class (reference type), but isn't there major overhead in doing that? Is there no way of simply using an integral type reference (so-called "memory address" in C++) as a parameter?
C++ makes so much more sense than C# ... | <c#><.net><algorithm><optimization> | 2016-03-26 05:03:46 | LQ_EDIT |
36,232,183 | Can I commit files to GitHub from Android Phone | <p>I've been doing a school assignment on HTML and CSS. It was an easy assignment and I almost missed the due date when I was away for the weekend. </p>
<p>I have done the assignment on my phone but to hand it in I have to put it on my GitHub page.</p>
<p>Is there a way to put files from Android onto my GitHub page?</p>
| <android><github> | 2016-03-26 06:05:28 | HQ |
36,232,906 | How to access private Docker Hub repository from Kubernetes on Vagrant | <p>I am failing to pull from my private Docker Hub repository into my local Kubernetes setup running on Vagrant:</p>
<blockquote>
<p>Container "hellonode" in pod "hellonode-n1hox" is waiting to start: image can't be
pulled</p>
<p>Failed to pull image "username/hellonode": Error: image username/hellonode:latest not found</p>
</blockquote>
<p>I have set up Kubernetes locally via Vagrant as described <a href="http://kubernetes.io/docs/getting-started-guides/vagrant/" rel="noreferrer">here</a> and created a secret named "dockerhub" with <em>kubectl create secret docker-registry dockerhub --docker-server=<a href="https://registry.hub.docker.com/" rel="noreferrer">https://registry.hub.docker.com/</a> --docker-username=username --docker-password=... --docker-email=...</em> which I supplied as the image pull secret.</p>
<p>I am running Kubernetes 1.2.0.</p>
| <docker><kubernetes> | 2016-03-26 07:46:42 | HQ |
36,232,986 | Why isn't http server consuming a lot of CPU? | <p>The server should response as soon as possible, isn't the server process always polling if there are requests?
So, it would like a while loop. But why is not CPU(single core) all consumed if there is no visit?</p>
| <performance><http><networking><polling> | 2016-03-26 07:58:54 | LQ_CLOSE |
36,233,133 | elixir - how to get all elements except last in the list? | <p>Let say I have a list <code>[1, 2, 3, 4]</code></p>
<p>How can I get all elements from this list except last? So, I'll have <code>[1, 2, 3]</code></p>
| <elixir> | 2016-03-26 08:22:21 | HQ |
36,233,507 | How can i check my android device having a internet connection in android? | <p>Explanation:
I am trying to connect my device which has internet connection.I added a permission in manifiest both network state and internet.I check correctly my device is connected with specific network.e.g. WIFI.</p>
<p>How can i check this wifi connection share the internet.</p>
<p>Here is my class which has two method for internet connection checking and network connection checking.</p>
<pre><code>package comman;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import java.net.URL;
import java.io.IOException;
import java.net.HttpURLConnection;
public class ConnectionDetector {
private Context _context;
public ConnectionDetector(Context context) {
this._context = context;
}
public boolean isConnectingToInternet() {
if (networkConnectivity()) {
try {
HttpURLConnection urlc = (HttpURLConnection) (new URL(
"http://www.google.com").openConnection());
urlc.setRequestProperty("User-Agent", "Test");
urlc.setRequestProperty("Connection", "close");
urlc.setConnectTimeout(3000);
urlc.setReadTimeout(4000);
urlc.connect();
// networkcode2 = urlc.getResponseCode();
return (urlc.getResponseCode() == 200);
} catch (IOException e) {
return (false);
}
} else
return false;
}
private boolean networkConnectivity() {
ConnectivityManager cm = (ConnectivityManager) _context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
return true;
}
return false;
}
}
</code></pre>
<p>Here is the code where i am trying to check whether device having internet connection or not?</p>
<pre><code>ConnectionDetector cd=new ConnectionDetector(getContext());
if (cd.isConnectingToInternet()) {
new TabJson().execute();
}
else{
dialog_popup();
}
</code></pre>
<p>Here, is an exception </p>
<pre><code>FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.angelnx.cricvilla.cricvilla/com.angelnx.cricvilla.cricvilla.MainActivity}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
at comman.ConnectionDetector.isConnectingToInternet(ConnectionDetector.java:29)
at com.angelnx.cricvilla.cricvilla.HomeFragment.onCreateView(HomeFragment.java:130)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
at android.app.Activity.performStart(Activity.java:5187)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2083)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4950)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
</code></pre>
<p>how can i solve this problem???
Please help me to solve out this problem.</p>
| <android> | 2016-03-26 09:07:20 | LQ_CLOSE |
36,233,818 | Java , binary search in file | I want to write a program that makes binary search in a file. I have a treeset adt that has strings int and i want to make research in file for each string this way : First i want to read the middle page of the file and do research in it . if the string is found then the position of the string is returned. if not then i have to read the page from the left or right half of the file depends on the alphabetical order of the strings.
My code for the class of the binary search is this :
public class PageBinarySearch {
final int NOT_FOUND = -1;
final int BOUND_LIMIT = -1;
final int EVRTHG_OK = 0;
final int ON = 1;
final int OFF = 0;
private DataInputStream inFile;
private String[] readBuffer; //This buffer is used to read a specified page from
//the disk.
private String[] auxBuffer; //Auxiliary buffer is used for searching in the la-
//st page. This buffer has less than PAGE_SIZE ele-
//ments.
private int lastPage, leftElemNum, lastPageNo;
private int diskAccessMeter; //This variable is used to count disk accesses.
private int firstNum;
/********************************************************************************/
//Constructor of the class
public PageBinarySearch(String filename, String key, int PageSize, int numPage, int numOfWords) throws IOException{
System.out.println();
System.out.println("Binary Search on disk pages");
System.out.println("*************************************************");
System.out.println();
//Initializing the elements of the class.
readBuffer = new String[PageSize];
lastPage = numPage*PageSize;
leftElemNum = numOfWords-(lastPage);
auxBuffer = new String[leftElemNum];
lastPageNo = numPage;
diskAccessMeter = 0;
this.setFirstNum(filename);
basicPageBinarySearchMethod(filename, 0, lastPageNo, key,PageSize,numPage,numOfWords);
System.out.println("Disk accesses:"+this.getDiskAccessMeter());
}
/********************************************************************************/
//Recursive binary search on disk pages.
public void basicPageBinarySearchMethod(String filename, int start, int end,
String key, int PageSize, int numPage, int numOfWords) throws IOException{
inFile = new DataInputStream(new FileInputStream(filename));
int bound = boundHandler(start, key);
if (bound != EVRTHG_OK){return;}
int midPage = start + (end-start)/2;
int midPageIndex = ((midPage) * (PageSize));
int midPageEnd = midPageIndex + PageSize;
//System.out.println("----------------------------------------");
System.out.println("Page:"+(midPage+1));
System.out.println(" Index:"+midPageIndex+" End:"+midPageEnd);
//Accessing midPage's index.
accessPageIndex(midPageIndex - 1);
fillBasicBuffer(PageSize);
System.out.println();
if (key.compareTo(readBuffer[0])<0){
//Case that the key is in the left part.
end = midPage - 1;
inFile.close(); //We close the stream because in the next recursion
//we want to access new midPage.
basicPageBinarySearchMethod(filename, start, end, key, PageSize, numPage, numOfWords);
}
else if (key.compareTo(readBuffer[255])>0){
//Case that the key is in the left part.
start = midPage+1;
inFile.close();
basicPageBinarySearchMethod(filename, start, end, key, PageSize, numPage, numOfWords);
}
else{
//Case that:
//a) key is bigger than the integer, which is in the midPage-
//Index position of the file, and
//b) key is less than the integer, which is in the midPageEnd
//position of the file.
LookingOnPage(midPage, key);
}
}
/********************************************************************************/
public int boundHandler(int start, String key) throws IOException{
if (start == this.getLastPageNo()){
//In this case the program has to start searching in the last page,
//which has less than PAGE_SIZE elements. So we call the alternative
//function "LookingOnLastPage".
System.out.println("Start == End");
accessPageIndex(this.getLastPage());
LookingOnLastPage(key);
return BOUND_LIMIT;
}
//if (key < this.getFirstNum()){
//System.out.println("Key does not exist.");
//return BOUND_LIMIT;
//}
return EVRTHG_OK;
}
/********************************************************************************/
//This function is running a binary search in the specified disk page, which
//is saved in the readBuffer.
public void LookingOnPage(int pageNo, String key) throws IOException{
int i, result;
System.out.println("Looking for key:"+key+" on page:"+(pageNo+1));
result = myBinarySearch(key, readBuffer);
if (result != -1){
System.out.println("Key found on page:"+(pageNo+1));
inFile.close();
return;
}
else{
System.out.println("Key is not found");
inFile.close();
return;
}
}
/********************************************************************************/
//This function is running a binary search in the last disk page, which
//is saved in the auxBuffer.
public void LookingOnLastPage(String key) throws IOException{
int i, result;
this.setDiskAccessMeter(this.getDiskAccessMeter()+1);
System.out.println("Looking for key:"+key+" on last page:"
+(this.getLastPageNo()+1));
for (i=0; i<this.getLeftElemNum(); i++){
auxBuffer[i] = inFile.readUTF();
}
result = myBinarySearch(key, auxBuffer);
if (result != -1){
System.out.println("Key found on last page");
inFile.close();
return;
}
else{
System.out.println("Key is not found");
inFile.close();
return;
}
}
/********************************************************************************/
public void accessPageIndex(int intNum) throws IOException
{
//This function is skipping intNum integers in the file, to access page's
//index.
int i;
System.out.println(" Accessing page's index...");
inFile.skipBytes(intNum*4);
//inFile.readInt();
}
/********************************************************************************/
public void fillBasicBuffer(int PageSize) throws IOException{
//Loading readBuffer.
int i;
this.setDiskAccessMeter(this.getDiskAccessMeter()+1);
for (i=0; i<PageSize; i++){
readBuffer[i] = inFile.readUTF();
}
}
/********************************************************************************/
//This function implements binary search on a given buffer.
public int myBinarySearch(String key, String[] auxBuffer) {
int lo = 0;
int hi = auxBuffer.length - 1;
while (lo <= hi) {
// Key is in a[lo..hi] or not present.
int mid = lo + (hi - lo) / 2;
if (key.compareTo(auxBuffer[mid])<0) hi = mid - 1;
else if (key.compareTo(auxBuffer[mid])>0) lo = mid + 1;
else return mid;
}
return NOT_FOUND;
}
/********************************************************************************/
public int getLastPage() {
return lastPage;
}
public void setLastPage(int lastPage) {
this.lastPage = lastPage;
}
public int getLeftElemNum() {
return leftElemNum;
}
public void setLeftElemNum(int leftElemNum) {
this.leftElemNum = leftElemNum;
}
public int getLastPageNo() {
return lastPageNo;
}
public void setLastPageNo(int lastPageNo) {
this.lastPageNo = lastPageNo;
}
public int getDiskAccessMeter() {
return diskAccessMeter;
}
public void setDiskAccessMeter(int diskAccessMeter) {
this.diskAccessMeter = diskAccessMeter;
}
public int getFirstNum() {
return firstNum;
}
public void setFirstNum(String filename) throws IOException {
inFile = new DataInputStream(new FileInputStream(filename));
this.firstNum = inFile.readInt();
inFile.close();
}
}
and my main is :
public class MyMain {
private static final int DataPageSize = 128; // Default Data Page size
public static void main(String[] args) throws IOException {
TreeSet<DictPage> listOfWords = new TreeSet<DictPage>(new MyDictPageComp());
LinkedList<Page> Eurethrio = new LinkedList<Page>();
File file = new File("C:\\Kennedy.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
//This will reference one line at a time...
String line = null;
int line_count=0; //Metavliti gia na metrame grammes ..
int byte_count; //Metavliti gia na metrame bytes...
int total_byte_count=0; //Metavliti gia synoliko arithmo bytes ...
int fromIndex;
int middleP;
int kat = 0;
while( (line = br.readLine())!= null ){
line_count++;
fromIndex=0;
String [] tokens = line.split(",\\s+|\\s*\\\"\\s*|\\s+|\\.\\s*|\\s*\\:\\s*");
String line_rest=line;
for (int i=1; i <= tokens.length; i++) {
byte_count = line_rest.indexOf(tokens[i-1]);
fromIndex = fromIndex + byte_count + 1 + tokens[i-1].length();
if (fromIndex < line.length())
line_rest = line.substring(fromIndex);
listOfWords.add(new DictPage(tokens[i-1],kat));
kat++;
Eurethrio.add(new Page("Kennedy",fromIndex));
}
total_byte_count += fromIndex;
Eurethrio.add(new Page("Kennedy", total_byte_count));
}
//for(DictPage p : listOfWords){
//System.out.println(p.getWord() + " " + p.getPage());
//}
//for (int i = 0;i<Eurethrio.size();i++){
//System.out.println(""+Eurethrio.get(i).getFile()+" "+Eurethrio.get(i).getBytes());
//}
ByteArrayOutputStream bos = new ByteArrayOutputStream(128) ;
DataOutputStream out = new DataOutputStream(bos);
String s ;
int integ;
byte[] buf ;
int nPag=1; //Aritmos selidwn
int numOfWords=0;
for (DictPage p : listOfWords){
s = p.getWord();
integ = p.getPage();
numOfWords++;
byte dst[] = new byte[20];
byte[] src = s.getBytes(); //metatrepei se bytes to string
System.arraycopy(src, 0, dst, 1, src.length); //to antigrafei ston buffer dst
out.write(dst, 0, 20); // to grafei sto arxeio
out.writeInt(integ); // grafei ton akeraio sto file
out.close();
buf = bos.toByteArray(); // Creates a newly allocated byte array.
System.out.println("\nbuf size: " + buf.length + " bytes");
//dhmiourgia selidas (h opoia einai enas byte array)
if(buf.length> nPag*DataPageSize){
nPag++;
}
byte[] DataPage = new byte[nPag*DataPageSize];
System.arraycopy( buf, 0, DataPage, 0, buf.length); // antigrafw buf sth selida
System.out.println("TARRARA"+DataPage.length);
bos.close();//kleinw buf
// write to the file
RandomAccessFile MyFile = new RandomAccessFile ("newbabis", "rw");
MyFile.seek(0);
MyFile.write(DataPage);
}
System.out.println("Number of Pages :"+nPag);
if (nPag%2 == 0){
middleP = nPag/2;
}
else{
middleP = (nPag+1)/2;
}
System.out.println("Middle page is no:"+middleP);
PageBinarySearch BinarySearch;
String key;
for(DictPage p : listOfWords){
key = p.getWord();
BinarySearch = new PageBinarySearch("C:\\Kennedy.txt", key , DataPageSize, nPag, numOfWords);
}
}
}
My program is not working well and i can't find what I am doing wrong . | <java><file><search><binary><adt> | 2016-03-26 09:44:05 | LQ_EDIT |
36,233,838 | How to pass the text box data using session to the nextpage in php | I want to pass the text box data to the next page(demo2) and i need to save all the data together in my db i tried using session the value i passed is sending to the next page but i want the textbox data to be passed...
Help me out!!
Below is my code
**demo1.php**
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
**demo1.php**
<?php
session_start();
if($_POST)
{
if($_POST['act'] == "add")
{
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$nationality = $_POST['nationality'];
$conn = mysql_connect("localhost","root","");
$db = mysql_select_db("reg",$conn);
}
}
echo "Session variables are set.";
if(@$_GET)
{
$_SESSION["firstname"] = "$firstname";
$_SESSION["lastname"] = " $lastname";
$_SESSION["nationality"] = "$nationality";
echo $firstname;
echo $lastname;
echo $nationality;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<form method="POST">
<?php if(isset($_GET['id'])) { ?>
<input type="hidden" name="act" value="edit"/>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<?php } else{ ?>
<input type="hidden" name="act" value="add"/>
<?php } ?>
<label> FirstName</label>
<input type="text" name="firstname" value="<?php echo @$firstname; ?>"><br>
<label> LastName</label>
<input type="text" name="lastname" value="<?php echo @$lastname; ?>"><br>
<label> Nationality</label>
<input type="text" name="nationality" value="<?php echo @$nationality; ?>"><br>
<a href="demo2.php"> <input type="button" id="next" name="next" value="next" >
<?PHP $_SESSION["firstname"] = "Preethi";
$_SESSION["lastname"] = " Rajan";
$_SESSION["nationality"] = "Indian"; ?>
</form>
</body>
</html>
<!-- end snippet -->
**demo2.php**
<?php
session_start();
if($_POST)
{
if($_POST['act'] == "add")
{
$firstname= $_SESSION['firstname'];
$lastname= $_SESSION['lastname'];
$nationality= $_SESSION['nationality'];
$mobileno = $_POST['mobileno'];
$email = $_POST['email'];
$commaddr = $_POST['commaddr'];
$city = $_POST['city'];
$pincode = $_POST['pincode'];
$state = $_POST['state'];
$permaddr = $_POST['permaddr'];
$conn = mysql_connect("localhost","root","");
$db = mysql_select_db("reg",$conn);
$sql = "INSERT INTO registration (firstname,lastname,nationality,mobileno,email,commaddr,city,pincode,state,permaddr) VALUES ('".$_SESSION["firstname"]."','".$_SESSION["lastname"]."' ,'".$_SESSION["nationality"]."', '".$mobileno."' , '".$email."' , '".$commaddr."','".$city."','".$pincode."','".$state."','".$permaddr."')";
$rep = mysql_query($sql);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<form action="demo2.php" method="POST">
<?php if(isset($_GET['id'])) { ?>
<input type="hidden" name="act" value="edit"/>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<?php } else{ ?>
<input type="hidden" name="act" value="add"/>
<?php } ?>
<label> Mobile Number</label>
<input type="text" name="mobileno" value="<?php echo @$mobileno; ?>"><br>
<label> E Mail ID</label>
<input type="text" name="email" value="<?php echo @$email; ?>"><br>
<label> Communication Address</label>
<input type="text" name="commaddr" value="<?php echo @$commaddr; ?>"><br>
<label> City</label>
<input type="text" name="city" value="<?php echo @$city; ?>"><br>
<label>Pin Code</label>
<input type="text" name="pincode" value="<?php echo @$pincode; ?>"><br>
<label>State</label>
<input type="text" name="state" value="<?php echo @$state; ?>"><br>
<label> Permanent Address</label>
<input type="text" name="permaddr" value="<?php echo @$permaddr; ?>"><br>
<input type="submit" name="submit" value="submit" style="height:50px; width:150px">
</form>
</body>
</html> | <php><html><session> | 2016-03-26 09:46:34 | LQ_EDIT |
36,233,842 | c system function gets before other strings | <p>i am trying to write a simple c program that prints the C compiler version. so i wrote:</p>
<pre><code>#include <stdio.h>
int main() {
printf("you have %d", system("gcc --version");
}
</code></pre>
<p>the output:</p>
<pre><code>gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
you have compiler 0
</code></pre>
<p>any idea?</p>
| <c><system> | 2016-03-26 09:46:48 | LQ_CLOSE |
36,234,088 | How do I point a docker image to my .m2 directory for running maven in docker on a mac? | <p>When you look at the <a href="https://github.com/carlossg/docker-maven/blob/40cbcd2edc2719c64062af39baac6ae38d0becf9/jdk-7/Dockerfile" rel="noreferrer">Dockerfile for a maven build</a> it contains the line:</p>
<pre><code>VOLUME /root/.m2
</code></pre>
<p>Now this would be great if this is where my <code>.m2</code> repository was on my mac - but it isn't - it's in</p>
<pre><code>/Users/myname/.m2
</code></pre>
<p>Now I could do:</p>
<p>But then the linux implementation in Docker wouldn't know to look there. I want to map the linux location to the mac location, and have that as part of my <code>vagrant init</code>. Kind of like:</p>
<pre><code>ln /root/.m2 /Users/myname/.m2
</code></pre>
<p>My question is: <strong>How do I point a docker image to my .m2 directory for running maven in docker on a mac?</strong></p>
| <linux><macos><maven><docker><vagrant> | 2016-03-26 10:13:59 | HQ |
36,234,635 | What is the equivalent of django.db.models.loading.get_model() in Django 1.9? | <p>I want to use <code>get_model()</code> to avoid cyclic imports in my models, but I get <code>name 'get_model' is not defined</code> error. I read that <code>get_model()</code> was depreciated in 1.8 and apparently is not present in 1.9. What is the equivalent call? Or is there another way to avoid cyclic imports in two <code>models.py</code> files?</p>
| <django> | 2016-03-26 11:18:22 | HQ |
36,235,446 | Angular2 template driven async validator | <p>I have a problem with defining asynchrous validator in template driven form.</p>
<p>Currently i have this input:</p>
<pre><code><input type="text" ngControl="email" [(ngModel)]="model.applicant.contact.email" #email="ngForm" required asyncEmailValidator>
</code></pre>
<p>with validator selector <strong>asyncEmailValidator</strong> which is pointing to this class:</p>
<pre><code>import {provide} from "angular2/core";
import {Directive} from "angular2/core";
import {NG_VALIDATORS} from "angular2/common";
import {Validator} from "angular2/common";
import {Control} from "angular2/common";
import {AccountService} from "../services/account.service";
@Directive({
selector: '[asyncEmailValidator]',
providers: [provide(NG_VALIDATORS, {useExisting: EmailValidator, multi: true}), AccountService]
})
export class EmailValidator implements Validator {
//https://angular.io/docs/ts/latest/api/common/Validator-interface.html
constructor(private accountService:AccountService) {
}
validate(c:Control):{[key: string]: any} {
let EMAIL_REGEXP = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;
if (!EMAIL_REGEXP.test(c.value)) {
return {validateEmail: {valid: false}};
}
return null;
/*return new Promise(resolve =>
this.accountService.getUserNames(c.value).subscribe(res => {
if (res == true) {
resolve(null);
}
else {
resolve({validateEmailTaken: {valid: false}});
}
}));*/
}
</code></pre>
<p>}</p>
<p>Email regex part is working as expected and form is being validated successfuly if regex is matching. But after that I want to check if e-mail is not already in use, so im creating promise for my accountService. But this doesn't work at all and form is in failed state all the time. </p>
<p>I've read about model driven forms and using FormBuilder as below:</p>
<pre><code>constructor(builder: FormBuilder) {
this.email = new Control('',
Validators.compose([Validators.required, CustomValidators.emailFormat]), CustomValidators.duplicated
);
}
</code></pre>
<p>Which have async validators defined in third parameter of <strong>Control()</strong> But this is not my case because im using diffrent approach.</p>
<p>So, my question is: is it possible to create async validator using template driven forms?</p>
| <validation><asynchronous><typescript><angular> | 2016-03-26 12:45:26 | HQ |
36,235,802 | How to count for each row using other table in SQL? | <p>I have two tables: book table and author table. I need to count for each author how many book is registered in book table. How to do that?</p>
| <mysql><sql> | 2016-03-26 13:22:35 | LQ_CLOSE |
36,236,464 | this method add a request to a queue but what is done in second line of code ? | public <T> void addToRequestQueue(Request<T> req, String tag) {
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
what is done in this second line i cant understand what is this (tag) ?TAG :tag ...I mean what is this code done | <java><string><ternary-operator> | 2016-03-26 14:28:48 | LQ_EDIT |
36,237,253 | Android - transform Classes With Dex For Debug | <p>My project was working fine until I added the Facebook dependency.
I've started getting this error.
I've read many question, the problem seems to be related to <code>MultiDex</code>.
But none of the solutions worked for me</p>
<pre><code>Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1
</code></pre>
<p>Even after I remove what I've added, it still show and also gradle seems to be taking a lot of time while building than usual </p>
<p>Here is my build.gradle</p>
<pre><code>apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "net.ciblo.spectrodraft"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
}
</code></pre>
| <android><android-gradle-plugin><android-multidex> | 2016-03-26 15:41:50 | HQ |
36,237,847 | Why using checkout and reset naming for the file-level operations in git? | <p>After reading <a href="https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting/summary" rel="nofollow noreferrer">this</a> nice article on git Reset, Checkout, and Revert I still don't quite understand the connection between some commands naming and their behaviour. Let's take a look at the table below:</p>
<p><a href="https://i.stack.imgur.com/2r8AX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2r8AX.png" alt="enter image description here"></a></p>
<p>On the commit-level the naming-behaviour correspondences seem fine to me, but on the file-level instead of typing <code>git checkout <some_file></code> I would rather go with <code>git reset <some_file></code> because what we are essentially doing here is resetting.</p>
<p>And in for the unstaging procedure I would expect to have something like <code>git unstage <some_file></code>. Much more understandable and nice.</p>
<p>So, is this weird naming for the file-level <code>checkout</code> and <code>unstage</code> is just a historical legacy or there is some logical reasons behind it?</p>
| <git> | 2016-03-26 16:32:00 | LQ_CLOSE |
36,238,400 | How can I create sections on my app? [ANDROID] | I want to improve my new app so I have question for you. How can I make sections in my app, in Navigation Drawer?
[There's a photo if you don't understand what's in my mind. This photo is from Google Play][1]
[1]: http://i.stack.imgur.com/65r7O.png
There's my activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_pagrindinis"
android:icon="@drawable/ic_menu_pagrindinis"
android:title="Pagrindinis" />
<item
android:id="@+id/nav_soctinklai"
android:icon="@drawable/ic_menu_soctinklai"
android:title="Gimnazijos socialiniai tinklai" />
<item
android:id="@+id/nav_dienynas"
android:icon="@drawable/ic_menu_dienynas"
android:title="El. dienynas" />
<item
android:id="@+id/nav_naudingosnuor"
android:icon="@drawable/ic_menu_naudingosnuor"
android:title="Naudingos nuorodos"/>
<item
android:id="@+id/nav_kontaktai"
android:icon="@drawable/ic_menu_kontaktai"
android:title="Kontaktinė informacija" />
</group>
</menu>
And there's an excerpt from MainActivity.java
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_pagrindinis) {
//Set the fragment initially
PagrindinisFragment fragment = new PagrindinisFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
// Handle the camera action
} else if (id == R.id.nav_soctinklai) {
//Set the fragment initially
SocTinklaiFragment fragment = new SocTinklaiFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
} else if (id == R.id.nav_dienynas) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://sistema.tamo.lt"));
startActivity(i);
} else if (id == R.id.nav_naudingosnuor) {
} else if (id == R.id.nav_kontaktai) {
KontaktaiFragment fragment = new KontaktaiFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
I want to make section in this place
android:id="@+id/nav_naudingosnuor"
Thanks for your support, mates! :) | <java><android> | 2016-03-26 17:22:31 | LQ_EDIT |
36,238,545 | Erro pattern output | I have a shell script which writes sqlplus errors to a log with the following output. I only want to capture @DB with errors and redirect to output to a error log. any tips? :
@DB_1
ERROR-123
ORA-123
@DB_2
@DB_3
@DB_4
ERROR-2222
ORA-3333
thx. | <oracle><shell><sqlplus> | 2016-03-26 17:36:35 | LQ_EDIT |
36,238,561 | select n rows, evaluate a condition, swap the columns if met using R | <p>I have a situation that I am curious to know how R can handle efficiently. let's say I have a data set that has two columns-V1 and V2.
Now, I want a way to evaluate column V1 and check in 3 rows at a time (i.e rows 1 to 3, then 4 to 6 and so on) for the following two conditions:-
a) do either of the 3 rows of V1 contain zero
b) do either of 3 rows of V1 contains a three digit number</p>
<p>if the conditions meet, then we swap the 3 values in V1 column with the values in V2.</p>
<p>I am struggling to find a way to do this in R. This has to be done over 500,000 rows and 5 columns, so efficiency would be important.</p>
<p>Thanks!</p>
| <r> | 2016-03-26 17:37:31 | LQ_CLOSE |
36,238,619 | Extending multiple recommended configurations in ESLint | <p><strong>The Story:</strong></p>
<p>Currently, we are <em>extending the recommended ESLint configuration</em>:</p>
<pre><code>{
"extends": "eslint:recommended",
...
"plugins": [
"angular",
"jasmine",
"protractor"
],
"rules": {
"no-multiple-empty-lines": 2,
"no-trailing-spaces": 2,
"jasmine/valid-expect": 2
}
}
</code></pre>
<p>And also using <code>angular</code>, <code>jasmine</code> and <code>protractor</code> ESLint plugins which also ship with <em>their own recommended configurations</em> (default rule strictness levels and default rule parameters). </p>
<p><strong>The Question:</strong></p>
<p>How can we use all the recommended configurations at the same time - the one that ESLint and all the used plugins ship with?</p>
<hr>
<p>Tried the following:</p>
<pre><code>{
"extends": [
"eslint:recommended",
"plugin:protractor/recommended",
"plugin:jasmine/recommended",
"plugin:angular/recommended"
],
...
}
</code></pre>
<p>but got the following error:</p>
<blockquote>
<p>Cannot read property 'recommended' of undefined</p>
</blockquote>
| <javascript><angularjs><jasmine><static-code-analysis><eslint> | 2016-03-26 17:42:03 | HQ |
36,239,193 | I'm currently learning JavaScript and am having problems with my code | So I am practicing JavaScript in the Brackets Text Editor after learning a little bit of it on Codecademy.
I want to alter the text in the p tags to gain (upon clicking the text) the properties set by the attribution class.
Here is the HTML:
<p onclick="function">Hello</p>
CSS:
.attribution{
color:blue;
font-weight:bold;
}
Javascript:
var main = function() {
$('<p>').text('.attribution');
};
$(document).ready(main);
Thank You!
| <javascript><html><css> | 2016-03-26 18:32:28 | LQ_EDIT |
36,239,903 | What's the difference between Remove and Exclude when refactoring with PyCharm? | <p>The <a href="https://www.jetbrains.com/help/pycharm/2016.1/refactoring-source-code.html?origin=old_help" rel="noreferrer">official PyCharm docs</a> explain <code>Exclude</code> when it comes to refactoring: One can, say, rename something with refactoring (Shift+F6), causing the Find window to pop up with a Preview. Within, it shows files which will be updated as a result of the refactor. One can right-click on a file or folder in this Preview and choose <code>Remove</code> or <code>Exclude</code>. What's the difference? </p>
| <refactoring><pycharm> | 2016-03-26 19:29:55 | HQ |
36,239,997 | Validate multiple textbox in javascript? | i want to validate name, email,zip code on button click, but it's showing only last error msg, not specific to the filed, i m wirtting this code in javascript & jquery. anyone please help us . thanks | <javascript> | 2016-03-26 19:39:09 | LQ_EDIT |
36,240,080 | trying to get perl regex to "find" multi-line AND single-line HTML comments in an HTML file.... | I'm reading in an html file, trying to find HTML comments, both single and multi-line. I've stripped it down to just a few examples, and some other content just to have something there.
I've read a lot of the entries here, can't get a definitive answer to this... I'm reading in the html file in "slurp" mode, and doing a match of my pattern.. this code runs now and produce 1 (the first) match..
#!C:\Perl\bin\perl.exe
BEGIN { unshift @INC, 'C:\rmhperl';}
use warnings;no warnings 'uninitialized';
chdir 'c:\watts\html';
open FILE, "test.html" or print 'error opening file "test.html" ';
my $text = do { local $/; <FILE> };
close(FILE);
if ($text =~ m/(?s)(<!--.*?)(-->\n)/sg) {
print "1 = $1 2= $2\n";
}
exit;
in my html file, I've set up single and multi-line html comments... I can get the first OR the last to appear, but not EVERY one (at least in "slurp" mode)...
I'm told I should be able to accomplish this with one regex... so the objective is "find ALL HTML comments, regardless of their being single/multi-line comments"...
so I built the regex to find both... it doesn't find the single-lines, and only finds 1 match...
I'm trying to find switches/way to tell regex to find EVERY match, whether it occurs on one line, or is a multi-line... I can do it either/or, but can't get them to work with one regex...
I can do non-slurp mode, and find the "<!--" tag, then loop until I see the "-->" tag, but wanted to see if I can get it to work...
I've been reading about this, and trying to find relevant examples... can't see what I'm missing... Here's the HTML file snippet I have been using for the regex:
#########################1st line of html file below #########################
<!DOCTYPE html>
<script type="text/javascript" src="fadeslideshow.js"></script>
<style>
.divTable {
display: block;
width: 100%;
}
.divTableBody, .divTableRow{ clear: both; }
.divTableCell {
border: 1px solid #999999;
float: left;
overflow: hide;
padding: 2%;
width: 45%; }
.divTable:after {
display: block;
font-size: 0;
content: " ";
clear: both;
height: 100px; }
</style>
<style type="text/css">
<!--
a:link {color: #0000ff;}
a:visited {color: #3563a8;}
a:active {color: #000000;}
a:hover {background-color: #000000;}
a {text-decoration: none;}
-->
</style>
</head>
<body class="home">
<div id="white_back">
<div style="text-align: center">
</div>
<div class="chromestyle" id="chromemenu">
<ul>
<!-- <li><a href="xyz.com">Home</a></li>
-->
<li><a href="#" rel="dropmenu0">About Us</a></li>
<li><a href="#" rel="dropmenu5">Publications</a></li>
</ul>
</div>
<!--1st drop down menu
-->
<div id="dropmenu0" class="dropmenudiv">
</div>
<!--2nd drop down menu -->
<div id="dropmenu1" class="dropmenudiv">
</div>
#########################last line of html file above#####################
any help, or rtfm reference link appreciated...
Mickey Holliday
| <html><regex><perl> | 2016-03-26 19:47:01 | LQ_EDIT |
36,240,135 | Script to add pre-made ppt to new ppt | <p>I have several ppt files, and I am wanting to create a script that asks which of these pre-made ppt files I would like to use to create a NEW presentation.
example -
I have ppt1, ppt2, ppt3 and ppt4.
A script opens asking "Select the ppt files you want to add to your new presentation" and then a list of these files is shown. I put a checkmark by the ones I want (let's say ppt2 and ppt4) and when I click OK it takes these files and copies or adds them to a new ppt and asks what I want to name the new presentation. That's all. I would think this would be easy, but I am new and looking for assistance. I have searched and tested several different scripting for powerpoint suggestions but nothing seems to be what I am looking for, or does not work. Even a simple starting point and I can take it from there (or at least I hope) LOL
Thanks in advance.</p>
| <vba><shell><powershell><powerpoint> | 2016-03-26 19:51:24 | LQ_CLOSE |
36,240,495 | <bound method Response.json of <Response [200]>> | <p>I trying to make a request GET to <a href="https://randomuser.me/api/" rel="noreferrer">https://randomuser.me/api/</a></p>
<pre><code>import requests
import json
url = "https://randomuser.me/api/"
data = requests.get(url).json
print data
</code></pre>
<hr>
<p>I kept getting</p>
<pre><code># <bound method Response.json of <Response [200]>>
</code></pre>
<p>How do I see the json response ? Something like this </p>
<pre><code>{
"results": [
{
"user": {
"gender": "female",
"name": {
"title": "ms",
"first": "kerttu",
"last": "tervo"
},
"location": {
"street": "9102 aleksanterinkatu",
"city": "eurajoki",
"state": "pirkanmaa",
"zip": 67561
},
"email": "kerttu.tervo@example.com",
"username": "silvercat709",
"password": "papa",
"salt": "tOCPX2GL",
"md5": "86c60371eeb94596916d66cee898c869",
"sha1": "d06c4f2e43f8c0e53d88e538655f1152169ce575",
"sha256": "5a6b011841b27b08c38d2091dfb3d7ca50f55192ca0fcf6929dae098316c9aae",
"registered": 1419602511,
"dob": 1266822680,
"phone": "03-479-964",
"cell": "047-950-61-69",
"HETU": "220210A290R",
"picture": {
"large": "https://randomuser.me/api/portraits/women/68.jpg",
"medium": "https://randomuser.me/api/portraits/med/women/68.jpg",
"thumbnail": "https://randomuser.me/api/portraits/thumb/women/68.jpg"
}
}
}
],
"nationality": "FI",
"seed": "7d24284202c2cfdb06",
"version": "0.8"
}
</code></pre>
| <python> | 2016-03-26 20:25:49 | HQ |
36,240,589 | In Julia, how to merge a dictionary? | <p>What is the best way to merge a dictionary in Julia?</p>
<pre><code>> dict1 = Dict("a" => 1, "b" => 2, "c" => 3)
> dict2 = Dict("d" => 4, "e" => 5, "f" => 6)
# merge both dicts
> dict3 = dict1 with dict2
> dict3
Dict{ASCIIString,Int64} with 6 entries:
"f" => 6
"c" => 3
"e" => 5
"b" => 2
"a" => 1
"d" => 4
</code></pre>
| <dictionary><merge><julia> | 2016-03-26 20:34:26 | HQ |
36,240,629 | What's the proper scheme file extension? | <p>Files of the programming language Scheme are by convention either of the extension <code>.scm</code> or <code>.ss</code>.</p>
<p>I'm interested in what the history of these extensions is, and also in the proper use, though it seems the universal attitude is that it's just whatever you prefer and it doesn't matter, but maybe I'm wrong about that.</p>
| <scheme> | 2016-03-26 20:39:27 | HQ |
36,240,692 | why thisphp code if else condition is not working please help me | CHECK THE IF ELSE STATEMENT ON after if(!empty){} section.
<form action="first.php" method ="post">
<input type="text" name="username" >Username</br>
<input type="password" name="password" >Password</br>
<input type="submit" value="Submit"></br>
</form>
<?php
if(isset($_POST['username'] )&& isset($_POST['password'])){
if(!empty($user) && !empty($pass)){
$user = $_POST['username'];
$pass = $_POST['password'];
if($user ==="habib" && $pass === "1234"){
echo $user;
echo $pass;
}else{
echo "wrong password and username";
}
}
}
?>
| <php> | 2016-03-26 20:46:12 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.