Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
38,645,319 | Order of operations not correct? (C++) | <p>I was writing a small Least common multiple algorithm and encountered something I don't understand. This is the first and last part of the code:</p>
<pre><code>long a = 14159572;
long b = 63967072;
int rest = 4;
long long ans;
.
. // Some other code here that is not very interesting.
.
else
{
//This appears correct, prints out correct answer.
ans = b/rest;
std::cout << a*ans;
}
</code></pre>
<p>But if I change the last "else" to this it gives an answer that is much smaller and incorrect:</p>
<pre><code> else
{
std::cout << a*(b/rest);
}
</code></pre>
<p>Anyone know why this is? I don't think it's an overflow since it was no negative number that came out wrong, but rather just a much smaller integer (around 6*10^8) than the actual answer (around 2.2*10^14). As far as I understand it should calculate "b/rest" first in both cases, so the answers shouldn't differ?</p>
| <c++><parentheses> | 2016-07-28 19:37:28 | LQ_CLOSE |
38,645,492 | How to set table name for @ElementCollection in hibernate | <p>I am using</p>
<pre><code>public class UserTask extends BaseObject implements Serializable {
@ElementCollection(targetClass = java.lang.String.class)
private List<String> userTaskMessage = new ArrayList<>();
.
.
.
.
</code></pre>
<p>Hibernate generate table, which name is <code>usertask_usertaskmessage</code>.</p>
<p>How do I set my name? For example <code>my_table_example</code></p>
<p>Thank you for your help!</p>
| <java><hibernate><annotations> | 2016-07-28 19:48:56 | HQ |
38,647,474 | the onmouseover function don't work | I have this table:
<tr><td><DIV align='center' onmouseover='dettaglio(<?php echo $cdclie;?>)' onmouseout='chiudiDettaglio()'>0</DIV></td>
and I have the javascript:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
<script>
// codice per mostrare il dettaglio
function dettaglio()
{
tooltip = '<div class="tooltiptopicevent" style="width:auto;height:auto;background:#feb811;position:absolute;z-index:10001;padding:10px 10px 10px 10px ; line-height: 200%;">'
+ 'Client' + ' ' + 'First and last name' + '</div>';
$("body").append(tooltip);
$(this).mouseover(function (e)
{
$(this).css('z-index', 10000);
$('.tooltiptopicevent').fadeIn('500');
$('.tooltiptopicevent').fadeTo('10', 1.9);
}).mousemove(function (e)
{
$('.tooltiptopicevent').css('top', e.pageY + 10);
$('.tooltiptopicevent').css('left', e.pageX + 20);
});
}
//
function chiudiDettaglio()
{
$(this).css('z-index', 8);
$('.tooltiptopicevent').remove();
}
</script>
<!-- end snippet -->
In the java script I want to read the database and return the result with json_encode.
to clarify : in java script must be the call to the php that returns me an array to be displayed with the " onmouseover "
Help me, thanks | <javascript> | 2016-07-28 22:02:43 | LQ_EDIT |
38,648,491 | What is a changeset in Git? | <p>What is changeset in Git? I keep hearing this term said, but cannot seem to find the answer online, and wikipedia is very vague. Is it if you commit 5 files at once via a git repository and type git log and see a single commit for that 5 files, that entire change is called a changeset?</p>
<pre><code>commit 01304a265f5d8f9bfd6eb64d3390846adc61db75
i.e.:Author: Some guy <someguy@hotmail.com>
Date: Thu Jul 28 18:28:07 2016 -0400
First commit
</code></pre>
<p>This entire thing would be a changeset?</p>
| <git> | 2016-07-28 23:54:17 | HQ |
38,648,772 | In Visual Studio Code How do I merge between two local branches? | <p>In Visual Studio Code it seems that I am only allowed to push, pull and sync. There is documented support for merge conflicts but I can't figure out how to actually merge between two branches. The Git command line within VSC (press F1) only facillitates a subset of commands:</p>
<p><a href="https://i.stack.imgur.com/Hy8qz.png"><img src="https://i.stack.imgur.com/Hy8qz.png" alt="eGit options available in VSCode"></a></p>
<p>Attempting to pull from a an alternate branch or push to an alternate branch yields:</p>
<p><a href="https://i.stack.imgur.com/KA3mY.png"><img src="https://i.stack.imgur.com/KA3mY.png" alt="git Command throttling"></a></p>
<p>Here's the documentation on VSCode's Git
<a href="https://i.stack.imgur.com/Hy8qz.png">Visual Studio Code Git Documentation</a></p>
<p>What am I overlooking?</p>
| <git><visual-studio-code> | 2016-07-29 00:32:52 | HQ |
38,649,442 | Mathematical derivation of O(n3) complexity for general three nested loops | http://stackoverflow.com/questions/526728/time-complexity-of-nested-for-loop goes into the mathematical derivation through summation of two loops O(n2) complexity.
I tried an exercise to derive how i can get O(n3) for the following examples of three nested loops.
Simple three nested loops.
--
for (int i = 1; i < n; i++)
for (int j = 1; j < n; j++)
for (int k = 1; k < n; k++)
print(i * k * j);
Summation is
= (n + n + n + .... + n) + (n + n + n + ... + n) + ... + (n + n + n + ... + n)
= n2 + n2 + .... + n2
n times n2 = O(n3)
Three nested loops not run n times from beginning
---
for(int i = 1; i < n; i++)
for(int j = i; j < n; j++)
for(int k = j; k < n; k++)
print(i *j * k)
The above is a pretty common form of nested loops and i believe the summation would be something as follows
= (n + (n -1) + (n -2) + (n - 3) + ... + 1)
+ ((n -1) + (n - 2) + (n - 3) +... + 1)
+ ((n -2) + (n -3) + (n - 4) + ... + 1)
+ ...
+ ((n - (n -2)) + 1)
= n(n - 1) /2 + (n-1) (n -2) / 2 + (n-2)(n-3)/2 + .... + 1
=
*From here i am slightly not sure if my logic is correct . I believe
each of the above evaluate to a polynomial whose greatest value is n2 and as thats what we care about in time complexity, the above equation breaks down to.*
= n2 + n2 + n2 +... +n2
= which is n times n2 = O(n3).
Is my assumption correct?
Three nested loops not run n times from end
--
for(int i = 1; i < n; i++)
for(int j = 1; j < i; j++)
for(int k = 1; k < j; k++)
print(i *j * k)
If the above was a two nested loop the summation would have been 1 + 2 + 3 + 4 + ... + n. However, for the three nested occurence i am deducing it to be
= 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3) + (1 + 2 + 3 + .... + n)
From here i am not sure how to derive O(n3) or how the above summation would be further simplified.
| <c++><algorithm><time-complexity><big-o><code-complexity> | 2016-07-29 02:07:42 | LQ_EDIT |
38,649,501 | Labeling boxplot in seaborn with median value | <p>How can I label each boxplot in a seaborn plot with the median value?</p>
<p>E.g.</p>
<pre><code>import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", data=tips)
</code></pre>
<p>How do I label each boxplot with the median or average value?</p>
| <python><matplotlib><seaborn> | 2016-07-29 02:13:10 | HQ |
38,649,793 | How to get distinct rows in dataframe using pyspark? | <p>I understand this is just a very simple question and most likely have been answered somewhere, but as a beginner I still don't get it and am looking for your enlightenment, thank you in advance:</p>
<p>I have a interim dataframe:</p>
<pre><code>+----------------------------+---+
|host |day|
+----------------------------+---+
|in24.inetnebr.com |1 |
|uplherc.upl.com |1 |
|uplherc.upl.com |1 |
|uplherc.upl.com |1 |
|uplherc.upl.com |1 |
|ix-esc-ca2-07.ix.netcom.com |1 |
|uplherc.upl.com |1 |
</code></pre>
<p>What I need is to remove all the redundant items in host column, in another word, I need to get the final distinct result like:</p>
<pre><code>+----------------------------+---+
|host |day|
+----------------------------+---+
|in24.inetnebr.com |1 |
|uplherc.upl.com |1 |
|ix-esc-ca2-07.ix.netcom.com |1 |
|uplherc.upl.com |1 |
</code></pre>
| <distinct><pyspark> | 2016-07-29 02:50:52 | HQ |
38,649,915 | Django; AWS Elastic Beanstalk ERROR: Your WSGIPath refers to a file that does not exist | <p>I am using this tutorial:
<a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html" rel="noreferrer">http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html</a></p>
<p>I create the <code>.ebextensions</code> directory inside the root directory, and put this <code>django.config</code> file in it:</p>
<pre><code>option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: mysite/wsgi.py
</code></pre>
<p>I've also tried setting the path to <code>mysite/mysite/wsgi.py</code> because I saw that work somewhere but it did not help me. </p>
<p>Everywhere I look shows a different <code>.config</code> file with different arrangements, and I don't know where to go from here. How can I properly set my WSGIPath in Elastic Beanstalk?</p>
| <python><django><amazon-web-services><amazon-ec2><amazon-elastic-beanstalk> | 2016-07-29 03:06:44 | HQ |
38,650,326 | dom ready event in React | <p>I have some components like below:</p>
<p><em>Wrapper: wrap Loader and Page</em></p>
<p><em>Loader: some animation</em></p>
<p><em>Page: page content</em></p>
<p>code like this:</p>
<pre><code><body>
<div id="app"></div>
</body>
class Loader extends Component {}
class Page extends Component {}
class Wrapper extends Component {
render() {
return (
<Loader/>
<Page />
);
}
}
ReactDOM.render(<Wrapper />, document.getElementById('app'));
</code></pre>
<p>I want hide Loader and show Page component after DOM has compeletely loaded.</p>
<p>How should I write dom ready event in <strong>React</strong>?</p>
<p>like jQuery: <code>$(window).on('ready')</code></p>
| <reactjs><domready> | 2016-07-29 04:03:00 | HQ |
38,651,104 | Sending data from one controller to another | <p>I think this is a very simple problem but i'm not able to figure it out.</p>
<p>I have 2 controllers in my angularjs file..</p>
<pre><code>analyzer.controller('AnalyzerController',function($scope,$http)
{
$scope.builds = [];
$http.get('/List').success(
function(data) {
$scope.builds = data.responseData;
});
$scope.showbuild=function(item){
alert(item);
}
});
analyzer.controller('Information',function($scope,$http)
{
$scope.cases = [];
$http.get('/info').success(
function(data) {
$scope.cases = data.responseData;
});
});
</code></pre>
<p>I want to send the value of item in the first controller to the 2nd controller . Item is the value user selects from a box of html page.</p>
| <angularjs> | 2016-07-29 05:29:25 | LQ_CLOSE |
38,651,177 | How to create a shared class and use it in another classes in swift | <p>I need to use a shared class for my new project for reusing objects and functions in swift .I also need to know how this can be used in another classes.
Thanks in Advance
Berry</p>
| <swift><shared><nsobject> | 2016-07-29 05:35:54 | LQ_CLOSE |
38,653,357 | How to set color for imageview in Android | <p>I want set icon into <code>ImageView</code> and i downloaded icons from this site : <a href="http://www.flaticon.com/" rel="noreferrer">FlatIcon</a><br>
Now i want set color to this icons but when use <code>setBackground</code> just add color for background and not set to icons!<br>
When use <code>NavigationView</code> i can set color to icons with this code : <code>app:itemIconTint="@color/colorAccent"</code>.<br></p>
<p>How can i set color to icons into <code>ImageView</code> such as <code>itemIconTint</code> ? Thanks all <3</p>
| <android> | 2016-07-29 07:52:06 | HQ |
38,653,800 | Why do ajax returns a TypeError undefined error if it calls a function on success? | <p>Im trying to get the contents of a json file from my localhost and display it on my page, i made a custom function <code>displayProfile</code> that is called inside the <code>success</code> whenever the file exist on the directory. the problem is i get an error saying: </p>
<blockquote>
<p>TypeError: data is undefined</p>
</blockquote>
<p><strong>JQUERY code version 1</strong></p>
<pre><code>$.ajax({
url:'api/profile.json',
dataType:'json',
data: {format: "json"},
success:function(data){
displayProfile();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//alert(textStatus+' '+errorThrown);
$("#myfirstname").text('Firstname');
$("#mymiddlename").text('M.I.');
$("#mylastname").text("Lastname");
$("#mybiography").text("Biography")
$("#myprofpic").attr("src","default.jpg");
$("#mycoverphoto").css("background-image","url(defaultcover.jpg");
}
});
var displayProfile = function(data){
// initialize values
var firstname = data.profile.firstname;
var middlename = data.profile.middlename;
var lastname = data.profile.lastname;
var biography = data.profile.biography;
var prof_pic = data.profile.profpic;
var cover_photo = data.profile.coverphoto;
// set values
$("#myfirstname").text(firstname);
$("#mymiddlename").text(middlename.substr(0,1)+".");
$("#mylastname").text(lastname);
$("#mybiography").text(biography)
$("#myprofpic").attr('src',prof_pic);
$("#mycoverphoto").css("background-image","url("+cover_photo+")");
};
</code></pre>
<p>But it works when i just copy the content of the function and paste it inside the success like this:</p>
<p><strong>JQUERY code version 2</strong></p>
<pre><code>$.ajax({
url:'api/profile.json',
dataType:'json',
data: {format: "json"},
success:function(data){
// initialize values
var firstname = data.profile.firstname;
var middlename = data.profile.middlename;
var lastname = data.profile.lastname;
var biography = data.profile.biography;
var prof_pic = data.profile.profpic;
var cover_photo = data.profile.coverphoto;
// set values
$("#myfirstname").text(firstname);
$("#mymiddlename").text(middlename.substr(0,1)+".");
$("#mylastname").text(lastname);
$("#mybiography").text(biography)
$("#myprofpic").attr('src',prof_pic);
$("#mycoverphoto").css("background-image","url("+cover_photo+")");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//alert(textStatus+' '+errorThrown);
$("#myfirstname").text('Firstname');
$("#mymiddlename").text('M.I.');
$("#mylastname").text("Lastname");
$("#mybiography").text("Biography")
$("#myprofpic").attr("src","default.jpg");
$("#mycoverphoto").css("defaultcover.jpg)");
}
});
</code></pre>
<p>Can you guys explain why version 2 works? i am a beginner with this languages. Thanks!</p>
| <javascript><jquery><json><ajax> | 2016-07-29 08:14:39 | LQ_CLOSE |
38,654,429 | button click inside Usercontrol loaded in main form | I have main form and 2 usercontrols.The main form contains split container, In splitcontainer.panel1 i loaded UserControl1. In usercontrol different buttons are placed. I wants to load usercontrol2 on panel2(in main form) on button clicks which are placed inside the usercontrol1. | <c#><winforms> | 2016-07-29 08:48:10 | LQ_EDIT |
38,654,438 | rvalues with copy operator | <p>Consider this simple class</p>
<pre><code>class Foo
{
public:
Foo() = default;
Foo(const Foo &) = default;
Foo & operator=(const Foo & rhs)
{
return *this;
}
Foo & operator=(Foo && rhs) = delete;
};
Foo getFoo()
{
Foo f;
return f;
}
int main()
{
Foo f;
Foo & rf = f;
rf = getFoo(); // Use of deleted move assignment.
return 0;
}
</code></pre>
<p>When I compile the example above I get <code>error: use of deleted function 'Foo& Foo::operator=(Foo&&)'</code></p>
<p>From the <a href="http://en.cppreference.com/w/cpp/language/copy_assignment">Copy Assignment</a>:</p>
<blockquote>
<p>If only the copy assignment is provided, all argument categories select it (as long as it takes its argument by value or as reference to const, since rvalues can bind to const references), which makes copy assignment the fallback for move assignment, when move is unavailable.</p>
</blockquote>
<p>Why doesn't the compiler fallback to copy assignment when const lvalue reference can bind to rvalue and <code>const Foo & f = getFoo();</code> works.</p>
<p>Compiler - gcc 4.7.2.</p>
| <c++><c++11> | 2016-07-29 08:48:52 | HQ |
38,656,955 | Allow implicit any only for definition files | <p>I am using TypeScript with the <code>"noImplicitAny": true</code> option set in my <code>tsconfig.json</code>.</p>
<p>I am using <a href="https://www.npmjs.com/package/typings"><code>typings</code></a> to manage type definition files and am including them using a reference path directive in the entry point of my app:</p>
<pre><code>/// <reference path="./typings/index.d.ts" />
</code></pre>
<p>The problem is that some of the definition files rely on implicit any, so now I get a lot of compile errors from <code>.d.ts</code> files.</p>
<p>Is there a way to disable/silence these errors, for example based on the path or the file type?</p>
| <typescript><typescript-typings> | 2016-07-29 10:49:55 | HQ |
38,658,063 | How can I make a good use of didFinishLaunchingWithOptions in Appdelegate (xcode,swift) | I want to extract some data from the server or database, now im confusing if i have to put the extracting code in didFinishLaunchingWithOptions() function or put the code in viewdidload() function in the first viewcontroller. what's the execution efficiency of both methods? Thanks. | <ios><swift> | 2016-07-29 11:48:03 | LQ_EDIT |
38,658,588 | How to add .0 if the value is not decimal in C# | I need to convert some value into decimal and show the value in
WPF Text Box i have done with the below
Double calculateinputPower="somegivenvalue";
String valuePower="somevalue";
Double calculatePower = Double.Parse(valuePower);
calculatePower = calculatePower - calculateinputPower + calculateErp * 1;
calculatePower = Double.Parse(String.Format("{0:0.0}", calculatePower));
valuePower = System.Convert.ToString(calculatePower);
ERP.Text = valuePower;
if my output value is like
ex:66.2356 -> 66.2 , 32.568 -> 32.5 , 22.35264 ->22.3
i am getting the format which i need exactly but if the output value is like
22,33,11,66,55 something like this then i want convert that value to
22->22.0
33->33.0
11->11.0
66->66.0 how can i get this in C#.
| <c#><string><format><decimal> | 2016-07-29 12:14:47 | LQ_EDIT |
38,658,913 | In Angular 2, how do I submit an input type="text" value upon pressing enter? | <p>I'm building a search box in my Angular 2 app, trying to submit the value upon hitting 'Enter' (the form does not include a button). </p>
<p><strong>Template</strong></p>
<pre><code><input type="text" id="search" class="form-control search-input" name="search" placeholder="Search..." [(ngModel)]="query" (ngSubmit)="this.onSubmit(query)">
</code></pre>
<p>With a simple onSubmit function for testing purposes...</p>
<pre><code>export class HeaderComponent implements OnInit {
constructor() {}
onSubmit(value: string): void {
alert('Submitted value: ' + value);
}
}
</code></pre>
<p>ngSubmit doesn't seem to work in this case. So what is the 'Angular 2 way' to solve this? (Preferably without hacks like hidden buttons)</p>
| <angular> | 2016-07-29 12:31:16 | HQ |
38,659,645 | Sort keys and values in dictionary using LINQ | <p>I just wrote some code adding data into this Dictionary:</p>
<pre><code> Dictionary<string, Dictionary<string, double>> studentsExamsMarks =
new Dictionary<string, Dictionary<string, double>>();
studentsExamsMarks.Add("Peter", new Dictionary<string, double>());
studentsExamsMarks["Peter"].Add("History", 5.15);
studentsExamsMarks["Peter"].Add("Biology", 4.20);
studentsExamsMarks["Peter"].Add("Physics", 4.65);
studentsExamsMarks.Add("John", new Dictionary<string, double>());
studentsExamsMarks["John"].Add("History", 6.00);
studentsExamsMarks["John"].Add("Biology", 3.75);
studentsExamsMarks["John"].Add("Physics", 4.15);
studentsExamsMarks.Add("Michael", new Dictionary<string, double>());
studentsExamsMarks["Michael"].Add("History", 3.00);
studentsExamsMarks["Michael"].Add("Biology", 3.95);
studentsExamsMarks["Michael"].Add("Physics", 4.95);
</code></pre>
<p>How should I sort and print first by the name of the student (ascending order)and than by the value of the doubles in the inner dictionary or by the name of the subject? I`ll be very thankful if you show me both Versions. Thank you!</p>
| <c#><linq><sorting><dictionary> | 2016-07-29 13:03:18 | LQ_CLOSE |
38,660,369 | Adding an element beneath the root based on condition |
I'm reading an xml file using SAX, then I'm comparing the children of the xml file to validation rules that I got from my database in (validateByRules) Now based on the validation, I'm adding to each chilld, a subchild: <DESC><DESC/> . Now What I want is that after iterating all the children of the document, if at least one validation is wrong, in any of the children. Then an element is added beneath the root of name: <error>. For that I created a counter in VALIDATEbYrULES. Bur from there I'm not positively sure on how to continue. Any help?
public void execute() throws Exception {
try{
Document xmlDoc = convertXmlFileToDocument("c:\\TEST.xml");
String xmlType = xmlDoc.getRootElement().getAttributeValue("type");
HashMap<String, HashMap<String, String>> hashValidationRules = getRulesByType(xmlType);
List<Element> childElem = xmlDoc.getRootElement().getChildren();
Element updatedElem = null;
updatedElem = validateByRules(hashValidationRules, childElem.get(j));
xmlDoc.getRootElement().getChildren().remove(j);
xmlDoc.getRootElement().getChildren().add(j, updatedElem);
}
}
private Element validateByRules(HashMap<String, HashMap<String, String>> hashValidationRules, Element element) {
HashMap<String, String> rules = null;
String desc = "";
String value = "";
int counter = 0;
String fileName = null;
for ( String key : hashValidationRules.keySet() ) {
rules = hashValidationRules.get(key);
if(rules.get("mandatory").equals("true") && (element.getChild(key)==null || element.getChild(key).getValue().equals(""))){
counter ++;
desc = "Mandatory Element ("+key+") does not exist";
}
value = element.getChild(key).getValue();
if(value.length()> Integer.parseInt(rules.get("size"))){
counter ++;
desc = "Field "+key+" exceeded max size ("+rules.get("size")+")";
}
}
element.addContent(new Element("DESC").setText(desc));
System.out.println(counter);
return element;
}
private Document convertXmlFileToDocument(String path){
SAXBuilder sb=new SAXBuilder();
File xmlFile = new File(path);
Document doc = null;
try {
doc = sb.build(xmlFile);
} catch (Exception e) {
e.printStackTrace();
}
return doc;
}
| <java><xml><file><copy> | 2016-07-29 13:38:53 | LQ_EDIT |
38,660,571 | Coding unity shaders with unity visual studio | <p>Recently I've been coding shaders for unity in visual studio and I've noticed that since unity shaders are written in a combination of unity's shader lab language and CG, visual studio 2015 doesn't seem to recognize the languages. Because of this, visual studio is not reconizing keywords, has no intellesense, and worse of all tabbing incorrectly whenever I press enter to go to a new line. I've tried this visual studio extension <a href="https://visualstudiogallery.msdn.microsoft.com/ed812631-a7d3-4ca3-9f84-7efb240c7bb5" rel="noreferrer">https://visualstudiogallery.msdn.microsoft.com/ed812631-a7d3-4ca3-9f84-7efb240c7bb5</a> and it doesn't seem to fully work. I was wondering if anyone on here has had experience working with shaders and has an extension they know about to fix this problem.</p>
| <unity3d><visual-studio-2015><code-formatting><cg> | 2016-07-29 13:49:15 | HQ |
38,660,735 | How bind Android DataBinding to Menu? | <p>As it supports Data Binding menu in android?
I write this code, but error: "Error:(16, 26) No resource type specified (at 'visible' with value '@{item.visible}')."</p>
<pre><code><menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="item"
type="ru.dixy.ubiworkerchecklistsmobile.Models.Fact"/>
<import type="android.view.View"/>
</data>
<item
android:id="@+id/compliteitem"
android:title="mybutton"
android:icon="@drawable/complite"
android:visible="@{item.visible}"
app:showAsAction="ifRoom"
/>
</menu>
</code></pre>
| <android><layout><data-binding> | 2016-07-29 13:58:00 | HQ |
38,661,958 | Making firebase storage public for reading and writing on android | <p>I am new to firebase storage. Can anyone tell me how to make the storage files public for reading and writing?. The default code provided by firebase is given below. What changes should I make ?</p>
<pre><code>service firebase.storage {
match /b/image-view-b1cf5.appspot.com/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
</code></pre>
| <android><firebase><firebase-realtime-database><firebase-authentication><firebase-security> | 2016-07-29 15:01:56 | HQ |
38,661,993 | C# passing objects to different methods | <p>I have a quick question. I have an object that I am trying to pass to a different method in a different class. </p>
<pre><code> public virtual void Geocode(ICustomer customer)
{
RouteObjects.Customer roCustomer = customer as RouteObjects.Customer;
if (customer != null)
{
RouteObjectsRepository.Geocode(roCustomer);
GeoCodeUpdateEventPublisher.UpdateGeoCustomer(roCustomer);
}
}
</code></pre>
<p>I am trying to pass the roCustomer object to GeoCodueUpdateEventPublisher in method updategeocustomer. my updateGeoCustomer looks like this </p>
<pre><code> public virtual void UpdateGeoCustomer(object roCustomer)
{
Publish(roCustomer);
}
</code></pre>
<p>I wanted to know if this is the proper way to pass this object? I am then going to call method publish and it will look something like this.</p>
<pre><code> protected virtual void Publish(object roCustomer)
{
PublishMessage publishMessage = CreatePublishMessage(roCustomer);
if (publishMessage != null)
{
Subscribers.AsParallel().ForAll(s => s.Send(publishMessage));
}
}
</code></pre>
<p>I am just trying to verify if I am passing this object around correctly</p>
| <c#><.net> | 2016-07-29 15:03:56 | LQ_CLOSE |
38,662,667 | matplotlib and subplots properties | <p>I'm adding a matplotlib figure to a canvas so that I may integrate it with pyqt in my application. I were looking around and using <code>plt.add_subplot(111)</code> seem to be the way to go(?) But I cannot add any properties to the subplot as I may with an "ordinary" plot</p>
<p>figure setup</p>
<pre><code>self.figure1 = plt.figure()
self.canvas1 = FigureCanvas(self.figure1)
self.graphtoolbar1 = NavigationToolbar(self.canvas1, frameGraph1)
hboxlayout = qt.QVBoxLayout()
hboxlayout.addWidget(self.graphtoolbar1)
hboxlayout.addWidget(self.canvas1)
frameGraph1.setLayout(hboxlayout)
</code></pre>
<p>creating subplot and adding data</p>
<pre><code>df = self.quandl.getData(startDate, endDate, company)
ax = self.figure1.add_subplot(111)
ax.hold(False)
ax.plot(df['Close'], 'b-')
ax.legend(loc=0)
ax.grid(True)
</code></pre>
<p>I'd like to set x and y labels, but if I do <code>ax.xlabel("Test")</code></p>
<pre><code>AttributeError: 'AxesSubplot' object has no attribute 'ylabel'
</code></pre>
<p>which is possible if I did it by not using subplot </p>
<pre><code>plt.figure(figsize=(7, 4))
plt.plot(df['Close'], 'k-')
plt.grid(True)
plt.legend(loc=0)
plt.xlabel('value')
plt.ylabel('frequency')
plt.title('Histogram')
locs, labels = plt.xticks()
plt.setp(labels, rotation=25)
plt.show()
</code></pre>
<p>So I guess my question is, is it not possible to modify subplots further? Or is it possible for me to plot graphs in a pyqt canvas, without using subplots so that I may get benefit of more properties for my plots.</p>
| <python><matplotlib> | 2016-07-29 15:39:57 | HQ |
38,662,676 | Removing Line Break (Special Character) in text file. VB.Net | I have a Text file which shows a Line Break in Ultraedit if we replace a special character in text file manually it works fine.[Line Break][1]. I have to change it manually and then process the files. Please let me know some way out pragmatically.
[1]: http://i.stack.imgur.com/T9W7y.jpg | <vb.net><file-io><special-characters><text-rendering><ultraedit> | 2016-07-29 15:40:33 | LQ_EDIT |
38,663,254 | How to interrupt, exit a compose or pipe? | <p>What's the proper way to interrupt a long chain of compose or pipe functions ?</p>
<p>Let's say the chain doesn't need to run after the second function because it found an invalid value and it doesn't need to continue the next 5 functions as long as user submitted value is invalid.</p>
<p>Do you return an undefined / empty parameter, so the rest of the functions just check if there is no value returned, and in this case just keep passing the empty param ?</p>
| <functional-programming><ramda.js> | 2016-07-29 16:13:10 | HQ |
38,663,428 | Android ScrollView gets cut off at the bottom | <p>I am trying to programmatically add form fields picked from an HTML file to a LinearLayout. I have a next button at the bottom but it keeps getting cut off in the display. I tried it on a tablet and it still doesnt show up. </p>
<p>Here's a screenshot of the app:
<a href="https://i.stack.imgur.com/EPBb6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EPBb6.png" alt="screenshot"></a></p>
<p>As you can see, the elements are getting rendered but the last one runs off the screen for some reason. </p>
<p>Fragment's XML:</p>
<pre><code><FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".dataInput.PropertyInfoFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linear_layout_property_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
<Button
android:id="@+id/nextButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/next"
android:background="@color/colorPrimary"
android:textColor="@android:color/white"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
</code></pre>
<p>Calling Activity's XML: </p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".dataInput.DataInputActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_media_play" />
</android.support.design.widget.CoordinatorLayout>
</code></pre>
<p>I am calling a method <code>formInflator</code> that I made in the fragment's <code>onCreateView</code> and passing the LinearLayout from the fragment and an <code>Elements</code> object (from Jsoup library) which contains all the Elements that I want to put inside the LinearLayout:</p>
<pre><code>@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_property_info, container, false);
nextButton = (Button) view.findViewById(R.id.nextButton);
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onButtonPressed();
}
});
helpers.formInflator((LinearLayout) view.findViewById(R.id.linear_layout_property_info), generator.propertyTextElements);
return view;
}
</code></pre>
<p>Here's the method <code>formInflator</code>:</p>
<pre><code>public void formInflator(LinearLayout parentLayout, Elements formElements) {
TextInputLayout index = null;
for(Element textField : formElements) {
TextInputEditText editText = new TextInputEditText(context);
editText.setId(View.generateViewId());
editText.setHint(textField.id());
editText.setText(textField.text());
LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
editText.setLayoutParams(editTextParams);
TextInputLayout textInputLayout = new TextInputLayout(context);
textInputLayout.setId(View.generateViewId());
textInputLayout.setTag(textField.id());
RelativeLayout.LayoutParams textInputLayoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
if (index == null)
index = textInputLayout;
else
textInputLayoutParams.addRule(RelativeLayout.BELOW, index.getId());
textInputLayout.setLayoutParams(textInputLayoutParams);
textInputLayout.addView(editText, editTextParams);
parentLayout.addView(textInputLayout, textInputLayoutParams);
index = textInputLayout;
}
}
</code></pre>
<p>Any idea what I am doing wrong?</p>
| <android><android-fragments><android-linearlayout><android-scrollview> | 2016-07-29 16:23:11 | HQ |
38,663,624 | dplyr: access current group variable | <p>After using data.table for quite some time I now thought it's time to try dplyr. It's fun, but I wasn't able to figure out how to access
- the current grouping variable
- returning multiple values per group</p>
<p>The following example shows is working fine with data.table. How would you write this with dplyr</p>
<pre><code>foo <- matrix(c(1, 2, 3, 4), ncol = 2)
dt <- data.table(a = c(1, 1, 2), b = c(4, 5, 6))
# data.table (expected)
dt[, .(c = foo[, a]), by = a]
a c
1: 1 1
2: 1 2
3: 2 3
4: 2 4
# dplyr (?)
dt %>%
group_by(a) %>%
summarize(c = foo[a])
</code></pre>
| <r><data.table><dplyr> | 2016-07-29 16:35:35 | HQ |
38,663,751 | How to safely render html in react? | <p>I've got some user generated html markup from a text area and I'd like to render it on another part of the screen. The markup is saved as a string in the props of the component. </p>
<p>I don't want to use dangerouslysethtml for obvious reasons. Is there a parser such as <a href="https://github.com/chjj/marked" rel="noreferrer">marked</a> but for html so that it strips out script tags and other invalid html. </p>
| <html><reactjs> | 2016-07-29 16:44:18 | HQ |
38,664,401 | How to declare a variable that can not insert in function | <p>I wanna declare a function with 2 Input parameters.</p>
<pre><code>function myFunc( $first , $second )
{
return $first;
}
</code></pre>
<p>When it called I only need the first parameter and don't wanna use "NULL" for the second.</p>
<pre><code>echo myFunc("Hello");
</code></pre>
<p>Sorry because of my poor English</p>
<p>Thanks</p>
| <php> | 2016-07-29 17:29:12 | LQ_CLOSE |
38,664,421 | How do I call git diff on the same file between 2 different local branches? | <p>Is there a way to check the difference between the working directory in my current branch against the working directory of another branch in a specific file? For example, if I'm working in branch A on file 1, I want to compare the difference with file 1 on branch B.</p>
| <git><diff><git-branch><git-diff><working-directory> | 2016-07-29 17:30:29 | HQ |
38,665,282 | How to set custom context for docker.build in jenkinsfile | <p>I'm trying to adapt a docker build for jenkins. I'm following our docker-compose file and I'm creating a Jenkinsfile that is creating each container and linking them together. The problem I'm running into is that the docker-compose files declare a context that is not where the Dockerfile is. As far as I understand, jenkins will set the context to where the Dockerfile is, which puts files to be copied in a different relative location depending on whether the jenkinsfile or docker-compose file is building.</p>
<p>The folder structure is:</p>
<pre><code>workspace
|-docker
|-db
|-Dockerfile
|-entrypoint.sh
</code></pre>
<p>This is how the Dockerfile declares the COPY instruction for the file in question</p>
<pre><code>COPY docker/db/entrypoint.sh /
</code></pre>
<p>This is how my jenkinsfile builds the file. Which to my knowledge puts the context at that directory</p>
<pre><code>docker.build("db", "${WORKSPACE}/docker/db")
</code></pre>
<p>the docker-compose file declares it like:</p>
<pre><code>db:
build:
context: .
dockerfile: docker/db/Dockerfile
</code></pre>
<p>which puts the context at the root of the project.</p>
<p>Is there any way to tell a jenkinsfile to use the same context as the docker-compose file so that the Dockerfile's COPY instruction can remain unchanged and valid for both Jenkins and docker-compose? If that's not possible, does anyone know of any alternative solutions?</p>
| <docker><jenkins-pipeline><jenkinsfile> | 2016-07-29 18:24:27 | HQ |
38,665,904 | Why does increase() return a value of 1.33 in prometheus? | <p>We graph a timeseries with <code>sum(increase(foo_requests_total[1m]))</code> to show the number of foo requests per minute. Requests come in quite sporadically - just a couple of requests per day. The value that is shown in the graph is always 1.3333. Why is the value not 1? There was one request during this minute.</p>
<p><a href="https://i.stack.imgur.com/eGgIh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eGgIh.png" alt="enter image description here"></a></p>
| <prometheus> | 2016-07-29 19:04:15 | HQ |
38,666,404 | not enough arguments in call to method expression | <p>While learning go I came to following error: </p>
<pre><code>prog.go:18: not enough arguments in call to method expression JSONParser.Parse
</code></pre>
<p>in my test program (<a href="https://play.golang.org/p/PW9SF4c9q8" rel="noreferrer">https://play.golang.org/p/PW9SF4c9q8</a>):</p>
<pre><code>package main
type Schema struct {
}
type JSONParser struct {
}
func (jsonParser JSONParser) Parse(toParse []byte) ([]Schema, int) {
var schema []Schema
// whatever parsing logic
return schema, 0
}
func main() {
var in []byte
actual, err2 := JSONParser.Parse(in)
}
</code></pre>
<p>Anyone willing to help me to move on here?</p>
| <go> | 2016-07-29 19:43:22 | HQ |
38,666,556 | How to access array within PHP object | <p>I know this question is a little n00b but I am struggling to work out to how to access the array 'ta[]' within the PHP object below. Usually I would have no problem but because my key contains the brackets i.e. 'ta[]' I can't wrap my head around how to access it, I guess I somehow need to escape it..?</p>
<p>I have tried most combinations such as..</p>
<pre><code>object->ta[]
object["ta[0]"]
object["ta[]"]
object->ta[0]
</code></pre>
<p>Any help welcome!</p>
<pre><code>object(stdClass)#6 (11) {
["tc"]=> string(4) "4500"
["tct"]=> string(1) "1"
["pd"]=> string(2) "AT"
["df"]=> string(10) "08/04/2016"
["dt"]=> string(10) "08/08/2016"
["nt"]=> string(1) "2"
["ta[]"]=> array(2)
{
[0]=> string(2) "40"
[1]=> string(2) "35"
}
["rc"]=> string(2) "US"
["rs"]=> string(2) "AR"
["cc"]=> string(2) "US"
["dfp"]=> string(10) "07/30/2016"
}
</code></pre>
| <php><object> | 2016-07-29 19:54:30 | LQ_CLOSE |
38,666,676 | What is this techinique called? | <p>I come from C#. A small example with C# syntax:</p>
<pre><code>// using System.Linq;
int[] array = { 1, 2, 3, 5 };
int result = array.SingleOrDefault(x => x % 2 == 0);
</code></pre>
<p>I want to <code>convert</code> that syntax to javascript syntax:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>Array.prototype.singleOrDefault = function (tsource) {
var $self = this
if ($self.length) {
for (let i = 0; i < $self.length; i++) {
if (tsource($self[i])) {
return $self[i]
}
}
return null
}
};
var test = function () {
var array = [1, 2, 3, 5];
var result = array.singleOrDefault(x => x % 2 === 0)
if (result !== null) {
alert(result)
}
};</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><button onclick="test()">Click me</button></code></pre>
</div>
</div>
</p>
<p>In C#: <code>.SingleOrDefault(TSource)</code> is called <code>Linq method</code> which referenced from <code>System.Linq</code> namespace.</p>
<p>So, my question is: what is <code>.singleOrDefault(x => x % 2 === 0)</code> called in this case (in javascript)?</p>
| <javascript> | 2016-07-29 20:05:02 | LQ_CLOSE |
38,666,719 | Calculating average of all bytes in a given file in C | <p>I wrote the program but couldn't find the problem. Its reading file well but gives result 0. Did I do anything wrong on passing the file pointer?</p>
<pre><code>#include <stdio.h>
unsigned char average(const char *filename){
unsigned int BLOCK_SIZE=512;
unsigned int nlen=0, nround=0;
unsigned char avg = 0;
FILE *fp;
unsigned char tmp[512];
if ( (fp = fopen(filename,"r")) == NULL){
printf("\nThe file did not open\n.");
return 500;
}
while(!feof(fp)){
if(fread(tmp, 1, BLOCK_SIZE, fp)){
nlen+=BLOCK_SIZE;
nround++;
}else{
BLOCK_SIZE=BLOCK_SIZE/2;
}
}
avg=(unsigned char)(nlen/nround);
return avg;
}
int main(void){
printf(" The average of all bytes in the file : %d \n" ,average("v") );
return 0;
}
`
</code></pre>
| <c> | 2016-07-29 20:08:20 | LQ_CLOSE |
38,666,841 | foo(bar) and foo(bar, baz) | <p>In ES6, is it possible to have some code like this:</p>
<pre><code>class MyClass
{
foo(bar)
{
console.log(bar + "Bar")
}
foo(bar, baz)
{
console.log(bar + baz + "Bar baz")
}
}
</code></pre>
<p>so that when I did:</p>
<pre><code>MyClass.foo("Hello, ", "World and ")
</code></pre>
<p>I would get:</p>
<pre><code>Hello, World and Bar baz
</code></pre>
<p>And I would be able to do:</p>
<pre><code>MyClass.foo("Hello, world!")
</code></pre>
<p>to get:</p>
<pre><code>Hello, world!Bar
</code></pre>
<p>like in Java?</p>
| <javascript><ecmascript-6> | 2016-07-29 20:17:29 | LQ_CLOSE |
38,667,142 | node.js noobie trying to follow a tutorial - need to change jade reference to pug | <p>I'm trying to follow this tutorial to learn about node.js: </p>
<p><a href="http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/" rel="noreferrer">http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/</a></p>
<p>When I run "npm install" some of the messages I see include this:</p>
<pre><code>npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
</code></pre>
<p>And then it goes ahead and seems to set up the application anyways.
My package.json file currently looks like this: </p>
<pre><code>{
"name": "testapp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"jade": "~1.11.0",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0",
"mongodb": "^1.4.4",
"monk": "^1.0.1"
}
}
</code></pre>
<p><strong>Questions:</strong>
(these questions apply to both packages that I got warned about, but for discussion purposes, I'm just going to pick on jade / pug)</p>
<p>If I wanted to change jade to pug, do i need to specify a version number in this package.json file? Or can I just tell it to get latest somehow?
Also, do I need to blow away my folder structure and then rerun the npm install command? Or can I just edit the package.json file and retry npm install? </p>
<p>Lastly, based on your experience, how critical is it for me to change from jade to pug if i'm just trying to learn how node works? I'm tempted to just leave as is... but then again, if this app works, i know it's going to be rolled out into production..
so... i guess i should make the right decisions up front. </p>
<p>Thanks and sorry if my questions are really remedial. </p>
| <json><node.js><mongodb><express> | 2016-07-29 20:40:44 | HQ |
38,667,386 | Testing Google Cloud PubSub push endpoints locally | <p>Trying to figure out the best way to test PubSub push endpoints locally. We tried with ngrok.io, but you must own the domain in order to whitelist (the tool for doing so is also broken… resulting in an infinite redirect loop). We also tried emulating PubSub locally. I am able to publish and pull, but I cannot get the push subscriptions working. We are using a local Flask webserver like so:</p>
<pre><code>@app.route('/_ah/push-handlers/events', methods=['POST'])
def handle_message():
print request.json
return jsonify({'ok': 1}), 200
</code></pre>
<p>The following produces no result:</p>
<pre><code>client = pubsub.Client()
topic = client('events')
topic.create()
subscription = topic.subscription('test_push', push_endpoint='http://localhost:5000/_ah/push-handlers/events')
subscription.create()
topic.publish('{"test": 123}')
</code></pre>
<p>It does yell at us when we attempt to create a subscription to an HTTP endpoint (whereas live PubSub will if you do not use HTTPS). Perhaps this is by design? Pull works just fine… Any ideas on how to best develop PubSub push endpoints locally?</p>
| <google-cloud-pubsub> | 2016-07-29 20:58:24 | HQ |
38,667,891 | Does web scraping pull contents from a database (php) | <p>I don't know anything about web scraping so before I spend time toying with it I want to see if it will even work for what I'm trying to do. I want to be able to return all the pertinent information about a part using the part number (quantity, cost, etc.) I assume the contents of the website is stored in a database so my question is does web scraping have the ability to get to the contents on the database?</p>
<p>Thanks for the help. </p>
| <php><web-scraping> | 2016-07-29 21:42:19 | LQ_CLOSE |
38,668,147 | An unhandled exception of type 'System.Net.WebException' occurred in System.dll i dont know how to fix it | MY CODE
I keep getting this error i have no idea how to fix it 1 hour still no solutions
===============================================
InitializeComponent();
pictureBox1.BackColor = Color.Transparent;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
using (WebClient client = new WebClient())
{
client.DownloadFile("http://itzyzex.comlu.com/itzy.PNG", @"C:\Users\fatih\Desktop\stuff");
}
}
// WebClient Client = new WebClient();
//Client.DownloadFile("https://cdn.meme.am/instances/60569499.jpg", @"C:\Users\fatih\Desktop");
}
} | <c#><.net><visual-studio> | 2016-07-29 22:06:24 | LQ_EDIT |
38,668,280 | C++ operator overloading for embedded DSL language in C++ | <p>Is it possible to use C++ operator overloading and create a DSL-like syntax for embedded DsL code in c++.</p>
<pre><code>"a": auto = call("add2Numbers", "b", "c");
</code></pre>
<p>This is what I would like ideally. But anything close to this as valid C++ would be acceptable.</p>
| <c++><operator-overloading> | 2016-07-29 22:20:50 | LQ_CLOSE |
38,668,434 | Please anyone tell me how to put this php myql query in proper way | <p>I have written the query below but there is no errors and no records are updated
please can anyone correct it.</p>
<pre><code>$db->query("INSERT INTO members (username, password, email)
VALUES ('$username', '$password', '$email')");
</code></pre>
| <php><mysql><sql><mysqli> | 2016-07-29 22:36:10 | LQ_CLOSE |
38,668,444 | 'Go Get' Private Repo from Bitbucket | <p>So basically, I have an Openshift Project that on Git push, downloads all libraries with 'Go get' and builds the project on-the-fly and so, I have some code I don't want people to see from my own library, and for it to compile properly, the code needs to be taken from github.com or another repo, so I created a private bitbucket.org repo, now, as a public repo it works fine, but when I try to 'Go Get' from my private repo, it gives me 'Forbidden 403' </p>
<p>How can I avoid this occurency?
Thank you for reading and have a nice day!</p>
| <git><go><bitbucket> | 2016-07-29 22:36:57 | HQ |
38,669,795 | How to hide javascript with cryptography? | <p>I am looking for method to hide my plugin's javascript with complex obfuscator but i read everywhere that it is not possible to hide javascript completely.
I want to know that is there any way to hide java script with cryptography?
can any one make the algorithm which can be adopt by every web hosting like they have php , jommla, java, magneto etc in which we can encrypt our javascript with our own secret key and we add this key in our license manager in our hosting and on user side we can add license manager client in our applications which need to connect our server and get that key to run our application.</p>
| <java><php><cryptography> | 2016-07-30 02:24:42 | LQ_CLOSE |
38,670,163 | Safari Print Media Queries not matching other browsers / cutting off | <p>I have a web app that looks fine when rendered in Safari but the print media queries are not being respected by the browser. In Chrome the entire printable area looks fine, however in Safari it appears to be only some variation of visible content.</p>
<p>When scrolling down on the page the header or top area is cut off, when printing higher on the page the bottom is cut off.</p>
<p>I've tried the following for the print media queries (with no effect) -</p>
<ol>
<li>Setting a <code>min-height</code> </li>
<li>Setting any variation of a <code>height</code> value on the container</li>
<li>Zooming out and printing </li>
<li>Changing resolution / scale</li>
</ol>
<p>Nothing appears to have any effect at all.</p>
<p>Unlike Chrome, I can't find a way to debug why it is happening nor a way to debug the print styles themselves.</p>
<p>Note - I am using Bootstrap for styles so there are containers, rows, spans, etc... but even removing them completely and everything being on it's own line makes no difference, the same "height" of the content is shown on print.</p>
| <css><printing><safari><media-queries> | 2016-07-30 03:47:23 | HQ |
38,670,372 | Are Boto3 Resources and Clients Equivalent? When Use One or Other? | <p>Boto3 Mavens,</p>
<p>What is the functional difference, if any, between Clients and Resources?</p>
<p>Are they functionally equivalent?</p>
<p>Under what conditions would you elect to invoke a Boto3 Resource vs. a Client (and vice-versa)?</p>
<p>Although I've endeavored to answer this question by RTM...regrets, understanding the functional difference between the two eludes me.</p>
<p>Your thoughts?</p>
<p>Many, <em>many</em> thanks!</p>
<p><em>Plane Wryter</em></p>
| <python><amazon-web-services><boto3> | 2016-07-30 04:36:28 | HQ |
38,670,566 | How to find people near me using google maps in android | <p>I want to store user longitude and latitude in mysql and want to push a notification when user is in 2Km Range In Android </p>
| <android><android-studio> | 2016-07-30 05:13:22 | LQ_CLOSE |
38,670,626 | PHP - Managing A Lot of Data Without Database | <p>The Problem</p>
<p>I have an app that scrapes data and presents it to the user, directly, because of lack of disk space.</p>
<p>This data is very volatile, it can change within minutes. Much like the stock market.</p>
<p>Since the data changes so often, and it varies from user to user, it is useless to save it in a database.</p>
<p>The question</p>
<p>I need to sort the data presented to the user, compare it, link it etc. A lot of functions that a database provides. Yet I cannot save it in said database because of the above conondrums, what should I do?</p>
<p>What I've Thought of Doing So Far</p>
<p>I've tried organizing the data presented to each user using just PHP but seems troublesome, fragile and inefficient.</p>
<p>Should I just create some sort of virtual table system in MySQL just for data handling? Maybe use a good database engine for that purpose?</p>
<p>Maybe I can save all data for each user but have a cron job remove the old data in the database in a constant fashion? Seems troublesome.</p>
<p>The Answer</p>
<p>I'd like some implementation ideas from folks who have encountered a similar problem. I do not care for "try all of the above and see what is faster" type of answers. </p>
<p>Thanks all for your help.</p>
| <php><mysql><web-scraping> | 2016-07-30 05:25:36 | LQ_CLOSE |
38,670,667 | Is there a way to retrieve available disk space in java or some other language? | <p>I want to build an application that gives me a warning when my harddrive is about to become full. For this the program needs to retrieve the amount of available disk space. Anyone kows how I can do this?</p>
| <java><c++><c><storage><home-automation> | 2016-07-30 05:34:06 | LQ_CLOSE |
38,671,193 | React-Native fetch API aggressive cache | <p>I'm using fetch API for interacting with server in my react-native@0.28 app, but facing with quite aggressive caching.</p>
<p>Call which I proceed can be expressed like:</p>
<pre><code>fetch(route + '&_t=' + Date.now(), {
headers: {
'Cache-Control': 'no-cache',
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'Custom-Auth-Header': 'secret-token'
},
method: 'POST',
body: data,
cache: 'no-store'
})
</code></pre>
<p>In IOS simulator response get cached for 15-20 mins, can be cleared via Reset Content and Settings.</p>
<p>In result I just don't want to have any cache for any of my calls (including GET requests).</p>
<p>I tried all options which I know in order to avoid caching, but seems there is something else, any help would be very appreciated!</p>
| <ios><caching><react-native> | 2016-07-30 06:50:18 | HQ |
38,671,641 | Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies | <p>I have a WinJS project that is previously built on Windows 8.1 using VS 2013. </p>
<p>Recently I upgraded this project to Universal Windows 10 by creating a blank Javascript Universal windows 10 project and then added all my files from old project. </p>
<p>I have Windows Runtime Components and also Class Library for SQLite. </p>
<p>I added Universal Windows Runtime Component and Universal Class Library and copied all my files from old project to respective places.</p>
<p>Somehow I managed to remove all the build errors. </p>
<p>I installed all the required SQLite-net, SQLite for Universal Windows Platform, Newtonsoft, etc.</p>
<p>But when I run the application and call a Native method in Windows Runtime Component it gives some kind of strange errors as:</p>
<p><code>An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code.</code></p>
<p><code>Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.</code></p>
<p><a href="https://i.stack.imgur.com/inIpi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/inIpi.png" alt="enter image description here"></a></p>
<p>Newtonsoft version is: 9.0.1</p>
<p>My <strong>project.json</strong> file of Windows Runtime Component has following:</p>
<pre><code> {
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
</code></pre>
<p>My Visual Studio version is:</p>
<p><a href="https://i.stack.imgur.com/YldNd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YldNd.png" alt="enter image description here"></a></p>
<p>I tried removing all the Newtonsoft json and re-installing it but no luck.</p>
| <c#><visual-studio><win-universal-app><windows-10><windows-10-universal> | 2016-07-30 07:49:54 | HQ |
38,671,756 | Syntax error on curl intilization | Why it says syntax error and could not feel the form with this no......hey guys today I am trying to put my number on external site and login without opening it but it couldn't work what is the problem I don't know...............any type of help is greatly appreciated
<?php
$phone=$_REQUEST['9155499248'];
function send_sms($phone) {
if (!function_exists('curl_init')) {
echo "Error : Curl library not installed";
return FALSE;
}
$user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36";
// LOGIN TO TOPPER
$url = "https://www.toppr.com/signup/";
$parameters = array("email"=>"$phone","button"=>"Signup");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($parameters));
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
$result = curl_exec ($ch);
curl_close ($ch);
// SEND OTP AGAIN AND AGAIN
?>
And now this is the source code of site on which I am trying to put My no. And login automatically............
<form action="/signup/" method="post" class="mdAuth_form">
<input type="hidden" name="next" value="">
<div class="mdAuth_inputGroup js-input-group">
<label class="mdAuth_inputGroup_label">Enter your phone number</label>
<input type="text" name="email" class="inputText mdAuth_inputGroup_input">
<label class="mdAuth_inputGroup_error js-error"></label>
</div>
<div class="ac mt-20 mb-25">
<button class="button button-big button-arrowed button-green mdAuth_centerBtn -strk" data-strk='{ "e": "ui.tapped", "ui_element_name": "submit_email"}'>
Signup <span class="arrowRight white inline-block ml-20"></span>
</button>
</div>
</form>
| <php><html> | 2016-07-30 08:02:40 | LQ_EDIT |
38,672,762 | Self executable python file | <p>Actually, I am new to python and I want to download some content from a website daily. So what can I use to run that file each day?
Any help would be appreciated! </p>
| <python> | 2016-07-30 10:14:28 | LQ_CLOSE |
38,673,318 | Azure ASP .net WebApp The request timed out | <p>I have deployed an ASP .net MVC web app to Azure App service. </p>
<p>I do a GET request from my site to some controller method which gets data from DB(DbContext). Sometimes the process of getting data from DB may take more than 4 minutes. That means that my request has no action more than 4 minutes. After that Azure kills the connection - I get message:</p>
<blockquote>
<p><h2>500 - The request timed out.</h2> The web server failed
to respond within the specified time.</p>
</blockquote>
<p>This is a method example: </p>
<pre><code> [HttpGet]
public async Task<JsonResult> LongGet(string testString)
{
var task = Task.Delay(360000);
await task;
return Json("Woke", JsonRequestBehavior.AllowGet);
}
</code></pre>
<p>I have seen a lot of questions like this, but I got no answer:</p>
<p><a href="https://social.msdn.microsoft.com/Forums/azure/en-US/560dc2a9-43e1-4c68-830c-6e1defe2f72d/azure-web-app-request-timeout-issue?forum=" rel="noreferrer">Not working 1</a>
Cant give other link - reputation is too low. </p>
<p>I have read this <a href="https://azure.microsoft.com/ru-ru/blog/new-configurable-idle-timeout-for-azure-load-balancer/" rel="noreferrer">article</a> - its about Azure Load Balancer which is not available for webapps, but its written that common way of handling my problem in Azure webapp is using TCP Keep-alive. So I changed my method: </p>
<pre><code>[HttpGet]
public async Task<JsonResult> LongPost(string testString)
{
ServicePointManager.SetTcpKeepAlive(true, 1000, 5000);
ServicePointManager.MaxServicePointIdleTime = 400000;
ServicePointManager.FindServicePoint(Request.Url).MaxIdleTime = 4000000;
var task = Task.Delay(360000);
await task;
return Json("Woke", JsonRequestBehavior.AllowGet);
}
</code></pre>
<p>But still get same error.
I am using simple GET request like </p>
<pre><code>GET /Home/LongPost?testString="abc" HTTP/1.1
Host: longgetrequest.azurewebsites.net
Cache-Control: no-cache
Postman-Token: bde0d996-8cf3-2b3f-20cd-d704016b29c6
</code></pre>
<p>So I am looking for the answer what am I doing wrong and how to increase request timeout time in Azure Web app. Any help is appreciated. </p>
<p>Azure setting on portal: </p>
<p>Web sockets - On</p>
<p>Always On - On</p>
<p>App settings: </p>
<p>SCM_COMMAND_IDLE_TIMEOUT = 3600</p>
<p>WEBSITE_NODE_DEFAULT_VERSION = 4.2.3</p>
| <c#><asp.net-mvc><azure> | 2016-07-30 11:16:47 | HQ |
38,674,007 | After creating the second object the constructor program wont ask what I use getline for | <p>So I am relatively new to C++ and I was doing a small project where I have the user enter a movie title, rating, and year. For the first run through, the program works well. After the user enters the desired information I print it back to the screen with no problem. However, when I create a second movie object to do the same thing during the same run it skips the section where it asks for the Title and goes directly to the rating. Any ideas? It's most likely a noob error. My Code is below.</p>
<p>MovieProject.cpp</p>
<pre><code>#include "stdafx.h"
#include "Movie.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
Movie starwars;
starwars.MovieTeller(starwars);
Movie FerrisBueller;
FerrisBueller.MovieTeller(FerrisBueller);
Movie TheFoxandTheHound;
TheFoxandTheHound.MovieTeller(TheFoxandTheHound);
return 0;
}
</code></pre>
<p>Movie.cpp</p>
<pre><code> #include "stdafx.h"
#include "Movie.h"
#include <string>
#include <iostream>
using namespace std;
Movie::Movie()
{
cout << "What is the title of your movie:";
getline(cin,Title);
cout << "What is the Rating:";
getline(cin,Rating);
cout << "What year was it made:";
cin >> Year;
cout << "\n" << endl;
if (Year > 2016) {
cout << "Comon Dude stop messing around" << endl;
exit(404);
}
}
void Movie::MovieTeller(Movie a) {
cout << "Title:" << Title << "\n" << "Rating:" << Rating << "\n" << "Year:" << Year << "\n" << endl;
}
Movie::~Movie()
{
}
</code></pre>
<p>Movie.h</p>
<pre><code>#pragma once
#include <iostream>
using namespace std;
class Movie
{
public:
Movie();
~Movie();
void MovieTeller(Movie a);
private:
string Title;
string Rating;
int Year;
};
</code></pre>
| <c++><constructor> | 2016-07-30 12:31:41 | LQ_CLOSE |
38,674,200 | What are selectors in redux? | <p>I am trying to follow this <a href="https://github.com/yelouafi/redux-saga/blob/7628def689433e678d78d9dd978c14162a1d45f1/examples/real-world/reducers/selectors.js#L2" rel="noreferrer">code</a> in <code>redux-saga</code></p>
<pre><code>export const getUser = (state, login) => state.entities.users[login]
export const getRepo = (state, fullName) => state.entities.repos[fullName]
</code></pre>
<p>Which is then used in the saga like <a href="https://github.com/yelouafi/redux-saga/blob/master/examples/real-world/sagas/index.js" rel="noreferrer">this</a>:</p>
<pre><code>import { getUser } from '../reducers/selectors'
// load user unless it is cached
function* loadUser(login, requiredFields) {
const user = yield select(getUser, login)
if (!user || requiredFields.some(key => !user.hasOwnProperty(key))) {
yield call(fetchUser, login)
}
}
</code></pre>
<p>This <code>getUser</code> reducer (is it even a reducer) looks very different from what I would normally expect a reducer to look like.</p>
<p>Can anyone explain what a selector is and how <code>getUser</code> is a reducer and how it fits in with redux-saga?</p>
| <reactjs><redux><redux-saga> | 2016-07-30 12:55:12 | HQ |
38,675,619 | Using Radio Buttons to Filter Data | I have a database of records which display on the page, with pagination set up.
This is all working fine.
However, I want to let users filter the records by date asc / desc by clicking a radio button on a sidebar.
- when a user clicks a radio button (asc / desc) the data should be filtered as per their choice. So the MySQL would be:
SELECT * FROM tasks ORDER BY date ASC;
SELECT * FROM tasks ORDER BY date DESC;
- When a user clicks the clear filters button the data should go back to displaying the original results.
SELECT * FROM tasks;
Can anyone help me out? Here is what I have set up so far, I have included my comments.
**HTML**
<form action="" method="post">
<p>Date:</p>
<input id="dateorderasc" type="radio" name="dateorder" onclick="javascript:submit()" value="dateasc"<?php if (isset($_POST['dateorder']) && $_POST['dateorder'] == 'dateasc') echo ' checked="checked"';?> /> <label for="dateasc">Newest › Oldest</label>
<br>
<input id="dateorderdesc" type="radio" name="dateorder" onclick="javascript:submit()" value="datedesc" <?php if (isset($_POST['dateorder']) && $_POST['dateorder'] == 'datedesc') echo ' checked="checked"';?> /> <label for="datedesc">Oldest › Newest</label><br>
</form>
**PHP**
//connect
include ("db.connect.php");
//Retrieve the tasks from the database table
$query = "SELECT * FROM tasks";
$result = mysqli_query($dbc, $query) or die('Error querying database.');
//If RadioButton Clicked Sort the Database by Date Asc / Desc
if(isset($_POST['dateorder']) && !empty($_POST['dateorder'])){
if (($_POST['dateorder'] == 'dateasc') $query .= " ORDER BY date ASC";
if ($_POST['dateorder'] == 'datedesc') $query .= " ORDER BY date DESC";
}
mysqli_query($dbc, $query) or die('Error Refreshing the page: ' . mysqli_error($dbc));
include("dbresults.php");
?> | <php><html><mysql><css> | 2016-07-30 15:33:22 | LQ_EDIT |
38,675,675 | how to add a button after add to cart and redirect it to some custom link in woocommerc | I had add a button after add to cart button using hook i.e
add_action( 'woocommerce_after_add_to_cart_button', array(&$this, 'add_button'));
But when i click on that button it is doing the functionality of add to cart button.
Can someone will help me how to redirect that button link to some other page.
Thanks in advance.
| <php><wordpress><woocommerce><cart><hook-woocommerce> | 2016-07-30 15:40:35 | LQ_EDIT |
38,675,840 | which type of argument passes a value to a procedure from the calling environment | which type of argument passes a value to a procedure from the calling environment
1.IN
2.IN OUT
3.OUT
4.OUT IN
if more than one answer is possible than give the answer. | <mysql><sql><database><plsql><parameters> | 2016-07-30 16:00:39 | LQ_EDIT |
38,676,148 | text isn't minimizing with screen html/css | hope someone can help! When I minimize the browser screen on this code, everything is minimizing appropriately except for my body text. Not sure why this is happening! Can anybody find the issue in the html or css?
<!DOCTYPE html>
<!--
Ex Machina by TEMPLATED
templated.co @templatedco
Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
-->
<html>
<head>
<title>History: Skating Today</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<meta content="" name="description">
<meta content="" name="keywords">
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<script src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<script src="js/skel.min.js">
</script>
<script src="js/skel-panels.min.js">
</script>
<script src="js/init.js">
</script> <noscript>
<link href="css/style.css" rel="stylesheet">
<style type="text/css">
.header {
}
</style></noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
<!--[if lte IE 9]><link rel="stylesheet" href="css/ie/v9.css" /><![endif]-->
</head>
<body class="page">
<!-- Header -->
<div id="page">
<img alt="Black and white photo of boy skateboarding" height="" src=
"images/OldTimey.jpg" width="100%">
<div class="unit header">
<section>
<header>
<h3>Unit 1: Skateboarding, Then and Now<br>
Lesson 1/3</h3>
</header>
</section>
</div><!-- Main -->
<div class="container" id="main">
<div class="row">
<div class="3u">
<section class="sidebar">
<h4><a href="Index.html">Home</a></h4>
</section>
<section class="sidebar">
<h4><a href="Programme%20Overview.html">Programme
Overview</a></h4>
</section>
<section class="sidebar">
<h4><a href="Unit1.html">Unit 1: Skateboarding, Then
and Now</a></h4>
<ul class="style3">
<li><a href="History.html">Lesson 1: History of
Skateboarding</a></li>
<li><a href="Types.html">Lesson 2: Types of
Skating</a></li>
<li><a href="Quiz1.html">Unit 1 Quiz</a></li>
</ul>
</section>
<section class="sidebar">
<h4><a href="Unit2.html">Unit 2: Why You Should
Skate</a></h4>
<ul class="style3">
<li><a href="EmotionalBenefits.html">Lesson 1:
Emotional and Physical Benefits</a></li>
<li><a href="SocialBenefits.html">Lesson 2: Social
and Enviromental Benefits (Plus a Few
More!)</a></li>
<li><a href="Quiz2.html">Unit 2 Quiz</a></li>
</ul>
</section>
<section class="sidebar">
<h4><a href = "Unit3.html">Unit 3: Safety & Upkeep</a></h4>
<ul class="style3">
<li><a href="SafePlace.html">Lesson 1: Determining Safe Places
to Skate</a></li>
<li><a href="Stopping.html">Lesson 2: How to Stop a
Board</a></li>
<li><a href="Rules.html">Lesson 3: Rules of the
Road</a></li>
<li><a href="Bearings.html">Lesson 4: Changing Your Bearings</a></li>
<li><a href="Trucks.html">Lesson 5: Adjusting Your Trucks</a></li>
</ul>
</section>
<section class="sidebar">
<h4>Extras: Skating Routes & Meet a Skater</h4>
<ul class="style3">
<li><a href="#">From the Flag Poles</a></li>
<li><a href="#">From the White Gates</a></li>
<li><a href="#">From the Pavilion</a></li>
<li><a href="MeetandGreet.html">Meet a Skater</a></li>
</ul>
</section>
</div>
<div class= "9u skel-cell-important"">
<header>
<h3>Skating Today</h3>
</header>
<p> While some people may still see skaters as
rebellious or alternative, skateboarding has once
again evolved. In places like Afghanistan, where
girls are not allowed to ride bikes but can
skateboard, the sport is used to engage and empower
youth (skateistan.org). Furthermore, although many
skaters still take part in skateboarding to perfect
tricks and take risks, skateboarding has become the
way that many people get from point A to point B.</p>
<p></p>
<p>While any type of skateboard may be used for
transportation, the longboard is having its heyday.
A longboard can range anywhere from 33 to 80 inches
and typically has softer wheels, making for a
smoother and more stable ride, perfect for
cruising, less experienced, and older skaters
(Ruibal 2006).</p>
<img src="images/header.jpg" width="736" height="189" alt=""/><br>
<div id="course description">
<br>
<p>This lesson is now complete. To continue to lesson 2, "Types of Skating", click <a href=
"Types.html">next</a>.</p>
</div>
</div>
</section>
</div><!-- Main -->
</div>
</div>
</div>
</body>
</html>
And the CSS here:
@charset "UTF-8";
/*
Ex Machina by TEMPLATED
templated.co @templatedco
Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
*/
/*********************************************************************************/
/* Basic */
/*********************************************************************************/
body {
background-image: url(../images/BackgroundImage.jpg);
}
body,input,textarea,select {
font-family: Verdana,Geneva,sans-serif;
font-weight: 300;
font-size: 16px;
line-height: 1.5em;
}
h1,h2,h3,h4,h5,h6 {
letter-spacing: 1px;
font-weight: 300;
color: #1b1b5e;
}
h4
{
letter-spacing: 1px;
font-weight: 700;
color: #1b1b5e;
}
/* Change this to whatever font weight/color pairing is most suitable */
strong,b {
font-weight: 700;
color: #000;
}
em,i {
font-style: italic;
}
/* Don't forget to set this to something that matches the design */
a {
color: blue;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
sub {
position: relative;
top: .5em;
font-size: .8em;
}
sup {
position: relative;
top: -.5em;
font-size: .8em;
}
hr {
border: 0;
border-top: solid 1px #ddd;
}
blockquote {
border-left: solid .5em #ddd;
padding: 1em 0 1em 2em;
font-style: italic;
}
p,ul,ol,dl,table {
margin-right: ;
margin-bottom: 1em;
color: #1b1b5e;
}
tr. highlight td {
padding: 2em;
}
header {
margin-bottom: .5em;
line-height: 2.5em;
color: #1b1b5e;
}
header h2 {
font-size: 24px;
text-align: left;
}
header h3 {
font-size: 22px;
}
footer {
margin-top: 1em;
}
/* Sections/Articles */
section,article {
margin-bottom: 1em;
}
.row
{
padding: 0;
position; center;
}
.intro {
text-align: left;
padding-bottom: 2em;
font-weight: 700;
}
.aims {
padding-top: 2px;
}
.unit header {
text-align: right;
margin-right: 1em;
color: purple;
}
table,th,td {
border: ;
border-collapse: collapse;
align-content: center;
}
th,td {
padding: 5px;
}
.boxed {
border: 1px solid #000;
padding: 2%;
margin-right: 10%;
margin-bottom: 2em;
}
* {
margin: 0;
padding: 0;
outline: none;
}
.formativequiz {
margin-top: 10px;
margin-bottom: 10px;
padding: 10px;
background: ;
text-align: left;
}
.formativequiz h1 {
font: bold;
}
.formativequiz p {
font: bold;
}
.question {
overflow: auto;
margin: ;
width: 80%;
background: #fff;
}
.question h2 {
float: left;
margin: 0 40px;
color: blue;
font: bold;
}
.question h2:hover {
color: #333;
cursor: pointer;
}
.question p {
float: left;
margin-right: 0;
color: #fff;
font: bold 0;
-webkit-transition: color .3s ease;
-moz-transition: color .3s ease;
-ms-transition: color .3s ease;
-o-transition: color .3s ease;
transition: color .3s ease;
}
h2:active ~ .yes {
color: #1b1b5e;
font-size: ;
}
.course description {
margin-bottom: 3em;
padding-right: 10%;
}
#icons {
height: 128;
text-align: justify;
border: none;
font-size: .1px;
/* IE 9 & 10 don't like font-size: 0; */
max-width: 888px;
}
#icons div {
display: inline-block;
margin-top: 3em;
margin-bottom: 3em;
padding-right: 10%;
}
#icons:after {
content: '';
width: 100%;
/* Ensures there are at least 2 lines of text, so justification works */
display: inline-block;
}
/* Images */
.image {
display: block;
margin: 2em;
}
.image img {
display: block ;
width: ;
margin: 2em;
padding: 2em;
}
.image.featured {
display: block;
width: 100%;
margin: 0;
}
.image.full {
display: block;
width: 100%;
margin-bottom: 2em;
}
.image.left {
float: left;
margin: 0 2em .8em 0;
}
.image.centered {
display: block;
margin: 0 0 .8em;
}
.image.centered img {
margin: 0 auto;
width: auto;
}
/* Lists */
ul.default {
margin-bottom: 0;
padding-bottom: 0;
list-style: none;
}
ul.default li {
display: block;
padding: 2em 0 1.25em;
border-top: 1px solid #303030;
}
ul.default li:first-child {
padding-top: 0;
border-top: none;
}
ul.default a {
text-decoration: none;
color: rgba(255,255,255,.5);
}
ul.default a:hover {
}
ul.style1 {
margin: 0;
padding: 0;
list-style: none;
}
ul.style1 li {
padding: .6em 0;
}
ul.style1 li:first-child {
padding-top: 0;
border-top: 0;
}
ul.style1 img {
}
ul.style2 {
text-align: left;
margin-right: 10%;
padding: 2%;
list-style: disc;
padding-bottom: 1em;
}
ul.style2 li {
padding: .5em 0 0;
list-style-position: inside;
}
ul.style2 li:first-child {
padding-top: 0;
border-top: 0;
}
ul.style3 {
margin: 0;
padding: 5px;
list-style: none;
font: 14px;
}
ul.style3 li {
padding-left: .6em;
line-height: 150%;
}
ul.style3 li:first-child {
padding-top: 0;
border-top: 0;
}
ul.style5 {
overflow: hidden;
margin: 0 0 1em;
padding: 0;
list-style: none;
}
ul.style5 li {
float: left;
padding: .25em;
line-height: 0;
}
ul.style5 a {
}
/*********************************************************************************/
/* Header */
/*********************************************************************************/
/*********************************************************************************/
/* Main */
/*********************************************************************************/
#page {
margin: 7em;
position: center;
background: #fff;
}
#main {
padding: 1em;
}
#container {
position: center;
margin: 1em;
padding: 1em;
}
/*********************************************************************************/
/* Icons */
/*********************************************************************************/
.greenleaf {
align-content: relative;
}
.trafficlight {
align-content: relative;
}
.pinkskater {
}
.map {
} | <html><css><text><centering> | 2016-07-30 16:36:00 | LQ_EDIT |
38,676,944 | Basic functionality of cljc files | <p>Normally, Clojure source files are named (for example) foo.clj, and Clojurescript source files are named foo.cljs. My impression is that in Clojure versions >= 1.7, I can name a file foo.cljc if I want it to be available for loading with <code>require</code> or <code>use</code> both from Clojure and Clojurescript. </p>
<p>Is this correct? It seems to be implicit in the primary documentation pages on <a href="https://github.com/clojure/clojurescript/wiki/Using-cljc" rel="noreferrer">Using cljc</a>
and <a href="https://github.com/clojure/clojurescript/wiki/Using-cljc" rel="noreferrer">reader conditions</a>, but as far as I can see it's never explicitly stated.</p>
<p>This is not a question about using reader conditionals to specify alternate code for running in Clojure and Clojurescript; it's more fundamental. For example, I have a source file that contains code that's completely generic: It will run in both Clojure and Clojurescript unchanged. Can I assume that by naming it with ".cljc", <code>require</code> will always find it from inside both Clojure and Clojurescript (assuming it's named correctly, is in the correct location, etc.)?</p>
<p>[I'm pretty sure that I'm right, but I'm not certain, and I thought it would be worth having the answer documented here if I'm correct.]</p>
| <clojure><clojurescript> | 2016-07-30 18:01:30 | HQ |
38,677,063 | Can I put <?php> inside <p> tag? | <p>It's a php file on wordpress. And I'd like to know if I can put <code><?php></code> inside <code><p></code>, <code><h></code> or something similar so I can add css on specific id.</p>
<p>For example</p>
<pre><code> <div class="eight columns">
<div class="padding-right">
<p id="address"><?php the_candidate_address(); ?></p>
</div>
</div>
</code></pre>
<p>Thanks!</p>
| <php><html><wordpress> | 2016-07-30 18:13:39 | LQ_CLOSE |
38,677,740 | spring data jpa utf-8 encoding not working | <p>I use <code>spring-data-jpa</code> and <code>mysql</code> database. My tables character set is utf-8. Also I added <code>?useUnicode=yes&amp;characterEncoding=utf8</code> to mysql url in application.properties file. Problem when I pass characters like "ąčęėį" to controller to save it in mysql. In mysql I got ??? marks. But when I use mysql console example <code>update projects_data set data="ąęąčę" where id = 1;</code> every works well.</p>
<p>application.properties:</p>
<pre><code># "root" as username and password.
spring.datasource.url = jdbc:mysql://localhost:3306/gehive?useUnicode=yes&amp;characterEncoding=utf8
spring.datasource.username = gehive
spring.datasource.password = pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager)
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
</code></pre>
<p>tables:</p>
<pre><code>+---------------+--------------------+
| TABLE_NAME | character_set_name |
+---------------+--------------------+
| customer | utf8 |
| projects | utf8 |
| projects_data | utf8 |
+---------------+--------------------+
</code></pre>
| <mysql><spring><jpa><spring-data><spring-data-jpa> | 2016-07-30 19:27:58 | HQ |
38,678,254 | What would be a good approach for developing front-end for ios apps? | <p>I'm new to ios app development. I was told to do the front-end development for an app, which has already been designed by a graphic designer. My question is that what language or tool do I need to learn or use in order to build the front-end for the app. I suppose it's a different thing than web front-end development. </p>
| <ios><iphone><frontend> | 2016-07-30 20:36:15 | LQ_CLOSE |
38,678,268 | Stack Implementation in Java | <p>I'm trying to implement a stack using Arrays in Java. My Stack class consists of non static methods push, pop, peek and isempty. I want to test the stack implementation be instantiating the stack in a non static main method within a main class. When I try to do that I get an error <strong>"non-static method push(int) cannot be referenced from a static context"</strong>
What am I doing wrong ?</p>
<p>Stack.java</p>
<pre><code>public class Stack {
private int top;
private int[] storage;
Stack(int capacity){
if (capacity <= 0){
throw new IllegalArgumentException(
"Stack's capacity must be positive");
}
storage = new int[capacity];
top = -1;
}
void push(int value){
if (top == storage.length)
throw new EmptyStackException();
top++;
storage[top] = value;
}
int peek(){
if (top == -1)
throw new EmptyStackException();
return storage[top];
}
int pop(){
if (top == -1)
throw new EmptyStackException();
return storage[top];
}
}
</code></pre>
<p>Main.java</p>
<pre><code>public class Main {
public static void main(String[] args) {
new Stack(5);
Stack.push(5);
System.out.println(Stack.pop());
}
}
</code></pre>
| <java><data-structures><stack> | 2016-07-30 20:37:44 | LQ_CLOSE |
38,678,388 | SwiftyJSON Shuffle | <p>Using Swift 2, I have the following code:</p>
<pre><code>var datas = SwiftyJSON.JSON(json)
// now datas has products. I need to shuffle products and get them in random order
datas["products"] = datas["products"].shuffle()
</code></pre>
<p>Unfortunately, that didn't work.</p>
<p>Any help to make it work?</p>
| <swift><swift2> | 2016-07-30 20:52:01 | LQ_CLOSE |
38,678,802 | How to return multiple values in a function (Python)? | <p>So I'm new to coding and working my way through the Titanic data set from Kaggle. In the data frame there are columns labeled "Age" and "Sex." I want to make a new column that has 4 values that indicate for different things:
0: Male aged 16 or over
1: Female aged 16 or over
2: Male aged 15 or younger
3: Female aged 15 or younger</p>
<p>So far I've gotten this, but this just splits it up into 3 values, not the 4 I'm looking for.</p>
<pre><code>def person_detail(Person):
Age, Sex = Person
return 2 if Age < 16 else Sex
</code></pre>
<p>I then apply the function to the "Age" and "Sex" columns to get a new column. I know that you can't have two returns, but if it gets across what I am trying to accomplish, it would look something like the below.</p>
<pre><code>def person_detail(Person):
Age, Sex = Person
return 2 if Age < 16 and Sex == 0
return 3 if Age < 16 and Sex == 1 else Sex
</code></pre>
<p>Thanks in advance. For reference in the "Sex" column 0 is for male, and 1 is for female.</p>
| <python><function> | 2016-07-30 21:49:24 | LQ_CLOSE |
38,678,804 | In React Router, how do you pass route parameters when using browser history push? | <p>Using the newer version of React Router, how do you pass parameters to the route you are transitioning to if you are transitioning using the browserHistory.push()? I am open to using some other way to transitioning if browserHistory does not allow this. I see that in my top most child component in React Router there is this.props.routeParams but I can't seem to get this populated with values I want from the previous route when transitioning.</p>
| <react-router> | 2016-07-30 21:49:38 | HQ |
38,679,186 | excel 2013 keeps crashing | my excel vb macro keeps crashing excel spreadsheet.
i know my macros must be full of bad techniques and coding, but please help where you can. it might be because i am asking excel to send multiple sms texts/emails or perhaps my keyval function. please help
- - - - - -
Option Explicit
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim em As String
Dim st As String
Dim str As String
Dim em2 As String
Dim mon As Worksheet
Sub SingleButtonEvent()
Set mon = Sheets("MON")
st = ""
ActiveSheet.Unprotect
If ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row < 30 Then
a = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row
If mon.Cells(a, "BB") = "" Then
'MsgBox "No Number in Column BB. Message Will Not Send", vbCritical
Exit Sub
Else
em = mon.Cells(a, "BB").Value
With Cells(a, "AV").Font
.Color = RGB(166, 166, 166)
.Size = 12
End With
Call SendSMS
End If
Else
For b = 1 To 29
If Cells(b, "B") <> 0 Then
a = b
If mon.Cells(a, "BB") = "" Then
Else
em = mon.Cells(a, "BB").Value
Call SendSMS
End If
End If
Next
End If
ActiveSheet.Protect
End Sub
Sub SendSMS()
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Fields.Update
iMsg.To = em
'Change Bellow email to your email
iMsg.From = "test@gmail.com"
iMsg.Subject = ""
c = Cells(a, "A").End(xlToRight).Column
st = ""
em2 = ""
If c > 2 Then
'st = Format(Date, "DDDD") & "<br/>"
For d = 3 To c
If Cells(a, d) <> "" And CInt(Cells(30, d).Value) <= 7 Then
st = st & Cells(30, d).Value & ". " & Application.WorksheetFunction.Clean(Cells(a, d).Value) & " | " & Application.WorksheetFunction.Clean(Cells(a, d + 1).Value) & " | " & Application.WorksheetFunction.Clean(Cells(a, d + 2).Value) & "<br/>"
d = d + 2
ElseIf Cells(a, d) <> "" And CInt(Cells(30, d).Value) > 7 Then
If em2 = "" Then
em2 = Cells(30, d).Value & ". " & Application.WorksheetFunction.Clean(Cells(a, d).Value) & " | " & Application.WorksheetFunction.Clean(Cells(a, d + 1).Value) & " | " & Application.WorksheetFunction.Clean(Cells(a, d + 2).Value) & "<br/>"
d = d + 2
Else
em2 = em2 & Cells(30, d).Value & ". " & Application.WorksheetFunction.Clean(Cells(a, d).Value) & " | " & Application.WorksheetFunction.Clean(Cells(a, d + 1).Value) & " | " & Application.WorksheetFunction.Clean(Cells(a, d + 2).Value) & "<br/>"
d = d + 2
End If
Else
Exit Sub
End If
Next
End If
'If ActiveSheet.Name = "MON" Then
'str = Cells(a, "B").Value
'Else
'str = Cells(a, "B").Value
'End If
If em2 = "" Then
iMsg.HTMLBody = st & "Visa triet " & Cells(a, "AY").Value & "<br/>Total " & Cells(a, "B").Value & "<br/>"
Set iMsg.Configuration = iConf
iMsg.Send
Else
iMsg.HTMLBody = st
Set iMsg.Configuration = iConf
iMsg.Send
iMsg.HTMLBody = em2 & "Visa " & Cells(a, "AY").Value & "<br/>Total " & Cells(a, "B").Value & "<br/>"
Set iMsg.Configuration = iConf
iMsg.Send
End If
Set iMsg = Nothing
End Sub
Function KeyVal(ParamArray ran() As Variant)
Application.Volatile True
Dim str As String
a = 0
Do While a < UBound(ran) + 1
If ran(a) = 0 Or ran(a) = "" Then
a = a + 1
Else
b = Sheets("Key").Cells(Rows.Count, "A").End(xlUp).Row
str = ran(a)
If InStr(str, "/") > 0 Then
Do While InStr(str, "/") > 0
d = Application.WorksheetFunction.Search("/", str)
st = Mid(str, 1, d - 1)
str = Application.WorksheetFunction.Clean(Trim(Mid(str, d + 1, Len(str))))
For c = 1 To b
If LCase(st) = LCase(Sheets("Key").Cells(c, "A").Value) Then
KeyVal = KeyVal + Sheets("Key").Cells(c, "B").Value
End If
Next
If InStr(str, "/") <= 0 Then
For c = 1 To b
If str = Sheets("Key").Cells(c, "A").Value Then
KeyVal = KeyVal + Sheets("Key").Cells(c, "B").Value
End If
Next
End If
Loop
Else
For c = 1 To b
If ran(a) = Sheets("Key").Cells(c, "A").Value Then
KeyVal = KeyVal + Sheets("Key").Cells(c, "B").Value
End If
Next
End If
a = a + 1
End If
Loop
End Function
| <excel><vba> | 2016-07-30 22:49:16 | LQ_EDIT |
38,679,346 | Get Public IP Address on current EC2 Instance | <p>Using Amazon CLI, is there a way to get the public ip address of the current EC2? I'm just looking for the single string value, so not the json response describe-addresses returns. </p>
| <amazon-web-services><amazon-ec2> | 2016-07-30 23:14:57 | HQ |
38,680,216 | people.connections.list not returning contacts using Python Client Library | <p>I'm trying to programmatically access the list of contacts on my own personal Google Account using the Python Client Library</p>
<p>This is a script that will run on a server without user input, so I have it set up to use credentials from a Service Account I set up. My Google API console setup looks like this. </p>
<p><a href="https://i.stack.imgur.com/bTX2H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bTX2H.png" alt="enter image description here"></a></p>
<p>I'm using the following basic script, pulled from the examples provided in the API docs -</p>
<pre><code>import json
from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
# Only need read-only access
scopes = ['https://www.googleapis.com/auth/contacts.readonly']
# JSON file downloaded from Google API Console when creating the service account
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'keep-in-touch-5d3ebc885d4c.json', scopes)
# Build the API Service
service = build('people', 'v1', credentials=credentials)
# Query for the results
results = service.people().connections().list(resourceName='people/me').execute()
# The result set is a dictionary and should contain the key 'connections'
connections = results.get('connections', [])
print connections #=> [] - empty!
</code></pre>
<p>When I hit the API it returns a result set without any 'connections' key. Specifically it returns -</p>
<pre><code>>>> results
{u'nextSyncToken': u'CNP66PXjKhIBMRj-EioECAAQAQ'}
</code></pre>
<p>Is there something pertaining to my setup or code that's incorrect? Is there a way to see the response HTTP status code or get any further detail about what it's trying to do?</p>
<p>Thanks!</p>
<p>Side note: When I try it using <a href="https://developers.google.com/people/api/rest/v1/people.connections/list#try-it" rel="noreferrer">the "Try it!" feature in the API docs</a>, it correctly returns my contacts. Although I doubt that uses the client library and instead relies on user authorization via OAuth</p>
| <python><google-people> | 2016-07-31 02:25:48 | HQ |
38,680,623 | Ruby: test returns ArgumentError | Greeting Stackoverflow fellow people!
I'm learning Ruby and as one of the intro exercises I'm meant to type
"test" and receive "nil"
However I receive this instead:ArgumentError: wrong number of arguments (0 for 2..3)
from (irb):15:in `test'
from (irb):15
from /usr/bin/irb:12:in `<main>'
Does anyone know if I need to fix something, because I can't seem to find anything on this anywhere I've looked so far.
Thanks in advance!
| <ruby> | 2016-07-31 03:56:55 | LQ_EDIT |
38,681,034 | Error multiple definition when compiling using headers | <p>I am having a lot of trouble with my header files and the compilation. I have everything linked with header guards but for some reason I am still getting a lot of multiple definition errors. I'm also look for help on better way to organize code. Whatever help is appreciated! </p>
<p>This is the out output of my console when I do the g++ call: </p>
<pre><code>g++ main.cpp close.cpp init.cpp load_media.cpp texture.cpp -w -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -o run
/tmp/cc3oNgPs.o:(.bss+0x0): multiple definition of `g_font'
/tmp/ccg0hCKW.o:(.bss+0x0): first defined here
/tmp/cc3oNgPs.o:(.bss+0x8): multiple definition of `g_window'
/tmp/ccg0hCKW.o:(.bss+0x8): first defined here
/tmp/cc3oNgPs.o:(.bss+0x10): multiple definition of `g_renderer'
/tmp/ccg0hCKW.o:(.bss+0x10): first defined here
/tmp/cc3oNgPs.o:(.bss+0x20): multiple definition of `g_text_texture'
/tmp/ccg0hCKW.o:(.bss+0x20): first defined here
/tmp/ccIgzhbZ.o:(.bss+0x0): multiple definition of `g_font'
/tmp/ccg0hCKW.o:(.bss+0x0): first defined here
/tmp/ccIgzhbZ.o:(.bss+0x8): multiple definition of `g_window'
/tmp/ccg0hCKW.o:(.bss+0x8): first defined here
/tmp/ccIgzhbZ.o:(.bss+0x10): multiple definition of `g_renderer'
/tmp/ccg0hCKW.o:(.bss+0x10): first defined here
/tmp/ccIgzhbZ.o:(.bss+0x20): multiple definition of `g_text_texture'
/tmp/ccg0hCKW.o:(.bss+0x20): first defined here
/tmp/ccQs9gPv.o:(.bss+0x0): multiple definition of `g_font'
/tmp/ccg0hCKW.o:(.bss+0x0): first defined here
/tmp/ccQs9gPv.o:(.bss+0x8): multiple definition of `g_window'
/tmp/ccg0hCKW.o:(.bss+0x8): first defined here
/tmp/ccQs9gPv.o:(.bss+0x10): multiple definition of `g_renderer'
/tmp/ccg0hCKW.o:(.bss+0x10): first defined here
/tmp/ccQs9gPv.o:(.bss+0x20): multiple definition of `g_text_texture'
/tmp/ccg0hCKW.o:(.bss+0x20): first defined here
/tmp/ccxzUgM2.o:(.bss+0x0): multiple definition of `g_font'
/tmp/ccg0hCKW.o:(.bss+0x0): first defined here
/tmp/ccxzUgM2.o:(.bss+0x8): multiple definition of `g_window'
/tmp/ccg0hCKW.o:(.bss+0x8): first defined here
/tmp/ccxzUgM2.o:(.bss+0x10): multiple definition of `g_renderer'
/tmp/ccg0hCKW.o:(.bss+0x10): first defined here
/tmp/ccxzUgM2.o:(.bss+0x20): multiple definition of `g_text_texture'
/tmp/ccg0hCKW.o:(.bss+0x20): first defined here
collect2: error: ld returned 1 exit status
</code></pre>
<p>here are my 2 header files:</p>
<p>isolation.h</p>
<pre><code>//include //include guard
#ifndef ISOLATION_H
#define ISOLATION_H
//include dependencies
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <stdio.h>
#include <string>
//include headers
#include "texture.h"
//Screen dimension constants
const int SCREEN_WIDTH = 1280;
const int SCREEN_HEIGHT = 800;
//forward delcarlation
//class Texture;
//start up SDL create window
bool init();
//load all media
bool load_media();
//free all and shut down SDL
void close();
//load global front
TTF_Font* g_font = NULL;
//window
SDL_Window* g_window = NULL;
//renderer
SDL_Renderer* g_renderer = NULL;
//load jpeg + font
//Texture background_texture;
//rendered font texture
Texture g_text_texture;
#endif
</code></pre>
<p>texture.h</p>
<pre><code>//include guard
#ifndef TEXTURE_H
#define TEXTURE_H
//include dependencies
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <stdio.h>
#include <string>
//include headers
//#include "isolation.h"
class Texture {
public:
//initializes variables
Texture();
//deallocates memory
~Texture();
//load image from path
bool load_from_file( std::string path );
//create image from font string
bool load_from_rendered_text( std::string textureText, SDL_Color text_color );
//deallocates texture
void free();
//set color modulation
void set_color( Uint8 red, Uint8 green, Uint8 blue );
//set blend mode
void set_blend_mode( SDL_BlendMode blending );
//set alpha
void set_alpha( Uint8 alpha );
//render texture at point
void render( int x, int y, SDL_Rect* clip = NULL, double angle = 0.0, SDL_Point* center = NULL, SDL_RendererFlip flip = SDL_FLIP_NONE ) const;
//get image dimensions
int get_width() const;
int get_height() const;
private:
//texture pointer
SDL_Texture* m_texture;
//dimensions
int m_width;
int m_height;
};
#endif
</code></pre>
<p>init.cpp</p>
<pre><code>#include "isolation.h"
//#include "texture.h"
bool init() {
//initialization flag
bool success = true;
//initialize SDL
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
printf( "SDL could not initialized. SDL Error: %s\n", SDL_GetError() );
success = false;
}
else {
//set texture filtering linear
if ( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) ) {
printf( "Warning: Linear filtering not enabled\n" );
}
//create window
g_window = SDL_CreateWindow( "Isolation", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if ( g_window == NULL ) {
printf( "Window could not be created. SDL Error: %s\n", SDL_GetError() );
success = false;
}
else {
//create vsynced renderer
g_renderer = SDL_CreateRenderer( g_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
if ( g_renderer == NULL ) {
printf( "Renderer could not be created. SDL Error: %s\n", SDL_GetError() );
success = false;
}
else {
//initialize renderer color
SDL_SetRenderDrawColor (g_renderer, 0xFF, 0xFF, 0xFF, 0xFF );
//initialize JPEG loading
int img_flags = IMG_INIT_JPG;
if ( !( IMG_Init( img_flags ) & img_flags ) ) {
printf( "SDL_image could not be initialize. SDL_image Error: %s\n", IMG_GetError() );
success = false;
}
//initialize SDL_ttf
if (TTF_Init() == -1 ) {
printf( "SDL_ttf could not be initialize. SDL_ttf Error: %s\n", TTF_GetError() );
}
}
}
}
return success;
}
</code></pre>
<p>load_media.cpp</p>
<pre><code>#include "isolation.h"
//s#include "texture.h"
bool load_media() {
bool success = true;
//load background img
//if( !background_texture.load_from_file( "img/vancouver.jpg" ) ) {
// printf( "Failed to load background texture!\n" );
// success = false;
//}
//open font
g_font = TTF_OpenFont( "lazy.ttf", 28 );
if ( g_font == NULL ) {
printf( "Failed to load lazy font. SDL_ttf Error: %s\n", TTF_GetError() );
success = false;
}
else {
//render texture
SDL_Color text_color = { 0, 0, 0 };
if ( !g_text_texture.load_from_rendered_text( "hello from the other side ", text_color ) ) {
printf( "Failed to render text texture\n" );
success = false;
}
}
return success;
}
</code></pre>
<p>close.cpp</p>
<pre><code>#include "isolation.h"
//#include "texture.h"
void close() {
//free loaded text
g_text_texture.free();
//free font
TTF_CloseFont( g_font );
g_font = NULL;
//destroy window
SDL_DestroyWindow( g_window );
SDL_DestroyRenderer( g_renderer );
g_window = NULL;
g_renderer = NULL;
//quit SDL subsystems
TTF_Quit();
IMG_Quit();
SDL_Quit();
}
</code></pre>
<p>main.cpp</p>
<pre><code>#include "isolation.h"
//#include "texture.h"
int main( int argc, char* args[] ) {
//start up SDL
if ( !init() ) {
printf( "Failed to initialize.\n" );
}
else {
//load media
if ( !load_media() ) {
printf( "Failed to load media.\n" );
}
else{
//main loop flag
bool quit = false;
//event handler
SDL_Event e;
//while running
while ( !quit ) {
//handle events on queue
while ( SDL_PollEvent( &e ) != 0 ) {
//user quit
if ( e.type == SDL_QUIT ) {
quit = true;
}
}
//clear screen
SDL_SetRenderDrawColor( g_renderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( g_renderer );
//render frame
g_text_texture.render( ( SCREEN_WIDTH - g_text_texture.get_width() ) / 2, ( SCREEN_HEIGHT - g_text_texture.get_height() ) / 2 );
//update screen
SDL_RenderPresent( g_renderer );
}
}
}
//free memory and close SDL
close();
return 0;
}
</code></pre>
| <c++><makefile><header><g++><sdl> | 2016-07-31 05:25:37 | LQ_CLOSE |
38,681,340 | How to remove common rows in two dataframes in Pandas? | <p>I have two dataframes - <code>df1</code> and <code>df2</code>.</p>
<pre><code>df1 has row1,row2,row3,row4,row5
df2 has row2,row5
</code></pre>
<p>I want to have a new dataframe such that <code>df1-df2</code>. That is, the resultant dataframe should have rows as - <code>row1,row3,row4</code>. </p>
| <python-2.7><pandas><scikit-learn> | 2016-07-31 06:21:47 | HQ |
38,681,539 | regex find all utf8 text, started with # and end by space or enter | <p>I want render Utf8 text and link all tag that started with <code>#</code> and ended with <code>space</code> or <code>enter</code> or any separator such as <code>\r</code> <code>\t</code> <code>\n</code>.</p>
<p>text example:</p>
<pre><code>Текстовые теги #общий #тест
Хиджаб в исламе, философии безопасности #женщин
english #teg #test
</code></pre>
| <regex> | 2016-07-31 06:53:44 | LQ_CLOSE |
38,682,314 | i need proper mysql query to fetch record from mysql | i have THREE tables.
Table : products column : id, productname
Table :attribute_master column : id, attributename
Table : assignedproductfilter column : id productid <-- this is from products table filterid <-- this is from attribute_master
table "assignedproductfilter" may contain same productid with multiple filterid.
Example :
id productid filterid
1 105 56
2 105 50
3 105 34
4 200 56
5 201 22
Now suppose i want to get all those products where filterid is 56,50 and 34. All these three filter id should be assigned to products.
How to write query for this in mysql ? | <mysql> | 2016-07-31 08:47:02 | LQ_EDIT |
38,682,675 | Is CppCoreGuidelines C.21 correct? | <p>While reading the Bjarne Stroustrup's CoreCppGuidelines, I have found a guideline which contradicts my experience.</p>
<p>The <a href="https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-five">C.21</a> requires the following:</p>
<blockquote>
<p>If you define or <code>=delete</code> any default operation, define or <code>=delete</code> them all</p>
</blockquote>
<p>With the following reason:</p>
<blockquote>
<p>The semantics of the special functions are closely related, so if one needs to be non-default, the odds are that others need modification too.</p>
</blockquote>
<p>From my experience, the two most common situations of redefinition of default operations are the following:</p>
<p>#1: Definition of virtual destructor with default body to allow inheritance:</p>
<pre><code>class C1
{
...
virtual ~C1() = default;
}
</code></pre>
<p>#2: Definition of default constructor making some initialization of RAII-typed members:</p>
<pre><code>class C2
{
public:
int a; float b; std::string c; std::unique_ptr<int> x;
C2() : a(0), b(1), c("2"), x(std::make_unique<int>(5))
{}
}
</code></pre>
<p>All other situations were rare in my experience.</p>
<p>What do you think of these examples? Are they exceptions of the C.21 rule or it's better to define all default operations here? Are there any other frequent exceptions?</p>
| <c++><oop><c++11><cpp-core-guidelines> | 2016-07-31 09:41:26 | HQ |
38,683,310 | Session on wordpress site, | Please help, I have a client page coded in php. The page then goes to a wordpress page, The session is there on this page is remembered, but when I load a new page from this wordpress page. The session is not remembered and take back to the login page ..
This code is on the login page ..
my_session_register('user_id');
$_SESSION['user_id']=$user_id;
header('Location: booking_user.php');
Then is code checks the session
if (!my_session_is_registered('user_id')) {
header('Location: login.php');
}
I just dont no how I would keep this alive in this page and stop ending the session
Thanks
| <php><wordpress><session> | 2016-07-31 11:05:51 | LQ_EDIT |
38,683,439 | How to decode base64 in python3 | <p>I have a base64 encrypt code, and I can't decode in python3.5</p>
<pre><code>import base64
code = "YWRtaW46MjAyY2I5NjJhYzU5MDc1Yjk2NGIwNzE1MmQyMzRiNzA" # Unencrypt is 202cb962ac59075b964b07152d234b70
base64.b64decode(code)
</code></pre>
<p>Result:</p>
<pre><code>binascii.Error: Incorrect padding
</code></pre>
<p>But same website(<a href="http://www.base64decode.org" rel="noreferrer">base64decode</a>) can decode it, </p>
<p>Please anybody can tell me why, and how to use python3.5 decode it?</p>
<p>Thanks</p>
| <python><base64> | 2016-07-31 11:23:01 | HQ |
38,684,375 | Serilog's AddSerilog is not recognized | <p>I'm trying to call <strong>loggerFactory.AddSerilog();</strong> as per <a href="https://github.com/serilog/serilog-docker/blob/master/web-sample/src/Startup.cs" rel="noreferrer">this</a> documentation, but the <strong>AddSerilog</strong> method is not recognized:</p>
<p>"Error CS1061 'ILoggerFactory' does not contain a definition for 'AddSerilog' and no extension method 'AddSerilog' accepting a first...".</p>
<p>I'm using ASP.NET CORE with the full .NET framework.
What am I doing wrong?</p>
| <c#><.net><asp.net-core><serilog> | 2016-07-31 13:18:41 | HQ |
38,685,019 | Laravel: how to create a function After or Before save|update | <p>I need to generate a function to call after or before save() or update() but i don't know how to do.
I think I need a callback from save() update() but I don't know how to do.
Thanks</p>
| <laravel><save><updates> | 2016-07-31 14:32:24 | HQ |
38,685,570 | make a GET call 100,000 times | <p>I have a requirement where I am writing a small utility to test apis(ofcourse there are existing tools but it has been decided to write one). I am required to bombard the api, for the same api call, with say 100 threads, around say 100,000 times.</p>
<p>I am using 'PoolingHttpClientConnectionManager' for the making the calls. I am using something as mentioned in the below link:</p>
<p><a href="https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html" rel="nofollow">https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html</a></p>
<p>My question is:</p>
<p>(1) How can I run the above code for 100,000 iterations? Using that many number of threads is obviously a bad idea. Initially thought of using ExecutorService for maintaining thread count and number of jobs to be submitted but it felt redundant.</p>
<p>(2)I read about 'setMaxTotal'(max connections) and 'setDefaultMaxPerRoute'(concurrent connections) but I dont think it will help achieve(1) though I will obviously be required to increase the values. </p>
<p>Please advise. Thanks in advance.</p>
| <java><multithreading><connection-pooling><apache-httpclient-4.x> | 2016-07-31 15:35:13 | LQ_CLOSE |
38,685,849 | Can't find variable: React | <p>I just started learning react so I apologise in advance if this may sound like a stupid question.
I'm trying to make a simple iOS page with a button that triggers an action.
I have followed the tutorial on how to get started and this is my index code:</p>
<pre><code>'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
TouchableHighlight,
Component,
AlertIOS // Thanks Kent!
} = React;
class myProj extends Component {
render() {
return (
<View style={styles.container}>
<Text>
Welcome to React Native!
</Text>
<TouchableHighlight style={styles.button}
onPress={this.showAlert}>
<Text style={styles.buttonText}>Go</Text>
</TouchableHighlight>
</View>
);
}
showAlert() {
AlertIOS.alert('Awesome Alert', 'This is my first React Native alert.', [{text: 'Thanks'}] )
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFFFFF'
},
buttonText: {
fontSize: 18,
color: 'white',
alignSelf: 'center'
},
button: {
height: 44,
flexDirection: 'row',
backgroundColor: '#48BBEC',
alignSelf: 'stretch',
justifyContent: 'center'
}
});
AppRegistry.registerComponent('myProj', () => myProj);
</code></pre>
<p>The problem is that when I run it from Xcode on my device I get</p>
<pre><code>Can't find variable: React
render
main.jsbundle:1509:6
mountComponent
mountChildren
</code></pre>
<p>I tried to search online for the answer but couldn't find anything that actually help. Any idea what might be the problem here?</p>
| <javascript><ios><react-native> | 2016-07-31 16:03:06 | HQ |
38,686,071 | Error message "Use of Undeclared identifier "field"" | <p>Im trying to create a button to copy images that are in my application and when I enter the code in Xcode I receive a error messege saying Error message "Use of Undeclared identifier "field"" I've been trying to solve this for several days now and i just can't figure it out
#import "ViewController.h"</p>
<pre><code>@implementation ViewController
-(IBAction)copyimage:(id)sender {
pasteboard.string = field.copyimage;
}
-(IBAction)pasteimage:(id) sender{
}
- (void)viewDidLoad {
[super viewDidLoad];
pasteboard = [UIPasteboard generalPasteboard];
// Do any additional setup after loading the view, typically from a nib.
}
</code></pre>
| <objective-c><xcode><xcode7> | 2016-07-31 16:26:35 | LQ_CLOSE |
38,686,285 | C++ Operator Overloading in Class with Const Members? | <pre><code>class SomeClass {
int someNum;
const int someConst;
public:
SomeClass() : someNum(12), someConst(15)
{
}
SomeClass operator+(int num) {
SomeClass newSomeClass;
newSomeClass.someNum += num;
return newSomeClass;
}
};
int main() {
SomeClass someClass;
SomeClass newClass;
newClass = someClass + 3;
}
</code></pre>
<p>I don't understand why the above doesn't compile, but does so when the const related code is removed.</p>
| <c++><constants><overloading><operator-keyword> | 2016-07-31 16:49:18 | LQ_CLOSE |
38,686,636 | Js, function not working | <pre><code>`var y = 0 ;
var x = 0;
function atm(num1, num2){
console.log((num1 - num2));
return num1 - num2 ;
}
var items =[1,2,3,4,5,6,7,8,9,10];
function vm(y, x){
if( atm(y , items[x]) < 0 ){
result = "U Do not have enough money to pay";
}
else if ( atm(y , items[x]) === 0 );{
result = "Ur money just matches the required paying fee";
}
if ( atm(y , items[x]) > 0 );{
result="U will reserve atm(y, items[x]) as a remainder";
}
}
vm(2, 3);`
</code></pre>
<p>**the error is that it gives me 3 answers as u can see:
\\
-2</p>
<p>"U Do not have enough money to pay"</p>
<p>"Ur money just matches the required paying fee"</p>
<p>-2</p>
<p>"U will reserve atm(y, items[x]) as a remainder"
\\</p>
<p>\\
also the 3rd result " result="U will reserve atm(y, items[x]) as a remainder" " wont show the remainder</p>
<p>"y goes to the amount of money u hold"</p>
<p>"x goes to the number of items from array"</p>
<p>vm is the vending machine and what it should do is show 1 answer of these up </p>
<p>1- u do not have enough money to pay</p>
<p>2- Ur money just matches the required paying fee</p>
<p>3- is that he has more money and he will reserve " y - items[x] " as remainder</p>
<p><strong>Please when u got my error write me the error and the full code, sometimes it gets hard on me, im still new...</strong></p>
| <javascript> | 2016-07-31 17:29:18 | LQ_CLOSE |
38,686,732 | For a database, what number does it start with, 0, or 1? | <p>I am making a phpMyAdmin database for my website, and have something called "rank". I want there to be three ranks. For where it says "Length/Values" should I put 3 or 2? Is it like in Java where it starts with a 0 (i.e. an array of 3 is 0, 1, 2)?</p>
<p>And a follow up, if I put in 3, will it auto make it 0, 1, 2? Or is it 1, 2, 3?</p>
| <php><mysql><database><phpmyadmin><numbers> | 2016-07-31 17:38:30 | LQ_CLOSE |
38,686,880 | Matlab not working on Ubuntu 16.04 | i've installed Matlab for MOOC of Coursera in my laptop running Ubuntu 16.04. The installation route is /usr/local/MATLAB. All the installation proccess is ok, but after I go and try to run it using the command `matlab` on the terminal, it gives me this window:
[enter image description here][1]
[1]: http://i.stack.imgur.com/bJxUP.png
And this Error Details:
MATLAB crash file:/home/carlosab1802/matlab_crash_dump.15687-1:
------------------------------------------------------------------------
Segmentation violation detected at Sun Jul 31 12:49:35 2016
------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled
Crash Mode : continue (default)
Current Graphics Driver: Unknown hardware
Current Visual : 0x63 (class 4, depth 24)
Default Encoding : UTF-8
GNU C Library : 2.23 stable
Host Name : carlosab1802
MATLAB Architecture : glnxa64
MATLAB Root : /usr/local/MATLAB/R2016a
MATLAB Version : 9.0.0.341360 (R2016a)
OpenGL : hardware
Operating System : Linux 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64
Processor ID : x86 Family 6 Model 60 Stepping 3, GenuineIntel
Virtual Machine : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : The X.Org Foundation (11803000), display :0
If this problem is reproducible, please submit a Service Request via:
http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.
I don't know how to fix it, i've searched a lot and people always say "install matlab-support", i've done it but it still does not work.
I hope you people help me.
Thanks a lot.
| <matlab><ubuntu> | 2016-07-31 17:56:51 | LQ_EDIT |
38,686,934 | android studio : error in Type in number in edittext then do math on it and show result | hi the title says it all
here is the code
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ImageButton imageButton = (ImageButton) findViewById(R.id.imageButton);
ImageButton imageButton2 = (ImageButton) findViewById(R.id.imageButton2);
ImageButton imageButton3= (ImageButton) findViewById(R.id.imageButton3);
ImageButton imageButton4 = (ImageButton) findViewById(R.id.imageButton4);
ImageButton imageButton5 = (ImageButton) findViewById(R.id.imageButton5);
ImageButton imageButton6 = (ImageButton) findViewById(R.id.imageButton6);
ImageButton imageButton7 = (ImageButton) findViewById(R.id.imageButton7);
ImageButton imageButton8 = (ImageButton) findViewById(R.id.imageButton8);
ImageButton imageButton9 = (ImageButton) findViewById(R.id.imageButton9);
final EditText editText = (EditText) findViewById(R.id.editText);
EditText editText2 = (EditText) findViewById(R.id.editText2);
EditText editText3 = (EditText) findViewById(R.id.editText3);
final TextView textView50 = (TextView)findViewById(R.id.textView50);
//here where the android monitor says it error
final int dayNumber = Integer.parseInt(editText.getText().toString());
editText2.getText();
editText3.getText();
imageButton3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int a = dayNumber * 4;
textView50.setText(String.valueOf(a));
}
});
and here is the android monitor result
07-31 19:45:54.353 19858-19858/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: ahmednageeb.com.yourageinotherplanets, PID: 19858
java.lang.RuntimeException: Unable to start activity ComponentInfo{ahmednageeb.com.package/ahmednageeb.com.package.Main2Activity}: java.lang.NumberFormatException: Invalid int: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:334)
at ahmednageeb.com.package.Main2Activity.onCreate(Main2Activity.java:40)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-31 19:45:56.587 19858-19858/ahmednageeb.com.package I/Process: Sending signal. PID: 19858 SIG: 9
| <android><android-edittext> | 2016-07-31 18:03:31 | LQ_EDIT |
38,687,212 | spark dataframe drop duplicates and keep first | <p>Question: in pandas when dropping duplicates you can specify which columns to keep. Is there an equivalent in Spark Dataframes?</p>
<p>Pandas:</p>
<pre><code>df.sort_values('actual_datetime', ascending=False).drop_duplicates(subset=['scheduled_datetime', 'flt_flightnumber'], keep='first')
</code></pre>
<p>Spark dataframe (I use Spark 1.6.0) doesn't have the keep option</p>
<pre><code>df.orderBy(['actual_datetime']).dropDuplicates(subset=['scheduled_datetime', 'flt_flightnumber'])
</code></pre>
<p>Imagine 'scheduled_datetime' and 'flt_flightnumber' are columns 6 ,17. By creating keys based on the values of these columns we can also deduplicate </p>
<pre><code>def get_key(x):
return "{0}{1}".format(x[6],x[17])
df= df.map(lambda x: (get_key(x),x)).reduceByKey(lambda x,y: (x))
</code></pre>
<p>but how to specify <strong>to keep the first row</strong> and get rid of the other duplicates ? What about the last row ? </p>
| <apache-spark><dataframe><duplicates> | 2016-07-31 18:35:21 | HQ |
38,687,243 | How to bundle lazy loaded components inside the production dist folder in angular-cli? | <p>I am using <code>angular-cli</code> for development and I have used the following commands and code to build my project.</p>
<p><code>npm install angular-cli</code> (angular-cli: 1.0.0-beta.10)</p>
<p><code>ng new my-app</code></p>
<p><code>ng g component lazy-me</code></p>
<p>Then added a file <code>app.router.ts</code> with the following script</p>
<pre><code>import { provideRouter, RouterConfig } from '@angular/router';
import { AppComponent } from './app.component';
// import { LazyMeComponent } from './+lazy-me/lazy-me.component';
const appRoutes : RouterConfig = [
{path: '', component: AppComponent},
// {path: 'lazyme', component: LazyMeComponent}
{path: 'lazyme', component: 'app/+lazy-me#LazyMeComponent'}
];
export const APP_ROUTER_PROVIDER = [
provideRouter(appRoutes)
];
</code></pre>
<p>And changed my main.ts as following</p>
<pre><code>import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode,
SystemJsComponentResolver,
ComponentResolver } from '@angular/core';
import {RuntimeCompiler} from '@angular/compiler';
import { AppComponent, environment } from './app/';
import { APP_ROUTER_PROVIDER } from './app/app.router';
if (environment.production) {
enableProdMode();
}
bootstrap(AppComponent,[
APP_ROUTER_PROVIDER,
{
provide: ComponentResolver,
useFactory: (r) => new SystemJsComponentResolver(r),
deps: [RuntimeCompiler]
},
]);
</code></pre>
<p>And to do a production build I have used the following command
<code>ng build -prod</code></p>
<p>When I deploy my code to a webserver and navigate to <code>lazyme</code> path, I get 404 error for <code>app/lazy-me/lazy-me.component.js</code></p>
<p>The folder exists but <code>lazy-me.component.js</code> is missing as expected as everything gets bundled in <code>main.js</code> except .css and .html files.
However, I want <code>ng build -prod</code> to include <code>lazy-me.component.js</code> in <code>dist/app/lazy-me/</code>.</p>
<p>Is there any settings in <code>system-config.ts</code> or anywhere else where I can include lazy loaded components to be part of the <code>dist</code> folder when doing a <code>-prod</code> build?</p>
| <angular><systemjs><angular-cli> | 2016-07-31 18:38:02 | HQ |
38,687,394 | Force intellij to download scala-library sources in an existing project | <p>It seems that Intellij does well when "Download sources" and "Download javadocs" are checked in the import settings.</p>
<p>But if they were <em>not</em> checked then how do we get the scala sources after the fact? In the screenshot below I did click on <code>Download Sources</code> </p>
<p><a href="https://i.stack.imgur.com/fkodT.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/fkodT.jpg" alt="enter image description here"></a></p>
<p>But it failed <code>Sources for 'scala-library.jar' not found</code> . </p>
<p><a href="https://i.stack.imgur.com/PINcp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/PINcp.jpg" alt="enter image description here"></a></p>
<p>Seems Intellij should realize to properly ornament the <code>scala-library.jar</code> with the appropriate scala version from the project . no? </p>
<p>So is there any alternative to simply nuking the project and re-importing? The reason for the inquiry is I have a number of projects in this state and also would like the flexibility to <em>not</em> always have <code>Download sources</code> checked - due to both longer build time and occasional build failures caused by it.</p>
| <scala><intellij-idea> | 2016-07-31 18:56:46 | HQ |
38,687,605 | i keep receiving this error: Call to undefined method mysqli_result::fetch_both()... can somebody please answer this for me |
**im trying to create a dummy login page as practice. i keep getting this error: Call to undefined method mysqli_result::fetch_both()
**
<?php
if (isset($_POST['LOGIN'])){
$EMAIL = $_POST['loginusernameinput'];
$PASS = $_POST['loginpasswordinput'];
$result = $conn->query("SELECT * FROM userinformationtbl WHERE Email ='$EMAIL' AND password ='$PASS'");
$row = $result -> fetch_both(MYSQLI_BOTH);
session_start();
$_SESSION["userID"] = $row["userID"];
header ('location: account.php');
}
?> | <mysqli> | 2016-07-31 19:20:31 | LQ_EDIT |
38,687,720 | Why does this implementation of move corresponding work? vb.net | Since three is read only and depends on a non property (four). Three should be undefined.
How does props, which does not set four, set three to the correct value?
--------------------------------------------------
public sub main
Dim x1 = New one, x2 = New two
x1.one = 3
MoveCorresponding(x1, x2)
end sub
Public Sub MoveCorresponding(a As Object, b As Object, Optional ignoreList As List(Of String) = Nothing)
Dim oType As Type = b.GetType
Dim iType = a.GetType
Dim props = iType.GetProperties()
For Each pInf As PropertyInfo In props
Dim parName = pInf.Name
If pInf.CanWrite Then
Try
Dim val = pInf.GetValue(a, Nothing)
pInf.SetValue(b, val)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Next
End Sub
End Class
Class one
Public Property one As String = "1"
Dim four As Integer = 1
Public ReadOnly Property three As Integer
Get
Return four * 10
End Get
End Property
End Class | <vb.net> | 2016-07-31 19:34:32 | LQ_EDIT |
38,688,431 | echo out a php variable inside a class | <p>I'm trying to echo out a php variable inside a div like that <code><div class="kor $value"></code></p>
<pre><code> $value = get_theme_mod( 'ani', 'fadeIn' );
$output .= apply_filters( 'wal') ? '<div class="kor' <?php echo $value' ">':'');
</code></pre>
| <php><syntax> | 2016-07-31 21:11:21 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.