pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
33,360,646
0
<p>sequalise queries return promises so below is how i query stored procedures.</p> <pre><code>sequelize.query('CALL calculateFees();').then(function(response){ res.json(response); }).error(function(err){ res.json(err); }); </code></pre>
15,223,739
0
Google Maps API v3 - circle sector <p>I would like to draw sector of circle on map defined by point, radius, startAngle and stopAngle. I found lots of exmaples but with polygons etc whitch was too complicated for my case.</p> <p>Thanks for any help!</p>
4,233,587
0
<pre><code>imports MyDictionary = System.Collections.Generic.Dictionary(Of string, string) public module MyModule Sub Main() dim myData as New MyDictionary mydata.Add("hello", "world") Console.WriteLine(mydata.Keys.Count) mydata.Add("hello2", "world2") Console.WriteLine(mydata.Keys.Count) End Sub end module </code></pre>
21,734,074
0
<p>try this..</p> <pre><code>echo $_SERVER['HTTP_REFERER']; </code></pre>
25,107,717
0
<p>I just encountered this issue in CE v1.9.0.1. My admin module was getting all processes as a collection and looping through each one calling reindexEverything(). I based the code on the adminhtml process controller which was working fine, but my code wasn't working at all.</p> <p>I finally figured out the issue was that I had previously set the reindex mode to manual (to speed up my product import routine) as follows:</p> <pre><code>$processes = Mage::getSingleton('index/indexer')-&gt;getProcessesCollection(); $processes-&gt;walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL)); // run product import $processes = Mage::getSingleton('index/indexer')-&gt;getProcessesCollection(); foreach($processes as $p) { if($p-&gt;getIndexer()-&gt;isVisible()) { $p-&gt;reindexEverything(); //echo $p-&gt;getIndexer()-&gt;getName() . ' reindexed&lt;br&gt;'; } } $processes = Mage::getSingleton('index/indexer')-&gt;getProcessesCollection(); $processes-&gt;walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME)); </code></pre> <p>SOLUTION: set mode back to MODE_REAL_TIME before reindexing everything:</p> <pre><code>$processes = Mage::getSingleton('index/indexer')-&gt;getProcessesCollection(); $processes-&gt;walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL)); // run product import $processes = Mage::getSingleton('index/indexer')-&gt;getProcessesCollection(); $processes-&gt;walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME)); $processes = Mage::getSingleton('index/indexer')-&gt;getProcessesCollection(); foreach($processes as $p) { if($p-&gt;getIndexer()-&gt;isVisible()) { $p-&gt;reindexEverything(); //echo $p-&gt;getIndexer()-&gt;getName() . ' reindexed&lt;br&gt;'; } } </code></pre> <p>Note: these are snips from a few different methods hence the repeated assignment of $processes etc..</p> <p>It seemed reindexEverything() wasn't doing anything when the processes index mode was set to MODE_MANUAL. Setting mode back to MODE_REAL_TIME and then calling reindexEverything worked fine.</p> <p>I hope this helps someone as I had a few frustrated hours figuring this one out!</p> <p>Thanks</p>
931,767
0
<h2>Binary Trees</h2> <p>There exists two main types of binary trees, balanced and unbalanced. A balanced tree aims to keep the height of the tree (height = the amount of nodes between the root and the furthest child) as even as possible. There are several types of algorithms for balanced trees, the two most famous being AVL- and RedBlack-trees. The complexity for insert/delete/search operations on both AVL and RedBlack trees is <strong><em>O(log n)</em></strong> or <strong>better</strong> - which is the important part. Other self balancing algorithms are AA-, Splay- and Scapegoat-tree.</p> <p>Balanced trees gain their property (and name) of being balanced from the fact that after every delete or insert operation on the tree the algorithm introspects the tree to make sure it's still balanced, if it's not it will try to fix this (which is done differently with each algorithm) by rotating nodes around in the tree.</p> <p>Normal (or unbalanced) binary trees do not modify their structure to keep themselves balanced and have the risk of, most often overtime, to become very inefficient (especially if the values are inserted in order). However if performance is of no issue and you mainly want a sorted data structure then they might do. The complexity for insert/delete/search operations on an unbalanced tree range from O(1) (best case - if you want the root) to O(n) (worst-case if you inserted all nodes in order and want the largest node)</p> <p>There exists another variation which is called a randomized binary tree which uses some kind of randomization to make sure the tree doesn't become fully unbalanced (which is the same as a linked list)</p>
13,374,164
0
<p>Maybe ?:</p> <pre><code> SELECT * FROM `tbl_notes` WHERE `active` = '0' AND `valid_note` = '0' AND `user_id` = '33' AND (`note` LIKE '%biology%' OR `topic` LIKE '%biology%' OR `note_title` LIKE '%biology%' OR `course` IN (SELECT `id` FROM tbl_courses WHERE `course_name` LIKE '%biology%' AND user_id = '33') ) ORDER BY id DESC LIMIT 0, 6 </code></pre>
23,249,089
0
Sum of a field with respect to another field <p>I have a table of employees Salary named as <strong>empSalary</strong>.</p> <p><img src="https://i.stack.imgur.com/mOFVj.png" alt="empSalary"></p> <p>I want to calculate sum of salaries issued by each department. What comes to my mind is </p> <pre><code>Select sum(Salary) from empSalary where deptId = (Select deptId from empSalary) </code></pre> <p>This statement gives me <strong>5100</strong> which is the sum of Salary where <strong>deptId = 1</strong>. How is this possible using only sql query? Sorry for the question title as i was unable to find words.</p>
28,558,301
0
<p>Since it's invisible, it wont move to the top. You have to remove it with something like:</p> <pre><code>// remove vbox.getChildren().remove(...) </code></pre> <p>Once you've removed the element you want invisible then, the other element should move to the top.</p>
5,032,569
0
<p><strong>edit</strong> Martin's answer is far superior to this one. His is the correct answer.</p> <hr> <p>There are a couple ways to do it. Probably the simplest would just be to build a giant OR predicate:</p> <pre><code>NSArray *extensions = [NSArray arrayWithObjects:@".mp4", @".mov", @".m4v", @".pdf", @".doc", @".xls", nil]; NSMutableArray *subpredicates = [NSMutableArray array]; for (NSString *extension in extensions) { [subpredicates addObject:[NSPredicate predicateWithFormat:@"SELF ENDSWITH %@", extension]]; } NSPredicate *filter = [NSCompoundPredicate orPredicateWithSubpredicates:subpredicates]; NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectoryPath error:nil]; NSArray *files = [dirContents filteredArrayUsingPredicate:filter]; </code></pre> <p>This will create a predicate that's equivalent to:</p> <pre><code>SELF ENDSWITH '.mp4' OR SELF ENDSWITH '.mov' OR SELF ENDSWITH '.m4v' OR .... </code></pre>
11,801,138
0
Program compiling program fail at links for objective c files <p>I am trying to compile a program using its source code and I am unable too and the problem seems to happen in the same folder in every ocurrance, and when I check the files, they are all objective c language, could it be that I am missing libraries or programs? If so which may they be? I tried researching online and here but all I find is stuff on gcc and g++ but I already have both installed along with the boost library which is another pre-req for this program. Here are some of the command line outputs I got:</p> <pre><code> "g++" -o "phrase-extract/pcfg-score/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi/pcfg-score" -Wl,--start-group "phrase-extract/pcfg-score/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi/pcfg_score.o" "phrase-extract/pcfg-score/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi/main.o" "phrase-extract/pcfg-score/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi/tree_scorer.o" "phrase-extract/pcfg-common/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi/libpcfg_common.a" -Wl,-Bstatic -lboost_program_options-mt -lboost_system-mt -lboost_thread-mt -Wl,-Bdynamic -lSegFault -lrt -Wl,--end-group -g -pthread ...failed gcc.link phrase-extract/pcfg-score/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi/pcfg-score... ...skipped &lt;p/home/rowe/Moses/bin&gt;moses_chart for lack of &lt;pmoses-chart-cmd/src/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;moses_chart... ...skipped &lt;p/home/rowe/Moses/bin&gt;moses for lack of &lt;pmoses-cmd/src/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;moses... ...skipped &lt;p/home/rowe/Moses/bin&gt;lmbrgrid for lack of &lt;pmoses-cmd/src/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;lmbrgrid... ...skipped &lt;p/home/rowe/Moses/bin&gt;CreateOnDiskPt for lack of &lt;pOnDiskPt/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;CreateOnDiskPt... ...skipped &lt;p/home/rowe/Moses/bin&gt;queryOnDiskPt for lack of &lt;pOnDiskPt/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;queryOnDiskPt... ...skipped &lt;p/home/rowe/Moses/bin&gt;pro for lack of &lt;pmert/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;pro... ...skipped &lt;p/home/rowe/Moses/bin&gt;kbmira for lack of &lt;pmert/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;kbmira... common.copy /home/rowe/Moses/bin/processPhraseTable ...skipped &lt;p/home/rowe/Moses/bin&gt;processLexicalTable for lack of &lt;pmisc/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;processLexicalTable... common.copy /home/rowe/Moses/bin/queryPhraseTable ...skipped &lt;p/home/rowe/Moses/bin&gt;queryLexicalTable for lack of &lt;pmisc/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;queryLexicalTable... ...skipped &lt;p/home/rowe/Moses/bin&gt;extract-ghkm for lack of &lt;pphrase-extract/extract-ghkm/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;extract-ghkm... ...skipped &lt;p/home/rowe/Moses/bin&gt;pcfg-extract for lack of &lt;pphrase-extract/pcfg-extract/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;pcfg-extract... ...skipped &lt;p/home/rowe/Moses/bin&gt;pcfg-score for lack of &lt;pphrase-extract/pcfg-score/bin/gcc-4.6/release/debug-symbols-on/link-static/threading-multi&gt;pcfg-score... common.copy /home/rowe/Moses/lib/libLM.a ...failed updating 12 targets... ...skipped 12 targets... ...updated 8 targets... </code></pre>
37,369,628
0
<p>PHP cannot find the index referer in the variable $_GET, you should first test if the index exist, Try this:</p> <p><strong>PHP</strong></p> <pre><code>&lt;input id="refer" placeholder="&lt;?php echo $txt['not_oblige']; ?&gt;" type="text" name="referer" value="&lt;?php echo (isset($_GET['referer'])) ? $_GET['referer'] : '' ; ?&gt;" class="form-control" /&gt; </code></pre>
16,666,425
0
How to use the output statement and insert multiple values with that id <p>I want to insert values into two tables.</p> <p>The first one looks like this</p> <p><strong>Recipes</strong></p> <pre><code>RecipeId (unique and AI) RecipeName Method Discontinued </code></pre> <p>The second one looks like this</p> <p><strong>IngredientRecipe</strong></p> <pre><code>RecipeUniqId (unique and AI) RecipeId (same as the RecipeId in the Recipes table) IngredientId </code></pre> <p>I want to insert a RecipeName and a Method. If I do that the RecipeId gets auto incremented. Than I want to insert three times an ingredient with the RecipeId. Its working for one ingredient.</p> <pre><code>INSERT INTO Recipes (RecipeName, Method, Discontinued) OUTPUT INSERTED.RecipeId, '5' INTO IngredientRecipe( RecipeId, IngredientId ) VALUES ('Potato and Chips', 'Potato and Chips bake everything', 'false'); </code></pre> <p>So what I want is that I can add three times the same RecipeId with a different number for the IngredientId.</p> <p>How to do this? I use sql server </p> <p>EDIT:</p> <p>I use asp.net with c# and an N-tier structure. I use a sql server database</p>
25,818,596
0
<p>change:</p> <pre><code>w=console.next(); </code></pre> <p>to:</p> <pre><code>w=console.nextLine(); </code></pre> <p>".next()" gets the next word, if you want the whole input you need to use ".nextLine()". Hope this helps :)</p>
34,339,841
0
<p>It depends on the type of instance. If it's EBS backed you are probably safe to proceed as the volume will be reattached. If it's instance store backed and you lost access to it you basically have lost what's on that machine.</p> <p>By the sounds of it it's EBS backed. If it's instance store backed and you later created and attached an EBS volume and used that, you're going to be able to restore/reattach that volume just fine - but it's going to be to another machine. </p>
35,477,550
0
How to write active record query to details by using and <p>i have two tables</p> <p>1)Properties :fields are id, name, propert_type,category_id</p> <p>2)Admins : fields id, name,mobile,category_id</p> <p>i want to write an active record to list all properties , where category_id in properties table and category_id in Admins table are equal, according to current_user_id</p> <p>i am listing this property list by logging as admin.</p> <p>model relation</p> <p><code>class Category &lt; ActiveRecord::Base has_many :admins,dependent: :destroy has_many :properties,dependent: :destroy end</code></p> <p><code>class Admin &lt; ActiveRecord::Base belongs_to :category has_many :properties end</code></p> <p><code>class Property &lt; ActiveRecord::Base belongs_to :admin belongs_to :category end</code></p> <p>i wrote active record like this , but i got error, can anyone please suggest me a solution for this</p> <p><code>@properties= Property.where('properties.category_id=?','admins.category_id=?').and('admins.id=?',current_user.specific.id)</code></p>
8,023,571
0
What's wrong with this QuickSort program? <p>I've written a QuickSort algorithm based off pseudo-code that I had been given. I've been running through the outputs for about 4 hours now and I can't seem to find exactly why my algorithm starts to derail. This sort of collection logic is something I struggle with.</p> <p>Anyway, whenever I run my program there's 3 possible results:</p> <ol> <li>The list is organized and is 100% correct.</li> <li>The list is 90% organized, one or two pairs of elements are off.</li> <li>The list is never sorted and results in an infinite loop.</li> </ol> <p>Given my results it leads me to believe that something has to do with the <code>index</code> variable I'm using. However, I can' figure out why or what's wrong with it.</p> <p>Here's ALL of my code that I use for my QuickSort algorithm:</p> <pre><code>public void QuickSort(IList&lt;int&gt; list, int l, int r) { if (l&gt;=r) return; int index = Partition(list, l, r); Console.WriteLine("index: " + index); QuickSort(list, l, (index-1)); QuickSort(list, (index+1), r); } public int Partition(IList&lt;int&gt; list, int l, int r) { int pivot = list[l]; int i = l; int j = r + 1; do { do { i++; } while(i &lt; list.Count &amp;&amp; list[i] &lt; pivot); do { j--; } while(j &gt; 0 &amp;&amp; list[j] &gt;= pivot); Swap(list, i, j); } while(i&lt;j); Swap(list, i ,j); Swap(list, j, l); return j; } public void Swap(IList&lt;int&gt; list, int i, int j) { //Console.WriteLine("Swapping [i] " + list[i] + " with [j] " + list[j]); //PrintList(list, i, j, false); int temp = list[i]; list[i] = list[j]; list[j] = temp; //PrintList(list, j, i, true); } </code></pre> <p>PrintList is simply used to test my outputs.</p> <p>Here is a sample input/output:</p> <p>INPUT: [18,43,5,73,59,64,6,17,56,63]</p> <p>OUTPUT: [5,6,18,17,43,59,56,63,64,73]</p>
7,470,714
0
<p>You need to add the context of the td, you're already in a for loop so the 'this' variable can be used. In this context 'this' is equal to the tr you're currently iterating on.</p> <pre><code>$('tr').each(function(index) { $("td:last",this).css({backgroundColor: 'yellow', fontWeight: 'bolder'}); }); </code></pre>
13,874,174
0
<p>There is no built in functionality for resizing category images. However you can utilize <code>Varien_Image</code> class. Here I wrote a piece of code you need:</p> <pre><code>foreach ($collection as $_category){ $_file_name = $_category-&gt;getImage(); $_media_dir = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; $cache_dir = $_media_dir . 'cache' . DS; if (file_exists($cache_dir . $_file_name)) { echo Mage::getBaseUrl('media') . DS . 'catalog' . DS . 'category' . DS . 'cache' . DS . $_file_name; } elseif (file_exists($_media_dir . $_file_name)) { if (!is_dir($cache_dir)) { mkdir($cache_dir); } $_image = new Varien_Image($_media_dir . $_file_name); $_image-&gt;constrainOnly(true); $_image-&gt;keepAspectRatio(true); $_image-&gt;keepFrame(true); $_image-&gt;keepTransparency(true); $_image-&gt;resize(50, 50); $_image-&gt;save($cache_dir . $_file_name); echo Mage::getBaseUrl('media') . DS . 'catalog' . DS . 'category' . DS . 'cache' . DS . $_file_name; } } </code></pre>
24,658,299
0
How to optimize a subset of JavaScript files created as RequireJS modules <p>I have single-page web application that uses RequireJS to organize and structure JavaScript code. <strong>Inside the app, I have some JS files that I want to optimize using r.js because they belong to an API that will be consumed by my customers. So, I just want to optimize those files and keep the rest of the code as it is now.</strong></p> <p>This is my application structure:</p> <ul> <li>app <ul> <li>main.js</li> <li>many other files and folders</li> </ul></li> <li>scripts <ul> <li>myAPI <ul> <li>app.js </li> <li>many other files and folders</li> </ul></li> <li>require.js </li> <li>jquery.js</li> <li>build.js</li> </ul></li> <li>index.htm</li> </ul> <p>All the JavaScript code is located under the <em>app</em> and <em>scripts</em> folders. As I mentioned before, all those files are defined as RequireJS modules. This is how the main.js looks now:</p> <pre><code>require.config({ baseUrl: 'scripts', paths: { base: 'myAPI/base', proxy: 'myAPI/proxyObject', localization: 'myAPI/localization', app: '../app', } }); require(['myAPI/app'], function (app) { //app.init.... } ); </code></pre> <p>As you can see, in the <em>paths</em> configuration I'm defining some aliases that point to <em>myAPI</em> (the folder I want to optimize).</p> <p>This is how I reference RequireJS from the index.htm file:</p> <pre><code>&lt;script data-main="app/main" src="scripts/require.js"&gt;&lt;/script&gt; </code></pre> <p>This is the build file I created for r.js (scripts/build.js):</p> <pre><code>({ baseUrl: '.', out: 'build/myAPI.js', name: 'myAPI/app', include: ['some modules'], excludeShallow: ['some modules defined in the app folder'], mainConfigFile: '../app/main.js', optimize: 'uglify2', optimizeCss: 'none' }) </code></pre> <p><strong>The optimized file is generated, but I have some challenges trying to use it</strong>:</p> <ol> <li>How do I reference that file from the app?</li> <li>The dependencies to <em>myAPI</em> modules are broken now. RequireJS doesn't find the modules defined in <em>myAPI</em>.</li> <li>What can I do to keep the aliases defined in require.config.paths working?</li> </ol> <p>Could you please help me with some suggestions or feedback for this situation?</p> <p>Thanks!!</p>
29,213,710
0
<p>Turn the HTML into a <a href="http://php.net/manual/en/class.domdocument.php" rel="nofollow">DOMDocument</a>, then fetch the requested values using <a href="http://php.net/manual/en/class.domxpath.php" rel="nofollow">XPath</a> <a href="http://www.w3.org/TR/xpath/" rel="nofollow">queries</a>:</p> <pre><code>$html = &lt;&lt;&lt;EOS &lt;table id='table1'&gt; &lt;tr&gt; &lt;td&gt; &lt;div class='us'&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt; &lt;span&gt;text1&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;span&gt;text2&lt;/span&gt; &lt;/td&gt; &lt;td&gt;text3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;div class='jo'&gt;&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt; &lt;span&gt;text4&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;span&gt;text5&lt;/span&gt; &lt;/td&gt; &lt;td&gt;text6&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; EOS; // Load HTML into a DOMDocument $dom = new DOMDocument(); $dom-&gt;loadHTML($html); // Find div's with class attribute $xPath = new DOMXPath($dom); $divsWithClassAttribute = $xPath-&gt;query('//div[@class]'); // Loop through divs foreach ($divsWithClassAttribute as $div) { // Create row array starting with class name $row = array($div-&gt;getAttribute('class')); // Get siblings of the td parent of each div $siblings = $xPath-&gt;query('parent::td/following-sibling::td', $div); // Loop through (td) siblings and extract text content foreach ($siblings as $sibling) { $row[] = trim($sibling-&gt;textContent); // Add text value } // Output row echo implode(' - ', $row), PHP_EOL; } </code></pre> <p>Output:</p> <pre><code>us - text1 - text2 - text3 jo - text4 - text5 - text6 </code></pre>
31,301,870
0
<p>This info on the changelog is more related to the fact that before the maximum number of concurrent sockets node could handle was set to <code>5</code> (it was changeable of course) but now it is set to <code>Infinity</code> by default.</p> <p>This has nothing to do with the capacity of connexions an application can handle, that will be limited by the network's characteristics, the OS specifications, the available resources on the server, etc.</p> <p>In short, you are looking at something (the blog post) that has nothing to do with your question.</p>
26,286,380
0
Segmentation fault when filling a 2-d Jagged array <p>I am attempting to fill a jagged array with random values, where the columns and rows are determined by the user.</p> <p>The following code sometimes produces a segmentation fault. Why?</p> <pre><code>int main() { int row; int *col; int **ragArray; setupArray(ragArray, row, col); fillArray(ragArray, row, col); } void setupArray(int **&amp;ragArray, int &amp;row, int *&amp;col) { cout &lt;&lt; "Enter number of rows for the ragged array: "; cin &gt;&gt;row; int a; ragArray = (int**)malloc(row * sizeof(int*)); col = new int[row]; for (int i = 0; i &lt; row; i++) { cout &lt;&lt; "Enter number of columns for row " &lt;&lt; i + 1 &lt;&lt; ": "; cin &gt;&gt; a; col[i] = a; ragArray[i] = (int*)malloc(a * sizeof(int)); } } void fillArray(int **&amp;ragArray, int &amp;row, int *&amp;col) { for (int j = 0; j &lt; row; j++) { for (int i = 0; i &lt; col[j]; i++) { ragArray[i][j] = (rand()%9); } } } </code></pre> <p>This code produces a segmentation fault when I try to create an array with one row having a column greater than the amount of rows. For example, </p> <pre><code>Enter number of rows for the ragged array:5 Enter number of columns for row 1: 6 Enter number of columns for row 2: 2 Enter number of columns for row 3: 4 Enter number of columns for row 4: 1 Enter number of columns for row 5: 3 </code></pre> <p>produces a segfault when attempting to assign a value to <code>ragArray[0][5]</code>, however,</p> <pre><code>Enter number of rows for the ragged array:5 Enter number of columns for row 1: 5 Enter number of columns for row 2: 2 Enter number of columns for row 3: 4 Enter number of columns for row 4: 1 Enter number of columns for row 5: 3 </code></pre> <p>works just fine.</p>
34,095,477
0
<p>call url with domain, try this</p> <pre><code>file_get_contents('https://www.example.com/inventory/index.php?id=100'); </code></pre>
24,008,218
0
Is it possible for a web service operation to return multiple types? <p>I'm working with a web service which is written by another team.</p> <p>The operation which I'm using in the WSDL is:</p> <pre><code>&lt;wsdl:operation name="transactionReport"&gt; &lt;wsdl:input name="transactionReportRequest" message="schema:transactionReportRequest"&gt; &lt;/wsdl:input&gt; &lt;wsdl:output name="transactionReportResponse" message="schema:transactionReportResponse"&gt; &lt;/wsdl:output&gt; &lt;/wsdl:operation&gt; </code></pre> <p>As it describes in WSDL the result of the <code>transactionReport</code> operation must be of type <code>transactionReportResponse</code>.</p> <p>But in some cases (on error) it returns this XML as result:</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;SOAP-ENV:Header /&gt; &lt;SOAP-ENV:Body&gt; &lt;errorOccur xmlns="http://thecompany/servicesCompanyInfo/definitions"&gt; &lt;errorCode&gt;3&lt;/errorCode&gt; &lt;errorDescription&gt;CUSTOMER_ID or FROM_DATE should have value&lt;/errorDescription&gt; &lt;/errorOccur&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>It seems that it's against the WSDL. Am I true?</p> <p>I expect this operation to return just <code>transactionReportResponse</code> or <code>Fault</code>.</p> <p><strong>Question1:</strong> Is it OK for this operation to return a <code>errorOccur</code> too?</p> <p><strong>Question2:</strong> If it's OK, then how can I get this object in C#? (As it returns null despite of the XML which contains a <code>errorOccur</code>)</p>
33,857,976
0
<p>Thats <code>REGDB_E_CLASSNOTREG</code> so <code>CLSID_SQLNCLI11</code> is not available, download and install the redistributable package for the Native Client (Matching the bitness of your application).</p> <p><a href="https://www.microsoft.com/en-gb/download/details.aspx?id=29065" rel="nofollow">Download</a>.</p>
9,945,049
0
Tablet landscape specific with media queries <p>I have a 'responsive' website but there are some links I only want on 'pc browsers' only and not on 'tablet landscape' becasue they link off to flash objects.</p> <p>So far this is what I have done but it't not a 100% fix as some android tablets such as 'Lenovo think pad' which have a bigger screen.</p> <p>I am using media queries to make my site responsive and this is what I'm currently using...</p> <pre><code>@media only screen and (max-device-width : 1024px) and (orientation:landscape) { header.Site { nav.Site &gt; ul &gt; li { line-height: 2 ; } div.BidSessionCountdown, a.LiveOnline { display: none; } } } </code></pre> <p>Is there any CSS fixes you can think of?</p> <p>Thank you in advance Tash :D</p>
11,478,260
0
Spring Integration HTTP inbound adapter method name? <p>Is it possible to map the method name to a header with a int-http:inbound-gateway? for example:</p> <pre><code>&lt;int-http:inbound-gateway request-channel="requests" reply-channel="replies" supported-moethds="GET,PUT" path="/user"&gt; &lt;int-http:header name="requestMethod" expression="#requestMethod"/&gt; &lt;/int-http:inbound-gateway&gt; &lt;!-- ... --&gt; &lt;int:header-value-router input-channel="requests" header-name="requestMethod&gt; &lt;int:mapping value="GET" channel="getUserRequests"/&gt; &lt;int:mapping value="PUT" channel="addUserRequests"/&gt; &lt;/int:header-value-router&gt; </code></pre> <p>Furthermore, I see examples that utilize #requestParams, but the javadoc for 2.1 mentions #queryParameters, and I don't see documentation for either of these in the official documentation page. Do you guys know a good resource that describes not only how SpEL parses expressions but what fields are available to use with it? All I can tell is I have headers, payload, #pathVariables, and maybe #requestParams or #queryParams, along with any other @beans I have defined in the current context.</p> <p>Thanks in advance!</p>
30,507,308
0
<p>I suggest to store coordinates and address info in data-attributes, obtaining more flexible code in result: need one more marker? — just add another &lt;a&gt;!</p> <pre><code>&lt;html&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#" class="location_class" data-location_phi="41.3947901,2.1487679" data-loan="loan 1" data-add="address 1" data-add_phi="some1"&gt;Barcelona&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#" class="location_class" data-location_phi="41.1258048,1.2385834" data-loan="loan 2" data-add="address 2" data-add_phi="some2"&gt;Tarragona&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#" class="location_class" data-location_phi="46.4841143,30.7388449" data-loan="" data-add="address 3" data-add_phi=""&gt;Odessa&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;div id="testmap"&gt;&lt;/div&gt; &lt;/html&gt; </code></pre> <p>JS</p> <pre><code>google.maps.event.addDomListener(window, 'load', initialize); function initialize() { var mapOptions = { zoom: 8, center: new google.maps.LatLng(41.3947901, 2.1487679), mapTypeId: google.maps.MapTypeId.ROADMAP } setMarkers( new google.maps.Map(document.getElementById('testmap'), mapOptions) ); } function setMarkers(map) { // Find links with "data-location_phi" attribute, // that contains coordinates required for marker placement var a = document.querySelectorAll('[data-location_phi]'); for (var i = 0; i &lt; a.length; i++) { // Create an instance of MapMarker class for every location link new MapMarker(map, a[i]); } } function MapMarker(map, a) { this.a = a; this.map = map; this.dataset = {}; this.fillDataSet(); // Since we don't validate data in attributes it may cause some exceptions try { var loc = this.dataset.location_phi.split(','); this.latLng = new google.maps.LatLng(loc[0], loc[1]); this.marker = new google.maps.Marker({ map: this.map, title: this.dataset.loan, position: this.latLng }); // Bind event listeners this.bind(); } catch (e) { console.log(e); } } MapMarker.prototype.fillDataSet = function () { var self = this; Array.prototype.slice.call(self.a.attributes).forEach(function (attr) { if (attr.name.substr(0, 5) == 'data-') { self.dataset[attr.name.substr(5)] = attr.value; } }); } MapMarker.prototype.panTo = function () { this.map.panTo(this.latLng); } MapMarker.prototype.showInfo = function () { var infowindow = new google.maps.InfoWindow(); var content = '&lt;h3&gt;Loan Number: ' + this.dataset.loan + '&lt;/h3&gt;' + 'Address: ' + this.dataset.add + this.dataset.add_phi; infowindow.setContent(content); infowindow.open(this.map, this.marker); } MapMarker.prototype.bind = function () { var self = this; // Click on the link self.a.addEventListener('click', function (e) { e.preventDefault(); self.panTo(); }); // Click on the marker google.maps.event.addListener( self.marker, 'click', function () { self.showInfo(); self.panTo(); } ); } </code></pre> <p><a href="https://jsfiddle.net/9Lemwp07/9/" rel="nofollow">Demo</a></p>
5,598,476
1
Django filter for converting the number of seconds into a readable form <p>I have model:</p> <pre><code>class Track(models.Model): artist = models.CharField(max_length=100) title = models.CharField(max_length=100) length = models.PositiveSmallIntegerField() </code></pre> <p>where length is the duration of track in seconds</p> <p>I have template:</p> <pre><code>{% for track in tracks %} {{track.artist}} - {{track.title}} {{track.length}} {% endfor %} </code></pre> <p>How can I convert a length in the readable form, ie 320 seconds should be displayed as 5:20, 3770 as 1:02:50?</p> <p>Forgive sorry for bad english.</p>
28,285,970
0
<p>You are missing the <code>.call()</code> when you're trying to make an array copy from the <code>HTMLCollection</code>. Instead of this:</p> <pre><code>var x = document.getElementsByTagName("th"); var plop = Array.prototype.slice(x); </code></pre> <p>You can do this:</p> <pre><code>var x = document.getElementsByTagName("th"); var plop = Array.prototype.slice.call(x); console.log(plop); </code></pre> <hr> <p>Note: you don't need to make an array copy just to iterate over it. You can iterate an HTMLCollection directly:</p> <pre><code>var items = document.getElementsByTagName("th"); for (var i = 0; i &lt; items.length; i++) { console.log(items[i]); } </code></pre>
6,919,756
0
<p>There are two ways user-defined types can be implicitly converted:</p> <ol> <li>With a conversion constructor (e.g. "std::string::string(const char* c_string)").</li> <li>With a conversion operator (e.g. "OldType::operator NewType() const").</li> </ol> <p>Any constructor that takes a single parameter and does not use the keyword "explicit" defines an implicit conversion (from the type of the parameter, to the type of the object being constructed). The standard string class intentionally does not use "explicit" in order to provide the convenience of this conversion.</p>
29,666,302
0
Using a single user for mysql queries or multiple users for specific tasks? <p>Should I have multiple mysql user accounts with specific tasks (update,insert,select) for 1 web application OR a single mysql user account with multiple privileges?</p> <p>Are there any specific pros and cons?</p>
23,466,363
0
<p>Here's an example to add to the IDE's context menu - originally posted on the livecode forums. There's also an example stack you can download : <a href="http://forums.runrev.com/viewtopic.php?f=9&amp;t=18613" rel="nofollow">http://forums.runrev.com/viewtopic.php?f=9&amp;t=18613</a></p> <pre><code># catch the IDE's context menu message on revHookBuildObjectEditorContextMenu pMenuTarget, pMenuName, @pMenu, pModifiedMenu # custom menu item put "Custom Item" &amp; "-" &amp; LF before pMenu pass revHookBuildObjectEditorContextMenu end revHookBuildObjectEditorContextMenu # catch the IDE's message when an item is selected from the context menu function dispatchContextMenuPick pMenuName, pItem switch word 1 to -1 of pItem case "Custom Item" answer "Custom Item Selected" exit to top break end switch pass dispatchContextMenuPick end dispatchContextMenuPick </code></pre> <ul> <li><p>To get it to work, put the code above into a button then use;</p> <p>insert the script of button "MyFrontScript" into front</p></li> </ul>
15,093,494
0
Using sed to remove lines from a txt file <p>I have a big text file from which I want to remove some lines that are in another text file. It seems that the <code>sed</code> command in Unix shell is a good way to do this. However, I haven't been able to figure out which flags to use for this. .</p> <p>database.txt:</p> <pre><code>this is line 1 this is line 2 this is line 3 this is line 4 this is line 5 </code></pre> <p>lines_to_remove.txt</p> <pre><code>this is line 1 this is line 3 </code></pre> <p>what_i_want.txt</p> <pre><code>this is line 2 this is line 4 this is line 5 </code></pre>
5,177,191
0
<p><em>(I realise this question is old, but it's something that other people might want an answer to)</em></p> <p>BASIC Authentication doesn't really allow what you're asking for, but you can get something that works a bit like what you want, if you're willing to live with some "quirks".</p> <p>BASIC Authentication has 2 aspects that make it hard to control in this way</p> <ul> <li>It is stateless</li> <li>It is client-side</li> </ul> <p>Both of those aspects are features, but they make it hard to link BASIC authentication to Java sessions. That is why alternate login mechanisms (like Java FORM login exist)</p> <p><strong>BASIC Authentication is stateless</strong><br> That means that the client has absolutely no idea what is going on on the server-side, and it certainly has no way of linking a set of BASIC Authentication credentials to a cookie (which is what mostly controls the java session)<br> What happens in that the browser will simply send the username+password with <em>every</em> request, until it decides to stop (generally because the browser was closed, and a new browser session was created).<br> The browser doesn't know what the server is doing with the credentials. It doesn't know whether they're needed any more, or not, and it doesn't know when the server side has decided that a "new session" has started, it just keeps on sending that username+password with each request.</p> <p><strong>BASIC Authentication is Client-Side</strong><br> That dialog for the user/password is handled by the client. All the server says is "The URL you requested needs a username+password, and we've named this security realm 'xyz' ".<br> The server doesn't know whether the user is typing in a password each time, or whether the client has cached them. It doesn't know if there really is a user there, or whether the password was pulled out of a file.<br> The only thing the server can do is say "You need to give me a user+password before accessing this URL"</p> <p><strong>How to fake it</strong><br> Essentially, you need to detect (i.e. make an educated guess) when the browser is sending old credentials and then send the "Please give me a user+password" response (HTTP 401) again.</p> <p>The simplest way to do that is to have a filter in your application that detects the first time the user has logged in for that session, and sends a <code>401</code> response code. Something like:</p> <pre><code> if(session.getAttribute("auth") == null) { response.setStatus(401); response.setHeader("WWW-Authenticate", "basic realm=\"Auth (" + session.getCreationTime() + ")\"" ); session.setAttribute("auth", Boolean.TRUE); writer.println("Login Required"); return; } </code></pre> <p>In that example I've named the realm with the creation time of the session (although it's not very pretty - you'd probably want to format it differently). That means that the name of the security realm changes each time you invalidate the session, which helps prevent the client from getting confused (why is it asking me for a user+password again, for the same realm, when I just gave one?).<br> The new realm name will not confuse the servlet container, because it will never see it - the client response does not include the realm name.</p> <p>The trick though, it that you don't want the user to get asked for their password twice the first time they logon. And, out of the box, this solution will do that - once for the container to ask for it, and then again when your filter does.</p> <p><strong>How to avoid getting 2 login boxes</strong> There are 4 options.</p> <ol> <li>Do it all in code.</li> <li>Use a secondary session cookie to try and tell whether the user is logging in for the first time. </li> <li>Have your root URL be unsecured (but have it do nothing)</li> <li>Have all your app be unsecured, except for 1 page, and redirect users to that page if they are not logged in.</li> </ol> <p><strong>Do it in code</strong></p> <p>If you're happy to do all of the security inside your own servlet/filter, and get no help from the servlet container (Jetty) then that's not too hard. You simply turn off BASIC auth in your web.xml, and do it all in code. (There's a fair bit of work, and you need to make sure you don't leave any security holes open, but it's conceptually quite easy)<br> Most people don't want to do that.</p> <p><strong>Secondary Cookies</strong><br> After a user logins in to your application, you can set a cookie ("authenticated") that expires at the end of the browser session. This cookie is tied to the browser session and <strong>not</strong> to the Java session.<br> When you invalidate the Java session - <em>do not</em> invalidate the <em>"authenticated"</em> cookie.<br> If a user logs in to a <em>fresh</em> java session (i.e. <code>session.getAttribute("auth")==null</code>), but still has this <em>"authenticated"</em> then you know that they're re-using an existing browser session and are <em>probably</em> re-using existing HTTP authentication credentials. In that case you do the <code>401</code> trick to force them to give new credentials.</p> <p><strong>Unsecured root URL</strong><br> If your root URL is unsecured, and you know that this is the URL that your users always login to, then you can simply put your "auth"/<code>401</code> check at that URL, and it will solve the problem. But make sure you don't accidentally open a security hole.<br> This URL should not have any functionality other than redirecting users to the "real" app (that is secured)</p> <p><strong>Single secured URL</strong><br> Have 1 URL that is secured (e.g. "/login").<br> As well as your "auth"/<code>401</code> filter, have another filter (or additional code in the same filter) on all pages (other than login) that checks whether <code>request.getUserPrincipal()</code> is set. If not, redirect the user to "/login".</p> <p><strong>The <em>much</em> easier solution</strong><br> Just use a FORM login method instead of BASIC authentication. It's designed to solve this problem.</p>
27,769,205
0
Swift Dictionary of Arrays <p>I am making an app that has different game modes, and each game mode has a few scores. I am trying to store all the scores in a dictionary of arrays, where the dictionary's key is a game's id (a String), and the associated array has the list of scores for that game mode. But when I try to initialize the arrays' values to random values, Swift breaks, giving me the error below. This chunk of code will break in a playground. What am I doing wrong?</p> <pre><code>let modes = ["mode1", "mode2", "mode3"] var dict = Dictionary&lt;String, [Int]&gt;() for mode in modes { dict[mode] = Array&lt;Int&gt;() for j in 1...5 { dict[mode]?.append(j) let array:[Int] = dict[mode]! let value:Int = array[j] //breaks here } } </code></pre> <p>ERROR:</p> <pre><code>Execution was interrupted, reason: EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP, subcode=0x0). </code></pre>
14,315,005
0
<p>Here is what I would do: I would write a static function for formatting your dates (either using my own class or extending Kohana <code>Date</code> class). I would use this function in your view directly:</p> <pre><code>&lt;?php echo SomeClass::date_format($result-&gt;time_start, $result-&gt;time_finished) ?&gt; </code></pre> <p>Why in the view? Because the function is used for formatting, it doesn't actually return different data set.</p>
37,145,127
0
java.lang.ClassCastException: org.glassfish.jersey.jackson.internal.JacksonAutoDiscoverable cannot be cast to spi.AutoDiscoverable <p>I am new to implementing REST API services. I have tried the simple resources to implement. unfortunately I stuck with this exception. I have googled and tried many options but no luck. I am unsure what am doing wrong. Please help me.</p> <ol> <li>Created a Dynamic Web project "JersyJson"</li> <li>Created a resouce named - JSONService.java (source is from googling)</li> <li>Created a Java Bean class - Track.java (source is from googling)</li> <li>Converted the project into Maven project</li> <li>Created a Application file - JersyJson.java file for Application Annotation</li> <li>using the latest Jersy Jars (version: 2.22.2)</li> <li>Imported &amp; configured jersey-media-json-jackson and jersey-media-moxy jars (2.22.2) in pom.xml</li> </ol> <p><strong>Pom.xml</strong></p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;JersyJson&lt;/groupId&gt; &lt;artifactId&gt;JersyJson&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;war&lt;/packaging&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt; &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt; &lt;version&gt;2.0.1&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt; &lt;!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" --&gt; &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt; &lt;version&gt;2.22.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-json-jackson&lt;/artifactId&gt; &lt;version&gt;2.22.2&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt; &lt;version&gt;2.22.2&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.3&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;1.8&lt;/source&gt; &lt;target&gt;1.8&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;version&gt;2.6&lt;/version&gt; &lt;configuration&gt; &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt; &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p><strong>Web.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt; &lt;display-name&gt;JersyJson&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;javax.ws.rs.core.Application&lt;/servlet-name&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;javax.ws.rs.core.Application&lt;/servlet-name&gt; &lt;url-pattern&gt;/json/metallica/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p><strong>JersyJson.java (ApplicationAnnotation file)</strong></p> <pre><code>@ApplicationPath("json") public class JersyJson extends ResourceConfig { public JersyJson() { packages("com.sai.jersyjson"); } } </code></pre> <p><strong>JSONservice.java:</strong></p> <pre><code>package com.sai.jersyjson; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @Path("/json/metallica") public class JSONService { @GET @Path("/get") @Produces(MediaType.APPLICATION_JSON) public Track getTrackInJSON() { Track track = new Track(); track.setTitle("Enter Sandman"); track.setSinger("Metallica"); return track; } @POST @Path("/post") @Consumes(MediaType.APPLICATION_JSON) public Response createTrackInJSON(Track track) { String result = "Track saved : " + track; return Response.status(201).entity(result).build(); } } </code></pre> <p><strong>Track.java (simple bean class)</strong></p> <pre><code>package com.sai.jersyjson; public class Track { String title; String singer; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getSinger() { return singer; } public void setSinger(String singer) { this.singer = singer; } @Override public String toString() { return "Track [title=" + title + ", singer=" + singer + "]"; } } </code></pre> <p><strong>After I run this project in Eclispe using Tomcat webserver, I get the following error with 404-Error Status</strong></p> <p>SEVERE: StandardWrapper.Throwable java.lang.ClassCastException: org.glassfish.jersey.jackson.internal.JacksonAutoDiscoverable cannot be cast to org.glassfish.jersey.internal.spi.AutoDiscoverable at org.glassfish.jersey.model.internal.CommonConfig$2.compare(CommonConfig.java:594) at java.util.TreeMap.put(Unknown Source) at java.util.TreeSet.add(Unknown Source) at java.util.AbstractCollection.addAll(Unknown Source) at java.util.TreeSet.addAll(Unknown Source) at org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:616) at org.glassfish.jersey.server.ResourceConfig.configureAutoDiscoverableProviders(ResourceConfig.java:811) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:447) at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:347) at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:392) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1238) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4996) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)</p>
15,968,895
0
<p>This is by design. When changing the writing direction, everything is reversed: left becomes right and right becomes left. So you need <code>Element.ALIGN_LEFT</code> instead of <code>Element.ALIGN_RIGHT</code>.</p>
24,854,481
0
<p>You should add following line of code to your script:</p> <pre><code>If InStr(nshow, Sheets("Sheet2").Cells(i, j).Value) = 0 Then End If </code></pre> <p>Basically InStr function here checks if current iterated value is already in nshow array.</p> <p>If yes - it does nothing, if no (function returns 0) - it lets the inside block of code being run and as a result of this the new value is being added to the nshow array.</p> <p>Finally your code should look like this:</p> <pre><code>Dim txt, show As String Dim NameList(1 To 50) As Variant Dim i, j, t As Integer t = 1 For i = 1 To 10 For j = 1 To 5 If InStr(nshow, Sheets("Sheet2").Cells(i, j).Value) = 0 Then NameList(t) = Sheets("Sheet2").Cells(i, j).Value nshow = nshow &amp; i &amp; " " &amp; t &amp; " " &amp; NameList(t) &amp; vbCrLf t = t + 1 End If Next j Next i MsgBox nshow </code></pre>
21,984,914
0
<p>You can use the view's <code>controller</code> <a href="http://emberjs.com/api/classes/Ember.View.html#property_controller" rel="nofollow">property</a> to access the controller. Using this property, you can access it in the <code>didInsertElement</code> handler like this.</p> <pre><code>var controller = this.get('controller'); </code></pre>
31,860,607
0
How to determine ODBC supported join operators - Cross Join <p>Given an ODBC connection string, I'm trying to determine whether this connection supports cross joining.</p> <p>Currently I use the following code to determine the supported join operators:</p> <pre><code>(SupportedJoinOperators)connection.GetSchema("DataSourceInformation").Rows[0]["SupportedJoinOperators"] </code></pre> <p>But this only gives me Inner, Left, Right and Full joins. </p> <p>For example, if a connection string uses the <em>microsoft text driver (</em>.txt <em>.csv)</em>, the supported join operators are left and right, and the driver actually doesn't support the cross join operator (fails with a message of incorrect syntax).</p> <p>Using workarounds doesn't guarantee a correct answer, as I gather from <a href="http://blog.jooq.org/2014/02/12/no-cross-join-in-ms-access/" rel="nofollow">this</a> link.</p> <p>I also thought of trying a lower level, like using Pinvoke with the ODBC API like <code>SqlGetInfo</code> or <code>SqlGetFunctions</code> but it seems like a dead end.</p> <p>Any help will be greatly appreciated!</p>
16,109,688
0
<p>Happens to me as well see a device is registered. But not from localhost: 8888 does not find any device.</p> <p>There is no official forum google apps?</p>
12,373,665
0
<p>Example 1: imagine having 5 different sorting algorithms. you just want to sort in all sorts of places, but you don't want to select between the 5 in each and every place you do it. instead, you have a pointer to the sorting algorithm (they all take the same parameters, types, etc.). simply select an algorithm once (set the pointer) and use the pointer to sort everywhere.</p> <p>Example 2: callback... a function does something in a loop but needs application feedback every iteration. to that function, the callback is a function pointer that's passed as an argument.</p>
15,130,490
0
<p>for server info add the following lines in apache2.conf</p> <pre><code>ServerTokens ProductOnly ServerSignature Off </code></pre> <p>For PHP info </p> <p>in your php.ini</p> <p>turn</p> <pre><code>expose_php = off </code></pre>
25,276,484
0
<p>Your performance is pretty good. Your problem is that you're being abused by, what sounds like poor coding, in the sproc you mentioned. So, let's say you manage to improve the performance of your query by 90% and soon after the sproc starts calling your query 20,000 times... you're back where you started. </p> <p>I would begin by investigating the problem sproc to see if there's a better solution than thousands of calls in a short period of time. Could be a simple fix of not calling a query from a loop, as a simple example. The client code could also use caching instead of calling a query repeatedly for data that doesn't change much.</p> <p>If you want to follow the performance route then I would suggest denormalizing. Since your query results are boxed by week, denormalizing is actually a good solution. You would create another table and populate it with results from your query... You would also not be calling tour subqueries all the time. SQL Server usually optimizes for that but it's definitely something worth trying. </p> <p>Good luck. </p>
7,631,459
0
Is there a way to add new items to enum in Objective-C? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3124012/possible-to-add-another-item-to-an-existing-enum-type">Possible to add another item to an existing enum type?</a> </p> </blockquote> <p>Say I have a class <code>Car</code> with the following enum defined:</p> <pre><code>typedef enum { DrivingForward, DrivingBackward } DrivingState; </code></pre> <p>Then, let's say I have a subclass of <code>Car</code> called <code>Tesla</code> and it happens to drive sideways too. Is there a way for <code>Tesla</code> to add new items to that original enum so that the final enum becomes like the following?</p> <pre><code>typedef enum { DrivingForward, DrivingBackward, DrivingLeft, DrivingRight } DrivingState; </code></pre>
38,012,171
0
<p><a href="http://stackoverflow.com/a/38012152/1163423">sodawillow provided a valid answer</a>. Howevery, you can simplify this using <code>-notin</code>:</p> <pre><code>if ($SER -notin 'Y', 'N') { Write-Host "ERROR: Wrong value for services restart" -ForegroundColor Red } </code></pre>
39,272,813
0
<p>If you run jhipster project with default elasticsearch configuration then be sure that your elasticsearh server version is 1.7 because jhipster java project works with this version(in production profile) </p> <p>In development profile there was such a problem which I couldn't solve yet</p>
11,517,151
0
How to manually install .Net 4.0.x and 4.5 on XP <p>XP isn't a supported OS for .NET 4.5. This is a known issue.</p> <p>I read a few months back that the reason XP can't install 4.5 is because there are kernel API that 4.5 calls which don't exist on XP. I also read that it would be possible to inject your own implementation of the 'new' kernel calls to an XP machine - and 4.5 <em>could</em> run.</p> <p>I can no longer find this information. Does anyone know more about this?</p> <p>A second, but related, question is - how can I take upgraded .Net 4.0 libraries from a windows 7 machine (which had 4.5 installed) and inject them into an xp machine? I believe I read that the implemention files of 4.5 are actually the same as the 4.0 files, there are not two sets. And in fact, the two .net folders (4.0 and 4.5) are only the interfaces - which link back to these same files. If this is the case, then a manual injection of the 4.0 files would likely need the solution to my first question.</p> <p>In short - does anyone have more information about hacking/manually upgraded .net for xp?</p>
72,616
0
Embed data in a C++ program <p>I've got a C++ program that uses SQLite. I want to store the SQL queries in a separate file -- a plain-text file, <em>not</em> a source code file -- but embed that file in the executable file like a resource.</p> <p>(This has to run on Linux, so I can't store it as an actual resource as far as I know, though that would be perfect if it were for Windows.)</p> <p>Is there any simple way to do it, or will it effectively require me to write my own resource system for Linux? (Easily possible, but it would take a lot longer.)</p>
7,648,083
0
<p>Generally there are 2 approaches:</p> <h2><a href="https://github.com/cucumber/cucumber/wiki/Background">Backgrounds</a></h2> <p>If you want a set of steps to run before <em>each</em> of the scenarios in a feature file:</p> <pre><code>Background: given my app has started then enter "guest" in "user-field" and enter "1234" in "password-field" and press "login" then I will see "welcome" Scenario: Some scenario then *** here's the work specific to this scenario *** Scenario: Some other scenario then *** here's the work specific to this scenario *** </code></pre> <h2><a href="https://github.com/cucumber/cucumber/wiki/Calling-Steps-from-Step-Definitions">Calling steps from step definitions</a></h2> <p>If you need the 'block' of steps to be used in different feature files, or a Background section is not suitable because some scenarios don't need it, then create a high-level step definition which calls the other ones:</p> <pre><code>Given /^I have logged in$/ do steps %Q { given my app has started then enter "guest" in "user-field" and enter "1234" in "password-field" and press "login" then I will see "welcome" } end </code></pre> <hr> <p>Also, in this case I'd be tempted <em>not</em> to implement your common steps as separate steps at all, but to create a single step definition: (assuming Capybara)</p> <pre><code>Given /^I have logged in$/ do fill_in 'user-field', :with =&gt; 'guest' fill_in 'password-field', :with =&gt; '1234' click_button 'login' end </code></pre> <p>This lends a little bit more meaning to your step definitions, rather than creating a sequence of page interactions which need to be mentally parsed before you realise 'oh, this section is logging me in'.</p>
27,875,839
0
<p>It looks like your are trying to produce/recieve json output. I see two problems with your approach. 1) You didn't specify the application/json in your Accept header 2) You need to specify produces="application/json" in your @RequestMapping</p>
8,785,063
0
Excel VBA: Get Last Cell Containing Data within Selected Range <p>How do I use Excel VBA to get the last cell that contains data within a specific range, such as in columns A and B <code>Range("A:B")</code>? </p>
28,982,680
0
<p>Yes. All SQL Server releases, from 2005 to 2014 inclusive, are <a href="http://rusanu.com/2007/11/28/is-service-broker-in-sql-server-2008-compatible-with-the-one-in-sql-server-2005/" rel="nofollow">compatible with each other at the Service Broker</a> layer. In fact the 2008 instances are not even going to be able to figure out they are talking to 2014.</p> <p>You should be able to migrate one machine at a time, w/o taking down everything. If the upgrades are don in-place (keeping the machine name the same and preserving the SSB endpoint settings) then you won't have to change anything after the upgrade, it should just keep working.</p> <p>If you do side-by-side upgrade then you will have to port the SSB endpoint settings and certificates used from one instance to the other, along with moving the database.</p> <p>Keep in mind that if you have a problem and you are forced to rollback to a backup then your entire, distributed, system state will not be consistent (basically conversations will no longer match the send sequence number and receive sequence numbers) and you may have to force some close conversations (manual END ... WITH CLEANUP on a case by case) or nuke the entire broker in the DB (ALTER DATABASE ... SET NEW_BROKER). Lets hope you won't have to do this. If is feasible then you could simply stop the entire system (eg. run ALTER ENDPOINT ... STATE = STOPPED on all 3 nodes to stop all SSB communication) and then do a backup and then do the upgrade, now being safe to rollback the upgrade and restore since everythign is 'frozen'.</p>
16,280,149
0
<p>It may be that you don't have a default image viewer set. Try opening the image file outside of the program and see if it asks you to select a program or just opens in another program.</p>
27,731,795
0
<p>Yes its absolutely possible to post an array data and the code you wrote at client side to post data is correct.</p> <p>The status code <code>400</code> you are getting must be due to problem at your server side code. I see a method <strong>createBatchSavings</strong> in your server side code but your URL at client side is lower case, <strong>batchsavings</strong>.</p> <p>This is just an hint. You need to add more information about server side code.</p>
22,121,840
0
OrderBy(propertyName) for complex types <p>I have </p> <pre><code>class User { public string Name {get; set; } } </code></pre> <p>and</p> <pre><code>class Example { public virtual User user {get; set; } } </code></pre> <p>they are 1..N relation and I'm using EF and that all works fine, but I want to do </p> <pre><code>var model = examples.OrderBy("user.Name"); </code></pre> <p>where examples is IQueryable of Examples and I get error that Example has no property of user.Name. Why is that? Can I specify my compare rules for class User? I tried implementing ICompare and IComparable with no success.</p> <p>EDIT: this is the extension for orderBy, how can I modify it to be able to use it for my example</p> <pre><code>public static IQueryable OrderBy(this IQueryable source, string propertyName) { var x = Expression.Parameter(source.ElementType, "x"); var selector = Expression.Lambda(Expression.PropertyOrField(x, propertyName), x); return source.Provider.CreateQuery( Expression.Call(typeof(Queryable), "OrderBy", new Type[] { source.ElementType, selector.Body.Type }, source.Expression, selector )); } } </code></pre>
30,398,442
0
Apply a LowPassFilter for a period of time, then fade it back to normal? <p>I'm trying to achieve the very common effect you often have in FPS games when you are hit by a grenade.. When you are hit, a LP Filter kicks in at a low frequency, wait for a couple of seconds before fading it back to normal. How is this effect created? I'm using C# and Unity 5. I've tried to google it, but there seems to be very little information about this subject.</p> <p>My code so far isn't super sexy, I've deleted about everything 250 times in a row now and I'm starting to lose my patience with myself :P</p> <pre><code>using UnityEngine; using System.Collections; public class DamageHandler : MonoBehaviour { [Range(5000, 22000)] public int standardLpFreq = 22000; [Range(10, 500)] public int hitLpFreq = 280; public float timeToHaveEffect = 4f; private AudioLowPassFilter lpFilter; void Awake() { lpFilter = Camera.main.GetComponent&lt;AudioLowPassFilter&gt; (); if (!lpFilter) { Camera.main.gameObject.AddComponent&lt;AudioLowPassFilter&gt;(); lpFilter = Camera.main.GetComponent&lt;AudioLowPassFilter&gt;(); } InitLPFilter (); } private void InitLPFilter() { lpFilter.cutoffFrequency = standardLpFreq; } } </code></pre>
32,000,533
0
Monogame mouse in windows 10 feels press only after move <p>I have monogame (3.4) XAML application for windows store (VS2012 on Win10). In my game's Update() I call attched code to receive toutch events. In windows 8/8.1 everything worked, but in windows 10 I have to hold button and move mouse several times to get ButtonState.Pressed - for end user this looks like mouse doesn't work at all. How can I manage this bug?</p> <p>Mouse event receive code:</p> <pre><code> MouseState st = Mouse.GetState(); if (st.LeftButton == ButtonState.Pressed) { if (prevMouseState == ButtonState.Released) { prevMouseValX = st.X; prevMouseValY = st.Y; pushEvent(EVT_POINTER_DOWN, (int)(st.X - mScrBiasX), (int)(st.Y - mScrBiasY), 1, 0); } else { if (Math.Abs(st.X - prevMouseValX) &gt; 2 || Math.Abs(st.Y - prevMouseValY) &gt; 2) pushEvent(EVT_POINTER_MOVE, (int)(st.X - mScrBiasX), (int)(st.Y - mScrBiasY), 1, 0); } prevMouseState = ButtonState.Pressed; } if (st.LeftButton == ButtonState.Released) { if (prevMouseState == ButtonState.Pressed) { pushEvent(EVT_POINTER_UP, (int)(st.X - mScrBiasX), (int)(st.Y - mScrBiasY), 1, 0); } prevMouseState = ButtonState.Released; } </code></pre>
18,006,262
0
<p>I'm assuming that the version of mongo listed in phpinfo is 1.2 -- MongoClient class wasn't out until v1.3</p> <p>if so, you need to update mongodb to the newer version.</p> <p><a href="https://bugs.launchpad.net/ubuntu/+source/php-mongo/+bug/1096587" rel="nofollow">https://bugs.launchpad.net/ubuntu/+source/php-mongo/+bug/1096587</a></p>
14,655,974
0
<pre><code>my $newvar = $text =~ m/ quick (.*) dog /; </code></pre> <p>is an assignment in scalar context, and assigns either <code>1</code> or <code>undef</code>.</p> <p>You want to make this assignment in list context</p> <pre><code>my ($newvar) = $text =~ m/ quick (.*) dog /; </code></pre> <p>which assigns the captured groups from the regular expression.</p> <p>The difference between scalar and list contexts is one of the trickiest things to get used to in Perl.</p> <p>Note that captured groups from regular expressions in Perl also get assigned to the special variables <code>$1</code>, <code>$2</code>, ... . So you also could just have said</p> <pre><code>print "$1\n"; </code></pre>
23,743,295
0
Regexp for removing certain IMG tags <p>Need a regexp to remove all the HTML tags like:</p> <pre><code>&lt;img border="0" alt="" src="/images/stories/j25.png"&gt; </code></pre>
37,973,299
0
<p><a href="http://www.tutorialspoint.com/python/python_strings.htm" rel="nofollow">Strings in python</a> are declared using double or single quotes, therefore the variable <strong>data</strong> contains a string. You can check the type of a variable directly in python:</p> <pre><code>data = "000000000000000117c80378b8da0e33559b5997f2ad55e2f7d18ec1975b9717" type(data) </code></pre> <p>which outputs</p> <pre><code>str </code></pre> <p>meaning that the variable is a string. When you call the function decode('hex') on a string you obtain another string:</p> <pre><code>data.decode('hex') '\x00\x00\x00\x00\x00\x00\x00\x01\x17\xc8\x03x\xb8\xda\x0e3U\x9bY\x97\xf2\xadU\xe2\xf7\xd1\x8e\xc1\x97[\x97\x17' </code></pre> <p>Every character in your original string is interpreted as an hexadecimal number, and every pairs of hexadecimal numbers - e.s. "17" - is converted into an hexadecimal character using the escape sequence \x - becoming "\x17".</p> <p>When you write "\x41" you are basically telling python to interpret 41 as a single ASCII character whose hexadecimal representation is 41.</p> <p>The <a href="http://www.asciitable.com/" rel="nofollow">ASCII table</a> contains the hexadecimal, decimal and octal values associated to the ascii characters.</p> <p>If you try for example</p> <pre><code>"48454C4C4F".decode('hex') </code></pre> <p>you obtain the string "HELLO"</p> <p>Lastly when you use [::-1] on a string you reverse it:</p> <pre><code>"48454C4C4F".decode('hex')[::-1] </code></pre> <p>produces the string "OLLEH"</p> <p>You can find more about the escape characters reading the <a href="https://docs.python.org/2.0/ref/strings.html" rel="nofollow">python documentation</a>.</p>
19,967,542
0
<p>You might want to preprocess the file. Say make a cache while each word maps to the set of lines it contains so you can just fetch it and return them. </p>
14,494,070
0
How to resolve java.net.SocketException Permission Denied error? <p>I have already included the Internet Permissions in the andoird manifest page, still the error seems to persist. I am also recieveing an unknown host excption in the similar code. Kindly guide me through! Ty! :)</p> <pre><code>package name.id; import android.app.Activity; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import org.ksoap2.*; import org.ksoap2.serialization.*; import org.ksoap2.transport.*; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class FirstPage extends Activity implements android.view.View.OnClickListener { /** Called when the activity is first created. */ TextView tv; Button bu; EditText et; private static final String SOAP_ACTION="http://lthed.com/GetFullNamefromUserID"; private static final String METHOD_NAME="GetFullNamefromUserID"; private static final String NAMESPACE="http://lthed.com"; private static final String URL="http://vpwdvws09/services/DirectoryService.asmx"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); et=(EditText) findViewById(R.id.editText1); tv=(TextView) findViewById(R.id.textView2); bu=(Button) findViewById(R.id.button1); bu.setOnClickListener((android.view.View.OnClickListener) this); tv.setText(""); } public void onClick(View v) { // creating the soap request and all its paramaters SoapObject request= new SoapObject(NAMESPACE, METHOD_NAME); //request.addProperty("ID","89385815");// hardcoding some random value //we can also take in a value in a var and pass it there //set soap envelope,set to dotnet and set output SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); soapEnvelope.dotNet=true; soapEnvelope.setOutputSoapObject(request); HttpTransportSE obj = new HttpTransportSE(URL); //to make call to server try { obj.call(SOAP_ACTION,soapEnvelope);// in out parameter SoapPrimitive resultString=(SoapPrimitive)soapEnvelope.getResponse(); //soapObject or soapString tv.setText("Status : " + resultString); } catch(Exception e) { tv.setText("Error : " + e.toString()); //e.printStackTrace(); } } } </code></pre>
38,110,092
0
<p>Put the <code>.append()</code> inside the loop:</p> <pre><code>def main(): Sqrs() def Sqrs(): import math lstSquares = [] for i in range(1,11): math.pow(i,2) lstSquares.append(math.pow(i,2)) ShowResults(lstSquares) def ShowResults(lstSquares): print(lstSquares) main() </code></pre> <p>Result:</p> <pre><code>[1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0, 81.0, 100.0] </code></pre>
34,679,384
0
SharePoint send notification by assignation <p>I created in SharePoint a list. It has several columns, one of these columns is called assined to. It contains one or more person. What i want, is that an email is send to the new person/s, if a new person is added to this column. Now i searched a little bit, and found out that I should use Workflows to solve this problem. But the problem is the Workflow is started only automaticly if any changes are made in an element or when an element is created. </p> <p>So my question is, is theire a possibility to trigger an email by content changes in a specified column.</p> <p>By the way im working with a list in SharePoint 2013.</p>
15,151,927
0
<p>1: You cannot make image clickable in one area and nonclickable in another. But you can get color of pixel under mouse and ignore ckicks over transparent pixels</p> <pre><code>import flash.events.MouseEvent; import flash.display.BitmapData; var rabbitBitmap:BitmapData = new BitmapData(rabbit.width, rabbit.height, true, 0xFFFFFFFF); rabbitBitmap.draw(rabbit); addEventListener(MouseEvent.MOUSE_MOVE, mmh) rabbit.addEventListener(MouseEvent.CLICK, mch) rabbit.buttonMode = true; function mmh(e:MouseEvent):void { rabbit.useHandCursor = getAlpha() != 255; } function mch(e:MouseEvent):void { if (getAlpha() != 255) { // ... do someth } } function getAlpha ():int { var rgba:uint = rabbitBitmap.getPixel32(rabbit.mouseX, rabbit.mouseY); return rgba &amp; 0xff; } </code></pre> <p>2: Use vector graphics for your rabbit :)</p>
35,905,699
0
Python: Make a file temporarily unexecutable <p>I'm writing a simple antivirus that checks for very specific files and patterns, and something I want to implement is a way to make a named file unexecuteable. By this I mean that the computer will realize that the file exists, and has a file extension that would usually launch an application or it's own code, but will not be able to execute it until the user gives the ok.</p> <p>So given the filename, how could I make a file unable to be executed by the windows operating system? </p>
5,125,210
0
<p>Let me start with this: I don't think a Python script is the best tool for the job. If you want to do enterprise-level management of updates (e.g., for all machines on a network), then you should seriously consider using <a href="http://www.microsoft.com/windows/enterprise/products/windows-7/management.aspx" rel="nofollow">the existing MS tools</a>. </p> <p>With that said, here is how you might go about this:</p> <ol> <li><p>Have a look at the <code>windows-update</code> tag on ServerFault, one of StackOverflow's sister sites: <a href="http://serverfault.com/questions/tagged/windows-update">http://serverfault.com/questions/tagged/windows-update</a> . A lot of the questions seem to cover command-line control of the update process. Keep in mind that the command line tools vary significantly between e.g. Windows XP on the one hand and Vista/7 on the other. With some luck, you should be able to use windows built-in commands rather than going to the windows update website programmatically.</p></li> <li><p>Assuming you find the command-line incantations that you need: Use the <a href="http://docs.python.org/library/subprocess.html" rel="nofollow">subprocess</a> module to call to the shell and execute those commands programmatically. Because you're using python, you may need to spend quite a bit of time parsing the command outputs to figure out how your shell calls are doing.</p></li> </ol> <p>Hope that helps. I realize this is a rather high-level answer, but as it stands, the question is not very specific about what exactly you want to accomplish and why you're using python to do it. </p>
25,930,365
0
<p>it can be <strong>fixed easly</strong> but radicaly, just go to the folder where you have stored <strong>mdf file</strong>. select file-> Right click ->click on properties and <strong>give full permissions to file for logged in user Security</strong>.</p>
27,747,889
0
<p>As per your error messages:</p> <blockquote> <p><code>01-03 00:25:57.443 2371-2387/com.example.androidhive E/JSON Parser﹕ Error parsing data org.json.JSONException: Value &lt;br&gt;&lt;table of type java.lang.String cannot be converted to JSONObject</code></p> </blockquote> <p><code>&lt;br&gt;&lt;table</code> is <strong>NOT</strong> JSON. E.g. your fetched data is html, not json. Since it's not JSON, the json parser barfs, and here we are...</p>
16,569,984
0
Adding a fadeOut to tabs <p>I'd like to add a fadeout to the tabs <a href="http://www.inside-guides.co.uk/brentwood/restaurants/chinese-restaurants/mizu-brentwood-402.html" rel="nofollow">on my page here</a>, if someone could help with the javascript side?</p> <p>Here's the html:</p> <pre><code>&lt;ul class="tabs clearfix"&gt; &lt;li class="aboutustab active" style="border-left:1px solid #ccc;"&gt;&lt;div class="up"&gt;&lt;/div&gt;About&lt;/li&gt; &lt;li class="maptab"&gt;&lt;div class="up"&gt;&lt;/div&gt;Map&lt;/li&gt; &lt;li class="featurestab"&gt;&lt;div class="up"&gt;&lt;/div&gt;Features&lt;/li&gt; &lt;li class="voucherstab"&gt;&lt;div class="up"&gt;&lt;/div&gt;Offers&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And the here's the javascript:</p> <pre><code>$(window).load(function(){ $('.tab:not(.aboutus)').hide(); $('.tabs li').click(function(){ var thisAd = $(this).parent().parent(); $(thisAd).children('.tab').hide(); $(thisAd).children('.'+$(this).attr('class').replace('tab','')).show(); $('.tabs li').removeClass('active'); $(this).addClass('active'); }); if(window.location.hash) { if (window.location.hash == "#map") { $(".Advert").children('.tab').hide(); $(".Advert").children('.map').show(); $('.tabs li').removeClass('active'); $('.maptab').addClass('active'); } if (window.location.hash == "#voucher") { $(".Advert").children('.tab').hide(); $(".Advert").children('.vouchers').show(); } } }); </code></pre> <p>I have the <a href="http://twitter.github.io/bootstrap/javascript.html#transitions" rel="nofollow">bootstrap.js plugin</a> from here and would like to use that, if anyone was familiar with that it'd be ideal.</p> <p><a href="http://www.inside-guides.co.uk/brentwood/pages/advertise.html" rel="nofollow">Here's how I would like it to work.</a></p> <p>Update: This is what I have now, but the fade effect is different for each tab almost - I like the transition back to the About Us tab which isn't as "heavy" as the transition of the others. The offers tab is leaving remnants of the 'Features' tab content too.</p> <pre><code> $(window).load(function(){ $('.tab:not(.aboutus)').fadeOut(); $('.tabs li').click(function(){ var thisAd = $(this).parent().parent(); $(thisAd).children('.tab').fadeOut(); $(thisAd).children('.'+$(this).attr('class').replace('tab','')).fadeIn(); $('.tabs li').removeClass('active'); $(this).addClass('active'); }); newContent.hide(); currentContent.fadeOut(750, function() { newContent.fadeIn(500); currentContent.removeClass('current-content'); newContent.addClass('current-content'); }); if(window.location.hash) { if (window.location.hash == "#map") { $(".Advert").children('.tab').fadeOut(750); $(".Advert").children('.map').fadeIn(500); $('.tabs li').removeClass('active'); $('.maptab').addClass('active'); } if (window.location.hash == "#voucher") { $(".Advert").children('.tab').fadeOut(750); $(".Advert").children('.vouchers').fadeIn(500); } } }); </code></pre>
32,183,873
0
Undefined property: Loader::$cart in opencart <p>I'm using a latest version of opencart,here i trying to display products that are added in shopping cart, while adding i'm getting that error "Undefined property: Loader::$cart" this error caused by $this->cart->getProducts() </p> <p>how to fix this error. </p>
31,193,716
0
UITabBarController - transition from one tab's navigation stack to a view controller of another tab's navigation stack <p>Novice iOS developer here. I am making a simple tabbed chat application in Swift using a UITabBarController. For simplicity, let's assume the application only has two tabs, "Contacts" and "Chats". Each of the two tabs has a navigation controller. </p> <p>The "Chats" navigation stack begins with a UITableViewController called "ChatsTableViewController" which lists the user's chats. When the user selects a chat, the app segues to a MessagesViewController which displays the messages for the selected chat.</p> <p>The "Contacts" navigation stack includes a UITableViewController which lists the user's contacts. Upon selecting a contact, another view controller is presented modally, asking the user whether they would like to begin a chat with the selected contact, and giving them the option to cancel. If the user chooses to begin a chat, I would like to transition from this modal view controller to the MessagesViewController of the "Chats" tab, passing the information necessary to display the chat (which I have at the ready in the modal view controller).</p> <p>When the MessagesViewController loads, regardless of whether we get to it by selecting a chat from the "Chats" tab or by creating a new chat from the "Contacts" tab, it should have a navigation bar at the top with a "Back" button that takes the user to the ChatsTableViewController.</p> <p>I have done a good deal of searching, but have not found any solutions that fit what I need. Any suggestions would be greatly appreciated! Here is a summary of what I am looking for.</p> <ol> <li>Standard way to perform a transition from a view controller in one tab's navigation stack to a view controller (that is not the root view controller in my case) of another tab's navigation stack, while passing relevant information to display in the destination view controller.</li> <li>The view controller I transition to should have a navigation bar with a back button that takes the user to the previous view controller in its navigation stack, just as if they had accessed it from the normal navigation flow of the tab.</li> </ol> <p><strong>EDIT</strong>: I've found that you can easily switch tabs programmatically using <code>self.tabBarController?.selectedIndex = index_of_tab_to_switch_to</code>, however, this takes me to the first view of the tab and I am still unsure of how I can pass data. Any thoughts on how I can proceed? </p>
18,837,792
0
<pre><code> CHOICE /C ABCDEFGHIJKLMNOPQRSTUVWXYZ /N echo %errorlevel% </code></pre>
38,889,484
0
CoffeeScript code only works after press home menu <p>I am using Rails 5. I have a <code>home_controller</code> with index action and <code>root 'home#index'</code>. There's a button on index.html.erb, i want to press this button call some js code (pop window).</p> <p>But my coffee script code only was call after i press <strong>Home</strong> menu. So i am wondering <code>/</code> and <code>home#index</code> are different? Thank you for your help.</p> <p><strong>application.html.erb</strong></p> <pre><code>&lt;nav&gt; &lt;li&gt;&lt;%= link_to "Home", "/"%&gt;&lt;/li&gt; &lt;/nav&gt; </code></pre> <p><strong>index.html.erb</strong></p> <pre><code>&lt;button id="myBtn"&gt;Open Modal&lt;/button&gt; &lt;div id="myModal" class="modal"&gt; &lt;div class="modal-content"&gt; &lt;span class="close"&gt;×&lt;/span&gt; &lt;p&gt;Some text in the Modal..&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;%= render :partial =&gt; 'stories/stories' %&gt; </code></pre> <p><strong>home.coffee</strong></p> <pre><code>modal = document.getElementById('myModal'); btn = document.getElementById("myBtn"); span = document.getElementsByClassName("close")[0]; btn.onclick = -&gt; modal.style.display = "block" span.onclick = -&gt; modal.style.display = "none" window.onclick = (event) -&gt; modal.style.display = "none" if event.target == modal </code></pre>
19,054,048
0
<p>The answer to this is to use intermediate layouts. </p> <pre><code>[self.collectionView setCollectionViewLayout: layoutForStepOne animated:YES completion:^(BOOL finished) { [self.collectionView setCollectionViewLayout: layoutForStepTwo animated:YES completion:^(BOOL finished) { [self.collectionView setCollectionViewLayout: layoutForStepThree animated:YES]; }]; }]; </code></pre>
22,520,566
0
css style for a button-like <div> <p>I am trying add in my project to simulate a popup window (where later I will add content from others pages from my application). I have the follow code:</p> <p><strong>html</strong></p> <pre><code>&lt;div id="box"&gt; &lt;div id="title"&gt;Titulo &lt;span id="button"&gt;X&lt;/span&gt; &lt;/div&gt; &lt;div id="text"&gt;Conteudo&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>javascript/jquery</strong></p> <pre><code>$('window').load(function(){ $('#box').draggable(); }); </code></pre> <p><strong>css</strong></p> <pre><code>#box { box-sizing: padding-box; box-shadow: 10px 5px 5px black; border-style: solid; position: absolute; width: 320px; height: 640px; min-width: 160px; min-height: 500px; max-width: 500px; max-height: 750px; top: 200px; left: 200px; } #button { background-color: red; padding: 0px 0px 0px 95%; min-width: 32px; max-width: 5%; position:absolute; } #title { background-color: black; text-decoration-color: white; font: 32px/36px arial; position: relative; } #text { background-color: white; text-decoration-color: black; font: 24px/28px sans-serif; position: relative; } </code></pre> <p>Bottom line: I want the element identified by id=button stay in the right corner of the title bar from my "window", but in this current state, that's what i got:</p> <p><a href="https://imgur.com/Og96LkY" rel="nofollow noreferrer"><img src="https://i.imgur.com/Og96LkY.png" title="Hosted by imgur.com" /></a></p> <p>how i can improve this to achieve what i want?</p> <p>ps.: i accept suggestion using jquery / jquery-ui. I try earlier BootstrapDialog, but don't serve for my project because dont't ajust itself according to loaded content and block the other contents from my page when it's open.</p>
1,255,891
0
<p>Maybe it won't be a full answer to your question, but here's what I've been able to find so far : there is some kind of a partial answer in the book "<strong>Extending and Embedding PHP</strong>", written by Sara Golemon (<a href="http://rads.stackoverflow.com/amzn/click/067232704X" rel="nofollow noreferrer">amazon</a> ; some parts are also available on google books).</p> <p>The relevant part <em>(a note at the top of page 56)</em> is :</p> <blockquote> <p>Ever wonder why some extensions are configured using <code>--enable-extname</code> and some are configured using <code>--with-extename</code>? Functionnaly, there is no difference between the two. In practice, however, <code>--enable</code> is meant for features that can be turned on witout requiring any third-party libraries. <code>--with</code>, by contrast, is meant for features that do have such prerequisites.</p> </blockquote> <p>So, not a single word about performance (I guess, if there is a difference, it is only a matter of "<em>loading one more file</em>" vs "<em>loading one bigger file</em>") ; but there is a technical reason behind this possibility.</p> <p>I guess this is done so PHP itself doesn't <strong>require</strong> an additionnal external library because of some extension ; using the right option allows for users to enable or disable the extension themselves, depending on whether or not they already have that external library.</p>
29,879,976
0
<p>I had the same problem and i was already applying the Judah answer before i found this topic after some googling. </p> <p>Well, imo the Judah answer is partially correct. I found a better answer <a href="https://social.msdn.microsoft.com/Forums/en-US/751637d8-2c98-49d1-a4d3-9bc0ef0996c1/runworkercompleted-not-capturing-exceptions?forum=csharplanguage" rel="nofollow">here</a></p> <p>The debugger is making the work well, if you run the application in "real-world conditions", the RunWorkerCompleted deals with the exception as expected and the application behavior is also the expected.</p> <p>I hope this answer helps.</p>
15,249,497
0
<p>selectedRow is populated after you click the row, while you are trying to loop trough it after binding the click handler, but before the actual click. You have to move that code in the click handler</p>
4,471,371
0
<p>This has nothing to do with calling revalidate as recommended by another and likely has all to do with calling a method on the wrong object. In your showEmployeesActionPerformed method you create a new Company object, one that is not visualized. The key is to call this method on the proper reference, on the visualized GUI. You do this by passing a reference to the visualized GUI object into the class that is wanting to call methods on it. This can be done via a setCompany method:</p> <pre><code>setCompany(Company company) { this.company = company); } </code></pre> <p>or via a constructor parameter.</p>
33,526,712
0
<p>Maybe cleaning and building your project fixes the problem?</p>
10,545,891
0
<p>It appears that you are using this database migration solely for populating the data. </p> <p>Database migrations are meant for changing the database schema, not for populating the database (though you can add some logic to populate the database after the change; for example, if you add a column - role to users table, you can add some custom logic to populate the newly added field for existing entries in users table). Refer to rails api - <a href="http://guides.rubyonrails.org/migrations.html" rel="nofollow">migrations</a> for details. </p> <p>If you forgot add the code to populate the database in your previous database migration, you can undo the previous migration and apply it again using: </p> <pre><code>rake db:rollback ... Edit the previous migration ..Add the code to populate rake db:migrate </code></pre> <p>If you just want to populate the database, you should seed the database instead. Watch <a href="http://railscasts.com/episodes/179-seed-data" rel="nofollow">this railscast</a> for more information.</p> <p>EDIT: To seed the database: </p> <p>Create a file called db/seeds.rb<br> Add the record creation code like this: </p> <pre><code>['Sampath', 'Suresh'].each do |name| User.create(role: 'admin', username: name) end </code></pre> <p>Then, </p> <pre><code>rake db:seed </code></pre> <p>This will read the seeds.rb and populate the database.</p>
31,613,860
0
<p>What's wrong with a <code>500 Internal Server Error</code>?! That's exactly what you experience. Your script is wrong and dies a sudden death; that's an internal error in your server. A <code>500</code> response signals to the client that there was an error which is not the fault of the client, so the client should not use whatever response it received and maybe try again later. That's exactly what must happen in this scenario and that's what <code>display_errors=off</code> does.</p>
20,295,820
0
<pre><code>#include &lt;stdio.h&gt; int inputFirstOne(void){ int ch; ch = getchar(); while('\n'!=getchar()); return ch; } int main(){ char a, b; a = inputFirstOne(); b = inputFirstOne(); printf("%c%c\n", a, b); return 0; } </code></pre>
11,206,773
0
memorystream contains bad xml markup when read <p>What is my issue here? When I write the stream back out to web, open the file it contains some of the content but all malformed and some missing.</p> <p>Am I experiencing loss of data due to a logic error?</p> <p><strong>Note:</strong> the readstream and writestream below mocks up what a service will be filling in. I will be receiving a stream to read from the service. I'll need to write that stream back out.</p> <pre><code> MemoryStream writeStream = new MemoryStream(); byte[] buffer = new byte[256]; OrderDocument doc = new OrderDocument(); doc.Format = "xml"; doc.DocumentId = "5555555"; doc.Aid = "ZZ"; doc.PrimaryServerPort = "PORT"; MemoryStream readStream = new MemoryStream(doc.GetDocument()); while (readStream != null &amp;&amp; readStream.Read(buffer, 0, buffer.Length) &gt; 0) { writeStream.Write(buffer, 0, buffer.Length); } writeStream.Flush(); writeStream.Position = 0; Response.Buffer = true; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "text/xml"; Response.ClearHeaders(); Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xml", doc.DocumentId)); Response.AddHeader("Content-Length", writeStream.Length.ToString()); Response.BinaryWrite(writeStream.ToArray()); Response.End(); </code></pre>
30,654,711
0
<p>In the original view controller add a IBAction that you want to handle the call back.</p> <p>In IB Control Drag from the cell to the Exit icon at the top of the view. On release you will see a a pop up menu with the name of available IBAction methods. Choose your IBAction method. </p> <p>I don't remember wether if you add a sender variable to the IBAction, you can retrieve info from it.</p>
11,566,824
0
<p>this is a problem with the lastest versions of Firefox and not your code. I have half a dozen sites that are not properly rendering css in firefox at this time. they were all fine not more than a week ago and no change to the code or codebase was made. the styles still work in other browsers. </p> <p>Firefox is having issues on thier current release of the browser and I am sure they are all aware of it, but really, if it does not get fixed soon, they will loose even more market share. which would be a shame really.</p>
2,210,564
0
<p>There is no way that this can happen. More often we think that there is bug in the language when we are sure that, we haven't done any thing wrong. But there is always some thing silly in the code. You must check the code again.</p>
4,458,273
0
Which CSS Selector is better practice? <p>I am wondering which selector is better practice and why?</p> <p><strong>Sample HTML Code</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;div class="main"&gt; &lt;div class="category"&gt; &lt;div class="product"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and we want to reach <code>.product</code> with CSS selectors:</p> <ol> <li><code>.product</code></li> <li><code>.main .category .product</code></li> <li><code>div.main div.category div.product</code></li> </ol> <p>I am comparing them to the following criteria:</p> <ul> <li>Performance</li> <li>Maintainability</li> <li>Readability</li> </ul> <p>We may assume that <code>.product</code> is unique throughout the page. We can have used id instead of class but in this case, we chose class attribute.</p>
18,101,538
0
Set timestamp on insert when loading CSV <p>I have a <code>Timestamp</code> field that is defined to be automatically updated with the <code>CURRENT_TIMESTAMP</code> value.<br/> It works fine when I fire a query, but when I import a csv (which I'm forced to do since one of the fields is longtext) , the update does not work.</p> <p>I have tried to:</p> <ol> <li>Give timestamp column as <code>now()</code> function in csv</li> <li>Manually enter timestamp like <code>2013-08-08</code> in the csv</li> </ol> <p>Both the approaches do not work</p>
18,595,545
0
L4 and Wordpress - How to install L4 on subdomain shared with Wordpress <p>Here is the structure I am aiming for:</p> <pre><code> project1.site.com -&gt; laravel projects project2.site.com -&gt; laravel projects project3.site.com -&gt; laravel projects www.site.com -&gt; wordpress install </code></pre> <p>How can I accomplish this? I currently tried the following web host structure</p> <pre><code> /home/user/www/wp -&gt; wordpress install /home/user/l4/project1 -&gt; laravel app folders /home/user/www/project1 -&gt; laravel public folder </code></pre> <p>However L4 is not loading properly - it cannot access the app folder ("No such file or directory" when trying to access the L4 bootstrap folder located outside the webroot). I checked the folder permissions and everything looks fine, my guess is wordpress is not playing well with laravel.</p> <p>Anyone know how to fix this? Or provide a setup to allow for a wordpress site with separate subdomains for each laravel project?</p>
21,565,167
0
<p>You must show not metadata but materials array, blender exporter doesn't save texture by default if it missed in materials then try 2-2 from <a href="http://graphic-sim.com/B_basic_export.html" rel="nofollow">this tutorial</a>.</p>
4,110,181
0
<p>I don't understand your concern about G, H, I appearing on branchB instead of branchA. What I mean is, if you rename your <code>branchA</code> to <code>branchB</code>, and branch off from <code>I</code> to create the new <code>branchA</code>, and commit <code>M</code> to <code>branchA</code>, you should get what you want.</p> <p>As far as I know, the branches are simply named heads pointing to particular commits (look at .git/refs/heads), and the rest of the tree is determined solely by parent-child relationships in git. Even if you somehow manage to rebase J-K-L onto a new branchB, and commit M to the now vacant space, the object data would be identical. Both M and J would point at I as their parents, and G/D would point to C as their parents, and the rest would simply point to their immediate parent. Am I missing something here?</p>
5,141,447
0
<p>I haven't tested the code yet but this will help you to get your output</p> <pre><code>function editRecord(id) { db.transaction(function(tx) { tx.executeSql('SELECT * FROM tableOne WHERE id=?', [id], function(tx,results){ for (var i=0; i &lt; results.rows.length; i++){ row = results.rows.item(i); editRecords2(row.name,row.total); } }); }); } function editRecords2(name,total) { f = $('#edit'); f.html(""); f.html(f.html() + ' &lt;form method="get" id="edit_form"&gt;&lt;div&gt;&lt;input type="name" id="editname" value="' + name+'" size="30"/&gt;&lt;input type="number" current id="editamount" value="' + total+'" name="amount" size="15" /&gt;&lt;input type="submit" value="Save" /&gt;&lt;/div&gt;&lt;/form&gt; '); } </code></pre> <p>if any problem occure contact me.</p>
19,451,800
0
SVN resolve tree conflict in merge <p>I have an SVN merge tree conflict that i can't figure out how to resolve and i'm hoping you guys(girls) can help out. </p> <p>Here's the situation: i created a branch A from trunk to do some development. Then i created a branch B, from branch A. Both branches are evolving concurrently. </p> <p>At some point i cherry-picked some revisions from branch B into trunk to get some features developed in branch B.</p> <p>Now, i synced branch A with trunk:</p> <pre><code>~/branch_a$ svn merge ^/trunk ~/branch_a$ svn commit </code></pre> <p>No problems here. Next step is to sync B with A:</p> <pre><code>~/branch_b$ svn merge ^/trunk </code></pre> <p>Here i get some tree conflicts, in files/dirs that already existed in trunk before the merge but were changed in the cherry-picks i did earlier (don't know if it has anything to do with it, i'm just mentioning it):</p> <pre><code> C some_dir/other_dir/some_file.php &gt; local add, incoming add upon merge C some_other_dir/some_sub_dir &gt; local add, incoming add upon merge </code></pre> <p>Essentially i want the versions of the files that are coming in from the merge and discard the current version. What's the best way to solve this?</p> <p>Thanks in advance!</p>