pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
27,588,611
0
<p>It should work with</p> <pre><code>.form input { /*your css code*/ } </code></pre> <p>Do not use the <code>&gt;</code> in this case, it only selects the direct children</p>
33,528,555
0
Error thrown when using BlockMatrix.add <p>I'm attempting to use the distributed matrix data structure BlockMatrix (Spark 1.5.0, scala) and having some issues when attempting to add two block matrices together (error attached below).</p> <p>I'm constructing the two matrices by creating a collection of MatrixEntry's, putting that into CoordinateMatrix (with specifying Nrows,Ncols), and then using the CoordinateMatrix routine toBlockMatrix(Rpb,Cpb). For both matrices the Rpb/Cpb's are the same.</p> <p>Unfortunately when attempting to use the BlockMatrix.add routine I'm getting:</p> <pre><code>15/11/04 10:17:27 ERROR executor.Executor: Exception in task 0.0 in stage 11.0 (TID 30) java.lang.IllegalArgumentException: requirement failed: The last value of colPtrs must equal the number of elements. values.length: 9164, colPtrs.last: 5118 at scala.Predef$.require(Predef.scala:233) at org.apache.spark.mllib.linalg.SparseMatrix.&lt;init&gt;(Matrices.scala:373) at org.apache.spark.mllib.linalg.SparseMatrix.&lt;init&gt;(Matrices.scala:400) at org.apache.spark.mllib.linalg.Matrices$.fromBreeze(Matrices.scala:701) at org.apache.spark.mllib.linalg.distributed.BlockMatrix$$anonfun$5.apply(BlockMatrix.scala:321) at org.apache.spark.mllib.linalg.distributed.BlockMatrix$$anonfun$5.apply(BlockMatrix.scala:310) at scala.collection.Iterator$$anon$11.next(Iterator.scala:328) at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:202) at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:56) at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:68) at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41) at org.apache.spark.scheduler.Task.run(Task.scala:64) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 15/11/04 10:17:27 INFO scheduler.TaskSetManager: Starting task 2.0 in stage 11.0 (TID 32, localhost, PROCESS_LOCAL, 2171 bytes) 15/11/04 10:17:27 INFO executor.Executor: Running task 2.0 in stage 11.0 (TID 32) 15/11/04 10:17:27 WARN scheduler.TaskSetManager: Lost task 0.0 in stage 11.0 (TID 30, localhost): java.lang.IllegalArgumentException: requirement failed: The last value of colPtrs must equal the number of elements. values.length: 9164, colPtrs.last: 5118 at scala.Predef$.require(Predef.scala:233) at org.apache.spark.mllib.linalg.SparseMatrix.&lt;init&gt;(Matrices.scala:373) at org.apache.spark.mllib.linalg.SparseMatrix.&lt;init&gt;(Matrices.scala:400) at org.apache.spark.mllib.linalg.Matrices$.fromBreeze(Matrices.scala:701) at org.apache.spark.mllib.linalg.distributed.BlockMatrix$$anonfun$5.apply(BlockMatrix.scala:321) at org.apache.spark.mllib.linalg.distributed.BlockMatrix$$anonfun$5.apply(BlockMatrix.scala:310) at scala.collection.Iterator$$anon$11.next(Iterator.scala:328) at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:202) at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:56) at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:68) at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41) at org.apache.spark.scheduler.Task.run(Task.scala:64) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 15/11/04 10:17:27 ERROR scheduler.TaskSetManager: Task 0 in stage 11.0 failed 1 times; aborting job 15/11/04 10:17:27 INFO storage.ShuffleBlockFetcherIterator: Getting 4 non-empty blocks out of 4 blocks 15/11/04 10:17:27 INFO storage.ShuffleBlockFetcherIterator: Started 0 remote fetches in 0 ms 15/11/04 10:17:27 INFO storage.ShuffleBlockFetcherIterator: Getting 2 non-empty blocks out of 4 blocks 15/11/04 10:17:27 INFO storage.ShuffleBlockFetcherIterator: Started 0 remote fetches in 1 ms 15/11/04 10:17:27 INFO scheduler.TaskSchedulerImpl: Cancelling stage 11 15/11/04 10:17:27 INFO executor.Executor: Executor is trying to kill task 1.0 in stage 11.0 (TID 31) 15/11/04 10:17:27 INFO scheduler.TaskSchedulerImpl: Stage 11 was cancelled 15/11/04 10:17:27 INFO executor.Executor: Executor is trying to kill task 2.0 in stage 11.0 (TID 32) 15/11/04 10:17:27 INFO scheduler.DAGScheduler: Stage 11 (map at kmv.scala:26) failed in 0.114 s 15/11/04 10:17:27 INFO executor.Executor: Executor killed task 2.0 in stage 11.0 (TID 32) 15/11/04 10:17:27 INFO scheduler.DAGScheduler: Job 2 failed: reduce at CoordinateMatrix.scala:143, took 6.046350 s Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 30, localhost): java.lang.IllegalArgumentException: requirement failed: The last value of colPtrs must equal the number of elements. values.length: 9164, colPtrs.last: 5118 at scala.Predef$.require(Predef.scala:233) at org.apache.spark.mllib.linalg.SparseMatrix.&lt;init&gt;(Matrices.scala:373) at org.apache.spark.mllib.linalg.SparseMatrix.&lt;init&gt;(Matrices.scala:400) at org.apache.spark.mllib.linalg.Matrices$.fromBreeze(Matrices.scala:701) at org.apache.spark.mllib.linalg.distributed.BlockMatrix$$anonfun$5.apply(BlockMatrix.scala:321) at org.apache.spark.mllib.linalg.distributed.BlockMatrix$$anonfun$5.apply(BlockMatrix.scala:310) at scala.collection.Iterator$$anon$11.next(Iterator.scala:328) at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) at org.apache.spark.util.collection.ExternalSorter.insertAll(ExternalSorter.scala:202) at org.apache.spark.shuffle.sort.SortShuffleWriter.write(SortShuffleWriter.scala:56) at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:68) at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41) at org.apache.spark.scheduler.Task.run(Task.scala:64) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Driver stacktrace: at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1204) at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1193) at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1192) at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59) at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47) at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1192) at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:693) at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:693) at scala.Option.foreach(Option.scala:236) at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:693) at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1393) at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1354) at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48) 15/11/04 10:17:27 WARN scheduler.TaskSetManager: Lost task 2.0 in stage 11.0 (TID 32, localhost): TaskKilled (killed intentionally) 15/11/04 10:17:27 INFO executor.Executor: Executor killed task 1.0 in stage 11.0 (TID 31) 15/11/04 10:17:27 WARN scheduler.TaskSetManager: Lost task 1.0 in stage 11.0 (TID 31, localhost): TaskKilled (killed intentionally) 15/11/04 10:17:27 INFO scheduler.TaskSchedulerImpl: Removed TaskSet 11.0, whose tasks have all completed, from pool </code></pre> <p>Edit: Below is a small reproducer (not the original) for the problem. It fails for 1.3.0 and 1.5.0 at least. Is there a dense+sparse issue I'm not understanding?</p> <pre><code>import org.apache.spark.mllib.linalg._ import org.apache.spark.mllib.linalg.distributed._ import org.apache.spark.{SparkConf, SparkContext} object runAddBug { def main(args: Array[String]) { val appName = "addbug" val conf = new SparkConf().setAppName(appName) val sc = new SparkContext(conf) val N = 200 val Nbx = 10 val diags = sc.parallelize(0 to N-1) val Eyecm = new CoordinateMatrix(diags.map{d =&gt; MatrixEntry(d, d, 1.0)}, N, N) val diagsq = diags.cartesian(diags) val Bcm = new CoordinateMatrix(diagsq.map{dd =&gt; MatrixEntry( dd._1, dd._2, 1.0*dd._1*dd._2)}, N, N) val Rpb = (N/Nbx).toInt val Cpb = (N/Nbx).toInt var A = Eyecm.toBlockMatrix(Rpb,Cpb) var B = Bcm.toBlockMatrix(Rpb,Cpb) var C = A.add(B) val entsOut = C.toCoordinateMatrix().entries val outLines = entsOut.map{anent =&gt; anent.i.toString + "\t" + anent.j.toString + "\t" + anent.value.toString } outLines.saveAsTextFile("Outdata") } } </code></pre> <p>Thanks for any help!</p>
12,858,922
0
Order by alphanumeric in mysql <p>Can you help me? </p> <p>my query is </p> <pre><code>SELECT num FROM sortnum ORDER BY lpad(num, 10, 0) </code></pre> <p>result of this query is not good here is the result </p> <pre><code>1 2 3 4 5 6 7 8 9 10 11 12 13 14 1a 2a 2b A1 A2 A3 A4 B1 A10 A11 B10 </code></pre> <p>What is the best query for this type of data i want number first, then data starting with a , then with b </p> <p>i want result like </p> <pre><code>1 1a 2 2a 2b 3 4 5 6 7 8 9 10 11 12 13 14 A1 A2 A3 A4 A10 A11 B1 B10 </code></pre> <p>Thanks in advance</p>
39,146,457
0
<p>Don't use mysql for this stuff. You need an engine optimized for indexing search material. You can use <code>elasticsearch</code> or <code>solr</code> for this purpose and index it using mysql. Mysql is simply not designed for this purpose</p>
23,046,211
0
<p>I found <strong>if</strong> statement in <strong>catalog/layer/view.phtml</strong> left by previous programmer, which disallowed to show layered navigation filters if page has an URL. :/ Sorry</p>
4,274,983
0
<p>use <code>.css("display", "none");</code> for hiding, <br/> and <code>.css("display", "block");</code> for showing</p>
12,792,342
0
How to scaling big image smoothly in canvas with drawImage? <p>When I use drawImage to scalle a big image (like 5M), the result looks terrible, is there any easier way that can scalling image with anti-aliasing? <a href="https://developer.mozilla.org/en-US/docs/Canvas_tutorial/Using_images" rel="nofollow">MDN</a> has mentioned about this:</p> <p>Note: Images can become blurry when scaling up or grainy if they're scaled down too much. Scaling is probably best not done if you've got some text in it which needs to remain legible.</p> <p><strong>EIDT:</strong> I wanna scale a image to 90x90, and my code is like this:</p> <pre><code>that.avatar_height &gt;= that.avatar_width ? that.context.drawImage($(this)[0], 86, 2, 90, that.avatar_height*90/that.avatar_width) : that.context.drawImage($(this)[0], 86, 2, that.avatar_width*90/that.avatar_height, 90); </code></pre> <p>avatar is the image to be scaled.</p>
33,005,839
0
SQL Cannot add foreign key? <p>Hey guys i am new to learning SQL, trying to make a simple movie database for school but getting cannot add foreign key constraint error on SQL fiddle any ideas would be very much appropriated thanks.</p> <pre><code>CREATE TABLE Actor ( ActorID INT AUTO_INCREMENT PRIMARY KEY, FName VARCHAR (255), LName VARCHAR (255) ); CREATE TABLE Genre ( GenreID INT AUTO_INCREMENT PRIMARY KEY, GenreType VARCHAR(255) ); CREATE TABLE Director ( DirectorID INT AUTO_INCREMENT PRIMARY KEY, FirstName VARCHAR (255), LastName VARCHAR (255), MovieID INT, FOREIGN KEY (MovieID) REFERENCES Movie(MovieID) ); CREATE TABLE Movie ( MovieID INT AUTO_INCREMENT PRIMARY KEY, MovieTittle VARCHAR (255) NOT NULL, ReleaseYear INT (4) NOT NULL, Watched BOOlEAN, StarRating INT (2), DirectorID INT, FOREIGN KEY (DirectorID) REFERENCES Director(DirectorID) ); CREATE TABLE JunctionMovieGenre ( GenreID INT, MovieID INT, FOREIGN KEY (GenreID) REFERENCES Genre(GenreID), FOREIGN KEY (MovieID) REFERENCES Movie(MovieID) ); CREATE TABLE JunctionMovieActor ( MovieID INT, ActorID INT, FOREIGN KEY (ActorID) REFERENCES Actor(ActorID), FOREIGN KEY (MovieID) REFERENCES Movie(MovieID) ); </code></pre>
15,218,152
0
<p>I think this is problem with file encoding, especially with <a href="http://en.wikipedia.org/wiki/Byte_order_mark" rel="nofollow">BOM</a>.</p> <p>Try to open with editor which show BOM (like notepad++) and then try to remove it.</p>
29,446,865
0
<p>A better way to describe "mount" is "attach".</p> <p>The filesystem being mounted is attached to an empty directory of the existing filesystem. That is, the top level directory of the mounted filesystem becomes the directory on the existing filesystem.</p> <p>Subdirectories of the mounted filesystem become the subdirectories of the former directory on the existing filesystem, and so on.</p> <p>(The directory that was mounted on doesn't really have to be empty, but after mounting any contents it had are inaccessible, until the filesystem is unmounted).</p>
18,290,918
0
<p>This is not a Laravel nor Sentry problem, this probably is a PDO (database) connection error.</p> <p>This is basic, but still: check if mysql is running and if mysqld.sock has the proper permissions.</p> <p>Check if your php.ini file has it configured properly, example:</p> <pre><code>pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock </code></pre> <p>Verify the proper location of it by running:</p> <pre><code>mysqladmin variables </code></pre> <p>OR</p> <pre><code>mysqld --verbose --help | grep ^socket </code></pre>
16,773,227
0
<p>In the DevCenter, you have to type the description and upload the screenshots for every language individually. Just change the current language on the list, then upload your assets. It is a step of the submission process, it has nothing to do with the application itself.</p>
20,001,908
0
String reverse without to turn the numbers in c <pre><code>int main() { char str[1000],temp; int i,j=0; printf("String: "); gets(str); i=0; j=strlen(str)-1; while(i&lt;j) { temp=str[i]; str[i]=str[j]; str[j]=temp; i++; j--; } printf("\n"); printf("%s",str); return 0; } </code></pre> <p>I want to change the rota </p> <p><strong>- In: 15 15 15 15 15 0 0<br> - Out: 0 0 51 51 51 51 51 but i want : 0 0 15 15 15 15 15</strong></p>
33,731,549
1
Python urllib2 read return different results for a ftp request, why? <p>I ran into some werid behavior, these two functions echo different sizes always. The first one echoes certain and right result, while the second one echoes random wrong results, is there anyone who knows why? I am using Python 2.7.10.</p> <pre><code>import urllib2 url = 'ftp://ftp.ripe.net/pub/stats/ripencc/delegated-ripencc-extended-latest' def one(): response = urllib2.urlopen(url) data = response.read() print len(data) def two(): print len(urllib2.urlopen(url).read()) one() two() </code></pre>
32,365,886
0
<p>Both <code>call</code> and <code>Popen</code> provide means of accessing the output of your command:</p> <ul> <li>With <code>Popen</code> you can use <code>communicate</code> or provide a file descriptor or file object to the <code>stdout=...</code> parameter.</li> <li>With <code>call</code> your only option is to pass a file descriptor or a file object to the <code>stdout=...</code> parameter (you can not use <code>communicate</code> with this one).</li> </ul> <p>Now, the reason why <code>stdout=PIPE</code> is insecure when used with <code>call</code> is because <code>call</code> doesn't return until the subprocess has finished, this means all the output would have to reside in memory until that moment, and if the amount of output is too much then that would fill the OS pipes' buffer.</p> <p>The references where you can validate the above information are the following:</p> <ol> <li>According to <a href="https://docs.python.org/2/library/subprocess.html#subprocess.call" rel="nofollow">this</a> the parameters for both <code>call</code> and <code>Popen</code> are the same:</li> </ol> <blockquote> <p>The arguments shown above are merely the most common ones, described below in Frequently Used Arguments (hence the slightly odd notation in the abbreviated signature). The full function signature is the same as that of the Popen constructor - this functions passes all supplied arguments directly through to that interface.</p> </blockquote> <ol start="2"> <li>According to <a href="https://docs.python.org/2/library/subprocess.html#subprocess.Popen" rel="nofollow">this</a> the possible values for the <code>stdout</code> parameter are:</li> </ol> <blockquote> <p>Valid values are PIPE, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created</p> </blockquote>
20,158,550
0
<p>You might look into using a modal for videos instead of the router if you want to overlay it on top of multiple states. If you stick with using the router, you might want to define videos as a child state of both home and portfolio instead of defining three states at the same level.</p>
22,443,545
0
Running batch file at Windows 7 UNLOCK <p>I have a very simple .bat file. It only has one line:</p> <pre><code>powercfg -h off </code></pre> <p>What this does is turn off the computer's ability to hibernate. It works fine when I double click the file. I can confirm this by going into the command prompt and typing "powercfg /a", which shows me that hibernate is indeed off. The problem is that this batch file doesn't seem to be running at logon even though it's in my Startup folder.</p> <p>I've tested it by turning hibernate on using the command prompt ("powercfg -h on") and then actually putting my computer into hibernation. Then I turn it back on and log in to Windows. But when I open a command prompt and type "powercfg /a" it shows me that hibernate is still on. It seems the batch file doesn't run at logon even though it is in my Startup folder.</p> <p>I've also tried making it run from a task scheduled to run at logon, but that didn't work either.</p>
5,144,902
0
<p>No -- the initialization syntax <em>only</em> works for initialization, not assignment, so it <em>must</em> be part of the array definition, not afterwards. Afterwards, what you'd have would be assigning an array instead of truly initializing it, and C does not support array assignment.</p>
18,636,373
0
Dropdownlist On Second Choose First Selected wont Display:none; <p>JS</p> <pre><code>function getData(dropdown) { var value = dropdown.options[dropdown.selectedIndex].value; if (value == 'emlak'){ document.getElementById("emlak").style.display = "block"; } if(value == 'vasita'){ document.getElementById("vasita").style.display = "block"; } } </code></pre> <p>HTML</p> <pre><code>&lt;select name="kategori" onChange="getData(this);"&gt; &lt;option value="hat" onClick=""&gt;Hat&lt;/option&gt; &lt;option value="emlak"&gt;Shirt&lt;/option&gt; &lt;option value="vasita"&gt;Pants&lt;/option&gt; &lt;/select&gt; &lt;select id="emlak" name="currentList" onChange=";" style="display:none;"&gt; &lt;option value="hat"&gt;Hat&lt;/option&gt; &lt;option value="emlak"&gt;Shirt&lt;/option&gt; &lt;option value="pants"&gt;Pants&lt;/option&gt; &lt;/select&gt; &lt;select id="vasita" name="currentList" onChange="" style="display:none;"&gt; &lt;option value="hat"&gt;Otomobil&lt;/option&gt; &lt;option value="emlak"&gt;Shirt&lt;/option&gt; &lt;option value="pants"&gt;Pants&lt;/option&gt; &lt;/select&gt; </code></pre> <blockquote> <p>When I Choose a Option second time first selected option wont display:none; it should show just one select</p> </blockquote>
37,190,793
0
Iterate array non-sequentially <p>I am working with an array of objects (tweets) and I only want to iterate over a certain number of those objects on each page load. Where the last count stopped iterating will be saved and started there again on the next page load. This is where I'm stuck.</p> <pre><code>var obj1 = [{ "name": "trai" }, { "name": "beth" }, { "name": "taylor" }, { "name": "trace" }, { "name": "dad" }, { "name": "elaine" }]; var i = 5; //last index. will be updated and retrieved in browser storage var num = 2; //number to iterate for (var count = 0; count &lt; num; count++) { $('body').append('&lt;div&gt;' + obj1[i].name + '&lt;/div&gt;'); if (i &gt;= obj1.length) { i = 0; } else {i++;} } </code></pre>
5,271,632
0
<p>I have idea of how to do it, i think it will be helpful to you , but never implemented like this. First you have to go with custom table . For that table you can give all the contact names from your addressbook. you can use <a href="http://developer.apple.com/library/mac/#documentation/userexperience/Reference/AddressBook/Classes/ABAddressBook_Class/Reference/Reference.html" rel="nofollow">http://developer.apple.com/library/mac/#documentation/userexperience/Reference/AddressBook/Classes/ABAddressBook_Class/Reference/Reference.html</a></p> <p>just go through it you can understand .</p> <p>you have to use these methods. 1) - (NSArray *)people you will get all people records into returned array. each record will have unique id , you have to retrieve it</p> <p>ABRecord rec = [returnedArray objectAtIndex:0];</p> <p>NSString *pid = rec.uniqueId </p> <p>-(NSString *) uniqueId ( this is ABRecord property method )</p> <p>once you got it you can retireve from your array what you want by using that recordid/ unique id .</p>
15,051,526
0
<p>You do not pass parameters to scripts, you pass parameters to functions.</p> <p>You will need to change your script so that it doesn't actually do anything until the functions therein are <em>invoked</em>, and pass the parameters at that point.</p> <p>Your problem then becomes just one of figuring out when the script has completed loading, which can be done by adding a <code>.onload</code> handler to the <code>&lt;script&gt;</code> element object.</p>
2,510,935
0
<p>The smallest builtin hash I am aware of is md5</p> <pre><code>&gt;&gt;&gt; import hashlib &gt;&gt;&gt; hashlib.md5("hello worlds").digest().encode("base64") 'uWuHitcvVnCdu1Yo4c6hjQ==\n' </code></pre> <p>Low collision and short are somewhat mutually exclusive due to the <a href="http://en.wikipedia.org/wiki/Birthday_problem" rel="nofollow noreferrer">birthday paradox</a></p> <p>To make it urlsafe you need to use the function from the base64 module</p> <pre><code>&gt;&gt;&gt; import base64 &gt;&gt;&gt; base64.urlsafe_b64encode(hashlib.md5("hello world").digest()) 'XrY7u-Ae7tCTyyK7j1rNww==' </code></pre> <p>However there should be no problem storing the 16 byte md5 digest in the database in binary form.</p> <pre><code>&gt;&gt;&gt; md5bytes=hashlib.md5("hello world").digest() &gt;&gt;&gt; len(md5bytes) 16 &gt;&gt;&gt; urllib.quote_plus(md5bytes) '%5E%B6%3B%BB%E0%1E%EE%D0%93%CB%22%BB%8FZ%CD%C3' &gt;&gt;&gt; base64.urlsafe_b64encode(md5bytes) 'XrY7u-Ae7tCTyyK7j1rNww==' </code></pre> <p>You can choose either the <code>quote_plus</code> or the <code>urlsafe_b64encode</code> for your url, then decode with the corresponding function <code>unquote_plus</code> or <code>urlsafe_b64decode</code> before you look them up in the database.</p>
34,066,153
0
How to exclude unit-tests with TestCaseFilter in TFS Build which do contain a namespace <p>I want to exclude all tests which include <strong>Abc</strong> in the namespace.</p> <p>What is the correct pattern to use ?</p> <pre><code>!(FullyQualifiedName~.Abc.) </code></pre> <p>is not valid ?</p> <p>I used this web-page as reference : <a href="http://blogs.msdn.com/b/visualstudioalm/archive/2012/09/26/running-selective-unit-tests-in-vs-2012-using-testcasefilter.aspx" rel="nofollow">http://blogs.msdn.com/b/visualstudioalm/archive/2012/09/26/running-selective-unit-tests-in-vs-2012-using-testcasefilter.aspx</a></p>
33,096,280
0
<p>I think you should use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Node/replaceChild" rel="nofollow">Node.replaceChild</a>.</p> <pre class="lang-js prettyprint-override"><code>var curImg = opener.document.getElementById("materiallogo"); var newImg = document.createElement("img"); // give it an id attribute newImg.setAttribute("id", curImg.id); var parentDiv = curImg.parentNode; // replace existing node curImg with the new img element newImg parentDiv.replaceChild(curImg, newImg); newImg.src = '' // &lt;-------------- HERE PUT NEW PATH FOR IMG </code></pre>
38,014,617
0
batch script for loop teminates the batch <p>I'm trying to use for loop and read contents of a file line by line the file is an xml and contains urls and paths delimited by <code>&lt;&gt;</code> </p> <p>I am using the following code</p> <pre><code>set @LOGFILE=F:\nircmd\hosts.xml :loop for /F "tokens=2-3 delims=&lt;&gt;" %%a in (%LOGFILE%)do echo "it works" timeout /t goto :loop </code></pre> <p>the batch is terminating as soon as it encounters the for loop</p> <p>i have already tried to pause or timeout the batch but nothing seems to work batch is anyway terminating</p> <p>what to do?</p>
40,766,199
0
<p>Please keep in mind that you are declaring an absolute path...</p> <p>Starting with "/" returns to the root directory and starts there.</p> <p>This can be useful</p> <p><a href="https://css-tricks.com/quick-reminder-about-file-paths/" rel="nofollow noreferrer">https://css-tricks.com/quick-reminder-about-file-paths/</a></p>
36,130,431
0
<p>There is a very minor difference (effectively negligible, we're talking micro-optimization here), since the string should be stored in a local variable which takes that extra bit of memory on the stack frame of the corresponding method. Whereas the constants are actually stored in the constant pool and shared. With the likely optimizations of the JVM based on the number of invocations, it won't make a difference.</p> <p>Note that the bytecode would be the same if the variables were <code>final</code> or effectively <code>final</code> (assigned only once), since in this case they are treated as constants.</p>
1,523,119
0
<p>I am personally using Orbited, both because I am already using Twisted and because it seems mature. Twisted has a nice long history with many users, especially in comparison to Diesel and Tornado. Orbited is indeed built on Twisted.</p> <p>There is a good blog entry covering an <a href="http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio/" rel="nofollow noreferrer">end-to-end orbit solution here</a>. It sends data from a python script to a STOMP server (MorbidQ) to Orbited to Javascript - rendering that data as a graph.</p> <p>Tornado seems pretty new to the scene, I couldn't find twisted-comet and I hadn't heard of diesel. I particularly like the way that Orbited can forward any sort of tcp/ip but makes it easy to hook javascript clients in with a message passing STOMP backend.</p>
17,451,594
0
<p>The caret <code>^</code> is an operator used to introduce a block variable or a block expression in the clang Block extension:</p> <p><a href="http://clang.llvm.org/docs/BlockLanguageSpec.html" rel="nofollow">http://clang.llvm.org/docs/BlockLanguageSpec.html</a></p>
32,699,309
0
<p>When I use Quartus II ver 15.0, assiging "don't care" to output is OK and generated area-efficient circuit.</p> <p>For example, if I synthesize this code, that :</p> <pre><code>module test1 ( input wire a, input wire b, output reg [3:0] s ); always @* begin case ({a,b}) 2'b00 : s = 4'b1000; 2'b01 : s = 4'b0100; 2'b10 : s = 4'b0010; 2'b11 : s = 4'b0001; default: s = 4'b0000; endcase end endmodule </code></pre> <p>Quartus generated a circuit which uses <strong>5 Logic Elements</strong>. <a href="https://i.stack.imgur.com/CaJOR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CaJOR.png" alt="not optimized"></a></p> <p>However, If I use "don't care" assignment in the code above:</p> <pre><code>module test1 ( input wire a, input wire b, output reg [3:0] s ); always @* begin case ({a,b}) 2'b00 : s = 4'b1xxx; 2'b01 : s = 4'b01xx; 2'b10 : s = 4'b001x; 2'b11 : s = 4'b0001; default: s = 4'b0000; endcase end endmodule </code></pre> <p>a circuit which uses only <strong>2 Logic Elements</strong> is generated. It's interesting that although the total logic elements are less used, the generated circuit seems to be more complex. <a href="https://i.stack.imgur.com/lBuCY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lBuCY.png" alt="optimized"></a></p> <p>I was wondering whether the generated circuit is correct. So I ran Quartus's simulator with the circuit which uses "don't care". The result is the simplest circuit we want. <a href="https://i.stack.imgur.com/uLD1U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uLD1U.png" alt="enter image description here"></a></p>
13,204,142
0
<p>Since the internal pointer of the stream is at index 4 after you write the data, you need to <a href="http://php.net/fseek" rel="nofollow"><code>fseek</code></a> back to the beginning of your stream:</p> <pre><code>// fwrite fseek($memory, 0); // same as rewind($memory); // fread </code></pre>
27,407,267
0
New to JavaScript - Need help creating multiple objects with data from a form <p>I just started learning JavaScript and have been stuck on an assignment for about a week now, I've tried several solutions but every time I add something I break something else. The assignment is to create a form (which I have completed). The form is to be used to enter data for a new favorite item, when each item is entered it should be displayed on the page and in the console log, as additional items are entered they are added to the list and all items are displayed - </p> <p>Ex - Favorites are: URL:<a href="http://oriellyschool.com" rel="nofollow">http://oriellyschool.com</a>, title: O'Reilly School, comment: help, tags: school, learning, URL: <a href="http://google.com" rel="nofollow">http://google.com</a>, title: Google, comment: Use google to find info on JavaScript, tags: search, finding info faves:html:133</p> <p>The specific instructions are to use objects for both all favorites and each new favorite item. The functionality to display the favorites (in console and on page) should be included in the methods for the objects.</p> <p>I am able to get the data from the form into a function and had the function to create the favorites working yesterday, not sure what happened this morning.</p> <p>If someone could please take a look at this and tell me if I am at least heading in the right direction I would appreciate it. I'm just going in circles now. (I have tons of console.log statements in the code so I could try to see what it was doing). Thanks!</p> <p>Code:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>// Function to create entries for favorite items from web form function FaveoriteEntry(url, title, comment, tags) { console.log("In Fave Function"); this.url = url; console.log(this.url); this.title = title; console.log(this.title); this.comment = comment; console.log(this.comment); this.tags = tags; console.log(this.tags); console.log("Have all items"); } //Function to retrieve data from web form and send to function to creat favorite //object. function addFavorite() { var myFavorites = []; console.log("In Function"); var furl = getFavorites.formURL.value; var ftitle = getFavorites.formTitle.value; var fcomment = getFavorites.formComment.value; var ftags = getFavorites.formTags.value; this.clear = getFavorites.reset(); console.log("Entry: " + furl + " " + ftitle + " " + fcomment + " " + ftags); this.createFavorites = function(url, title, comment, tags) { console.log("In Fave Function"); this.url = url; console.log(this.url); this.title = title; console.log(this.title); this.comment = comment; console.log(this.comment); this.tags = tags; console.log(this.tags); console.log("Have all items"); this.string = (this.url + "," + this.title + "," + this.comment + "," + this.tags); myFavorites.push(this.string); var addfavorite = new this.createFavorites(furl, ftitle, fcomment, ftags); console.log(myFavorites); } }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>body { font-family: Helvetica, Ariel, sans-serif; } form { display: table; border-spacing: 5px; } form p { display: table-row; } form label { display: table-cell; text-align: right; } form input { display: table-cell; } span.comment { font-size: 80%; color: #777777; } span.tags { font-size: 80%; color: rgb(48, 99, 170); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Advanced JavaScript Project: Favorites and Tags&lt;/title&gt; &lt;meta charset="utf-8"&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="getFavorites" onsubmit="return favorites(this)"&gt; &lt;h1&gt;Tag and save your favorites&lt;/h1&gt; &lt;text&gt;&lt;/text&gt; &lt;fieldset&gt; &lt;legend&gt;Add a new favorite:&lt;/legend&gt; &lt;p&gt; &lt;label&gt;URL:&lt;/label&gt; &lt;input type="text" name="formURL" value="" /&gt; &lt;p&gt; &lt;label&gt;Title:&lt;/label&gt; &lt;input type="text" name="formTitle" value="" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Comment:&lt;/label&gt; &lt;input type="text" name="formComment" value="" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Tags:&lt;/label&gt; &lt;input type="text" name="formTags" value="" /&gt; &lt;/p&gt; &lt;input type="button" name="button" value="Add Link" onClick="addFavorite(this.form)" /&gt; &lt;/fieldset&gt; &lt;u1 id="faves-lists"&gt; &lt;h1&gt; List of Favorites&lt;/h1&gt; &lt;li&gt;Test -&lt;/li&gt; &lt;p&gt; &lt;span class="comments"&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;span class="tags"&gt;&lt;/span&gt; &lt;/p&gt; &lt;/u1&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
3,296,262
0
<p>This MSDN article comparing the two is for SQL Server 2000: <a href="http://msdn.microsoft.com/en-us/library/aa224827(SQL.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa224827(SQL.80).aspx</a></p> <p>For most purposes, there's no difference - the constraint is implemented as an index under the covers. And though there's the ability to disable the constraint, it doesn't actually work in SQL Server.</p> <p>It only matters if you want to tweak things like FILLFACTOR, etc for which way you want to implement the unique constraint.</p> <p>SQL Server 2008+ added <code>INCLUDE</code> to provide more efficient covering indexes. Filtered indexes = unique constraint over a subset of rows/ignore multiple null etc.</p>
25,038,975
0
<p>You have forgotten to close the <code>$(document).ready</code> function</p>
17,440,148
0
<p>Let's simplify:</p> <pre><code>interface IAnimal { ... } interface ICage&lt;T&gt; where T : IAnimal { void Enclose(T animal); } class Tiger : IAnimal { ... } class Fish : IAnimal { ... } class Cage&lt;T&gt; : ICage&lt;T&gt; where T : IAnimal { ... } ICage&lt;IAnimal&gt; cage = new Cage&lt;Tiger&gt;(); </code></pre> <p>Your question is: why is the last line illegal?</p> <p>Now that I have rewritten the code to simplify it, it should be clear. <strong>An <code>ICage&lt;IAnimal&gt;</code> is a cage into which you can place <em>any animal</em>, but a <code>Cage&lt;Tiger&gt;</code> can <em>only hold tigers</em>, so this must be illegal.</strong> </p> <p>If it were not illegal then you could do this:</p> <pre><code>cage.Enclose(new Fish()); </code></pre> <p>And hey, you just put a fish into a tiger cage.</p> <p>The type system does not permit that conversion because doing so would violate the rule that the capabilities of the source type must not be <em>less</em> than the capabilities of the target type. (This is a form of the famous "Liskov substitution principle".)</p> <p>More specifically, I would say that you are abusing generics. The fact that you've made type relationships that are too complicated for you to analyze yourself is evidence that you ought to simplify the whole thing; if you're not keeping all the type relationships straight and you wrote the thing then your users surely will not be able to keep it straight either.</p>
4,687,866
0
<p>You can either accept the customParent as a argument in the constructor, or better yet, the <code>FindBox</code> form should take a <code>Action&lt;string&gt;</code> that it will call once the find button is pressed.</p> <h2>Example:</h2> <pre><code>class MainForm : Form { public void FindNext(string find) { // Do stuff } public void OpenFindWindow() { FindBox find = new FindBox(this.FindNext); find.Show(); } } class FindBox : Form { private Action&lt;string&gt; callback; public FindBox(Action&lt;string&gt; callback) { this.callback = callback; } public void FindButtonPressed() { callback(textBox1.text); } } </code></pre>
35,500,494
0
<p>Every object instance is also an instance of it's parent. You make all properties private in the parent and offer secured access through public methods. All public methods will be available to child classes as if they were their own, without access to private properties.</p> <pre><code>class foo { private $db; public function dbSelect() { return $this-&gt;db-&gt;select();// Example } } class bar extends foo { public function loadTemplate($file) { require($file); $selected = $this-&gt;dbSelect(); } } </code></pre>
36,811,687
0
Reason of Non-singleton dimensions mismatch in data under PCA <p>During pca analysis using built in pca function in matlab, I faced the following error. Data is actually a feature vector obtained from 30 MR images. </p> <pre><code>&gt;&gt; size(data) ans = 30 281 389 104 [coeff score varience] = pca(data); Error using bsxfun Non-singleton dimensions of the two input arrays must match each other. Error in pca&gt;localSVD (line 468) x = bsxfun(@times, x, PhiSqrt); Error in pca (line 341) [U,sigma, coeff, wasNaN] = localSVD(x, n,... </code></pre> <p>Would you let me know any solution? </p>
5,135,504
0
<p>Japanese_90 appears to be the new collation name.</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb330962%28v=sql.90%29.aspx#intlftrql2005_topic24" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb330962%28v=sql.90%29.aspx#intlftrql2005_topic24</a></p> <p>Note, you might want to consider the _KS suffix if you want to consider Hirigana/Katakana whilst sorting. Like Marc_S says, you will also want to ensure your column datatype is nvarchar</p>
30,419,579
0
<p>I would suggest doing the whole thing in awk, rather than using a shell loop:</p> <pre><code>awk '{for (i=1; i&lt;=12; ++i) printf "%d%s", $1+i, (i&lt;12?FS:RS)}' "$f1" &gt; output </code></pre> <p>This loop runs for each line of the file and outputs all of the columns, saving the need to use another tool such as <code>paste</code>. The ternary operator is used to output a space (<code>FS</code>) between each column and a newline (<code>RS</code>) at the end of the line.</p> <hr> <p>For the second part of your question, you can still do most of the work in awk.</p> <pre><code>declare -A companies companies=( [company1]=10 [company2]=25 [company3]=50 ) for c in "${companies[@]}"; do awk -v bonus="${companies[c]}" '{for (i=1; i&lt;=12; ++i) printf "%d%s", $i+(i==1||i==5||i==9?bonus:5), (i&lt;12?FS:RS)}' "$f1" &gt; "$c.txt" done </code></pre> <p>I have created an associative array containing each company name and their bonus. The loop goes through each company in the array, passing the bonus to awk as a variable (note that I'm doing this using <code>-v</code> rather than using string concatenation). The loop goes from 1 to 12, adding the bonus for months 1, 5 and 9, or 5 otherwise. The name of the company (the key of the shell array) is used for the output file.</p>
2,646,694
0
Running job in the background from Perl WITHOUT waiting for return <h3>The Disclaimer</h3> <p>First of all, I know this question (or close variations) have been asked a thousand times. I really spent a few hours looking in the obvious and the not-so-obvious places, but there may be something small I'm missing.</p> <h3>The Context</h3> <p>Let me define the problem more clearly: I'm writing a newsletter app in which I want the actual sending process to be async. As in, user clicks "send", request returns immediately and then they can check the progress in a specific page (via AJAX, for example). It's written in your traditional LAMP stack.</p> <p>In the particular host I'm using, PHP's exec() and system() are disabled for security reasons, but Perl's system functions (exec, system and backticks) aren't. So my <del>workaround</del> solution was to create a "trigger" script in Perl that calls the actual sender via the PHP CLI, and redirects to the progress page.</p> <h3>Where I'm Stuck</h3> <p>The very line the calls the sender is, as of now:</p> <pre><code>system("php -q sender.php &amp;"); </code></pre> <p>Problem being, it's not returning immediately, but waiting for the script to finish. I want it to run in the background and have the system call itself return right away. I also tried running a similar script in my Linux terminal, and in fact the prompt doesn't show until after the script has finished, even though my test output doesn't run, indicating it's really running in the background.</p> <h3>What I already tried</h3> <ul> <li>Perl's exec() function - same result of system().</li> <li>Changing the command to: "php -q sender.php | at now"), hoping that the "at" daemon would return and that the PHP process itself wouldn't be attached to Perl.</li> <li>Executing the command 'indirectly': "/bin/sh -c 'php -q sender.php &amp;'" - still waits until sender.php is finished sending.</li> <li>fork()'ing the process and executing the system call in the child (hopefully detached process) - same result as above</li> </ul> <h3>My test environment</h3> <p>Just to be sure that I'm not missing anything obvious, I created a sleeper.php script which just sleeps five seconds before exiting. And a test.cgi script that is like this, verbatim:</p> <pre><code>#!/usr/local/bin/perl system("php sleeper.php &amp;"); print "Content-type: text/html\n\ndone"; </code></pre> <h3>What should I try now?</h3>
30,023,417
0
animated GIFs with Twitter Player card not working? <p>I am trying to set Up Animated GIF with player card. but when I test my player card <a href="https://cards-dev.twitter.com/validator" rel="nofollow">https://cards-dev.twitter.com/validator</a> it dosen't show animated GIF.</p> <p>Here is my meta code for player card</p> <pre><code>&lt;meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/&gt; &lt;meta name="twitter:card" value="player"&gt; &lt;meta name="twitter:site" value="@uncleLaravel"&gt; &lt;meta name="twitter:title" value="domain.com"&gt; &lt;meta name="twitter:description" value="sample"&gt; &lt;meta name="twitter:image" value="http://domain.com/img/sample.gif"&gt; &lt;meta name="twitter:player" value="http://www.domain.com/container.html"&gt; &lt;meta name="twitter:player:width" value="320"&gt; &lt;meta name="twitter:player:height" value="320"&gt; &lt;meta name="twitter:domain" value="domain.com"&gt; </code></pre> <p>container.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;style&gt; html, body{ margin: 0; padding: 0; overflow: hidden; } img{ border: 0; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;img id="gif" src="/sample.gif" width="100%"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Is anything wrong here?</p>
40,664,995
0
<pre><code>if(hours * 100 + minutes &lt; mynum){ System.exit(0); } </code></pre>
23,279,957
0
<p>Data validation in javascript is always complicate, and with regular expression is hard to take care about differnt months lenght, leap years and cultures. </p> <p>You could make all simplier by introducing <a href="http://momentjs.com/" rel="nofollow">moment.js</a>. With this tiny library you can validate date without worry abot dates, months length, leap years.</p>
23,531,386
0
How can I update my DataGrid when a user makes a selection in the ComboBox? <p>Here's my ComboBox: </p> <pre><code>&lt;ComboBox HorizontalAlignment="Left" Margin="125,110,0,0" VerticalAlignment="Top" Width="120" DisplayMemberPath="lot_number" ItemsSource="{Binding LotNumList}" RenderTransformOrigin="0.583,2" Height="18" /&gt; </code></pre> <p>Here's a DataGrid that I want to update the values to:</p> <pre><code>&lt;DataGrid HorizontalAlignment="Left" Margin="228,177,0,0" VerticalAlignment="Top" Height="292" Width="617" ItemsSource="{Binding ComponentsList}" AutoGenerateColumns="False"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="Component" Binding="{Binding component}" CanUserResize="False"/&gt; &lt;DataGridTextColumn Header="Control" Binding="{Binding aControl}" CanUserResize="False"/&gt; &lt;DataGridTextColumn Header="Reference" Binding="{Binding cal_ref}" CanUserResize="False" /&gt; &lt;DataGridTextColumn Header="Family" Binding="{Binding family}" CanUserResize="False"/&gt; &lt;DataGridTextColumn Header="Id" Binding="{Binding componentId }" CanUserResize="False"/&gt; &lt;/DataGrid.Columns&gt; </code></pre> <p>Here's how I'm grabbing data from db to populate the ComboBox:</p> <pre><code>//Grabs the lot_number column from db that is distinct var lotNum = db.LotInformation.GroupBy(i =&gt; i.lot_number) .Select(group =&gt; group.FirstOrDefault()); //Loops through the lot numbers column in db and converts to list foreach (var item in lotNum) { Console.WriteLine(item.lot_number); } LotNumList = lotNum.ToList(); </code></pre> <p>Now I am wondering how do I connect my ComboBox so that when I select a value in the ComboBox... then the DataGrid gets updated based on the value of the selection in the ComboBox. </p> <p>I tried something like this: </p> <pre><code>private void UpdateExistLotList(string LotNumber) { using (var db = new DDataContext()) { //Grabs the lot_number column from db that is distinct var ExistLot = db.LotInformation.First(l =&gt; l.lot_number.Equals(LotNumber)); } } </code></pre> <p>Calling the method in my lot number list property but it doesn't get called or just doesn't work. I'm not sure what I'm doing wrong. Any ideas?</p> <p>EDIT: </p> <p>Properties: </p> <pre><code>public List&lt;Components&gt; ComponentsList { get { return components; } set { components = value; RaisePropertyChanged("ComponentsList"); } } public string LotNumber { get { return lotNumber; } set { lotNumber = value; RaisePropertyChanged("LotNumber"); } } public List&lt;LotInformation&gt; LotNumList { get { return lotNumList; } set { lotNumList = value; RaisePropertyChanged("LotNumList"); UpdateExistLotList(LotNumber); } } </code></pre> <p>Here's where LotNumber is declared (I take the deserialized value of lot number from memory and assign it to LotNumber): </p> <pre><code>public void DeSerializationXML(string filePath) { XmlRootAttribute xRoot = new XmlRootAttribute(); xRoot.ElementName = "lot_information"; xRoot.IsNullable = false; // Create an instance of lotinformation class. var lot = new LotInformation(); // Create an instance of stream writer. TextReader txtReader = new StreamReader(filePath); // Create and instance of XmlSerializer class. XmlSerializer xmlSerializer = new XmlSerializer(typeof(LotInformation), xRoot); // DeSerialize from the StreamReader lot = (LotInformation)xmlSerializer.Deserialize(txtReader); // Close the stream reader txtReader.Close(); //Storing deserialized strings to db using (var db = new DMIDataContext()) { LotInformation newLot = new LotInformation(); if (newLot != null) { newLot.Id = lot.Id; newLot.lot_number = lot.lot_number; newLot.exp_date = lot.exp_date; LotNumber = newLot.lot_number; ExpirationDate = newLot.exp_date.ToString(); //Grabs the lot_number column from db that is distinct var lotNum = db.LotInformation.GroupBy(i =&gt; i.lot_number).Select(group =&gt; group.FirstOrDefault()); //Loops through the lot numbers column in db and converts to list foreach (var item in lotNum) { Console.WriteLine(item.lot_number); } LotNumList = lotNum.ToList(); foreach (Components comp in lot.Components) { newLot.Components.Add(comp); } ComponentsList = newLot.Components; foreach (Families fam in lot.Families) { newLot.Families.Add(fam); } FamiliesList = newLot.Families; try { db.LotInformation.Add(newLot); db.SaveChanges(); Console.WriteLine("successfully"); } catch { //TODO: Add a Dialog Here } } } </code></pre>
559,708
0
<p>Django uses a cache. The RDBMS uses a cache. Don't prematurely optimize the queries. </p> <p>You can play with bulk queries in your view function instead of one-at-a-time queries in your template. </p> <pre><code>@render_to('home/main.html') def login(request): # Query all clients clients = Client.objects.all() # Assemble an in-memory table of pets pets = collections.defaultdict(list) for p in Pet.objects.all(): pets[pet.client].append(p) # Create clients and pets tuples clientsPetTuples = [ (c,pets[c]) for c in clients ] return {'clientPets': clientsPetTuples} </code></pre> <p>However, you don't seem to have any evidence that your template is the slowest part of your application.</p> <p>Further, this trades off giant memory use against SQL use. Until you have measurements that prove that your template queries are actually slow, you shouldn't be over thinking the SQL.</p> <p>Don't worry about the SQL until you have evidence.</p>
21,990,399
0
<p>If you do not know the default date format of your database, you should <a href="http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm" rel="nofollow">use a mask</a> and the to_date() function, like:</p> <pre><code>insert into emp_company values ('ANIL','ACC',1500.00,to_date('01-05-89', 'DD-MM-RR')); </code></pre> <p>Also, I'm not sure this is always the case, but I've never encountered an Oracle database that did not use the 'DD-MON-YY' as the default date format (so '01-MAY-89').</p>
40,181,754
0
<p>As c# knows the unicode values you can use</p> <pre><code>letter=(char)randomNumber; </code></pre> <p>although random a number between 97 and 122 as use did will random a lower case letter. If you want to random an uppercase letter like you quoted take a look in the unicode table for upper case unicode values. <a href="http://unicode-table.com/en/" rel="nofollow">http://unicode-table.com/en/</a></p>
3,946,573
0
<p>You'll get warnings if you access a class variable before it's been created if you're running in a strict mode, but otherwise you can define them anywhere - on that score PHP doesn't care at all if you do it first thing in the class or deep within the bowels of a method</p>
25,157,694
0
<p><a href="http://www.cplusplus.com/forum/general/33653/">http://www.cplusplus.com/forum/general/33653/</a></p> <p>You can add the "\" anywhere in the code and newline will be ignored.</p> <p>As a better reference the 2.2 paragraph of the standard:</p> <blockquote> <p>Each instance of a backslash character () immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. If, as a result, a character sequence that matches the syntax of a universal-character-name is produced, the behavior is undefined. A source file that is not empty and that does not end in a new-line character, or that ends in a new-line character immediately preceded by a backslash character before any such splicing takes place, shall be processed as if an additional new-line character were appended to the file.</p> </blockquote> <p>This is not clear regarding what happens if the last character in the file is a backslash. In such a case, presumably the result of adding the newline should not be a line splice but rather a backslash preprocessing-token (that will be diagnosed as an invalid token in phase 7), but that should be spelled out.</p>
37,979,199
0
<p>There might be a simpler way, but this combo of dplyr and tidyr works:</p> <pre><code>library(dplyr) library(tidyr) data3 &lt;- data1 %&gt;% group_by(tag) %&gt;% mutate(obstag = paste0("Obs", seq_along(Obs)), # Add markers eftag = paste0("Ef", seq_along(Effect)), altag = paste0("A", seq_along(Allele))) %&gt;% spread(altag, Allele) %&gt;% # Switch from rows to columns spread(obstag, Obs) %&gt;% spread(eftag, Effect) %&gt;% summarise_each(funs(unique(na.omit(.))), 1:Ef3) %&gt;% # Collapse into one row per tag mutate(Allele = paste(A1, A2, A3, sep = "/")) %&gt;% # paste alleles together select(-A1, -A2, -A3, -tag) # drop unwanted columns </code></pre>
9,559,557
0
<p>Using <code>invalidHandler</code> is one way to do this, but if you use the <code>errorContainer</code> option, jQuery validate will take care of hiding and showing the message for you. For example:</p> <p><strong>Html:</strong></p> <pre><code>&lt;form id="test"&gt; &lt;label for="name"&gt;Name&lt;/label&gt; &lt;input id="name" type="text" name="name" class="required"/&gt; &lt;label for="age"&gt;Age&lt;/label&gt; &lt;input id="age" type="text" name="age" class="required"/&gt; &lt;input type="submit" /&gt; &lt;/form&gt; &lt;div id="invalid"&gt;You have errors the on page&lt;/div&gt;​ </code></pre> <p><strong>CSS</strong></p> <pre><code>#invalid { display: none; } </code></pre> <p><strong>JavaScript:</strong></p> <pre><code>$("#test").validate({ errorContainer: "#invalid" }); </code></pre> <p><strong>Example:</strong> <a href="http://jsfiddle.net/andrewwhitaker/deArQ/" rel="nofollow">http://jsfiddle.net/andrewwhitaker/deArQ/</a></p>
12,629,831
0
<p>Answer from author of the library. Example linked <a href="https://github.com/mikejarema/em-whois/blob/master/examples/async_parallel_whois.rb" rel="nofollow">here</a>.</p> <pre><code>$: &lt;&lt; File.dirname(__FILE__) + '/../lib' require 'em-whois' require 'atomic' # Asynchronous, parallel multi-domain WHOIS lookup domains = ARGV.empty? ? ["github.com", "google.com", "bing.com", "yahoo.com", "mikejarema.com"] : ARGV whois = {} EM.synchrony do # Progress indicator EM.add_periodic_timer(0.1) do STDERR.print "." end # Exit condition EM.add_periodic_timer(0.1) do if domains.size == whois.keys.size puts "" whois.each do |k,v| if v.properties[:available?] puts "#{k}: available" else puts "#{k}: taken, expires #{v.properties[:expires_on]}" end end EM.stop end end # Async WHOIS lookup - fire and forget via parallel fibers domains.each do |i| Fiber.new do whois[i] = Whois.whois(i) end.resume end end </code></pre>
12,654,110
0
Can not seem to change SSL cert on httpd server <p>I am trying to setup SSL using httpd server. At I created self cert and it worked fine, of course displaying brocker lock in browsers.</p> <p>Now I got proper entrust cert but I can not seem to replace the old one. browser shows broken lock and when i open certificate info box it still does not show company name or proper server name, even though it has been changed.</p> <p>how do you properly replace SSL certificate?</p>
4,510,761
0
<p>you can use regular expression </p> <pre><code>import re y = "xdtwkeltjwlkejt7wthwk89lk" s = re.search("\d",y).start() </code></pre>
12,721,062
0
<p>First of all, you've got <code>UIViewContentModeScaleAspectFit</code> in your code, not <code>UIViewContentModeScaleToFill</code> as you've said. Post an original image, please.<br> Second, the 'change width of frame' part is useless, <code>imageView.size.width</code> is already set to <code>200</code>. Scaling modes don't change view's frame at all, they change the way it shows its content.</p> <p>I don't know what's the 'correct position' you are talking about, but try to make <code>imageView</code> fullscreen like this: </p> <pre><code>UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.contentMode = UIViewContentModeScaleToFill; imageView.frame = self.view.frame; </code></pre>
41,001,881
0
Bootstrap Datepicker doesn't return selected dates after changeDate event within Ember.js <p>I created an Ember.js component called <code>date-picker-multi.js</code> using the <a href="https://bootstrap-datepicker.readthedocs.io/en/latest/" rel="nofollow noreferrer">Bootstrap Datepicker</a> JavaScript plugin. I am trying to get the dates within both the input fields (from the date range) whenever the user selects a different date.</p> <p>As per the Bootstrap Datepicker component's <a href="https://bootstrap-datepicker.readthedocs.io/en/latest/events.html#changedate" rel="nofollow noreferrer">changeDate event</a>, I should be able to get both the dates by accessing <code>e.dates</code> however, when I do this, I get an array with just one item in it like this:</p> <pre><code>[Fri Dec 09 2016 00:00:00 GMT+0530 (IST)] </code></pre> <p>This is what my <code>date-picker-multi.js</code> component looks like:</p> <pre><code>import Ember from 'ember'; export default Ember.Component.extend({ tagName: 'div', maxViewMode: 1, autoclose: true, format: null, startDate: undefined, todayHighlight: true, datesDisabled: [], actualDates: null, // Store computer-friendly dates here didInsertElement() { this._super(...arguments); let self = this; // initiate jquery datepicker library let options = { maxViewMode: this.get('maxViewMode'), autoclose: this.get('autoclose'), todayHighlight: this.get('todayHighlight') }; if (this.get('format')) { options.format = this.get('format'); } if (this.get('startDate')) { options.startDate = this.get('startDate'); } if (this.get('datesDisabled') &amp;&amp; Ember.isArray(this.get('datesDisabled'))) { options.datesDisabled = this.get('datesDisabled'); } this.$().datepicker(options).on('changeDate', function(e) { console.log(e.dates); }); }, willDestroyElement: function() { //remove all event handlers on this component this.$().off(); } }); </code></pre> <p>Observe my <code>console.log(e.dates);</code> inside the <code>changeDate</code> event.</p> <p>This is how I am calling the component in my Handlebars file:</p> <pre><code>{{#date-picker-multi class="input-daterange input-group" id="datepicker" format='d MM' actualValues=data.dates}} {{input required="true" type="text" class="input-sm form-control date-icon" name="start" value=data.depart}} &lt;span class="input-group-addon"&gt;to&lt;/span&gt; {{input required="true" type="text" class="input-sm form-control date-icon" name="end" value=data.return}} {{/date-picker-multi}} </code></pre> <p>I can't figure out what the issue is. Does anyone know why this might be happening?</p>
5,827,126
0
<p>Are you sure it's an issue with imread? I'd be surprised if it is.</p> <p>See <a href="http://www.mathworks.com/help/toolbox/images/ref/medfilt2.html" rel="nofollow">this link about medfilt2</a> where it explains that "medfilt2 pads the image with 0s on the edges, so the median values for the points within [m n]/2 of the edges might appear distorted."</p> <p>EDIT: I tried to replicate your problem. This is an issue with <code>print</code> where it puts a white frame around the image after you save it. This functionality, <code>print</code> is made for printing plots. If you want to save the image, you should use <code>imwrite</code>.</p>
3,941,320
0
<p>If you try calling malloc from two separate threads (unless you have a thread-safe version, not guaranteed by C standard), bad things happen, because there's only one heap for two threads. Same for printf- the behaviour is undefined. That's what makes them in reality non-reentrant.</p>
2,291,633
0
<p>In <a href="http://www.atalasoft.com" rel="nofollow noreferrer">my company</a>'s toolkit, we implemented a technology we call <a href="http://www.atalasoft.com/products/dotimage/docs/RemoteInvoke.html" rel="nofollow noreferrer">remote invoke</a>. This consists of two parts - on the client side, there is a javascript method called RemoteInvoke() which takes a method name and an array of arguments to pass to the method. On the server side, you decorate a public method you would like to call with the attribute [RemoteInvokable]. RemoteInvoke matches signature as best as it can (type casting if needed) and then called the appropriate public method (if it found one).</p> <p>It's not for things as simple as click actions, but it if you need more complicated things, it will work just great.</p>
35,823,384
0
<p>Whats you did id the right way to do it all.</p> <p>Its described here as well: <a href="http://stackoverflow.com/questions/34634132/managing-two-ssh-keys/34634893#34634893">Managing two ssh keys</a></p> <p>Looks like you did not add the keys to your remote server.</p> <hr> <h2>Multiple SSH Keys settings for different github account:</h2> <p><a href="https://gist.github.com/jexchan/2351996" rel="nofollow">https://gist.github.com/jexchan/2351996</a></p> <hr> <h2><strong><em><code>create different public key</code></em></strong></h2> <p>create different ssh key according the article Mac Set-Up Git</p> <pre><code>$ ssh-keygen -t rsa -C "[email protected]" </code></pre> <p>for example, 2 keys created at:</p> <pre><code>~/.ssh/id_rsa_activehacker ~/.ssh/id_rsa_jexchan </code></pre> <h2><strong><em><code>Add these two keys to the ssh-agent:</code></em></strong></h2> <pre><code>$ ssh-add ~/.ssh/id_rsa_activehacker $ ssh-add ~/.ssh/id_rsa_jexchan you can delete all cached keys before $ ssh-add -D </code></pre> <h2><strong><em><code>check your keys</code></em></strong></h2> <pre><code>$ ssh-add -l </code></pre> <h2><strong><em><code>Modify the ssh config</code></em></strong></h2> <pre><code>$ cd ~/.ssh/ $ touch config $ subl -a config </code></pre> <h3><code>Add the keys to the config file:</code>***</h3> <pre><code>#activehacker account Host github.com-activehacker HostName github.com User git IdentityFile ~/.ssh/id_rsa_activehacker #jexchan account Host github.com-jexchan HostName github.com User git IdentityFile ~/.ssh/id_rsa_jexchan </code></pre> <h2><strong><em><code>Clone you repo and modify your Git config</code></em></strong></h2> <pre><code># clone your repo git clone [email protected]:activehacker/gfs.git gfs_jexchan cd gfs_jexchan and modify git config $ git config user.name "jexchan" $ git config user.email "[email protected]" $ git config user.name "activehacker" $ git config user.email "[email protected]" # or you can have global git config $ git config --global user.name "jexchan" git config --global user.email "[email protected]" </code></pre> <h2><strong><em><code>push your code</code></em></strong></h2> <pre><code>git add . git commit -m "your comments" git push </code></pre>
35,246,610
0
<p>The solution was to use destroy and create a callback to automatically do a deep cascading.</p> <pre><code>class Place &lt; ActiveRecord::Base before_destroy :delete_children_objects has_many :place_uploads, :dependent =&gt; :destroy protected def delete_children_objects @places = PlaceUpload.where(place_id: id) @places.each do |place| TagsCustomer.where(place_upload_id: place.id).destroy_all Match.where(place_upload_id: place.id).destroy_all end end end </code></pre>
23,241,068
0
Linking a div without javascript? <p>It's a very simple question, you may say that i can do this:</p> <pre><code>&lt;a href="link"&gt;&lt;div&gt;&lt;/div&gt;&lt;/a&gt; </code></pre> <p>but when i hover the div (110x74)px it hovers all across the width of the page, as if the div has a width of 100%, so when i click on blank part of the page it acts like if there's a link there, ideas? thanks</p> <p>I also tried with javascript and it worked but many smartphones can't support it.</p>
10,899,761
0
C# - Passing an anonymous function as a parameter <p>I'm using FluentData as an orm for my database and I'm trying to create a generic query method:</p> <pre><code>internal static T QueryObject&lt;T&gt;(string sql, object[] param, Func&lt;dynamic, T&gt; mapper) { return MyDb.Sql(sql, param).QueryNoAutoMap&lt;T&gt;(mapper).FirstOrDefault(); } </code></pre> <p>Except in my class's function:</p> <pre><code>public class MyDbObject { public int Id { get; set; } } public static MyDbObject mapper(dynamic row) { return new MyDbObject { Id = row.Id }; } public static MyDbObject GetDbObjectFromTable(int id) { string sql = @"SELECT Id FROM MyTable WHERE Id=@Id"; dynamic param = new {Id = id}; return Query&lt;MyDbObject&gt;(sql, param, mapper); } </code></pre> <p>at <code>Query&lt;MyDbObject&gt;(sql, param, mapper)</code> the compilers says:</p> <p><code>An anonymous function or method group connot be used as a constituent value of a dynamically bound object.</code></p> <p>Anyone have an idea of what this means?</p> <p>Edit:</p> <p>The compiler doesn't complain when I convert the method into a delegate:</p> <pre><code>public static Func&lt;dynamic, MyDbObject&gt; TableToMyDbObject = (row) =&gt; new MyDbObject { Id = row.Id } </code></pre> <p>It still begs the question of why one way is valid but not the other.</p>
37,610,622
0
Java implicit Overloading <p>Let's say I have a method called <em>order</em>(), which receives 3 parameters (arg0, arg1, arg2) and determine whether arg0 &lt; arg1 &lt; arg2. I want this method to be able to work on both integers and Strings. How should I perform the overloading? instead of declaring:</p> <pre><code> 1. order(int, int, int) 2. order(int, String, int) 3. order(int, int, String) 4. order(int, String, String) 5. order(String, int, int) 6. order(String, String, int) 7. order(String, int, String) 8. order(String, String, String) </code></pre> <p>Thank you</p>
9,743,948
0
<p>It's best if you can add a field that will not display on the application for the file unique_id in the table and then use that in a join to the data to populate the child tables. But sometimes you can't mess with the structure of a database especially if it is a COTS product. </p> <p>We have a sneaky trick for that. First load the data to a staging table (adding an identity if the file has no unique identifier on it's own) and an empty field for the parent_id. </p> <p>Next put the unique identifier into some other required field instead of its normal value (We use last_name but if you have one taht is the same datatype as the uniqueid that's better). Then you can join on the required field and the uniqueid from the staging table to update it to get the real parentid. Then update the field where you stored the temporary id with its real value (becasue now you can use teh real parent_id). Now you have the real parent_id in a table, the data flows for the child tables can join to that. This creates more work for the database, so only use it if you can't change the structure. </p> <p>Alternatively you can do all the inserting from a staging table using a stored proc and the execute SQL task rather than in a dataflow.</p>
7,921,648
0
In Perl, can refer to an array using its name? <p>I'm new to Perl and I understand you can call functions by name, like this: <code>&amp;$functionName();</code>. However, I'd like to use an array by name. Is this possible?</p> <p>Long code:</p> <pre><code>sub print_species_names { my $species = shift(@_); my @cats = ("Jeffry", "Owen"); my @dogs = ("Duke", "Lassie"); switch ($species) { case "cats" { foreach (@cats) { print $_ . "\n"; } } case "dogs" { foreach (@dogs) { print $_ . "\n"; } } } } </code></pre> <p>Seeking shorter code similar to this:</p> <pre><code>sub print_species_names { my $species = shift(@_); my @cats = ("Jeffry", "Owen"); my @dogs = ("Duke", "Lassie"); foreach (@&lt;$species&gt;) { print $_ . "\n"; } } </code></pre>
3,219,863
0
<p>In addition to what others have said, pointers are <em>necessary</em> for dynamic memory allocation (this also applys to higher level languages, but is (usually) abstracted away). This means that without pointers, you're limited to the (generally rather small) stack memory, which is more in need of conservation.</p>
14,984,100
0
How to control text in edittext with textwatcher <p>So I'm trying to make user insert text with some format that should be xx.xxxx. For that I'm using textwatcher class. Here is my class:</p> <pre><code>edittext.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { EditText edittext = (EditText) findViewById(R.id.my_edit); if(edittext.getText().length()==2)edittext.setText(edittext.getText().toString()+"."); } }); </code></pre> <p>So i basicly just add '.' if length after editing is 2. But after i do that it set my cursor to start of the text field and when i try to delete dot it just recreate it because length is again 2. I know there is some solution but it seems i can't figure it out today :S</p>
10,809,678
0
<p>The reason is that your <em>PageMethods.GetMarkers</em> is asynchronous, so the data hasn't loaded when you invoke <em>DrawMap</em>. I guess when you use the alert, it pauses execution long enough for the data to load. Put the <em>DrawMap</em> method inside the <em>OnSuccess</em> of the page method, and that should solve the problem.</p>
37,678,896
0
<p>There are several ways you can do this.</p> <p>It looks like you have four columns and 40,000 lines, correct?</p> <p>Then you can do the following. First, I will assume there is no header data in the ASCII file for the following commands.</p> <pre><code>FUNCTION read_my_file,file_name ;; Assume FILE_NAME is full path to and including file name with extension fname = file_name[0] ;; One could also find the file with the following ;; fname = FILE_SEARCH([path to file],[file name with extension]) ;; Define the number of lines in the file nl = FILE_LINES(fname[0]) ;; Define empty arrays to fill col1 = DBLARR(nl[0]) col2 = DBLARR(nl[0]) col3 = DBLARR(nl[0]) col4 = DBLARR(nl[0]) dumb = DBLARR(4) ;; Open file OPENR,gunit,fname[0],ERROR=err,/GET_LUN IF (err NE 0) THEN PRINT, -2, !ERROR_STATE.MSG ;; Prints an error message FOR n=0L, nl[0] - 1L DO BEGIN ;; Read in file data READF,gunit,FORMAT='(4d)',dumb ;; Fill arrays col1[n] = dumb[0] col2[n] = dumb[1] col3[n] = dumb[2] col4[n] = dumb[3] ENDFOR ;; Close file FREE_LUN,gunit ;; Define output output = [[col1],[col2],[col3],[col4]] ;; Return to calling routine RETURN,output END </code></pre> <p>Note that this will work better if you provide an explicit width for the format statement, e.g., <code>'(4d15.5)</code>, which means a 15 character input with 5 decimal places.</p> <p>This will return <code>col1</code> through <code>col4</code> to the user or calling routine as an [N,4]-element array, e.g., <code>col1 = output[*,0]</code>. You could use a structure where each tag contains one of the <code>colj</code> arrays or you could return them through <code>keywords</code>.</p> <p>Then you can pass these arrays to another function/program in the following way:</p> <pre><code>PRO my_algorithm_wrapper,file_name,RESULTS=results ;; Get data from files columns = read_my_file(file_name) ;; Pass data to [algorithm] function results = my_algorithm(columns[*,0],columns[*,1],columns[*,2],columns[*,3]) ;; Return to user RETURN END </code></pre> <p>To call this from the command line (after making sure both routines are compiled), you would do something like the following:</p> <pre><code>IDL&gt; my_algorithm_wrapper,file_name,RESULTS=results IDL&gt; HELP,results ;; see what the function my_algorithm.pro returned </code></pre> <p>The above code should work with IDL 6.2.</p> <h1><strong>General Notes</strong></h1> <ol> <li>Try to avoid using uppercase letters in IDL routine names as it can cause issues when IDL searches for the routine during a call or compilation statement.</li> <li>You need to name the program/function in the line with the <code>PRO</code>/<code>FUNCTION</code> statement at the beginning of the file. The name must come immediately after the <code>PRO</code>/<code>FUNCTION</code> statement.</li> <li>It is generally wise to use explicit formatting statements to avoid ambiguities/errors when reading data files.</li> <li>You can pass any variable type (e.g., scalar integer, array, structure, object, etc.) to programs/functions so long as they are handled appropriately within the program/function.</li> </ol>
24,866,240
0
File contents not being read in nodejs program <p>I have a file temp.js that contains text as below:</p> <pre><code>module.config = { key1 : 'value1', key2 : 'value2', key3 : ['abc','def'] } </code></pre> <p>I am reading the file as below:</p> <pre><code>fs.readFile('/temp.js', function(err,fileContents) { console.log(fileContents); }); </code></pre> <p>on the output I am getting values as below:</p> <pre><code>&lt;Buffer 6d 6f ..... ...&gt; </code></pre> <p>What am i missing here ?</p>
2,177,194
0
<pre><code>switch($argv[$i]) { case '-V': case '--version': $displayVersion = true; break; } </code></pre>
25,223,969
0
<p>I guess the problem is that you're not clearing <code>velocity.y</code> in your <code>update</code> function like this:</p> <pre><code>function update() { player.body.velocity.x = 0; player.body.velocity.y = 0; // below is your code from the question } </code></pre>
20,666,886
0
<p>You need to open the file before writing to it. Your <code>HANDLE hFind</code> is just a handle to iterate over directories/files, not an open handle to a file.</p> <p>Use <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx">CreateFile</a>() to open the file</p>
38,183,260
0
RallyRestToolkitForRuby - Unable to pull user permissions <p>Am trying to use <a href="https://github.com/RallyTools/RallyRestToolkitForRuby" rel="nofollow">https://github.com/RallyTools/RallyRestToolkitForRuby</a> to pull permissions of all users in my Rally Subscription. My authentication is through API Key. It fails with below error:</p> <p>C:\Users\Administrator\Desktop\Rally-User-Management-master\Rally-User-Management-master>user_permissions_summary.rb Connecting to Rally: <a href="https://rally1.rallydev.com/slm" rel="nofollow">https://rally1.rallydev.com/slm</a> as [email protected]... Running initial query of users... Found a total of 12392 Enabled Users. Summarizing users and writing permission summary output file... C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/lib/go_user_permissions_summary.rb:224:in <code>block (2 levels) in go_user_permissions_summary' C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_colle ction.rb:36:in</code>each' C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_collection.rb:36:in <code>each' C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/lib/go_user_permissions_summary.rb:201:in</code>block in go_user_permissions_summary' C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_query_result.rb:22:in <code>block in each' C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_query_result.rb:21:in</code>each' C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rally_api-1.2.1/lib/rally_api/rally_query_result.rb:21:in <code>each' C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/lib/go_user_permissions_summary.rb:180:in</code>go_user_permissions_summary'</p> <p>C:/Users/Administrator/Desktop/Rally-User-Management-master/Rally-User-Management-master/<strong>user_permissions_summary.rb:38:in <code>&lt;main&gt;' undefined method</code>[]' for nil:NilClass</strong></p> <p>How do i get over this error? The Readme.pdf in the GitHub page provides no info about this. </p>
7,280,763
0
<p>Are you willing to pay for it? Most of the big third party vendors e.g. Infragistics, Telerik etc have such a control. Here is a link to a demo of the Infragistics tag control:</p> <p><a href="http://samples.infragistics.com/sllob/ComponentOverview.aspx?cn=tag-cloud" rel="nofollow">http://samples.infragistics.com/sllob/ComponentOverview.aspx?cn=tag-cloud</a></p>
29,516,434
0
<p>1)If you forgot to disable speculative execution, It is possible that multiple instances of given Reducer could run, which would result extra data than expected into RDBMS. 2)Even we need the database driver for client machine, If you plan to connect to RDBMS from that client , it is not needed.</p> <p>So "1" option is correct.</p> <p>I got this solution , Can any body Improve this answer or let me correct If any issues. Thank you </p>
39,518,714
0
java array outofboundexception <pre><code>public static int[] squeeze(int[] ints) { int i; int[] temp; temp = new int[100]; for (i = 0; i &lt; ints.length; i++) { if (ints[i] != ints[i + 1]) { temp[i] = ints[i]; } else{ while (ints[i] != ints[i + 1]) { i++; } temp[i] = ints[i]; } } return temp; } </code></pre> <p>When I run this code, it gives me arrayOutOfBoundException. Can any body point the error? I am basically checking that no two consecutive numbers in an array are the same and then printing the same array but with a copy of the next number if two consecutive are same.</p>
40,294,163
0
__WEBPACK_AMD_DEFINE_ARRAY__ is not defined import Jquery with webpack <p>I have tried severally without luck importing jquery to global scope using webpack with below methods , but all throw errors :</p> <p>Try 1 : Expose Loader</p> <p>Used it in my webpack.config as below </p> <pre><code>{ test: require.resolve('jquery'), loader: 'expose?$!expose?jQuery' }, </code></pre> <p>Throws error $ is not defined when i console.log(typeof $)</p> <p>Try 2 : Webpack ProvidePlugin </p> <p>Used it in my webpack.config as below </p> <pre><code>plugins: [ new webpack.ProvidePlugin({ '$': 'jquery', 'jQuery': 'jquery', 'window.jQuery': 'jquery' }) ] </code></pre> <p>throws error <strong>WEBPACK_AMD_DEFINE_ARRAY</strong> is not defined when hot-reloading </p> <p>Am using vue.js V2</p>
11,190,234
0
<blockquote> <p>sudo apt-get install libcurl3-dev which to my understanding is a line for a Unix terminal. What is the equivalent command that I can run on Windows to achieve this?</p> </blockquote> <p>if you are looking for something similar like "apt-get", you could have a look at <a href="http://www.wuinstall.com" rel="nofollow">wuinstall</a> . it is for managing windows updates via command line, although it might not be applicable for your specific case, with a second party software.</p>
843,617
0
How do I write a search query using Kohana PHP? <p>I have a table (<code>product_shoppingcart</code>) with 4 columns :</p> <pre><code>id, product_id, shoppingcart_id, product_quantity. </code></pre> <p>I'm using Kohana's ORM.</p> <p>I want to write a search query which returns all the rows where the <code>shoppingcart_id</code> column contains 1 (for example).</p> <p>I already tried: </p> <pre><code>$arr = ORM::factory('product_shoppingcart')-&gt;where('shoppingcart_id',$shoppingcartID)-&gt;find_all(); </code></pre> <p>but that doesn't work.</p> <p>Can anyone please help me out?</p>
7,268,169
0
Django Newbie Question: Activation View Being Called Twice ... 99% of the time - Invalid token error <p>Hi and thank you for looking at my question. When a user clicks activation link in their email, they get a token invalid error page. The user is activated and can use the site. After adding debugging I see that the activation view is being called twice. The first time it works as expected, but the second time the activation key no longer exists so there is an error. Just to make thing more complicated, it does work once in a very blue moon. Why would this happen? How can I prevent this from happening? Thanks!</p>
40,364,558
0
<p>You are replacing the value of the input field. You want to append to it. Change <code>$(this).val('*');</code> to <code>$(this).val($(this).val() + '*'));</code></p>
25,667,333
0
<p>We fixed this in IRC I believe :-) The problem is that your template <code>ListBlogs</code>has no idea what <code>posts</code> means. You will have to define a helper, so that the <code>{{#each posts}}</code> block gets a meaning.</p> <p>Fortunately this only requires a very quick fix:</p> <pre><code>Template.ListBlogs.posts = function(){ return Blogs.find().fetch(); } </code></pre> <p>Put this in your <code>client/main.js</code> and all posts appear in realtime.</p>
40,848,364
0
JSP to display ksh script response <p>I have several servers. And on each of the servers, I have a shell script to verify the FileSystem, and some info of some files I parse. This script renders information to the console for example</p> <p>Server 1 fs /usr/user1 free 10 Gb</p> <p>File 100 Processed, File 200 Processed,</p> <p>etc..</p> <p>The script takes about 1 minute to execute completely.</p> <p>I already have a jboss server with a webapp with some servlets. I would like to create a jsp, and a servlet to run these commands on 4 different servers and display the results.</p> <p>Ajax maybe??</p> <p>Thanks in advance</p>
30,315,449
0
<p><a href="https://css-tricks.com/fluid-width-equal-height-columns/" rel="nofollow">https://css-tricks.com/fluid-width-equal-height-columns/</a></p> <p>I recommend seeing if any of these tricks work for you.</p>
30,477,337
0
liquibase database build from scratch <p>When I run liquibase update from scratch, it takes a while as the process fires each changelog one by one. Sometimes my own database changes diverge enough that its easiest to rebuild the database if I want to start again for example.</p> <p>The rebuild would be quickest if I did it from a mysql dump of the result of liquibase at a certain point in the changelogs, and I ignored the changelogs from there previously. So I would delete everything in changelog master except my master build dump changelog, which would be the entire database, and I keep hold of the actual changelogs for version control reasons.</p> <p>Is there a proper/ordained/safe way to do this from liquibase?</p>
19,169,115
0
Phonegap: Keyboard changes window height in iOS 7 <p>In iOS 6 everything works fine. The keyboard opens and moves the input into view. When the keyboard closes everything goes back where it should.</p> <p>In iOS 7 the keyboard opens fine and the input remains in view. When the keyboard is closed the whole bottom half of the app is gone, though. I've tracked the issue down to the height of the window changing when the keyboard is opened, and not changing back when it's closed.</p> <p>Right before the keyboard is opened the window height is 568 according to $(window).height() and after it's opened and after it's closed it is 828. The height of the document also changes accordingly.</p> <p>I've attempted preventing the window from resizing with:</p> <pre><code>$(window).resize(function(e) { e.preventDefault(); e.stopPropagation(); window.resizeTo(320,480); return false; }); </code></pre> <p>I've also attempted to set the size back after the keyboard closes with no success.</p> <p>I'm using phonegap 2.7 and have KeyboardShrinksView set to true. </p>
27,788,367
0
Google Apps Script - How to get A1 Notation of a range when you don't know the length <p>I'm sure there is a simple way to do this but I'm spinning wheels trying to figure it out. I have several columns, each of different lengths. I would like to get the A1 notation for each of them, minus a header. I get the index number of the column and then I want to get a range that includes all values under the header. What is the best way to go about this? Probably a trivial solution but thanks for help.</p> <pre><code>function get_range(header) { var data = s.getDataRange().getValues(); var row = data[0]; for( i in row){ if (row[i] == header) { var colinx = parseInt(i)+1; var range = s.getRange(2,colinx,); var notation = range.getA1Notation(); Logger.log(notation); } } } </code></pre>
37,901,838
0
How QSizePolicy work? <p>From <a href="http://doc.qt.io/qt-4.8/qsizepolicy.html" rel="nofollow noreferrer">qt</a></p> <blockquote> <p>QSizePolicy::Minimum <strong>The sizeHint() is minimal</strong>, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button). <strong>It cannot be smaller than the size provided by sizeHint().</strong></p> </blockquote> <p>But what we have?</p> <p><a href="https://i.stack.imgur.com/wgIqw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wgIqw.jpg" alt="img"></a></p> <p>Both QPushButton size are smaller than the size provided by its sizeHint(). Both QPushButton have horizontal SizePolicy set to Minimum and QGridLayout have layoutConstraint set to SetDefaultConstraint. Why am I seeing this result?</p> <p>XML part of code</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ui version="4.0"&gt; &lt;class&gt;Widget&lt;/class&gt; &lt;widget class="QWidget" name="Widget"&gt; &lt;property name="enabled"&gt; &lt;bool&gt;true&lt;/bool&gt; &lt;/property&gt; &lt;property name="geometry"&gt; &lt;rect&gt; &lt;x&gt;0&lt;/x&gt; &lt;y&gt;0&lt;/y&gt; &lt;width&gt;175&lt;/width&gt; &lt;height&gt;41&lt;/height&gt; &lt;/rect&gt; &lt;/property&gt; &lt;property name="sizePolicy"&gt; &lt;sizepolicy hsizetype="Preferred" vsizetype="Preferred"&gt; &lt;horstretch&gt;0&lt;/horstretch&gt; &lt;verstretch&gt;0&lt;/verstretch&gt; &lt;/sizepolicy&gt; &lt;/property&gt; &lt;property name="minimumSize"&gt; &lt;size&gt; &lt;width&gt;100&lt;/width&gt; &lt;height&gt;0&lt;/height&gt; &lt;/size&gt; &lt;/property&gt; &lt;property name="sizeIncrement"&gt; &lt;size&gt; &lt;width&gt;0&lt;/width&gt; &lt;height&gt;300&lt;/height&gt; &lt;/size&gt; &lt;/property&gt; &lt;property name="windowTitle"&gt; &lt;string&gt;Form&lt;/string&gt; &lt;/property&gt; &lt;layout class="QHBoxLayout" name="horizontalLayout"&gt; &lt;property name="sizeConstraint"&gt; &lt;enum&gt;QLayout::SetDefaultConstraint&lt;/enum&gt; &lt;/property&gt; &lt;property name="leftMargin"&gt; &lt;number&gt;14&lt;/number&gt; &lt;/property&gt; &lt;item&gt; &lt;widget class="QPushButton" name="pushButton"&gt; &lt;property name="sizePolicy"&gt; &lt;sizepolicy hsizetype="Minimum" vsizetype="Minimum"&gt; &lt;horstretch&gt;0&lt;/horstretch&gt; &lt;verstretch&gt;0&lt;/verstretch&gt; &lt;/sizepolicy&gt; &lt;/property&gt; &lt;property name="layoutDirection"&gt; &lt;enum&gt;Qt::LeftToRight&lt;/enum&gt; &lt;/property&gt; &lt;property name="text"&gt; &lt;string&gt;Minimum&lt;/string&gt; &lt;/property&gt; &lt;property name="checkable"&gt; &lt;bool&gt;false&lt;/bool&gt; &lt;/property&gt; &lt;property name="autoDefault"&gt; &lt;bool&gt;false&lt;/bool&gt; &lt;/property&gt; &lt;property name="default"&gt; &lt;bool&gt;false&lt;/bool&gt; &lt;/property&gt; &lt;property name="flat"&gt; &lt;bool&gt;false&lt;/bool&gt; &lt;/property&gt; &lt;/widget&gt; &lt;/item&gt; &lt;item&gt; &lt;widget class="QPushButton" name="pushButton_3"&gt; &lt;property name="sizePolicy"&gt; &lt;sizepolicy hsizetype="Minimum" vsizetype="Minimum"&gt; &lt;horstretch&gt;0&lt;/horstretch&gt; &lt;verstretch&gt;0&lt;/verstretch&gt; &lt;/sizepolicy&gt; &lt;/property&gt; &lt;property name="text"&gt; &lt;string&gt;Expanding&lt;/string&gt; &lt;/property&gt; &lt;/widget&gt; &lt;/item&gt; &lt;/layout&gt; &lt;/widget&gt; &lt;resources/&gt; &lt;connections/&gt; &lt;/ui&gt; </code></pre>
7,710,543
0
How to read mbox email messages using mstor <p>I am using mstor to read the mbox email messages, but i am not able to connect to the store using the urlName name which i m passing, by default its connecting to other location on my macbine.Do i need to create the store using mstor JCR before proceed to connect to the store?</p> <pre><code> Session session = Session.getDefaultInstance(new Properties()); Store store = session.getStore(new URLName("mstor:C:/mailbox/MyStore/Inbox")); store.connect(); Folder inbox = store.getDefaultFolder().getFolder("inbox"); inbox.open(Folder.READ_ONLY); Message m = inbox.getMessage(0); </code></pre> <p>Any suggetions are helpful</p> <p>Thanks in advance..</p>
21,682,725
1
TypeError django context using custom class <p>I am new to python and django, and I am trying to pass a class to my <code>RequestContext</code> in a template. So I have this code:</p> <pre><code>context = RequestContext(request, { 'test' : myClass, }) </code></pre> <p>And myClass is an instance of this:</p> <pre><code>class ajax_user_session(): user_model = None user_settings = None time_login = datetime.datetime.now() </code></pre> <p>Both <code>user_model</code> and <code>user_settings</code> are classes derived from django's <code>models.Model</code> (assigned before creating and using the context class). I get the following error:</p> <pre><code>TypeError at /settings &lt;playground.ajax_processing.ajax_user_session instance at 0x263fab8&gt; is not JSON serializable </code></pre> <p>Does somebody know how to solve this, please? I can assign "normal" variables like strings, integers, but I don't want to add several things to the dictionary, I just want to use one big class.</p> <p>Thank you.</p>
35,934,931
0
<p>As I spend some time with a similar issue, I feel its worth sharing:</p> <ol> <li>If you want to display video fullscreen: dont use html tag as there is a media plugin for that. If you dont need to play offline: the video src pointing to a web server will work just fine.</li> <li>If you need to play offline and the video is part of your app package, have a look to <a href="https://github.com/jaeger25/Html5Video" rel="nofollow">https://github.com/jaeger25/Html5Video</a> (it help to automatically copy the video files in a public location)</li> <li>If you need to play offline videos dynamically downloaded: (my case) <ul> <li>Use fileTransfer plugin</li> <li>Save file in cordova.file.externalDataDirectory as its public</li> <li>In some case you may need to force the file to be public</li> <li>you can do that by adding 'file.setReadable(true, false);' to FileTransfer.java line 820</li> </ul></li> </ol> <p>Cheers</p>
29,133,925
0
Declaring an extern variable in a header file <p>I have declared an extern <strong>global</strong> variable inside my main.<strong>h</strong> header file like this:</p> <pre><code>extern int variable; </code></pre> <p>Then, I defined the same global variable inside my main.<strong>c</strong> file like this:</p> <pre><code>int variable = 16; </code></pre> <p>The thing is that I am using another file called <strong>test.c</strong>, and I have included main.<strong>h</strong> header included inside. But I cannot gain access the the "<strong>16</strong>" value that I defined the extern with inside main.<strong>c</strong>. When I call "variable" inside <strong>test.c</strong>, the value of "variable" is "<strong>0</strong>". Should not any .c file that includes my main.<strong>h</strong> header have access to the "<strong>16</strong>" value since I have already defined my "variable" inside main.<strong>c</strong>???</p> <p>Thanks</p>
20,936,803
0
<p>For words (and I mean words not .com etc) this is simple</p> <p>You just want to pregmatch</p> <pre><code>'/\b' . $badword . '\b/' </code></pre> <p>\b is a word boundary</p> <p>for full stops you must escape them . to mean them literally (without \ they actually mean and character in a regex) so I would either write a function that looks for full stops and then adds a \ before them or just add them straight into your list with the \ already appended.</p>
11,944,486
0
multicast socket - will not work when computer wakes up from sleep <p>Hi guys I have a multicast socket that is receiving packets and is working fine.</p> <p>I had an issue though where when my computer wakes up from sleep the multicast socket does not work. Continually timing out:</p> <pre><code>MulticastSocket socket; \\initialise socket.. while (running) { try { synchronized (syncRoot) { socket.setSoTimeout(WAIT_TIME); socket.receive(recv); //Do Something... } } catch (SocketTimeoutException e) { } </code></pre> <p>Currently when my computer wakes up from windows sleep mode it continually throws a socket exception when I no their are packets being sent. I have checked variables socket.isBound(), socket.isClosed(), socket.isConnected() and they have not changed from when it was working. Am I missing a variable? Even when the socket is working it returns isConnected() = false, isBound() = true, isClosed() = false.</p> <p>Do I need to do something like count the number of SocketTimeoutExceptions if i get 10 then reinitialise my multicast socket?</p>
8,510,557
0
How to install LXC (or other linux container) on centOS 5 (2.6.18 kernel) without modify kernel? <p>[Background]</p> <p>I would like to regulate the resource allocation between different processes running on CentOS 5. I am not familiar with related tools. I have searched for a while and think LXC may be a good choice (Please correct me if I am wrong). But the problem is that the kernel version of our CentOS is 2.6.18, which does not have LXC built in. And it is a shared cluster. I do have sudo authority but I am not allowed to modify the kernel. The tutorials I found all require to modify the kernel or recompile it somehow. </p> <p>[Question]</p> <p>How can I install and use LXC (or other light weight linux virtualization tools) on CentOS 5 (2.6.18 kernel) without modify the kernel?</p> <p>Thanks</p>
39,233,172
0
NSXMLParser not recognizing local xml file <p>I have some code that builds a path to an xml file on a local computer. The path to the XML file is correct but when I convert my path to a URL for parsing purposes it then says the parse is "bad". I am new to objective-C and I am not sure if perhaps because the file extension is not .xml? All the files I am looking for have the extensions listed in my code below. Any help would be greatly appreciated. </p> <pre><code>- (void)parseXMLFile { //Create path to users motion files. NSString *beginning = @"/Users/"; NSString *user = NSUserName(); NSString *docPath =@"/myLocalPath/"; NSString *combined = [NSString stringWithFormat:@"%@%@%@", beginning, user, docPath]; NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:combined]; NSString *filename; NSMutableArray *motionPaths = nil; while ((filename = [dirEnum nextObject])) { if([[filename pathExtension] compare: @"moti"] == NSOrderedSame || [[filename pathExtension] compare: @"moef"] == NSOrderedSame || [[filename pathExtension] compare: @"motr"] == NSOrderedSame || [[filename pathExtension] compare: @"motn"] == NSOrderedSame) { NSString *fullPath = [NSString stringWithFormat:@"%@%@", combined, filename]; motionPaths = [NSMutableArray new]; [motionPaths addObject:fullPath]; NSLog(@"First Motion File Path: %@",[motionPaths firstObject]); NSURL *url = [NSURL URLWithString:[[motionPaths firstObject] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; self.parser = [[NSXMLParser alloc] initWithContentsOfURL:url]; self.parser.delegate = self; [self.parser parse]; NSLog(@"%@", url); NSLog( @"XML file was %@.", [self.parser parse] ? @"good" : @"bad" ); } } } </code></pre>