input
stringlengths
51
42.3k
output
stringlengths
18
55k
Scala: Why do I get a type mismatch error when I use "Option"? <p>I'm new to Scala. I have a Scala function, and one of its arguments uses "Option":</p> <pre><code>def generateTimeSnippet(startOfSentence: Double, endOfSentence: Option[Double]): (Double, Option[Double]) = { ... } </code></pre> <p>When I call this f...
<p>Of course, for an argument of the type <code>Option[Double]</code>, you can not send in the type <code>Double</code>. They are different types.</p> <p>You can send in <code>Some(20.5)</code> which is of the type <code>Option[Double]</code></p>
Persistence with NamedObjects in Spark Job Server <p>Im using the latest SJS version (master) and the application extends SparkHiveJob. In the runJob implementation, I have the following</p> <pre><code>val eDF1 = hive.applySchema(rowRDD1, schema) </code></pre> <p>I would like to persist eDF1 and tried the following</...
<p>I think you should define implicit persister. Looking at the test code, I see something like this</p> <p><a href="https://github.com/spark-jobserver/spark-jobserver/blob/ea34a8f3e3c90af27aa87a165934d5eb4ea94dee/job-server-extras/test/spark.jobserver/NamedObjectsSpec.scala#L20" rel="nofollow">https://github.com/spar...
Some confusion of utf8 in Linux server? <p>About character set I always have question.</p> <p>Local (Mac OS)</p> <pre><code>bash-3.2$ 你好 bash: 你好: command not found bash-3.2$ locale LANG="en_US.UTF-8" </code></pre> <p>Linux Server (ssh)</p> <pre><code>root@hg:~# 你好 -bash: $'\344\275\240\345\245\275': co...
<blockquote> <p>Why both are utf8, in Server 你好 changed to \344\275\240\345\245\275 but literal 你好?</p> </blockquote> <p>The display comes from your shell. Locally you're using <code>zsh</code> which just copies your input in the error message.</p> <p>Remotely, you're using <code>bash</code> which tries to ...
Disposal and cleanup in PowerShell - manual or automatic? <p>I have been working in PowerShell fairly heavily in these past several months. Gotta say, it took me by surprise. What I thought was just an over-inflated version of CMD is actually a very robust, object-oriented, and versatile .NET language.</p> <p>My previ...
<p>It's not required, but it's still good practice. Without it PowerShell will still clean up after you, but it might take considerably longer. Of course objects won't be automagically disposed as long as your code holds a reference to them.</p> <p><a href="http://stackoverflow.com/a/31631113/1630171">Related</a>.</p>...
android checkbox show and hide <p>I have a checkbox in linearlayout6 when i click on the checkbox i want to show linearlayout7,linearlayout8,linearlayout9. otherwise i want to hide these 3 linearlayout(7,8,9). </p> <p><strong>checkbox</strong></p> <pre><code>&lt;CheckBox android:layout_width="wrap_content" android:la...
<p>Add the three <code>checkboxes</code> in your <code>xml</code> layout like what you did for the <code>checkbox1</code> and then specify id to them. </p> <pre><code> CheckBox checkbox=(CheckBox)findViewById(R.id.checkBoxInLayout6); public void addListenerOnChk() // for checkbox { checkBo...
How do I make dynamic navigation child menus active when clicked in laravel? <p>I am retrieving side bar navigation from database.The navigation contains its child menus.I want to make child menus active when clicked.For this purpose I don't want to use jquery. My code for menus is below.</p> <pre><code>@foreach($pare...
<p>I found solution to my question.First we will add anchor tag to child menus in sidebar-blade.php.We can see that we are retrieving URL query string from database.So in this case we will make a condition for our active class and our code would look like this.</p> <pre><code> &lt;ul&gt; @foreach($parent as $parent) ...
Sending email with python script <p>What I'm trying to do is get my python code to send an email. This code is supposed to use the yahoo smtp to send the email. I don't need any attachments or anything else. The code bugs out where it says <code>Error: unable to send email.</code> Other than the obvious of putting in c...
<p>I don't know about Yahoo, but Google blocked the login via their smtp-port. It would be way too easy to conduct brute force attacks otherwise. So even if your code is perfectly ok, the login might still fail because of that. I have tried to do the exact same thing for my gmail account.</p>
Do i need to change database configuration in database.php file in laravel when upload to server? <blockquote> <p>Do i need to change database configuration in database.php file in laravel when upload to server?</p> </blockquote> <pre><code> 'mysql' =&gt; [ 'driver' =&gt; 'mysql', 'host' =&gt; env('D...
<p>Don't change anything in <code>database.php</code> config file. What you need to do is to change DB credentials in <code>.env</code> file on server side.</p> <p>So, you'll have different <code>.env</code> files on a local machine and server, but the same <code>database.php</code> config file.</p> <p><a href="https...
SQL Server Update Query Not Working <p>My query is updating all the records in table HumanResources.EmployeePayHistory, instead of updating only those where sick hours &lt;= 20...</p> <p>Also I realized some fields are being updated more than 1 time.</p> <p>I don't necessarily have to use this format below, but I do ...
<p>I noticed that your update statement is lacking a <code>WHERE</code> clause. I think, that is why you are updating ALL records instead of those records where sick hours &lt;= 20. Also, you are NOT initializing the values into variables while you are fetching records, which you should totally do, otherwise using the...
I have a Meteor app and needs to read data, from the /public/_assets/results/mmresults.json file, within the /client/controllers.js file <p>I have a Meteor app and needs to read data, from a file "/public/_assets/results/mmresults.json", within the file "/client/controllers.js".</p> <p>I do not want to read from the f...
<p>I have had issues trying to access files on mobile devices because of security and CORS. Try to do this as a simple import of the data as an object.</p> <p>Create a directory at the same level as the client folder called "imports" (assuming you don't have this folder already). In that directory, create a file calle...
ASP.NET : when trying to configure a SqlDataSource, the 'specify columns from table or view' option is grayed out. How to resolve this? <p>I don't have much experience with ASP.NET. I am attempting to choose which columns I want to view from a database table inside of a gridview. When I go to Configure Data Source and ...
<p>Found the issue. I was creating a table in a database and saving the table file, but I wasn't updating it to the database. In Visual Studio 2015 when creating a table for a database you must hit the update database button (with the arrow pointing up icon) after you finish configuring the table. This can also be perf...
R: Matching x-axis scales on upper and lower plot using layout with base graphics <p>I am trying to arrange 3 plots together. All 3 plots have the same y axis scale, but the third plot has a longer x axis than the other two. I would like to arrange the first two plots side by side in the first row and then place the th...
<p>I thought you could do this by using <code>par("plt")</code>, which returns the coordinates of the plot region as a fraction of the total figure region, to programmatically calculate how much horizontal space to allocate to the bottom plot. But even when using this method, manual adjustments are necessary. Here's wh...
SCCM Configuration Baseline Name table <p>Can you please help point me to the right direction as to where I can find the table to map the Name of the Configuration Baseline in SCCM?<a href="http://i.stack.imgur.com/f9Ceu.png" rel="nofollow">screenshot</a></p> <p>Thanks in advance!</p>
<p>It's rarely advisable to read anything from the tables directly, and you should instead use the views provided by MS.</p> <p>Not at work at the moment, so can't check, but I suspect you'll be wanting to look at the DisplayName column in v_LocalizedCIProperties.</p>
How can I check whether its parent view or subview when touch gesture event called? <p>I have two view. One is transparent view which contains subviews. I want to remove <code>screenView</code> only when parent view is clicked. I don't want to call tapGesture when i click <code>popUpView</code>. How to can check?</p> ...
<p>Use <code>shouldReceiveTouch</code> delegate method and check:</p> <p>Like,</p> <pre><code>- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view.tag == 100) { return YES; } else { return NO; } } </code></...
update data in database using selected data in option <p>I have a html form where I display all the list of candidates using dropdown or option. All data of option are comes from the database. Here:</p> <pre><code>&lt;form method ="post" action=""&gt; &lt;div class="gov-align"&gt; &lt;div class="hero-body-candidate_go...
<p>Do a small change</p> <pre><code>if(isset($_POST['governor'])) { $sql1="UPDATE cand_votecount SET votecount = votecount + 1 WHERE cand_id =".$_POST['governor']; $result1 = mysqli_query($con,$sql); } </code></pre>
CSS media queries not working in any browser <p>These media queries do not work. What am I doing wrong?</p> <p>I include this in the <code>&lt;head&gt;</code>:</p> <pre><code> &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt; </code></pre> <p>css:</p> <pre><code> /* LE...
<p>You're doing it backwards. Start in the smallest viewport then style up.</p> <p>This will allow you to have a better css flow by being able to check it up as you go and minimize on style overrides. </p> <p>example:</p> <pre><code>@media(min-width: 480px) { } @media(min-width: 767px) { } @media(min-width: 1024...
How to create buttons, text boxes and label in loop in tkinter <p>I am trying to create a framework to create a label, text box and button as an object, I can extend it easily.</p> <p>Idea:</p> <p><a href="http://i.stack.imgur.com/gsSAR.png" rel="nofollow">Original</a></p> <p><a href="http://i.stack.imgur.com/x8q8C....
<p>You have a lot of unnecessary code written like creating a string and assigning a widget to the same variable.<br> Now, I am not certain what the code should look like but I'll give you a way where, in case of making new variables every time in a loop, there is this built-in function <code>exec</code> that might hel...
DictVectorizer with a large dataset <p>I have a large dataset with categorical values and tried to encode them using <code>DictVectorizer</code>. The following is a snippet of the code I tried.</p> <pre><code>dv = DictVectorizer(sparse=True) _dicts = [] for line in fp: _dict = create_dict_feature(line) _dicts....
<p>According to the docs, <code>fit_transform</code> can take an iterable. If the memory issue is coming from the size of the list, consider using a generator instead of a <code>list</code>, which will yield your <code>dict</code>s one at a time as it is iterated. </p> <pre><code>_dicts = (create_dict_feature(line) fo...
Lambda expression - Read db <p>I want to allow user to edit their UserName(that have to be unique) and some other data. However, with the expression I'm using, if you choose to not edit your username, then it wont let you change anything because your current userName already in database. </p> <pre><code> if (db.Us...
<blockquote> <p>if there is ANY input.UserName(but except input.UserName that belongs to input.Id itself) in database</p> </blockquote> <p>It's simply</p> <pre><code>b.Users.Any(u =&gt; u.UserName == user.UserName &amp;&amp; u.Id != user.Id) </code></pre>
Idiomatic way to calculate template parameter depending on other parameters <p>I am looking for an idiomatic way to optimize this template I wrote.</p> <p>My main concern is how to correctly define the template parameter <code>n</code> and using it as a return parameter while the user must not overwrite it.</p> <p>I ...
<p>Regarding the <code>n</code> template parameter, you can avoid it by using <code>auto</code> as the return type in C++14. Here's a simpler example of the principle:</p> <pre><code>template&lt;int N&gt; auto f() { constexpr int bar = N * 3; std::array&lt;int, bar&gt; foo; return foo; } </code></pre> ...
JTextField is read before it is given an input <p>I made a simple try to make a Shop Billing app. Everything is good for now but I am now stuck with a problem. The original source code would be too big and thus could be confusing. So I made an example code to describe my problem. Here is the code.</p> <pre><code>packa...
<p>See the following and ask for clarifications as needed : </p> <pre><code>import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.ArrayList; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; publ...
Delegate function from protocol not being called <p>I have a previously working delegate and protocol that since the conversion to Swift 3 is no longer being called.</p> <pre><code>protocol TaskCellDelegate { func doneHit(_ cell : TaskCell) } class TaskCell : UITableViewCell { var delegate : TaskCellDelegate...
<p>There are following cases if delegate is not being called:</p> <ol> <li>The action: <code>buttonClicked</code> is not being called.</li> <li><p>The View Controller not Conforming to the protocol.</p> <pre><code>class ViewController: UIViewController, TaskCellDelegate { </code></pre></li> <li><p>The protocol method...
Camera calibration: 3D to 2D points mapping <p>I am working on problem related to camera calibration. In the below image, we consider a world coordinate system with X-axis going leftward, Y-axis rightward and Z-axis upward. We select 15 points(x,y,z) distributed uniformly across the 3 planes. The distance between grid ...
<p>It was a silly error from my me that was giving me the wrong camera matrix. I noted down the world coordinates of the point P wrongly ((7,0,1) instead of (1,0,1)). This led to wrongly formed 30x12 matrix which we use to form an equation to be solved by homogeneous linear least squares. I have obtained the calibratio...
How to move the search bar beside the nav bar <p>I've tried use <code>float</code> to make the nav bar arrange in horizontal and also the search bar will place beside the nav bar.<br/></p> <p>But the result is that the nav bar is not longer placed text align center.</p> <p><div class="snippet" data-lang="js" data-hid...
<p>By adding apsolute position you will force the element to always be in the upper right corner:</p> <pre><code>.formright { position: absolute; right: 50px; top: 80px } </code></pre> <p>And here you can see it in action: <a href="http://codepen.io/1GR3/pen/WGkwzo" rel="nofollow">http://codepen.io/1GR3/pen/WGk...
Why is `self` not used in this method? <p>I was under the impression that methods within Python classes <em>always</em> require the <code>self</code> argument (I know that it doesn't actually have to be <code>self</code>, just some keyword). But, this class that I wrote doesn't require it:</p> <pre><code>import ZipFil...
<p>You are trying to use it as a static method. In your example;</p> <pre><code>class MyClass: """A simple example class""" i = 12345 def f(self): return 'hello world' a = MyClass() a.f() # This should work. </code></pre> <p>Calling <code>MyClass.f()</code> assumes <code>f</code> is static for <...
Load data into Cassandra denormalized table <p>I understand that as Cassandra does not support join, we need to create denormalized table sometimes. Given I need to get Item names for each item within a order given order Id, I create a table using:</p> <pre><code>CREATE TABLE order ( order_id int, item_id int, i...
<p>there is a typo on the definition of the primary key, it should be</p> <pre><code>CREATE TABLE order ( order_id int, item_id int, item_name, primary key (order_id, item_id) ); </code></pre> <p>Are you using <a href="https://docs.datastax.com/en/cql/3.1/cql/cql_reference/copy_r.html" rel="nofollow">COPY</a>...
Unattended install of krb5-user on Ubuntu 16.04 <p>So, when running:</p> <pre><code>sudo apt-get install krb5-user </code></pre> <p>You are asked to enter the AD/LDAP domain. The problem is that I want this to be able to be run as a startup script for my machines. Is there any way to either pass the domain in as a pa...
<p>For an unattended installation try setting DEBIAN_FRONTEND variable to noninteractive with: </p> <p><code>export DEBIAN_FRONTEND=noninteractive</code></p> <p>And pass the -y flag to apt-get: </p> <p><code>apt-get install -y krb5-user</code></p>
How to use ng-change in select dropdown with population functionality <p>I'm newbie to angular js, I'm building an ionic app in which, I'm trying to populate the select option depends upon first select option, but the variable which is selecting in first select option is not able to process for getting second select op...
<pre><code>&lt;?php include 'connection.php'; $data = json_decode(file_get_contents("php://input")); $selectedCity1 = $_POST['selectedCity1']; $query = mysql_query("select Sites, Id from sitemaster where City = "+$selectedCity1+""); while ($fetch = mysql_fetch_array($query)) { $output[] = array("site" =&gt; $fetch[0],...
How to show value in if statement in laravel <p>I am doing my project but got stuck in this. I want to print both value of degrees and experiences. How can i achieve this? My controller file is like below:</p> <pre><code>public function industryPost (Request $request) { $industry = $request-&gt;input('industry...
<p>Try like this</p> <pre><code>$experiences = AreaOfExperience::where('industry_id', $industry)-&gt;where('is_active', 1)-&gt;where('is_deleted', 0)-&gt;get(); $degrees = Degree::where('industry_id', $industry)-&gt;where('is_active', 1)-&gt;where('is_deleted', 0)-&gt;get(); return view('view_name')-&gt;with('experie...
CssRewrite filter does not convert relative urls to absolute <p>I'm trying to combine all used css files into a single one. But included resources with relative paths causes problems. I tried assetic's CssRewriteFilter but it does not work.</p> <p>Here is my code:</p> <pre><code> $files = [ '/node_modules/...
<p>Try constructing your <code>FileAsset</code> class like:</p> <pre><code>new \Assetic\Asset\FileAsset( $filename, [new \Assetic\Filter\CssRewriteFilter()], '/node_modules/test/' ); </code></pre> <p>In <code>src/Assetic/Asset/FileAsset.php:37</code>, we see that you can include a <code>$sourcePath</code>...
sql merge rows into columns ( many to many situation ) <p>I am stuck with this sql problem : </p> <p>DB : MySQL 5.6.15 storage engine : MyISAM</p> <p>I have 3 tables : </p> <p>1) products</p> <pre><code>id product | product_name ---------- | -------------- 1 | alfa 2 | beta ...
<p>if there are 10 fixed products then you can do something like this:</p> <pre><code>select p.product_name, (select m.material_name from products p1 join products_materials pm on pm.id_product=p1.id join materials m on m.id=pm.id_material where m.id=1 and p1.id=p.id) as material1, (select m.material_name from produ...
nginx link nodejs app to subdomain <p>I have a dropplet on digital-ocean where I have a <code>node.js</code> app and <code>nginx</code>.</p> <p>So, I installed nginx and then in <code>/etc/nginx/sites-available/</code> I created a new file called <code>api</code> where I have the following content:</p> <pre><code>ser...
<p>You did not included your <code>/etc/nginx/sites-available/api</code> file into <code>/etc/nginx/nginx.conf</code>. You need to include <code>/etc/nginx/sites-available/api</code> in <code>/etc/nginx/nginx.conf</code> inside <code>http</code> module and then restart or reload nginx. Your <code>/etc/nginx/nginx.conf...
C#: Throws Command text was not set for the command object when execute command in OLEDB <pre><code> private void button3_Click(object sender, EventArgs e) { //OleDbCommand cmd = new OleDbCommand(); System.Data.OleDb.OleDbDataAdapter da; //OleDbCommand cmd = con.CreateCommand(); ...
<p>Try the below code...</p> <pre><code>private void button3_Click(object sender, EventArgs e) { OleDbConnection con = new OleDbConnection("Your connection string"); OleDbCommand cmd = new OleDbCommand(con); OleDbDataAdapter da; con.Open(); string sql = "SELECT * From Student2 where Enroll = '" + t...
How can I override a global variable on specific pages? <p>I'm using a plugin that allows you to set a global currency. However, I need to change the currency based on the page.</p> <p>Is there any way to override a global variable on specific pages?</p> <p>The variable I need to change is $currency. Here is what I'v...
<p>If you need to make $currency variable be global on the whole page then <code>&lt;?php global $currency; ?&gt;</code> is declare on the top of the page. Otherwise if you need inside a single function then use this function:</p> <pre><code>change_currency() { global $currency; } </code></pre>
ACTION_OPEN_DOCUMENT with Storage Access Framework returns duplicate results <p>I'm trying to select images using Storage Access Framework and upload them to my server.<br> The problem I'm encountering is that after selecting files I get result which contains duplicates.<br> I have 279 photos in the folder.<br> <code>A...
<p>Seems like it's a bug in Android Nougat.<br> I was able to reproduce it on my phone (Nexus 5X) and on emulator (Google Apis 24)<br> Maybe it's somehow connected to "virtual files" introduced in Nougat SAF: <a href="https://developer.android.com/about/versions/nougat/android-7.0.html#virtual_files" rel="nofollow">htt...
Wordpress conditional permalink <p>I have a specific page on my wordpress website <code>example.com/download/</code> that I already have a page for. I would like to add some sort of php code to enable the following functionality.</p> <ul> <li>If there is a subpath after the <code>/download/&lt;name&gt;</code>, I would...
<p>Yes, you have to add a custom rewrite rule. You can use your theme's functions.php to add the new functionality.</p> <pre><code>function custom_rewrite_rule() { add_rewrite_rule('^download\/([^/]+)\/?','your_url_to_the_downloader_file.php?download=$matches[1]','top'); } add_action('init', 'custom_rewrite_rule',...
Radio-button checked not registered with change() <p>I know this is a common question and I understand why it isn't working. Problem is that the suggested answers are not working for me.</p> <p>HTML code:</p> <pre><code>&lt;label class="radio"&gt;&lt;img id="boyImg" class="radio-img btn-boy" src="/wp-content/uploads/...
<p>As a workaround, you can use <code>click</code> event. It has something to do probably with browser autocomplete. Try different browser.</p>
displaying number of names in a new line in java <p>Trying to create a program which takes an input of names and also returns the next name from the inputted names, starting at a given position. Then writes all the names to the console each on a new line. was able to get the program to count names but not sure how to d...
<p>You already have stored the names in the variable <code>String numPeople[]</code>, moreover you return it.</p> <p>The only left to do is to get the array, loop it and print it out on the new line.</p> <pre><code>String[] names = countNames(null); for (String n : names){ System.out.println(n); } </code></pre> ...
The method scrollto(string) is undefined for the type webdriver <p><a href="http://i.stack.imgur.com/Gmqkg.png" rel="nofollow">I am unable to use scroll to method, I am getting red mark over that methiod. Please help me how to resolve this</a><a href="http://i.stack.imgur.com/Gmqkg.png" rel="nofollow">enter image descr...
<p>Use <code>driver.swipe()</code></p> <p><code>driver.scrollTo()</code> is no more in appium.</p>
Quickest way to update SQLite database on android (or add record if it does not yet exist) <p>I have written the following code to update some information in a database using SQLite. The idea is to update a value (userAverageTime) in case the entry already exist, or make a new record if the entry does not yet exist.</p...
<p>You can use a <code>REPLACE INTO</code> command as you would use an <code>INSERT INTO</code> one. </p> <p>So not to have to check if the record exists and execute the corresponding <code>UPDATE</code> or <code>INSERT INTO</code> command.</p> <p>This should speed up the process a bit:<br> SQLite will first delete t...
subtyping and type coercion <p>The type <code>T</code> below is a subtype of <code>Fruit</code>. <code>Apple</code> is also a subtype of <code>Fruit</code>. So, why doesn't the compiler coerce Apple to T when a type ascription is used below. Why do we need an explicit casting to make it work? What are the rules for coe...
<p>I think you're confusing the meaning of the definition <code> type T &lt;: Fruit</code>: It's an <em>abstract type</em> defintion (unlike <code>type T = Fruit</code> which is a <em>type alias</em>). Absract types do not <em>create</em> a class T that extends <code>Fruit</code>, rather it is an <em>abstract declarati...
switch variable and write problems,python <pre><code>import csv import sys def switch(): file1=open('enjoysport.csv','r') for line in file1: line.split(",")[0],line.split(",")[-1]=line.split(",")[-1],line.split(",")[0] file1.close() origin=sys.stdout f...
<p>You need to actually write the updated row to the file, you can also use the <em>csv</em> lib to read and write your file content:</p> <pre><code>def switch(): with open('enjoysport.csv') as f, open("test.csv", "w") as out: wr = csv.writer(out) for row in csv.reader(f): row[0], row[...
How to layer images one on top of another and make them infinite scroll using css? <p>Im trying to layer 2 images 1 on top of the other and make them scroll infinitely using css. I am able to make the images scroll but not layer them one on top of the other and scroll at different speeds to create an effect. </p> <p>M...
<p>I was able to fix this by adding <code>style="position:absolute;z-index:0;"</code> to the first div and <code>position:absolute;z-index:1;</code> to the second div which then layered them on top of each other</p>
How do I iterate over the product of different lists? <p>I have the following problem:</p> <p>I have a list <code>l1</code> and I want to iterate over the product with the function <code>itertools.product</code>, I also want to include the second list <code>l2</code> in the same way.</p> <p>For example:</p> <pre><co...
<p>By providing a <code>zip</code> of the lists to <code>product</code>:</p> <pre><code>for i in product(zip(l1,l2), repeat = 2): print(i) </code></pre> <p>Wrapping in a <code>list</code> isn't required, the for loop takes care of calling <code>next</code> on the iterator for you.</p> <p>If you want a new-line f...
Make user settings available in req <p>I know that passport exposes the current user (I think using the 'passport' policy) in req.user. I want to do a similar thing for settings of a particular user, which are stored in a separate collection (so that they are available in req.settings). How can I do this?</p>
<p>The serializeUser method is responsible for that <a href="https://github.com/jaredhanson/passport#sessions" rel="nofollow">https://github.com/jaredhanson/passport#sessions</a></p> <pre><code>passport.serializeUser(function(user, done) { done(null, user.id); }); </code></pre> <p>So instead of just serializing the...
Select a record having null if the id has only one record and select not null value when the id has more than one record <p>I want to get a record having null if the id has only one record and select not null value when the id has more than one record</p> <p>Below is example sample. </p> <pre><code>Id Field1 Field2 1...
<p>Use the below query for 2008+ versions of sql server.</p> <pre><code> ;with cte_1 As ( select *, count(1) over (partition by id order by id) Cnt From YourTable) Select Id,Field1,Field2 From Cte_1 Where Field1 is null and Cnt=1 UNION Select Id,Field1,Field2 From YourTable Where field1...
How can I make my WebAPI to stop working when specific exception has occured <p>In some scenarios I am getting exceptions in Startup.cs file. So I want to catch that exceptions and do not show specific errors to Users.</p> <p>I tried this:</p> <p>I catch exceptions and throw as Custom exceptions, even though it shows...
<p>I've No rights to comment so I'm going to write my answer here as far as I understood your question why don't you use <code>Application Error</code> in <code>global.asax</code> file Just like this</p> <pre><code> private void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastE...
Printing values saperated by space <p>I have a <code>foreach</code> loop which prints values of two variables: </p> <pre><code>$Var1 = ''; $Var2 = ''; foreach($variable as $key =&gt; $value) { $Var1 .= $value-&gt;Id; $Var2 .= $value-&gt;Name; } echo $Var1; echo $Var2; </code></pre> <p>If the loop runs 3 times, ...
<p>If <code>$variable</code> is an array of objects with properties <code>Id</code> and <code>Name</code>, then you can print it this way:</p> <pre><code>$a = []; foreach ($variable as $key =&gt; $value) { $a [] = $value-&gt;Id . ' ' . $value-&gt;Name; } echo implode(' ', $a); </code></pre> <p>where we simply conc...
Drag & Drop change style after drop into specific div <p>I have found nice script in: <a href="http://jsfiddle.net/wfG3L/554/" rel="nofollow">http://jsfiddle.net/wfG3L/554/</a> , it is about Drag &amp; Drop.</p> <p>I would like to change width or height of class .card if I drop it into .stackDrop1 or .stackDrop2 and g...
<p>Try this css:</p> <pre><code>.stack .card.ui-draggable { background-color:orange; } </code></pre>
File.Exists always returning true even when file doesn't exist <p>Before the question, sorry for my english, is not my native language.</p> <p>I think the title explain itself, I'm trying to know if the User PC has a dll in system32 folder, but even if I move the .dll to desktop(for test purpose) the File.Exists retur...
<p>Keep in mind that if you run a 32-bit application on a 64-bit system then <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx" rel="nofollow"><strong>file system redirection</strong></a> causes <code>C:\Windows\System32</code> to be redirected to <code>C:\Windows\SysWOW64</code> ...
SQL Query to return Unmatched Rows from two tables <p>I've 2 tables tblEmp1 and tblEmp2 from which i need to extract non matching rows of tblEmp1 by comparing tblEmp2. </p> <p>select * from tblEmp1</p> <pre><code>EmpMasterID DeptID MngrID TEMPID Salary1 Salary2 DOJ 46 ...
<p>Try with the below script. Change the ',' in your on condition with AND operator.</p> <pre><code> SELECT t1.EmpMasterID, t1.DeptID, t1.MngrID, t1.TEMPID, t1.Salary1, t1.Salary2, t1.DOJ FROM tblEmp1 as t1 left outer join tblEmp2 as t2 on t1.DeptID = t2.DeptID and t1.MngrID = t2.MngrID and t1...
how to take youtube embedded code as input from user and echo in php <p>I've created a form that user can input youtube embedded code, so that it can display on website:</p> <pre><code>&lt;form action="postvideo.php" method="post"&gt; &lt;textarea name="videocode"&gt;&lt;/textarea&gt; &lt;input class="button" ...
<p>Try Using this</p> <p>$postdata = file_get_contents("php://input");</p> <p>If you get the data . The reason for empty $_POST is mod_security</p>
Apply *ngFor on object having two arrays with objects, Angular2 <p>This is the data object in abc.component.ts (user[] is getting filled by objects after http request)</p> <pre><code>data = { users: [], photos: [] }; </code></pre> <p>The template file is abc.component.html</p> <pre><code>&lt;div *ngFor="#d o...
<p>When you try to display the user name with <code>{{ d.users.name }}</code> you are trying to access the name property of the array users which obviusly does not have. You have to do <code>{{ d.users[0]].name }}</code> or loop over the users array instead of the <code>data</code> object.</p>
Can we choose next master node in RabbitMQ? <p>Can we prefer one slave node to be a master than another slave node? Assuming I want to choose next master node to be a node with the minimum masters or with the maximum resource available if current master node fails. Is it possible to organize?</p>
<p>You can have a look the <code>x-queue-master-locator</code> policy. Read here: <a href="https://www.rabbitmq.com/ha.html" rel="nofollow">https://www.rabbitmq.com/ha.html</a></p> <blockquote> <p>Queue Master Location Every queue in RabbitMQ has a home node. That node is called queue master. All queue operations ...
Get console user input as typed, char by char <p>I have a console application in Elixir. I need to interpret user’s input on by keypress basis. For instance, I need to treat “q” as a command to end the session, without user to explicitly press <kbd>⏎</kbd> a.k.a. “carriage return.”</p> <p><a href="http://e...
<p>The simplest thing I could cook up is based on <a href="https://github.com/mazenharake/cecho" rel="nofollow">this</a> github repo. So you need the following:</p> <p><code>reader.c</code></p> <pre><code>#include "erl_driver.h" #include &lt;stdio.h&gt; typedef struct { ErlDrvPort drv_port; } state; static ErlDr...
Save received data in java <p>I have server that sends bmp file and a client in Android where I try to save the data that i received. I save the data in a file using the following code:</p> <pre><code>... byte[] Rbuffer = new byte[2000]; dis.read(Rbuffer); try { writeSDCard.writeToSDFile(Rbuffer); } catch (Ex...
<p>Try:</p> <pre><code>FileOutputStream f = new FileOutputStream(file, true); f.write(inputMsg); f.close(); </code></pre>
Ruby && and = operators misudnerstanding <p>What do you think would be the result of the next expression in Ruby?</p> <pre><code> a = 10 &amp;&amp; b = 25 </code></pre> <p>Try to calculate in the ming and only then use <code>irb</code>. So, if we take a look at the Ruby documentation about <a href="https://ruby-do...
<p>This has to do with the way Ruby identifies <strong>bareword identifiers</strong></p> <p>When it comes across an identifier like <code>a</code>, it has to resolve it by checking to see if it is a <strong>keyword, local variable</strong> or <strong>method</strong> in that order.</p> <ul> <li><code>keyword</code> - ...
Angular 2 http catch observable issue <p>I have a custom http service which overrides default angular 2 http service. This service sets custom default options and set loader on request start and hides loader on request completion.</p> <p>I also want to add, the functionality to redirect user to the login page in case ...
<p>You need to import the <code>empty</code> function:</p> <pre><code>import 'rxjs/add/observable/empty' </code></pre>
param is missing or the value is empty: ph - rails <p>This is a possible duplicate, but I have read and tried nearly all suggestions, but I keep getting the error on the New action view. I am using Rails 5.</p> <p>I have tried the following:</p> <pre><code>private def ph_params params.require(:ph).permit(:am...
<p>Modify your <code>new</code> action to</p> <pre><code>def new @ph = Ph.new end </code></pre> <p>The reason you're getting the error is because when you hit the route <code>phs/new</code>, no key <code>ph</code> is passed in the <code>params</code> hash to the controller but you're trying to access <code>params[:p...
Recycleview not scroll in nested scroolview android <p> </p> <pre><code>&lt;RelativeLayout android:id="@+id/todoEditMainLl" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/windowBackground" android:orientation="vertical"&gt; &lt;android.suppo...
<p>First of all this is bad layout technique you have implement </p> <p>According to <strong>android standard</strong> there are no more than two Scrolling views inside one layout </p> <p>Make a proper layout for same</p>
How to get slected value of telerik rad dropdownlist inside radgrid using javascript? <p>I have radgrid containing reddropdown inside it with autopostback=false. when user selects value from dropdown inside grid how that value can be get through javascript.</p> <pre><code>&lt;telerik:GridTemplateColumn UniqueName="Re...
<p>You will need to make a few changes to your code in order to make it work.</p> <p>Firstly, you should register the client-side <code>OnClientItemSelected</code> event instead of the server-side <code>OnSelectedIndexChanged</code> event which only happens upon postback.</p> <pre><code>&lt;telerik:RadDropDownList ru...
Numerical error for a graph implementantion <p>I am working for a project for my university and i am getting always the same error message </p> <blockquote> <p>java.lang.NullPointerException at Assignment2.ColumnGen$SubProblem.createModel(ColumnGen.java:283)</p> </blockquote> <p>The problem is in these lines</p>...
<p>I think your exception comes from all_customers.get(i) , debug your code and make sure all the keys u request are in the map, or you can add a condition to check whether the map contains your key</p>
not getting any value using $_POST in php file <p>Guys m not getting any value on the webpage. I am using post method and i am just accessing the first form textfield named 'user'.</p> <pre><code>&lt;?php require 'connect.php'; if(isset($_POST['user'])){ $username = $_POST['user']; echo $username; } ?&gt; ...
<p>each value in the form tag must be a name to be send but your submit input have not name property. you can see all $_POST values by this line:<code>echo var_export($_POST)</code></p>
connect Symfony 3 application to an externel sql database in (asterisk serevr) <p>I am developing a VoIP administration platform based on asterisk and I am not be able to connect to my asteriisk server from a web app developped with symfony 3</p> <p>I want to connect to my sql database existing on asterisk server wic...
<p>Audit your mysql server settings. Try to do the same via commandline. Most probably, your sql server wont be accepting connection from external ip's. It has nothing to do with asterisk.</p>
Replace all variables with integers <p>I am trying to replace all "variables" with integer using standard input. </p> <p>input string:</p> <blockquote> <p>"pq+pq+pqr+4"</p> </blockquote> <p>Say, I enter 1 for <code>pq</code> and 3 for <code>pqr</code>. What I want to get is</p> <blockquote> <p>"1+1+3+4"</p> </...
<p>Use <code>\b</code> to define the word boundaries at each side of your variable name in your <code>replaceAll</code> in order to indicate that you want to replace a complete word not a sub part of a word, as next:</p> <pre><code>line = line.replaceAll("\\b" + targetStr + "\\b", newStr); </code></pre>
Εxtract data in between paratheses and append at the end of the line <p>File.txt:</p> <pre><code>first_name NVARCHAR2(15) NOT NULL, middle_name NVARCHAR2(20) NOT NULL, last_name NVARCHAR2(11) NOT NULL, output i need:-&gt;output.txt first_name NVARCHAR2(15) NOT NULL,15 middle_name NVARCHAR2(20) NOT NULL,20 last_name ...
<p>Use regex - something like:</p> <pre><code>import re for line in input: m=re.search('\((\d+)\)',line) output.write(line.rstrip('\n')+m.group(1)+'\n') </code></pre> <p>The search content should match what you are looking for (<code>\d+</code> in my example - matches any number). If you expect more then one ...
What's wrong with my code? [SyntaxError] <p>So I'm writing a temporary program for boring jobs. In this program I'm writing the written text into the given file name. Later I'm gonna use these files for a word memorization program. Here's how the file looks like in Xubuntu;</p> <p>(Written with PyQt4)</p> <p><a href=...
<p>In line 173 as the editor.py says you forgot the colon (<code>:</code>)</p> <pre><code>File "editor.py", line 173 for s in words[(words.index(i) + 1):(searched_words + 1)] ^ </code></pre> <p>The devil's in the detail!</p>
Podfile not downloading latest Swift 3 version of pods <p>Since updating to Swift 3, I've had trouble getting the Swift 3 versions of pods to install. As an example, ReadabilityKit has Swift 3 support on master branch. In their readme, they state that for Swift 3 support, you must simply do:</p> <pre><code>platform :i...
<p>you can try adding this line to the end of your podfile:</p> <pre><code>post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end </code></pre> <p>Or try to update cocoapods t...
How to give different tags to buttons in different TableView cells in Swift <p>I'm developing an app where users writes entries to different topics then can give up and down points to the entries. I used in my tableViewController the function:</p> <blockquote> <p>func tableView(tableView: UITableView, cellForRowAtIn...
<p>Perhaps finally found an issue. When I reproduced the problem in my project, I realised that <strong>downcasting to</strong> <code>UIButton</code> was missing.</p> <p>So within <code>HubEntryTableViewCell</code> subclass update the method like this:</p> <pre><code>@IBAction func plus(sender: AnyObject) { // s...
PIL crop image give incorrect height result <pre><code>import PIL from PIL import Image img = Image.open('0009_jpg.jpg') width, height = img.size #height is 720 and width is 480 if height &gt; width: rm_height = abs(height - width) # rm_height = 240 x_offset = 0 y_offset = rm_height/2 # y_offset = 120 ...
<p>OK after i search for more. Now i get it from this <a href="http://labb.in/s/ZCwU" rel="nofollow">post</a></p> <p>Chris Clarke's (<a href="http://labb.in/s/ZCqu" rel="nofollow">edited</a> by San4ez) answer:</p> <pre><code>import Image im = Image.open(&lt;your image&gt;) width, height = im.size # Get dimensions ...
The difference of gevent and multiprocess <p>I am learning how to make my script run faster. I think parallel is a good way. So I try gevent and multiprocessing. But I am confused by it's different result. Let me show two examples I met,</p> <p>ex 1:</p> <pre><code>a=np.zeros([3]) def f(i): a[i]=1 print a def...
<p>ex1:</p> <p>when you use multiprocess each process has separate memory(unlike threads)</p> <p>ex2:</p> <p>gevent does not create threads, it creates Greenlets(coroutines)!</p> <blockquote> <p>Greenlets all run inside of the OS process for the main program but are scheduled cooperatively.</p> <p><strong>On...
Live wallpaper not change in Android device when set another live wallpaper <p>I am new to Android development and currently I am implementing Live wallpaper application.So, My question is How I can change live wallpaper when new live wallpaper is selected from the application.currently I am setting only one live wallp...
<p>For destroying previous wallpaper and set the new wallpaper,You have <strong>Clear</strong> previous wallpaper like this,</p> <p>In Your setWallpaper button click event use this code</p> <pre><code>setWallpaper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {...
reducer takes mapper cores <p>I'm running mapreduce job on hadoop cluster with 88 cores with 60 reducers. For some reason it only uses 79 cores of cluster. At start it runs with 79 mappers but when half splits are done it uses 53 mappers and 26 reducers and number of running mappers continues to shrink later which incr...
<p>Set <code>mapreduce.job.reduce.slowstart.completedmaps</code> to 1.0. Quote from <a href="https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xml">mapred-default.xml</a>:</p> <blockquote> <p>mapreduce.job.reduce.slowstart.completedmaps</p> <p>0.05</p> ...
Parsing JSON into HTML Table <p>Can anyone help me parsing the XML content present in Oracle DB with BLOB. And Display it in UI with HTML Table using Angular JS.</p> <p>From Oracle DB whenever I Query a field ,it will return multiple ROW with BLOB</p> <p>And Each Blob contains XML data. Now I want to Parse it from An...
<p>I got answer to myself. The Problem was the XML is having multiple root elements so it wasn't converted to JSON.</p> <p>As a work around now I am Appending my XML with So Now I am able to convert it into JSON</p> <pre><code>&lt;Persons&gt; &lt;Person:PersonEvent xmlns:Person = "http://PERSON/PersonEvent"&gt; ...
.htaccess rewrite all URLs, even if path <p>I've made some PHP code that will direct the user based on the URL, and I've found some code for htaccess that gives the URL to the index page which lets my code work. However, it's also technically revealing what is a file/folder and what isn't.</p> <p>If I go to <code>webs...
<p>If you want to hide some file or directory, i.e. appear it as not existant, you might redirect with the <a href="https://httpd.apache.org/docs/current/rewrite/flags.html#flag_r" rel="nofollow"><code>R|redirect</code></a> flag</p> <pre><code>RewriteRule ^cache/private - [R=404,L] </code></pre> <p>This tells the cli...
Resetting template driven forms in angular 2 (models and validations both) <p>How do we reset the controls with validation states of <strong>Template driven</strong> forms in angular 2? I know that controls can be reset by setting model values to which they are bound to. But what about the validation states(pristine, d...
<p>Both of these worked for me:</p> <pre><code>playlistForm.reset(); playlistForm.resetForm(); // I think this is the one to use </code></pre> <p>Angular docs have resetForm() only <a href="https://angular.io/docs/ts/latest/api/forms/index/NgForm-directive.html" rel="nofollow">https://angular.io/docs/ts/latest/api/fo...
Passing ID of selected DIV to next PHP page without form or URL variables <p>I've got some variables that I have in javascript that are:</p> <pre><code>window.location.href = 'chosendivs.php?Selected=' + qs; </code></pre> <p>where qs is an array of different div ID's that passes to the next page in the URL as follows...
<p>You can send an <a href="http://www.w3schools.com/ajax/" rel="nofollow">ajax</a> request with <code>POST</code> like</p> <pre><code>qs= []; qs[0] = 'id1'; qs[1] = 'id2'; $.ajax({ type: "POST", data: {qs:qs}, url: "http://localhost/{web_server}/chosendivs.php", }); </code></pre> <p>and if you do a <code>va...
Repeat array date in php for fullcalendar <p>I have to be able to view on fullcalendar.io a series of shakes that are repeated.</p> <p>With php I managed, to repeat an array, now I have difficulty display it on the calendar.</p> <p>Here is the code</p> <pre><code>$aDate = '2016-09-20'; $rounds = array('Sera', 'Pomer...
<p>Please Check below code [<strong>NOTE:</strong> I have managed to make a similar structure as you mentioned, you can changed according to satisfy full calendar needs]</p> <pre><code>&lt;?php $aDate = '2016-09-20'; $rounds = array('Sera', 'Pomeriggio', 'Mattina', 'Notte', 'Riposo'); $events = array(); for($i=0; $...
Git doesnt show commited icon <p>I've just installed Git latest version on Window 64 bit.</p> <p>Problems: Git does not show icon (tick symbol with green circle around) showing the files have been committed to git although it is a git repository..<a href="http://i.stack.imgur.com/dMxQe.png" rel="nofollow">View the pic...
<p>Maybe it's just a simple glitch or an update. IDK. But you can see you git commit with the command <code>git log</code>. So you can see if they are realy commited and if it's a simple display bug, or another bug. Keep us informed.</p>
PHP file upload error Undefined index <p>I have this HTML code:</p> <pre><code>&lt;form id="uploadForm" action="" method="post" enctype= "multipart/form-data"&gt; &lt;input type="file" name="fileToUpload" &gt; &lt;input type="submit" name="submit" value="Submit"&gt;&lt;br /&gt; </code></pre> <p>This is the PHP code:...
<pre><code>&lt;form id="uploadForm" action="" method="post" enctype= "multipart/form-data"&gt; &lt;input type="file" name="fileToUpload" &gt; &lt;input type="submit" name="submit" value="Submit"&gt;&lt;br /&gt; &lt;/form&gt; &lt;?php if(isset($_POST["submit"])) { $target_dir = "/"; $file = $_FILES['fileToUploa...
I've tried using vertical-align and color in static_nav div but it didn't work. Is this because its inside of the header? how would I fix this? <pre><code> &lt;!DOCTYPE HTML&gt; &lt;html lang ="en"&gt; &lt;meta charset = "utf-8" /&gt; &lt;head&gt; &lt;title&gt;Example Page&lt;/title&gt; &lt;link rel="stylesheet" t...
<p>To <code>color</code> the links in <code>#static_navbar</code>, you have to style them directly. Otherwise the browsers default link color will be used:</p> <pre><code>div#static_nav a { color: white; } </code></pre> <p>To vertically align the links, one possibility is to use the padding of the <code>#static_nav...
Python - multiprocessing while writing to a single result file <p>I am really new to the multiprocessing package and I am failing to get the task done.</p> <p>I have lots of calculations to do on a list of objects. </p> <p>The results I need to write down are saved in those objects, too.</p> <p>The results should be...
<p>You can use <a href="https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.imap_unordered" rel="nofollow">imap_unordered</a></p> <pre><code>def mp_handler(data_list): p = multiprocessing.Pool(4) with open('results.csv', 'a') as f: writer= csv.writer(f, lineterminator = '\n...
Add header to HTTP Post content Flume <p>I am testing out Flume HTTP Source with HDFS as sink. Below is the conf file used.</p> <pre><code>httpagent.sources = httpsource httpagent.sinks = hdfs-file-sink httpagent.channels = ch3 httpagent.sources.httpsource.type = http httpagent.sources.httpsource.bind = address ht...
<p>You may want to take a look at event serializers ( <a href="https://flume.apache.org/FlumeUserGuide.html#event-serializers" rel="nofollow">https://flume.apache.org/FlumeUserGuide.html#event-serializers</a> )</p> <p>Serializer can be set as described at <a href="https://flume.apache.org/FlumeUserGuide.html#hdfs-sink...
Android Studio 2.2 doesn't generate R.java <p>I can't create new projects anymore with this problem now despite my version is the latest 2.2.</p> <p>Whenever I create a new project I get this message from gradle build:</p> <blockquote> <p>Error:Execution failed for task ':app:compileDebugAidl'.</p> <p>java.lan...
<p>PROPLEM SOLVED: android studio was notifying me of new updates to be installed and i made sure to check all (android SDK build tools) in tools packages folder in SDK manager</p>
php + sqllite3: Error by prepered update binding, when using IS NULL/ IS NOT NULL <p>So I have to use a prepared statement, otherwise there will be other errors. </p> <p>I don't know why, but it wasn't possible to prepare two update statements at the same time like this:</p> <pre><code>$sql_update_users =&lt;&lt;&lt;...
<pre class="lang-sql prettyprint-override"><code>UPDATE users SET following_on = :time WHERE user_id = :usernameId, following_on IS NULL </code></pre> <p>In this query, the comma must be an AND.</p> <pre class="lang-sql prettyprint-override"><code>UPDATE users SET was_follower = :sync_id AND unfollowed_me_on = :tim...
I am not able to fetch and delete data from Sq-lite <p>I have created database to perform add to cart functioning. This is my database helper class.</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 pret...
<p>You <strong>don't have to specially</strong> use anything for user unique id as <strong>every logged in user is assigned a unique id</strong> and you can retrieve it like this :</p> <pre><code>FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user != null) {     // Name, email address, and prof...
Unable to adjust the BODY width with CSS <p>I need body to have a silver background and fill only 75% of the page. That is, only 75% of the page is painted silver, while the remaining part is unused and painted according to broswer's defaults. The left part of the page is my BODY, the right part is unused. I tried</p>...
<p>You would need to set the background color for both <code>html</code> and <code>body</code>.</p> <p>In addition you have set a height of <code>100%</code> to the <code>html</code> element and a <code>min-height</code> of <code>100%</code> or <code>100vh</code> to the <code>body</code> so that it will alway fill the...
how to overide background-color: #000000 !important; <p>I want to override the <code>background-color: black !important</code> property on a WordPress project or delete that property but I can't find it in my CSS Files. </p> <pre><code>#top-nav &gt; div &gt; ul &gt; li.current-menu-item, #top-nav &gt; div &gt; div &g...
<p>Find a way to include the rule you want after the rule you're trying to override.</p> <p>CSS are, by definition, Cascading Style Sheets. That means that the following code:</p> <pre><code>.divwhatever { background-color: black; } // On WordPress Original File .divwhatever { background-color: white; } // On WordPre...
Scenekit SCNShadable texture2D not working <p>I have some code like this:</p> <pre><code>let myShader = "#pragma arguments\n" + "sampler uMaskTex;\n" + "uniform sampler2D uMaskTex;\n" + "#pragma body\n" + //none of these work "vec3 mask = texture2D( uMaskTex , vec2(1.,1.) ).xyz;\n" + //"...
<p>This seems to be caused by the shader cross-compiler's whitespace sensitivity. Specifically, if I change</p> <pre><code>vec3 mask = texture2D( uMaskTex , vec2(1.,1.) ).xyz; </code></pre> <p>to</p> <pre><code>vec3 mask = texture2D( uMaskTex, vec2(1.,1.) ).xyz; </code></pre> <p>(note the absence of a space after t...
Array with some null field in where clause not working in Codeigniter Activerecord <p>I'm trying to run this query passing <code>$data</code> array in where clause.But in this <code>$data</code> array one or more field value can be null and some fields are not as look like below: </p> <pre><code>$data = Array( [c.cli...
<p>In your example $data it would always have to contain entries that actually have values... so you example $data would need to be...</p> <pre><code> $data = array( 'c . pkg_id' =&gt; 2, 'c . area_id ' =&gt; 1, 'c . managed_by' =&gt; 3 ); </code></pre> <p>So you would need to b...
Apply zoom level condition for Google Maps iOS <p>I have a map here:</p> <pre><code>let camera = GMSCameraPosition.cameraWithLatitude(37.0902, longitude: -95.7129, zoom: 4.0) let mapView = GMSMapView.mapWithFrame(CGRect.zero, camera: camera) mapView.myLocationEnabled = true view = mapView ...
<p>You can use <code>didChangeCameraPosition</code> delegate method of <code>GMSMapView</code></p> <p>First, you need to extend your <code>GMSMapView</code> delegate in your class</p> <pre><code>class MyViewController: GMSMapViewDelegate </code></pre> <p>Then you need to assign your delegate after declaring the mapV...
why to use function to define a property? <p>i read about <code>defineProperty()</code>. </p> <p>but i found this notation in a program i don't understand:</p> <pre><code>myObject.defineProperty("something", "propertyNameExample", function() { // function body here }) </code></pre> <p>what i do not understand is tha...
<p>Nothing (or technically not sure), this is not a native method for defining a property in Javsacript.</p> <p>There are two things wrong here</p> <ul> <li>It should be <code>Object.defineProperty</code> not <code>myObject.defineProperty</code></li> <li><code>myObject.defineProperty</code> will be a user defined fun...
Convert json String to java object <p>I have the following jsonString,I need to convert it to java object, I have used the following code to convert it but i get this exception </p> <pre><code>com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.innvo.web....
<p>Your <code>Questiongroup</code> class is nested inside the <code>Responsedetail</code> class, and <code>Question</code> is nested inside <code>Questiongroup</code>.</p> <p>Since you didn't make them <code>static</code>, they are <em><a href="https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html" rel="nofo...
Comparing items of case-insensitive list <p>So I have two lists, with items in varying cases. Some of the items are the same but are lowercase/uppercase. How can I create a loop to run through all the items and do something with each item, that also ignores what case the item may have?</p> <pre><code>fruits = ['Apple'...
<p><code>fruit.lower()</code> in the for loop won't work as the error message implies, you can't assign to a function call..</p> <p>What you could do is create an auxiliary structure (<code>set</code> here) that holds the lowercase items of the existing fruits in <code>fruits</code>, and, <code>append</code> to <code>...
Why does this Python Tkinter stopwatch script crash? <p>I have this script I wrote as a timer, but it crashes whenever I press the start button. (Sorry, I'm very much so of a noob) <a href="http://pastebin.com/BWDaRTYv" rel="nofollow">http://pastebin.com/BWDaRTYv</a> Thanks, Sam</p>
<p>I can't see your code but I am willing to bet that you are using time.sleep to delay your time. DONT. Use the Tkinter .after method to schedule a function to be called periodically to update your timer.</p> <p><a href="http://effbot.org/tkinterbook/widget.htm" rel="nofollow">See here</a> or <a href="http://stackove...
Move onto next task in ansible without waiting for other hosts to finish that task <p>So I have noticed that in my ansible playbooks, if I target multiple hosts with the same playbook that each task must be complete for all hosts before it moves onto the next task.</p> <p>Is it possible to define the playbook such tha...
<p>This behaviour of Ansible can be controled by <a href="http://docs.ansible.com/ansible/playbooks_strategies.html" rel="nofollow">playbook strategies</a>.</p> <p>The default strategy is <code>linear</code> strategy:</p> <blockquote> <p>All hosts will run each task before any host starts the next task, using the n...
Fragment error accessing the view <p>I am trying to use tabs and <code>PagerAdapter</code> to make a tab layout.</p> <p>I have the following expression in my <code>Fragment</code>:</p> <pre><code>cpPrecTextView = (BootstrapLabel) getView().findViewById(R.id.cpPrec); cpPrecTextView.setText(cpPrecTextView.getText() + c...
<p><code>getView()</code> <strong>returns null</strong></p> <p>To solve this you should run all code that depends on a view in <code>onCreateView</code>. That way you will always have a reference to a view to use for finding other views.</p> <p>You can consult the <a href="https://developer.android.com/guide/componen...
No attribute 'HookManager' <p>I am copying the key logger from this video: (<a href="https://www.youtube.com/watch?v=8BiOPBsXh0g" rel="nofollow">https://www.youtube.com/watch?v=8BiOPBsXh0g</a>) and running the code:</p> <pre><code> import pyHook, sys, logging, pythoncom file_log = 'C:\Users\User\Google Drive\P...
<p>I'm still unsure what the issue is but I found a solution. If you move the program you are trying to run into the same folder as the HookManager.py file then it works. </p> <p>For me this file was: C:\Python27\Lib\site-packages\pyHook</p>
Unity 5.4 "Set Destination" can only be called on an active agent, Wrong destination when instantiating <p>I am trying to spawn soldiers and move them as a regiment via mouse clicks on a nav mesh. But i get the ""Set Destination" can only be called on an active agent" error. I read in the forums that this can be caused...
<p>I had this problem while trying to instantiate hidden gui elements for cloning. </p> <p>The problem is that GetComponent doesn't find components of inactive gameobjects. If you want to find an inactive gameobject(s) you must call <code>GetComponentsInChildren&lt;NavMeshAgent&gt;(true);</code> Like,</p> <pre><code>...
C#: A method that returns true if the value 3 is contained in the array and false otherwise <p>I'm trying to translate </p> <p>"A method that returns true if the value 3 is contained in the array and false otherwise." </p> <p>into code, but so far the only thing I could come up with is</p> <pre><code>class Test { ...
<p>An C#-Array implements the <code>IEnumerable&lt;TSource&gt;</code> interface. One of the defined methods on this interface is the <code>Contains(TSource element)</code> method which checks if the element is in the collection of elements.</p> <p>So in your case it should be:</p> <pre><code>static bool ValueThree() ...