pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
17,280,926 | 0 | <p>You have to prevent the default <code>onclick</code>-behaviour with <code>event.preventDefault</code>:</p> <pre><code>$("button#edit<?= $list['ID']; ?>").click(function(e) { e.preventDefault(); $('#longURL<?= $list['ID']; ?>').html("<input type='text' value='<?= $list['longURL']; ?>' />"); $('#shortURL<?= $list['ID']; ?>').html("<div class='input-prepend'><span class='add-on'>http://smurl.es/</span><input id='prependedInput' type='text' value='<?= $list['shortURL']; ?>' class='span1' /></div>"); $("button#edit<?= $list['ID']; ?>").attr({"class": "btn btn-info btn-small test", "data-original-title": "Click to Save", "id": "save<?= $list['ID']; ?>"}); }); </code></pre> |
8,416,406 | 0 | <pre><code>for i, fname in enumerate(dirList): print "%s) %s" % (i + 1, fname) selectedInt = int(raw_input("Select a file above: ")) selected = dirList[selectedInt - 1] </code></pre> <p>However, note that there is no error correction done. You should catch cases, where the input is no integer.</p> |
3,720,900 | 0 | How does JavaScript interpret indexing? <pre><code>function highlightRow(searchRow) { if(searchRow != null) { var oRows = document.getElementById('Table').getElementsByTagName('tr'); //use row number to highlight the correct HTML row. var lastTwo = searchRow; lastTwo = lastTwo.slice(-2); //extract last two digits oRows[lastTwo].style.background="#90EE90"; } } </code></pre> <p>I got paging off 100 rows. </p> <p>When searchRow returns 55, I highlight row 55.<br> When searchRow returns 177, I highlight row 77, hence the slice function. </p> <p>Now the issue:<br> When searchRow returns 03 or 201, the indexing on oRows[] does not work. </p> <p>Why is this? </p> <p>To confuse me more when I hard coding "03" it does work: </p> <pre><code>oRows[03].style.background="#90EE90"; </code></pre> <p>Any insight into how this works?</p> <p>Does jQuery have this issue?</p> <p>Thank you.</p> |
23,743,825 | 0 | Keep getting BAD_ACCESS when compiling C in Xcode <p>If I start a new Command Line C Project in Xcode and enter the following code I always get a EXC_BAD_ACCESS error when compiling the project.</p> <pre><code>int main(int argc, const char * argv[]) { char *foo = "Hello"; *foo = 'M'; // get EXC_BAD_ACCESS here when compiling } </code></pre> <p>I'm just learning C and can't workout what is wrong with this statement? I'm just trying to change the character at a certain memory location. Has anyone got any ideas?</p> |
37,107,327 | 0 | <p>If you want to send Push Notification on multiple platform use <a href="https://parse.com" rel="nofollow">Parse.com</a> but problem here is Parse.com is going to stop its services in January 28, 2017. You have alternatives like <a href="https://www.urbanairship.com/" rel="nofollow">urban airship</a> and many more. I personally suggest urban airship.</p> |
3,935,900 | 0 | How to commit and rollback transaction in sql server? <p>I have a huge script for creating tables and porting data from one server. So this sceipt basically has - </p> <ol> <li>Create statements for tables.</li> <li>Insert for porting the data to these newly created tables.</li> <li>Create statements for stored procedures. </li> </ol> <p>So I have this code but it does not work basically @@ERROR is always zero I think..</p> <pre><code>BEGIN TRANSACTION --CREATES --INSERTS --STORED PROCEDURES CREATES -- ON ERROR ROLLBACK ELSE COMMIT THE TRANSACTION IF @@ERROR != 0 BEGIN PRINT @@ERROR PRINT 'ERROR IN SCRIPT' ROLLBACK TRANSACTION RETURN END ELSE BEGIN COMMIT TRANSACTION PRINT 'COMMITTED SUCCESSFULLY' END GO </code></pre> <p>Can anyone help me write a transaction which will basically rollback on error and commit if everything is fine..Can I use <a href="http://msdn.microsoft.com/en-us/library/ms178592.aspx">RaiseError</a> somehow here..</p> |
1,093,319 | 0 | <p>Adding a ParentNode property to each node is "not really that bad". In fact, it's rather common. Apparently you didn't add that property because you didn't need it originally. Now you need it, so you have good reason to add it.</p> <p>Alternates include: </p> <ul> <li>Writing a function to find the parent of a child, which is processor intensive.</li> <li>Adding a separate class of some sort which will cache parent-child relationships, which is a total waste of effort and memory.</li> </ul> <p>Essentially, adding that one pointer into an existing class is a choice to use memory to cache the parent value instead of using processor time to find it. That appears to be a good choice in this situation.</p> |
14,068,125 | 0 | <p>PHP is indeed a <strong>server-side</strong> application and thus cannot perform <strong>client-side</strong> validation. </p> <p>If you really want to do client-side validation, you'll probably have to use javascript. Have a look at the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow">jQuery validation plugin</a>. Here is a big demo page showing you some of the possibilities: <a href="http://jquery.bassistance.de/validate/demo/" rel="nofollow">http://jquery.bassistance.de/validate/demo/</a> </p> <p>For more help and information, also have a look at the <a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow">jQuery.com/plugins/validation</a> page.<br> (Note the <strong>WARNING</strong> at the end of this post) </p> <p><strong>Example:</strong><br> (the javascript)</p> <pre><code><script> $(document).ready(function(){ $("#commentForm").validate(); }); </script> </code></pre> <p>(the form)</p> <pre><code><form class="cmxform" id="commentForm" method="get" action=""> <fieldset> <legend>A simple comment form with submit validation and default messages</legend> <p> <label for="cname">Name</label> <em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" /> </p> <p> <label for="cemail">E-Mail</label> <em>*</em><input id="cemail" name="email" size="25" class="required email" /> </p> <p> <label for="curl">URL</label> <em> </em><input id="curl" name="url" size="25" class="url" value="" /> </p> <p> <label for="ccomment">Your comment</label> <em>*</em><textarea id="ccomment" name="comment" cols="22" class="required"></textarea> </p> <p> <input class="submit" type="submit" value="Submit"/> </p> </fieldset> </form> </code></pre> <p><strong>WARNING</strong><br> Please keep in mind that javascript, being <em>client-side</em>, runs on the client's computer. Don't rely on javascript validation alone. Anyone can disable javascript and insert 'wrong' values in your form.</p> |
9,899,648 | 0 | Jquery UI disable dynamic tabs <p>My UI tabs can change based on user action (example - a status message may appear in tab[0]). </p> <p>I also need to be able to disable specific tabs - I know the href, but the index may well change.</p> <p>The UI dox say that you can pass a href instead of an index, but I can't seem to get that to fly.</p> <p>This is what I am doing instead:</p> <pre><code>var disableSlots = []; $('ul.ui-tabs-nav li').each(function(index, el){ if ($(this).children('a').attr('href') == '#DISABLE_ME'){ disableSlots.push(index); } }); $('#tabs').tabs("option","disabled",disableSlots); </code></pre> <p>Is there a better way?</p> |
924,834 | 0 | <p>You can use <code>Configure::read('Config.language')</code>. A part of the CakePHP cookbook states:</p> <blockquote> <p>The current locale is the current value of Configure::read('Config.language'). The value of Config.language is assigned in the L10n Class - unless it is already set.</p> </blockquote> <p>I18n, the class responsible for translation using <code>__()</code>, uses <code>Config.language</code> so, unless you override it in <code>bootstrap.php</code>, that variable contains the selected language. Actually, even if you override it, it will still contain the used language (there might be inconsistencies because I10n is not really aware of the change but I never ran into any).</p> <p>To get a list of languages, you can use <code>L10n::catalog()</code>. I'm not sure it's what you're after, however, since it lists all languages CakePHP knows about, not only the languages that actually have a translation in <code>app/locale</code>.</p> |
40,194,256 | 0 | <p>Your immediate problem is that you need parentheses around <code>(List.length xs)</code>. The code also treats an empty input list as an error in all cases, which is not correct. An empty list is a legitimate input if the desired length <code>k</code> is 0.</p> <p><strong>Update</strong></p> <p>You also have one extra parameter in your definition. If you say this:</p> <pre><code>let myfun k xs = function ... </code></pre> <p>the function <code>myfun</code> has 3 parameters. The first two are named <code>k</code> and <code>xs</code> and the third is implicitly part of the <code>function</code> expression.</p> <p>The quick fix is just to remove <code>xs</code>.</p> <p>I think you might be asking for the wrong number of elements in your recursive call to <code>take</code>. Something to look at anyway.</p> |
3,397,043 | 0 | <p>You can just use Windows Explorer. Open Windows Explorer and go into the <code>assembly</code> folder inside your Windows folder. You should then see all the assemblies that are registered, if you want to add yours in, just drag and drop it in there.</p> <p>Or if you prefer, you can locate the gacutil.exe and use that to do it (but it's not installed with the framework nowdays, only with the SDK I think).</p> |
16,257,105 | 0 | <p>Use a Backtick <code>`</code> to escape <code>"</code></p> <blockquote> <p>IfWinExist, "`"C:\Program Files (x86)\Git\" ahk_class VirtualConsoleClass</p> </blockquote> |
33,742,599 | 0 | <p>You have some acceleration function</p> <pre><code>a(p,q) where p=(x,y,z) and q=(vx,vy,vz) </code></pre> <p>Your order 1 system that can be solved via RK4 is</p> <pre><code>dotp = q dotq = a(p,q) </code></pre> <p>The stages of the RK method involve an offset of the state vector(s)</p> <pre><code>k1p = q k1q = a(p,q) p1 = p + 0.5*dt*k1p q1 = q + 0.5*dt*k1q k2p = q1 k2q = a(p1,q1) p2 = p + 0.5*dt*k2p q2 = p + 0.5*dt*k2q k3p = q2 k3q = a(p2,q2) </code></pre> <p>etc. You can either adjust the state vectors of the point <code>P</code> for each step, saving the original coordinates, or use a temporary copy of <code>P</code> to compute <code>k2, k3, k4</code>.</p> |
19,280,494 | 0 | What are inline PHP tags utilizing the PHP shortcut operator? <pre><code> <html> <head></head> <body> <h1>Welcome to Our Website!</h1> <hr/> <h2>News</h2> <h4><?=$data['title'];?></h4> <p><?=$data['content'];?></p> </body> </html> </code></pre> <p>Can anyone tell me what's the "=" sign before variable names ? I thought of some echo alias but I couldn't find anything, thanks for your help</p> |
4,828,109 | 0 | Create new identifier with macros <p>I want a macro that create a new identifier like</p> <pre><code>(new-name first second) => first-second </code></pre> <p>that could be used to define new toplevel bindings</p> <pre><code>(define-syntax define-generic (syntax-rules () ((define-generic (name a b ...)) (begin (define (new-name name data) 15) ; <= create a new binding (define name (lambda (a b ...) (add (new-name name-data) 7)))))) ; <= use new identifier </code></pre> <p>If i set! the value of the "new-name" binding, then it should affect the newly created procedure.</p> |
36,075,549 | 0 | <p>You should unquote to the true:</p> <pre><code>if(html==true) //or just, if(html) </code></pre> <p>Otherwise it will look for string "true" and this is why it goes to the else part.</p> |
1,470,480 | 0 | <pre><code>class Greeting(db.Model): author = db.UserProperty() content = db.StringProperty(multiline=True) date = db.DateTimeProperty(auto_now_add=True) </code></pre> <p>This code instructs the ORM (object relational mapper) to create a table in the database with the fields "author", "content" and "date". Notice how class Greeting is inherited from db.Model: It's a model for a table to be created in the database.</p> <pre><code>class Guestbook(webapp.RequestHandler): def post(self): greeting = Greeting() if users.get_current_user(): greeting.author = users.get_current_user() greeting.content = self.request.get('content') greeting.put() self.redirect('/') </code></pre> <p>Guestbook is a request handler (notice which class it's inherited from). The post() method of a request handler is called on the event of a POST request. There can be several other methods in this class as well to handle different kinds of requests. Now notice what the post method does: It instantiates the Greeting class- we now have an instance, greeting object. Next, the "author" and "content" of the greeting object are set from the request information. Finally, greeting.put() writes to the database. Additionally, note that "date" is also set automatically to the date/time of writing the object to the database.</p> |
39,980,536 | 0 | Geolocation.getCurrentPosition: Timeout expired <p>I am using Ionic2.</p> <p>I am using the following code, but get an error:</p> <pre><code>import { Geolocation } from 'ionic-native'; public getPosition(): void { if (this.markers && this.markers.length > 0) { var marker: google.maps.Marker = this.markers[0]; // only one this.latitude = marker.getPosition().lat(); this.longitude = marker.getPosition().lng(); this.getJobRangeSearch(this.searchQuery); } else { let options = { timeout: 10000, enableHighAccuracy: true }; Geolocation.getCurrentPosition(options).then((position) => { this.latitude = position.coords.latitude; this.longitude = position.coords.longitude; this.getJobRangeSearch(this.searchQuery); }).catch((error) => { console.log(error); this.doAlert(error+' Timeout trying to get your devices Location'); }); } } </code></pre> <p><strong>error:</strong></p> <blockquote> <p>PositionError {message: "Timeout expired", code: 3, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3}</p> </blockquote> <p><strong>package.json</strong></p> <pre><code>"ionic-native": "^1.3.2", </code></pre> <p>Thank you</p> |
34,970,499 | 0 | AWS S3 + CDN Speed, significantly slower <p>Ok,</p> <p>So I've been playing around with amazon web services as I am trying to speed up my website and save resources on my server by using AWS S3 & CloudFront. </p> <p>I ran a page speed test initially, the page speed loaded in <strong>1.89ms</strong>. I then put all assets onto an s3 bucket, made that bucket available to cloudfront and then used the cloudfront url on the page.</p> <p>When I ran the page speed test again using <a href="http://tools.pingdom.com/fpt/" rel="nofollow">this tool</a> using all their server options I got these results:</p> <blockquote> <p>Server with lowest speed of : 3.66ms</p> <p>Server with highest speed of: 5.41ms</p> </blockquote> <p>As you can see there is a great increase here in speed. Have I missed something, is it configured wrong? I thought the CDN was supposed to make the page speed load faster. </p> |
19,440,168 | 0 | <p>you're creating temporary variable <code>a</code> in function <code>calculateFlexibility</code>, then you store pointer to <code>f.flex</code> variable, but after function is ended - <code>a</code> is gone from memory, so your <code>f.flex</code> pointer is now pointing to nowhere</p> <p>if you want to have really variable length, you should do something like this:</p> <pre><code>Flexibility calculateFlexibility() { Flexibility f; f.flex = (int*)malloc(....); return f; } </code></pre> <p>and at the end of program:</p> <pre><code>free(f.flex); </code></pre> <p>for proper arguments of malloc I suggest you to read: <a href="http://en.cppreference.com/w/c/memory/malloc" rel="nofollow">http://en.cppreference.com/w/c/memory/malloc</a></p> |
16,670,708 | 0 | <p>finally it was fixed, the problem was with the encryption of the file, I put it UTF8 without BOM instead of UTF8 </p> |
12,171,220 | 0 | <p>div is a block element and it take the whole place horizantly, to place another div in parallel you need to use css property float left . use style property <code>style="float:left"</code>.</p> <p><code><div id="accountstabs-1"> <div id="links" style="text-align:left; float:left"> <li><a href="#DisplayData" id="settings1" onclick="manage(this.id)">Manage</a></li> <li><a href="#DisplayData-2" id="settings2" onclick="manage(this.id)">Users</a></li> </div> <div id="DisplayData" style="text-align:right"> <table class="data"> <thead> <tr> <th> First Name </th> <th> Last Name </th> </tr> </thead> </table> </div> </div></code></p> |
1,270,689 | 0 | <p>As an ex one-liner:</p> <pre><code>:syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch </code></pre> <p>This uses the <code>Repeat</code> group to highlight the repeated lines.</p> <p>Breaking it down:</p> <ul> <li><code>syn clear Repeat</code> :: remove any previously found repeats</li> <li><code>g/^\(.*\)\n\ze\%(.*\n\)*\1$/</code> :: for any line that is repeated later in the file <ul> <li>the regex <ul> <li><code>^\(.*\)\n</code> :: a full line</li> <li><code>\ze</code> :: end of match - verify the rest of the pattern, but don't consume the matched text (positive lookahead)</li> <li><code>\%(.*\n\)*</code> :: any number of full lines</li> <li><code>\1$</code> :: a full line repeat of the matched full line</li> </ul></li> <li><code>exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"'</code> :: add full lines that match this to the <code>Repeat</code> syntax group <ul> <li><code>exe</code> :: execute the given string as an ex command</li> <li><code>getline('.')</code> :: the contents of the current line matched by <code>g//</code></li> <li><code>escape(..., '".\^$*[]')</code> :: escape the given characters with backslashes to make a legit regex</li> <li><code>syn match Repeat "^...$"</code> :: add the given string to the <code>Repeat</code> syntax group </li> </ul></li> </ul></li> <li><code>nohlsearch</code> :: remove highlighting from the search done for <code>g//</code></li> </ul> <p>Justin's non-regex method is probably faster:</p> <pre><code>function! HighlightRepeats() range let lineCounts = {} let lineNum = a:firstline while lineNum <= a:lastline let lineText = getline(lineNum) if lineText != "" let lineCounts[lineText] = (has_key(lineCounts, lineText) ? lineCounts[lineText] : 0) + 1 endif let lineNum = lineNum + 1 endwhile exe 'syn clear Repeat' for lineText in keys(lineCounts) if lineCounts[lineText] >= 2 exe 'syn match Repeat "^' . escape(lineText, '".\^$*[]') . '$"' endif endfor endfunction command! -range=% HighlightRepeats <line1>,<line2>call HighlightRepeats() </code></pre> |
15,181,051 | 0 | Simple TextView and ImageView "Hello" App <p>I'm trying to run a simple greeting app that displays some text and 2 clipart-type images. I think I put my image files in the right place and named everything correctly but when I run it, the console gets stuck on the following message, without going any further. Any suggestions or advice would be great! </p> <pre><code>ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat[android.intent.category.LAUNCHER].... </code></pre> |
28,936,698 | 0 | <p>The first solution works fine, I get all areas except the ones of TBA, HBA and AWN. (My datasource is a POSTGIS-DB)</p> <p>I tried the other two as well:</p> <ul> <li>EXPRESSION /^[TBA|HBA|AWN]/: I get the areas of TBA,HBA and AWN (with NOT it doesn't work) </li> <li>EXPRESSION ("[zustaendigkeit]" NOT IN "TBA,HBA,AWN"): I don't get anything</li> </ul> <p>Thanks.</p> |
15,031,198 | 0 | Templates, variadic function, universal references and function pointer : an explosive cocktail <p>Consider the following code and the <code>apply</code> function :</p> <pre><code>// Include #include <iostream> #include <array> #include <type_traits> #include <sstream> #include <string> #include <cmath> #include <algorithm> // Just a small class to illustrate my question template <typename Type, unsigned int Size> class Array { // Class body (forget that, this is just for the example) public: template <class... Args> Array(const Args&... args) : _data({{args...}}) {;} inline Type& operator[](unsigned int i) {return _data[i];} inline const Type& operator[](unsigned int i) const {return _data[i];} inline std::string str() { std::ostringstream oss; for (unsigned int i = 0; i < Size; ++i) oss<<((*this)[i])<<" "; return oss.str(); } protected: std::array<Type, Size> _data; // Apply declaration public: template <typename Return, typename SameType, class... Args, class = typename std::enable_if<std::is_same<typename std::decay<SameType>::type, Type>::value>::type> inline Array<Return, Size> apply(Return (*f)(SameType&&, Args&&...), const Array<Args, Size>&... args) const; }; // Apply definition template <typename Type, unsigned int Size> template <typename Return, typename SameType, class... Args, class> inline Array<Return, Size> Array<Type, Size>:: apply(Return (*f)(SameType&&, Args&&...), const Array<Args, Size>&... args) const { Array<Return, Size> result; for (unsigned int i = 0; i < Size; ++i) { result[i] = f((*this)[i], args[i]...); } return result; } // Example int main(int argc, char *argv[]) { Array<int, 3> x(1, 2, 3); std::cout<<x.str()<<std::endl; std::cout<<x.apply(std::sin).str()<<std::endl; return 0; } </code></pre> <p>The compilation fails with :</p> <pre><code>universalref.cpp: In function βint main(int, char**)β: universalref.cpp:45:32: erreur: no matching function for call to βArray<int, 3u>::apply(<unresolved overloaded function type>)β universalref.cpp:45:32: note: candidate is: universalref.cpp:24:200: note: template<class Return, class SameType, class ... Args, class> Array<Return, Size> Array::apply(Return (*)(SameType&&, Args&& ...), const Array<Args, Size>& ...) const [with Return = Return; SameType = SameType; Args = {Args ...}; <template-parameter-2-4> = <template-parameter-1-4>; Type = int; unsigned int Size = 3u] universalref.cpp:24:200: note: template argument deduction/substitution failed: universalref.cpp:45:32: note: mismatched types βSameType&&β and βlong doubleβ universalref.cpp:45:32: note: mismatched types βSameType&&β and βfloatβ universalref.cpp:45:32: note: mismatched types βSameType&&β and βdoubleβ universalref.cpp:45:32: note: couldn't deduce template parameter βReturnβ </code></pre> <p>I am not very sure why it fails. In that code, I would like :</p> <ul> <li>to keep universal references to have the most generic function</li> <li>to be able to use the syntax <code>apply(std::sin)</code> </li> </ul> <p>So what do I have to change to make it compile ?</p> |
18,726,618 | 0 | <p>You could use the <code>Url</code> helper to create the right url using the table routes rules. For sample:</p> <pre><code>window.location = '@Url.Action("RejectDocument", "YourController", new { id = 222, rejectReason = "this is my reject reason" })'; </code></pre> |
39,802,637 | 0 | <pre><code>SELECT * FROM ticket_message ORDER BY created_at DESC LIMIT 5; </code></pre> <p>If the framework won't let you say that, the fie on them.</p> <p>(<code>GROUP BY</code> is not appropriate.)<br> (Subqueries are not required.)</p> |
7,602,199 | 0 | <p>Did you try just triggering a click?</p> <pre><code>$('button.butter').click(); </code></pre> |
4,529,350 | 0 | <p><a href="http://articles.sitepoint.com/article/ajax-jquery" rel="nofollow">Easy Ajax with jQuery</a></p> <p><strong>I also learned AJAX/jQuery step by step from this platform by postings different scenarios question. Here are my some questions that will be helpful for you also</strong></p> <ul> <li><p><a href="http://stackoverflow.com/questions/3326614/how-to-load-more-than-one-divs-using-ajax-json-combination-in-zend">How to load more than one DIVs using AJAX-JSON combination in zend?</a></p></li> <li><p><a href="http://stackoverflow.com/questions/3426276/ajax-how-to-replace-content-of-a-div-with-a-link-in-same-div">AJAX: How to replace content of a DIV with a link in same DIV ?</a></p></li> <li><p><a href="http://stackoverflow.com/questions/3429176/how-to-call-ajax-request-on-dropdown-change-event">How to call AJAX request on dropdown change event ?</a></p></li> <li><p><a href="http://stackoverflow.com/questions/3429858/how-to-pass-values-of-form-input-fields-to-a-script-using-ajax-jquery">How to pass values of form input fields to a script using AJAX/jQuery ?</a></p></li> <li><p><a href="http://stackoverflow.com/questions/3438123/how-to-submit-a-form-with-ajax-json">How to submit a form with AJAX/JSON ?</a></p></li> <li><p><a href="http://stackoverflow.com/questions/3272384/how-to-code-one-jquery-function-for-all-ajax-links">How to code one jquery function for all AJAX links.</a></p></li> </ul> <p>Some of these are zend framework specific but jQuery/AJAX part will be same for all cases.</p> |
9,926,097 | 0 | <p>Main problems:</p> <p>Database variable should be private, and dont create new variable in constructor.</p> <pre><code>private ArrayList<String> Database; public MovieDatabase(){ this.Database = new ArrayList<String>(); } </code></pre> <p>Your search methods returns list, but doesn't have return statement. Return null, or init empty arraylist an return it. For example:</p> <pre><code> public ArrayList<MovieEntry> searchTitle(String substring){ ArrayList<MovieEntry> entries = new ArrayList<MovieEntry>(); for (String title : Database) System.out.println(title); return entries; } } </code></pre> |
11,869,820 | 0 | TSQL Passing a varchar variable of column name to SUM function <p>I need to write a procedure where I have to sum an unknown column name.</p> <p>The only information I have access to is the column position.</p> <p>I am able to get the column name using the following:</p> <pre><code> SELECT @colName = (SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='TABLENAME' AND ORDINAL_POSITION=@colNum) </code></pre> <p>I then have the following: </p> <pre><code> SELECT @sum = (SELECT SUM(@colName) FROM TABLENAME) </code></pre> <p>I then receive the following error: </p> <blockquote> <p><em>Operand data type varchar is invalid for sum operator</em></p> </blockquote> <p>I am confused about how to make this work. I have seen many posts on convert and cast, but I cannot cast to an float, numeric, etc because this is a name.</p> <p>I would appreciate any help.</p> <p>Thank you</p> |
39,832,012 | 0 | Does gcc use "LD_LIBARRY_PATH" when doing linking '-L'? <p>I've got libo.a file under current directory, I found I have to use '-L.' to make gcc able to find current directory's archive files.</p> <p>I know under linux/solaris, there's environment variable of "LD_LIBRARY_PATH" to specify shared_library path. I found it doesn't work with gcc when doing link, 'export LD_LIBRARY_PATH' cannot be used to replace '-L.'</p> <blockquote> <p>Question(1) Is this by design of gcc, that linker search path doesn't read from environment variable, but should be specified by command line options?</p> </blockquote> <p>More weird is, I did 'export LIBPATH=.', it doesn't work either, but if I add LIBPATH into a scons file:</p> <pre><code>Library('o.c') Program('n.c',LIBS=['o'],LIBPATH='.') </code></pre> <p>Then it works!</p> <blockquote> <p>Question(2) What is the difference between environment shell variable of 'LIBPATH', and the scons parameter of 'LIBPATH'. Does scons has an internal parameter named 'LIBPATH', which has nothing to do with shell environment?</p> </blockquote> <p>Thanks!</p> |
19,397,143 | 0 | actionscript 3 export data to XML <p>How do I export data from my SWF file to an XML file?</p> <p>For example if there are 10 players (dyna blaster style game) and you want to store the scores over a longer period of time in a Excel file. You have to have the game create an XML file first, I figured that out myself. But how to export the data to an XML file first?</p> <p>And also - is there a way to export the data from an swf file to mySQL on the server where my webSite is located ?</p> |
36,270,761 | 0 | <p>AuditReaderFactory only has two static methods. Can you autowire a SessionFactory object or your EntityMananger? Looks like either would give you what you want, which is access to an AuditReader.</p> <pre><code>AuditReaderFactory.get(sessionFactory.getCurrentSession()) </code></pre> <p><strong>EDIT</strong> <a href="http://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory">this</a> post has some detail or wiring SessionFactory if needed</p> |
24,956,706 | 0 | use *this as std::shared_ptr <p>here is a "chess++" problem that I'm facing wright now with my nested class, although it may look like some joke, it's not a joke but real problem which I want to either solve or change the way to achieve the same thing in my project.</p> <pre><code>#include <map> #include <memory> #include <iostream> #include <sigc++/signal.h> class foo { public: struct bar; typedef sigc::signal<void, std::shared_ptr<bar>> a_signal; struct bar { bar() { some_signal.connect(sigc::mem_fun(*this, &foo::bar::func)); } void notify() { some_signal.emit(this); // how to ?? } void func(std::shared_ptr<foo::bar> ptr) { std::cout << "you haxor!" << std::endl; // use the pointer ptr-> } a_signal some_signal; }; std::map<int, std::shared_ptr<bar>> a_map; }; int main() { std::shared_ptr<foo::bar> a_foo_bar; foo foo_instance; foo_instance.a_map.insert(std::pair<int, std::shared_ptr<foo::bar>>(4, a_foo_bar)); foo_instance.a_map.at(0)->notify(); return 0; } </code></pre> <p>What I want to do here is to emit a signal. the signal is declared as one that triggers a handler that takes a shared_ptr as an argument. the function notify() should convert *this into shared_ptr, how do I do that to make the above code run?</p> |
8,266,818 | 0 | <p>In iOS 5 you can use the UIAppearance protocol to set the appearance of all UINavigationBars in your app. Reference: <a href="http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIAppearance_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIAppearance">link</a>.</p> <p>The way I got a solid color was to create a custom image for the navigation bar, and set it as UINavigationBars background. You might have to create the image with the same size as the UINavigationBar, at least that's what I did.</p> <p>In your app delegate, do something like this:</p> <pre><code>UIImage *image = [UIImage imageNamed:@"navbarbg.png"]; [[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; </code></pre> <p>You also have to add the <code>UIAppearanceContainer</code> protocol to the header file:</p> <pre><code>@interface AppDelegate : UIResponder <UIApplicationDelegate, UIAppearanceContainer> @end </code></pre> <p>You can probably achieve the same thing by setting some color or something, instead of an image. But I found this to be an easy solution.</p> |
14,373,981 | 0 | cloud foundry uploading error <p>Get the below error on doing <code>vmc push</code></p> <pre><code>Errno::EINVAL: Invalid argument - C:/DOCUME~1/lihengxu/LOCALS~1/Temp/.vmc_blog_files/E: C:/Ruby187/lib/ruby/1.8/fileutils.rb:243:in `mkdir' C:/Ruby187/lib/ruby/1.8/fileutils.rb:243:in `fu_mkdir' C:/Ruby187/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p' C:/Ruby187/lib/ruby/1.8/fileutils.rb:215:in `reverse_each' C:/Ruby187/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p' C:/Ruby187/lib/ruby/1.8/fileutils.rb:201:in `each' C:/Ruby187/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p' cfoundry-0.4.19/lib/cfoundry/zip.rb:27:in `unpack' rubyzip-0.9.9/lib/zip/zip_entry_set.rb:35:in `each' rubyzip-0.9.9/lib/zip/zip_entry_set.rb:35:in `each' rubyzip-0.9.9/lib/zip/zip_central_directory.rb:109:in `each' rubyzip-0.9.9/lib/zip/zip_file.rb:132:in `foreach' rubyzip-0.9.9/lib/zip/zip_file.rb:90:in `open' rubyzip-0.9.9/lib/zip/zip_file.rb:131:in `foreach' cfoundry-0.4.19/lib/cfoundry/zip.rb:24:in `unpack' cfoundry-0.4.19/lib/cfoundry/upload_helpers.rb:58:in `prepare_package' cfoundry-0.4.19/lib/cfoundry/upload_helpers.rb:42:in `upload' vmc-0.4.7/lib/vmc/cli/app/push.rb:119:in `upload_app' interact-0.5.1/lib/interact/progress.rb:98:in `with_progress' vmc-0.4.7/lib/vmc/cli/app/push.rb:118:in `upload_app' vmc-0.4.7/lib/vmc/cli/app/push.rb:100:in `setup_new_app' vmc-0.4.7/lib/vmc/cli/app/push.rb:82:in `push' mothership-0.3.5/lib/mothership/base.rb:61:in `send' mothership-0.3.5/lib/mothership/base.rb:61:in `run' mothership-0.3.5/lib/mothership/command.rb:68:in `invoke' manifests-vmc-plugin-0.4.19/lib/manifests-vmc-plugin/plugin.rb:113:in `call' manifests-vmc-plugin-0.4.19/lib/manifests-vmc-plugin/plugin.rb:113 mothership-0.3.5/lib/mothership/callbacks.rb:74:in `with_filters' manifests-vmc-plugin-0.4.19/lib/manifests-vmc-plugin/plugin.rb:112 mothership-0.3.5/lib/mothership/command.rb:78:in `instance_exec' mothership-0.3.5/lib/mothership/command.rb:78:in `invoke' mothership-0.3.5/lib/mothership/command.rb:82:in `instance_exec' mothership-0.3.5/lib/mothership/command.rb:82:in `invoke' mothership-0.3.5/lib/mothership/base.rb:50:in `execute' vmc-0.4.7/lib/vmc/cli.rb:106:in `execute' mothership-0.3.5/lib/mothership.rb:45:in `start' vmc-0.4.7/bin/vmc:11 C:/Ruby187/bin/vmc:23:in `load' C:/Ruby187/bin/vmc:23 </code></pre> |
27,246,620 | 0 | Pass Array as parameter in DB2 Stored Procedure <p>I am trying to create a stored procedure which takes an array as a parameter and in the WHILE loop iterates through this array and adds the chars into a table.</p> <p>For example if I had an array of ['a','b','c'] I would want to pass this into my stored procedure and the characters 'a' , 'b' and 'c' to be placed into a table.</p> <p>My SP creates successfully, but I am having issues when I try to call my procedure. Can anybody point me towards how to pass in an array? My procedure is as follows....</p> <pre><code> DROP PROCEDURE DB.LWRH_DYNAMIC_SP@ create type stringArray as VARCHAR(100) array[100]@ CREATE PROCEDURE DB.LWRH_SP ( IN list stringArray ) LANGUAGE SQL BEGIN DECLARE i, MAX INTEGER; DECLARE c CHAR(1); SET i = 0; SET MAX = CARDINALITY(list); WHILE i <= MAX DO SET c = list[i]; INSERT INTO schema.test ("SERVICE TYPE")values (c); END WHILE; END@ CALL DB.LWRH_SP('')@ </code></pre> |
7,431,908 | 0 | Wifi Device to Device Communication problem <p>I wrote a code in my application to enable Device to Device wifi Communication(transferring only a text/string).The code is same as the Apple's sample <strong>Witap</strong> Application which is downloaded from Developer.Apple.com.</p> <p>Its working in my network fine and another networks also.</p> <p>However its not working in my client site.</p> <p>I spent time at the Client site to sort out the issue with the Devices not communicating to each other and this is what I found. They in their security setup block peer to peer communicationβ¦" and my device communication is identified as peer to peer .</p> <p><strong>Is there any way to solve this problem Is there anything other than PEER 2 PEER wifi communication which apple supports?</strong></p> <p>Prototype WIFI applications Working Concepts</p> <hr> <p>There are mainly four classes in WiFi application named as AppController, Picker, BrowserViewController, TCP Server.</p> <p>When application loads the AppController class will initialize NSInputStraem and NSOutPut Stream.</p> <p>And also it will call βstartβ method from TcpServer class to set port number.</p> <p>After it will call βenableBounjourWithDomainβ method from TcpServer class.</p> <p>The above method call with a parameter called as identifier (it is a common name eg:WiTap) and the sender part is searching devices with this common identifier.</p> <p>After the execution of this method the sender device can identify our device and able to connect.</p> <p>Getting Own Device Name</p> <hr> <p>Tcp serverServer delegate βDidEnabledBounjerβ will work after the above code execution and it will give the current device name.</p> <p>Then NSNetservice delegate βdidFindServiceβ will work (it work when each service discovered) and retrieve the discovered service name.</p> <p>After getting the new service name we will check either it is same to our device name which we got from βDidEnabledBounjerβ delegate.</p> <p>if not ,the new service name will add into a NSMutable array named as services.</p> <p>Then services array bind t o the Table view and we can see the list of discovered device names.</p> <p>discovering the new devices:</p> <hr> <p>No timer settings for discovering the new devices.</p> <p>When a new device is connected in the same WiFi net work the βDidFindserviceβ delegate will trigger(it is a NSNetservice delegate implemented in BrowserViewController class).</p> <p>DidFindservice will give the new device name .After getting it we will check either it is same to our device name witch we got from βDidEnabledBounjerβ delegate.</p> <p>if not ,the service name will add into a NSMutable array named as services.</p> <p>Then sort all the discovered ;device names according to the Device name and reload the Table View.</p> <p>Working after selecting a device name from Table View</p> <hr> <p>After clicking device name on the TableView it will call βdidSelectRowAtIndexPathβ delegate which is implemented in BrowserViewController class( it is a TableView Class delegate) .</p> <p>It will select a NetService name from our services array(holds all the discovered services) according to the TableView index and set resultant NSService as Current Service.</p> <p>Trigger a delegate βdidResolveInstanceβ and it will set the InPutStream and OutPutStream values.</p> <p>After get ting values for InPutStream and OutPutStream it will call βOpenStreamβ method to open the input and output Streams.</p> <p>Finally it release the NSService and Picker objects and ready to send messages with selected devices.</p> <p>Working of send Button</p> <hr> <p>Call βsend β function from BrowserViewController class with a string parameter .It may be user text input or generated string after speech recognition.</p> <p>Convert the input string as a uint_8 data type and send it to the receiver device.</p> <p>Receiver Side Working</p> <hr> <p>When a data came to receiver device the βTcpServerAcceptCallBackβ delegate will trigger(implemented in TcpServer Class).</p> <p>It will call βDidAcceptConnectionForServerβ method from BrowserViewControll calss through another TcpServer class delegate named βHandleNewConnectionFromAddressβ.</p> <p>Trigger the βstream handle delegateβ which is in βAppController β class and it will check is there any bites available or not.</p> <p>If bytes are available convert the uint_8 type data to string and we are displaying the resultant string in receiver text box.</p> <p>And also loading images and displaying it in Image View from AppBundle using the resultant string.< /p></p> |
1,491,029 | 0 | <p><strong>First:</strong> I would really re-check your original code for the conditions, while its possible there is a bug in the query optimizer its more likely there was a bug on the expression used and it really didn't represent the below:</p> <blockquote> <p>var DesiredList = db.Things.Where(t=> condition1 || (!condition1 && condition2));</p> <p>the problem is query optimizer seems to trim the expression to condition2 only.</p> </blockquote> <p>That should really give you the ones that match condition1 regardless of condition2 ... and ones that don't match condition1 and match condition2. Instead condition2 alone is not equivalent because that leaves out records that only match condition1. </p> <p>JS version of just (condition1 || condition2) is equivalent to the quoted expression above, as when u are matching condition1 you are already matching both condition2 and !condition2 so you are already including condition2 for both condition1 and !condition1 cases. If this doesn't match what you intended with the queries, is then clearer that's not an issue with the optimizer but with the original expressions.</p> <p>You would only need the full expressions if you were joining 2 results with a Concat instead of Union, as that would mean you would end up with results matching in both expressions ... and then you would have repeated results. But in contrast, the Where is evaluated per row, so you don't have those concerns in there.</p> <hr> <p><strong>Second:</strong> From the code sample, I think what you are facing is less direct of what you are going after in your question. You mentioned you are getting the first tag, but what you are really doing can be seen in this re-written version:</p> <pre><code>public static IQueryable<BookTag> UniqueByTags(this IQueryable<BookTag> bookTags, User user) { return bookTags.GroupBy(BT => BT.TagId) .Select(g => new BookTag() { User = g.Any(bt => bt.UserId == user.Id) ? user : g.First().User, Tag = g.First().Tag, Book = bookTags.First().Book }); } </code></pre> <p>What's mentioned in the comment seems more like:</p> <pre><code>public static IQueryable<BookTag> UniqueByTags(this IQueryable<BookTag> bookTags, User user) { return bookTags.GroupBy(BT => BT.TagId) .Select(g => g.Any(bt => bt.UserId == user.Id) ? g.First(bt=>bt.UserId == user.Id) : g.First() ); } </code></pre> |
39,063,011 | 0 | gsap animation - import only one svg or multiple svgs <p>I would like to do "complex" animation with gsap and svgs. but I don't know what is the best approach to this. it is better to create and to import an unique svg with all the elements or maybe it is better 4 different svgs?</p> <p>I have 4 different characters: a tree, a lamp, a desk and a man. basically my animation is move the objects on the x, and appearing and to disappearing stuff.</p> |
30,731,510 | 0 | <p>I have resolved the issue by calculating pinv from Eigen, instead of Armadillo. </p> <p>The function definition I used for Eigen, based on this bug report: <a href="http://eigen.tuxfamily.org/bz/show_bug.cgi?id=257" rel="nofollow">http://eigen.tuxfamily.org/bz/show_bug.cgi?id=257</a></p> <p>is: </p> <pre><code>template<typename _Matrix_Type_> Eigen::MatrixXd pinv(const _Matrix_Type_ &a, double epsilon =std::numeric_limits<double>::epsilon()) { Eigen::JacobiSVD< _Matrix_Type_ > svd(a ,Eigen::ComputeThinU | Eigen::ComputeThinV); double tolerance = epsilon * std::max(a.cols(), a.rows()) *svd.singularValues().array().abs()(0); return svd.matrixV() * (svd.singularValues().array().abs() > tolerance).select(svd.singularValues().array().inverse(), 0).matrix().asDiagonal() * svd.matrixU().adjoint(); } </code></pre> |
20,857,325 | 0 | Newtonsoft.Json.JsonSerializationException <pre><code> i'm trying to convert the json to C# objects by the statement var organizations = response.Content.ReadAsAsync<IEnumerable<Organization>>().Result; i found so many questions like the same what i'm facing now but i didn't found the proper answer may i know the reason for this exception Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable `1[ConsoleApplication2.Organization]' because the type requires a JSON array (e. g. [1,2,3]) to deserialize correctly. To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or chang e the deserialized type so that it is a normal .NET type (e.g. not a primitive t ype like integer, not a collection type like an array or List<T>) that can be de serialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. </code></pre> <p>i'm trying to convert the json to C# objects by the statement i found so many questions like the same what i'm facing now but i didn't found the proper answer may i know the reason for this exception my Json is </p> <pre><code>{ </code></pre> <p>"code": 0, "message": "success", "organizations": [ { "organization_id": "10234695", "name": "Zillium Inc", "contact_name": "John Smith", "email": "[email protected]", "is_default_org": false, "plan_type": 0, "tax_group_enabled": true, "plan_name": "TRIAL", "plan_period": "", "language_code": "en", "fiscal_year_start_month": 0, "account_created_date": "2012-02-18", "account_created_date_formatted": "18 Feb 2012", "time_zone": "Asia/Calcutta", "is_org_active": true, "currency_id": "460000000000097", "currency_code": "USD", "currency_symbol": "$", "currency_format": "###,##0.00", "price_precision": 2 }, { "organization_id": "10407630", "name": "Winston Longbridge", "contact_name": "John Smith", "email": "[email protected]", "is_default_org": false, "plan_type": 0, "tax_group_enabled": true, "plan_name": "TRIAL", "plan_period": "", "language_code": "en", "fiscal_year_start_month": 0, "account_created_date": "2012-07-11", "account_created_date_formatted": "11 Jul 2012", "time_zone": "Asia/Calcutta", "is_org_active": true, "currency_id": "541000000000099", "currency_code": "INR", "currency_symbol": "Rs.", "currency_format": "###,##0.00", "price_precision": 2 } ] }</p> |
22,558,607 | 0 | The exception that is generated when SQLite returns an error. |
35,227,417 | 0 | Custom GcmListenerService not working <p>This is my manifest file </p> <pre><code><?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="be.customapp" > <uses-permission android:name="android.permission.INTERNET" /> <!-- GCM: keep device awake while receiving a notification --> <uses-permission android:name="android.permission.WAKE_LOCK"/> <!-- GCM: receive push notifications --> <permission android:name="be.customapp.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="be.customapp.permission.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <!-- Meta data --> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/google_maps_key"/> <!-- Activities --> <activity android:name=".ui.activities.MainActivity" android:label="@string/app_name" android:launchMode="singleTop" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- Services --> <service android:exported="false" android:name=".services.gcm.MyGcmListenerService"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> </intent-filter> </service> <service android:exported="false" android:name=".services.gcm.GcmRegisterService"/> <service android:name=".services.gcm.MyInstanceIDListenerService" android:exported="false"> <intent-filter> <action android:name="com.google.android.gms.iid.InstanceID"/> </intent-filter> </service> <!-- Broadcastreceivers --> <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="be.prior_it.evapp" /> </intent-filter> </receiver> </application> </manifest> </code></pre> <p>And this is the service that gets/registers my registration id;</p> <pre><code>InstanceID instanceID = InstanceID.getInstance(this); String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); </code></pre> <p>MyGcmListenerService;</p> <pre><code>public class MyGcmListenerService extends GcmListenerService { @Override public void onMessageReceived(String from, Bundle data) { super.onMessageReceived(from, data); Log.i(Constants.LOG_TAG, "Got GCM message " + data.getString("message")); } } </code></pre> <p>The server uses PushJack and sends to the registration id's. I can see that the server can send the messages, I can get my registration id and register it with our server, but the onMessageReceived never gets called... I also made the google-services.json using the link on the website, so that should also be okay.</p> <p>Any or all ideas are welcome.</p> |
8,151,662 | 0 | TestNG enabled = false tests not showing as Skipped <p>We have a number of TestNG tests that are disabled due to functionality not yet being present (enabled = false), but when the test classes are executed the disabled tests do not show up as skipped in the TestNG report. We'd like to know at the time of execution how many tests are disabled (i.e. skipped). At the moment we have to count the occurrences of enabled = false in the test classes which is an overhead.</p> <p>Is there a different annotation to use or something else we are missing so that our test reports can display the number of disabled tests?</p> |
16,362,186 | 0 | <p>Here is your validation simplified, and with the correct operation to check the length of the id.</p> <pre><code>if(empty($number)) { $msg = '<span class="error"> Please enter a value</span>'; } else if(!is_numeric($number)) { $msg = '<span class="error"> Data entered was not numeric</span>'; } else if(strlen($number) != 6) { $msg = '<span class="error"> The number entered was not 6 digits long</span>'; } else { /* Success */ } </code></pre> |
30,565,155 | 0 | <p>the question is a bit too broad. </p> <p>you have to step back and look at how source code in general ends up being executed (i.e. it is used). </p> <p>In case of some programming languages (e.g. C/C++) it's compiled to a native form and can be executed directly afterwards;</p> <p>In case of other languages it's compiled to an intermediate form (e.g. Java/C#) and executed by a vm (jvm/clr)</p> <p>In case of yet other languages is interpreted at runtime (e.g. Ruby/Python). </p> <p>So in the specific case of Ruby, you have the interpreter that loads the rb files and runs them. This can be in the context of standalone apps or in th e context of a web server, but you almost always have the interpreter making sense of the ruby files. you don't get an executable the same way as the you get for languages that are compiled to machine code.</p> |
8,804,593 | 0 | How to enable code coverage without using Visual Studio? <p>I have 80+ VS2010 solutions, each contains some unit test projects.<br> All solutions are merged into one big solution before build process.<br> All tests (or some test subset) are executed after the successful build.</p> <p>I want to enable test code coverage for all tests to get exact code coverage for all output assemblies.</p> <p>My question is: how to enable code coverage without using Visual Studio? </p> <p>Note: I'm using TFS2010 (MSBuild) to build merged solution. VS 2010 Premium is installed on the build server. MSTest is used for test execution. </p> |
7,593,294 | 0 | <p>wirte this in your css <code>word-wrap:break-word;</code> css:</p> <pre><code>#id_div_comments p{ word-wrap:break-word; } </code></pre> |
29,228,982 | 0 | <p>You can get the value using jQuery '.val()' function. <a href="https://api.jquery.com/val/" rel="nofollow">Jquery.fn.val()</a></p> <p>You can see how it works in the following example:</p> <p><a href="http://jsfiddle.net/uoL3s610/" rel="nofollow">http://jsfiddle.net/uoL3s610/</a></p> <pre><code>$(document).ready(function(){ $('[name="city"]').change(function(){ $('#selected_container').text($('[name="city"]').val()); }); }); </code></pre> <p>Or this example</p> <p><a href="http://jsfiddle.net/uoL3s610/1/" rel="nofollow">http://jsfiddle.net/uoL3s610/1/</a></p> <pre><code>$(document).ready(function(){ $('[name="city"]').change(function(){ $('#selected_container').text(''); $.each($('[name="city"]').val(),function(index,value){ $('#selected_container').text($('#selected_container').text() + ', ' + value) }); }); }); </code></pre> |
22,774,115 | 0 | Google Maps API data.setStyle not showing icons on map <p>I'm trying to create a little app using the Google Maps JS API. I'm using the data layer to load a bunch of points from a GeoJSON file. The file seems to be loading properly, and the map is displaying, but the icons that are set in the map.data.setstyle() won't show... </p> <p>Below is my HTML, CSS, and JS. I've been looking at this for 2 days, and I can't figure out what's going wrong. Thank you in advance!</p> <p>HTML</p> <pre><code><body> <div id="map-canvas"></div> </body> </code></pre> <p>CSS</p> <pre><code>html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map-canvas { height: 100% } </code></pre> <p>JS</p> <pre><code>$(document).ready(function() { var map; function initialize() { var mapOptions = { center: new google.maps.LatLng(37.000, -120.000), zoom: 7 }; map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); map.data.loadGeoJson('/map.json'); map.data.setStyle(function(feature) { var theaterName = feature.getProperty('name'); return { icon: "https://maps.gstatic.com/mapfiles/ms2/micons/marina.png", visible: true, clickable: true, title: theaterName }; }); } google.maps.event.addDomListener(window, 'load', initialize); }); </code></pre> <p>JSON</p> <pre><code>{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "rentrak_id": "9183", "name": "Palm Theatre", "address": "817 Palm St, San Luis Obispo, CA"}, "geometry": { "type": "Point", "coordinates": [35.2815558, -120.6638196] } }, { "type": "Feature", "properties": { "rentrak_id": "8961", "name": "King City 3", "address": "200 Broadway St, King City, CA"}, "geometry": { "type": "Point", "coordinates": [36.21372, -121.1261771] } }, {"type": "Feature", "properties": { "rentrak_id": "5549", "name": "Van Buren 3 DI", "address": "3035 Van Buren Blvd, Riverside, CA"}, "geometry": { "type": "Point", "coordinates": [33.9113137, -117.4364228] }}, {"type": "Feature", "properties": { "rentrak_id": "990802", "name": "CGV Cinemas LA", "address": "621 S Western Ave, Los Angeles, CA"}, "geometry": { "type": "Point", "coordinates": [34.0626656, -118.3093961] }}, {"type": "Feature", "properties": { "rentrak_id": "5521", "name": "Rancho Niguel 7", "address": "25471 Rancho Niguel Rd, Laguna Niguel, CA"}, "geometry": { "type": "Point", "coordinates": [33.5560509, -117.68533] }}]} </code></pre> <p><strong>EDIT::</strong></p> <p>So, my script is working when I use this file: <a href="http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week" rel="nofollow">http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week</a> </p> <p>Which makes me think there is something wrong with my local json file... However when I step through the javascript, I can look at each feature and check for the properties and geometries, and they seem to be correctly loaded into the google.maps.feature objects. So, I still have no idea why the points wouldn't be showing up.</p> |
16,743,471 | 0 | <p>Thomas's answer is much better than any of the three approaches I tried. Here I compare the four approaches with <code>microbenchmark</code>. I have not yet tried Thomas's answer with the actual data. My original nested for-loops approach is still running after 22 hours.</p> <pre><code>Unit: milliseconds expr min lq median uq max neval fn.1(x, weights) 98.69133 99.47574 100.5313 101.7315 108.8757 20 fn.2(x, weights) 755.51583 758.12175 762.3775 776.0558 801.9615 20 fn.3(x, weights) 564.21423 567.98822 568.5322 571.0975 575.1809 20 fn.4(x, weights) 367.05862 370.52657 371.7439 373.7367 395.0423 20 ######################################################################################### # create data set.seed(1234) n.rows <- 40 n.cols <- 40 n.sample <- n.rows * n.cols x <- sample(20, n.sample, replace=TRUE) x.NA <- sample(n.rows*n.cols, 10*(n.sample / n.rows), replace=FALSE) x[x.NA] <- NA x <- as.data.frame(matrix(x, nrow = n.rows)) weights <- sample(4, n.sample, replace=TRUE) weights <- as.data.frame(matrix(weights, nrow = n.rows)) weights ######################################################################################### # Thomas's function fn.1 <- function(x, weights){ newx <- reshape(x, direction="long", varying = list(seq(1,(n.cols-1),2), seq(2,n.cols,2)), v.names=c("v1", "v2")) newwt <- reshape(weights, direction="long", varying = list(seq(1,(n.cols-1),2), seq(2,n.cols,2)), v.names=c("w1", "w2")) condwtmean <- function(x,y,wtx,wty){ if(xor(is.na(x),is.na(y))){ if(is.na(x)) x <- (y / wty) * wtx # replacement function if(is.na(y)) y <- (x / wtx) * wty # replacement function return(weighted.mean(c(x,y),c(wtx,wty))) } else if(!is.na(x) & !is.na(y)) return(weighted.mean(c(x,y),c(wtx,wty))) else return(NA) } newx$wtmean <- mapply(condwtmean, newx$v1, newx$v2, newwt$w1, newwt$w2) newx2 <- reshape(newx[,c(1,4:5)], v.names = "wtmean", timevar = "time", direction = "wide") newx2 <- newx2[,2:(n.cols/2+1)] names(newx2) <- paste('X', 1:(n.cols/2), sep = "") return(newx2) } fn.1.output <- fn.1(x, weights) ######################################################################################### # nested for-loops with 4 if statements fn.2 <- function(x, weights){ for(i in 1: (ncol(x)/2)) { for(j in 1: nrow(x)) { if( is.na(x[j,(1 + (i-1)*2)]) & !is.na(x[j,(1 + (i-1)*2 + 1)])) x[j,(1 + (i-1)*2 + 0)] = (x[j,(1 + ((i-1)*2 + 1))] / weights[j,(1 + ((i-1)*2 + 1))]) * weights[j,(1 + (i-1)*2 + 0)] if(!is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) x[j,(1 + (i-1)*2 + 1)] = (x[j,(1 + ((i-1)*2 + 0))] / weights[j,(1 + ((i-1)*2 + 0))]) * weights[j,(1 + (i-1)*2 + 1)] if( is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) x[j,(1 + (i-1)*2 + 0)] = NA if( is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) x[j,(1 + (i-1)*2 + 1)] = NA } } x.weights = x * weights numerator <- sapply(seq(1,ncol(x.weights),2), function(i) { apply(x.weights[,c(i, i+1)], 1, sum, na.rm=T) }) denominator <- sapply(seq(1,ncol(weights),2), function(i) { apply(weights[,c(i, i+1)], 1, sum, na.rm=T) }) weighted.x <- numerator/denominator for(i in 1: (ncol(x)/2)) { for(j in 1: nrow(x) ) { if( is.na(x[j,(1 + (i-1)*2)]) & !is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = sum(c(x[j,(1 + ((i-1)*2))], x[j,(1 + ((i-1)*2 + 1))]), na.rm = TRUE) if(!is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = sum(c(x[j,(1 + ((i-1)*2))], x[j,(1 + ((i-1)*2 + 1))]), na.rm = TRUE) if( is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = NA } } return(weighted.x) } fn.2.output <- fn.2(x, weights) fn.2.output <- as.data.frame(fn.2.output) names(fn.2.output) <- paste('X', 1:(n.cols/2), sep = "") ######################################################################################### # nested for-loops with 2 if statements fn.3 <- function(x, weights){ for(i in 1: (ncol(x)/2)) { for(j in 1: nrow(x)) { if( is.na(x[j,(1 + (i-1)*2)]) & !is.na(x[j,(1 + (i-1)*2 + 1)])) x[j,(1 + (i-1)*2 + 0)] = (x[j,(1 + ((i-1)*2 + 1))] / weights[j,(1 + ((i-1)*2 + 1))]) * weights[j,(1 + (i-1)*2 + 0)] if(!is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) x[j,(1 + (i-1)*2 + 1)] = (x[j,(1 + ((i-1)*2 + 0))] / weights[j,(1 + ((i-1)*2 + 0))]) * weights[j,(1 + (i-1)*2 + 1)] } } x.weights = x * weights numerator <- sapply(seq(1,ncol(x.weights),2), function(i) { apply(x.weights[,c(i, i+1)], 1, sum, na.rm=T) }) denominator <- sapply(seq(1,ncol(weights),2), function(i) { apply(weights[,c(i, i+1)], 1, sum, na.rm=T) }) weighted.x <- numerator/denominator for(i in 1: (ncol(x)/2)) { for(j in 1: nrow(x) ) { if( is.na(x[j,(1 + (i-1)*2)]) & !is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = sum(c(x[j,(1 + ((i-1)*2))], x[j,(1 + ((i-1)*2 + 1))]), na.rm = TRUE) if(!is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = sum(c(x[j,(1 + ((i-1)*2))], x[j,(1 + ((i-1)*2 + 1))]), na.rm = TRUE) if( is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = NA } } return(weighted.x) } fn.3.output <- fn.3(x, weights) fn.3.output <- as.data.frame(fn.3.output) names(fn.3.output) <- paste('X', 1:(n.cols/2), sep = "") ######################################################################################### # my reshape solution fn.4 <- function(x, weights){ new.x <- reshape(x , direction="long", varying = list(seq(1,(n.cols-1),2), seq(2,n.cols,2)), v.names = c("v1", "v2")) wt <- reshape(weights, direction="long", varying = list(seq(1,(n.cols-1),2), seq(2,n.cols,2)), v.names = c("w1", "w2")) new.x$v1 <- ifelse(is.na(new.x$v1), (new.x$v2 / wt$w2) * wt$w1, new.x$v1) new.x$v2 <- ifelse(is.na(new.x$v2), (new.x$v1 / wt$w1) * wt$w2, new.x$v2) x2 <- reshape(new.x, direction="wide", varying = list(seq(1,3,2), seq(2,4,2)), v.names = c("v1", "v2")) x <- x2[,2:(n.cols+1)] x.weights = x * weights numerator <- sapply(seq(1,ncol(x.weights),2), function(i) { apply(x.weights[,c(i, i+1)], 1, sum, na.rm=T) }) denominator <- sapply(seq(1,ncol(weights),2), function(i) { apply(weights[,c(i, i+1)], 1, sum, na.rm=T) }) weighted.x <- numerator/denominator for(i in 1: (ncol(x)/2)) { for(j in 1: nrow(x) ) { if( is.na(x[j,(1 + (i-1)*2)]) & !is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = sum(c(x[j,(1 + ((i-1)*2))], x[j,(1 + ((i-1)*2 + 1))]), na.rm = TRUE) if(!is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = sum(c(x[j,(1 + ((i-1)*2))], x[j,(1 + ((i-1)*2 + 1))]), na.rm = TRUE) if( is.na(x[j,(1 + (i-1)*2)]) & is.na(x[j,(1 + (i-1)*2 + 1)])) weighted.x[j,i] = NA } } return(weighted.x) } fn.4.output <- fn.4(x, weights) fn.4.output <- as.data.frame(fn.4.output) names(fn.4.output) <- paste('X', 1:(n.cols/2), sep = "") ######################################################################################### rownames(fn.1.output) <- NULL rownames(fn.2.output) <- NULL rownames(fn.3.output) <- NULL rownames(fn.4.output) <- NULL all.equal(fn.1.output, fn.2.output) all.equal(fn.1.output, fn.3.output) all.equal(fn.1.output, fn.4.output) all.equal(fn.2.output, fn.3.output) all.equal(fn.2.output, fn.4.output) all.equal(fn.3.output, fn.4.output) library(microbenchmark) microbenchmark(fn.1(x, weights), fn.2(x, weights), fn.3(x, weights), fn.4(x, weights), times=20) ######################################################################################### </code></pre> |
15,164,620 | 0 | <p>Instead of trying to parse the output of <code>ls</code>, <a href="http://mywiki.wooledge.org/ParsingLs" rel="nofollow">which is bad</a>, you should simply use file system operation provided by node.js. Using file system operations you can be sure your program will work in (almost) any edge case as the output is well defined. It will even work in case the folder will contain more or less files than three in the future!</p> <p>As you stated in the comments that you want the names and date / time of the files from a folder. So let us have a look at:</p> <p><a href="http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback" rel="nofollow"><code>fs.readdir(path, callback)</code></a>: <code>fs.readdir</code> will give you an array of filenames in the folder specified in path. You can pass them to <code>fs.stat</code> to find out the mtime:</p> <p><a href="http://nodejs.org/api/fs.html#fs_fs_fstat_fd_callback" rel="nofollow"><code>fs.stat(path, callback)</code></a>: <code>fs.stat()</code> will give you an object of <a href="http://nodejs.org/api/fs.html#fs_class_fs_stats" rel="nofollow"><code>fs.Stats</code></a> which contains the mtime in the <code>mtime</code> property.</p> <p>So your code will look something like this afterwards:</p> <pre><code>fs.readdir('dir', function (err, files) { for (var i = 0; i < files.length; i++) { (function () { var filename = files[i] fs.stat('dir/' + filename, function (err, stats) { console.log(filename + " was last changed on " + stats.mtime); }); })(); } }); </code></pre> <p>The output is:</p> <pre><code>[timwolla@~/test]node test.js 5 was last changed on Fri Mar 01 2013 20:24:35 GMT+0100 (CET) 4 was last changed on Fri Mar 01 2013 20:24:34 GMT+0100 (CET) 2 was last changed on Fri Mar 01 2013 20:24:33 GMT+0100 (CET) </code></pre> <p>In case you need a return value use the respective <code>Sync</code>-versions of these methods. These, however, will block your node.js eventing loop.</p> |
40,420,033 | 0 | polymer init bash: polymer: command not found <p>Install git. Install the latest version of Bower. npm install -g bower npm install -g polymer-cli install these one but polymer init bash: polymer: command not found i am trying so many times but not resolve this error please solve this error $ npm install -g polymer-cli npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail o n node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible . Use 'npm ls graceful-fs' to find it in the tree. npm WARN deprecated [email protected]: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0. C:\Users\Haresh\AppData\Roaming\npm `-- (empty)</p> <p>npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\ node_modules\npm\bin\npm-cli.js" "install" "-g" "polymer-cli" npm ERR! node v6.9.1 npm ERR! npm v3.10.8 npm ERR! path C:\Users\Haresh\AppData\Roaming\npm\node_modules\polymer-cli npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall rename</p> <p>npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Haresh\AppData\ Roaming\npm\node_modules\polymer-cli' -> 'C:\Users\Haresh\AppData\Roaming\npm\no de_modules.polymer-cli.DELETE' npm ERR! at moveAway (C:\Program Files\nodejs\node_modules\npm\lib\install\a ction\finalize.js:38:5) npm ERR! at destStatted (C:\Program Files\nodejs\node_modules\npm\lib\instal l\action\finalize.js:27:7) npm ERR! at FSReqWrap.oncomplete (fs.js:123:15) npm ERR! npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Haresh\AppData\ Roaming\npm\node_modules\polymer-cli' -> 'C:\Users\Haresh\AppData\Roaming\npm\no de_modules.polymer-cli.DELETE' npm ERR! at Error (native) npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Haresh\AppData \Roaming\npm\node_modules\polymer-cli' -> 'C:\Users\Haresh\AppData\Roaming\npm\n ode_modules.polymer-cli.DELETE' npm ERR! at moveAway (C:\Program Files\nodejs\node_modules\npm\lib\install\a ction\finalize.js:38:5) npm ERR! at destStatted (C:\Program Files\nodejs\node_modules\npm\lib\instal l\action\finalize.js:27:7) npm ERR! at FSReqWrap.oncomplete (fs.js:123:15) npm ERR! npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Haresh\AppData\ Roaming\npm\node_modules\polymer-cli' -> 'C:\Users\Haresh\AppData\Roaming\npm\no de_modules.polymer-cli.DELETE' npm ERR! at Error (native) npm ERR! npm ERR! Please try running this command again as root/Administrator.</p> <p>npm ERR! Please include the following file with any support request: npm ERR! C:\Users\Haresh\npm-debug.log npm ERR! code 1</p> |
33,297,381 | 0 | <p>Maybe this is what you're trying to do:</p> <pre><code>def finalFuture(): Future[Option[(A1, Option[B1])]] = for ( o1 <- outerFuture(); o2 <- o1 match { case Some(a) => innerFuture(a.id).map(b => Some(a, b)) case _ => Future(None) } ) yield o2 </code></pre> |
37,072,931 | 0 | Getting HTML elements via XPath in bash <p>I was trying to parse a page (<a href="http://www.kaggle.com/competitions" rel="nofollow">Kaggle Competitions</a>) with <code>xpath</code> on MacOS as described in <a href="http://stackoverflow.com/questions/4984689/bash-xhtml-parsing-using-xpath">another</a> SO question:</p> <pre><code>curl "https://www.kaggle.com/competitions/search?SearchVisibility=AllCompetitions&ShowActive=true&ShowCompleted=true&ShowProspect=true&ShowOpenToAll=true&ShowPrivate=true&ShowLimited=true&DeadlineColumnSort=Descending" -o competitions.html cat competitions.html | xpath '//*[@id="competitions-table"]/tbody/tr[205]/td[1]/div/a/@href' </code></pre> <p>That's just getting a <code>href</code> of a link in a table.</p> <p>But instead of returning the value, <code>xpath</code> starts validating <code>.html</code> and returns errors like <code>undefined entity at line 89, column 13, byte 2964</code>.</p> <p>Since <code>man xpath</code> doesn't exist and <code>xpath --help</code> ends with nothing, I'm stuck. Also, many similar solutions relate to <code>xpath</code> from GNU distributions, not in MacOS.</p> <p>Is there a correct way of getting HTML elements via XPath in bash?</p> |
36,919,165 | 0 | <p>You're only calling <code>receiveBytes</code> once, so that's why you only get one answer.</p> <p>To receive the multiple individual answers you'll need to call <code>receiveBytes</code> repeatedly, and most likely implement a timeout after which you give up waiting for any more responses to be received (since you can't know apriori how many there'll be).</p> |
23,684,202 | 0 | <p>Here's a function that works for Chrome, Safari, and Firefox. See the test page here:</p> <h3>Test Page: <a href="http://phrogz.net/SVG/CalculateSVGViewport.html" rel="nofollow">http://phrogz.net/SVG/CalculateSVGViewport.html</a></h3> <pre class="lang-js prettyprint-override"><code>// Given an <svg> element, returns an object with the visible bounds // expressed in local viewBox units, e.g. // { x:-50, y:-50, width:100, height:100 } function calculateViewport(svg){ // http://phrogz.net/JS/_ReuseLicense.txt var style = getComputedStyle(svg), owidth = parseInt(style.width,10), oheight = parseInt(style.height,10), aspect = svg.preserveAspectRatio.baseVal, viewBox = svg.viewBox.baseVal, width = viewBox && viewBox.width || owidth, height = viewBox && viewBox.height || oheight, x = viewBox ? viewBox.x : 0, y = viewBox ? viewBox.y : 0; if (!width || !height || !owidth || !oheight) return; if (aspect.align==aspect.SVG_PRESERVEASPECTRATIO_NONE || !viewBox || !viewBox.height){ return {x:x,y:y,width:width,height:height}; }else{ var inRatio = viewBox.width / viewBox.height, outRatio = owidth / oheight; var meetFlag = aspect.meetOrSlice != aspect.SVG_MEETORSLICE_SLICE; var fillAxis = outRatio>inRatio ? (meetFlag?'y':'x') : (meetFlag?'x':'y'); if (fillAxis=='x'){ height = width/outRatio; var diff = viewBox.height - height; switch (aspect.align){ case aspect.SVG_PRESERVEASPECTRATIO_UNKNOWN: case aspect.SVG_PRESERVEASPECTRATIO_XMINYMID: case aspect.SVG_PRESERVEASPECTRATIO_XMIDYMID: case aspect.SVG_PRESERVEASPECTRATIO_XMAXYMID: y += diff/2; break; case aspect.SVG_PRESERVEASPECTRATIO_XMINYMAX: case aspect.SVG_PRESERVEASPECTRATIO_XMIDYMAX: case aspect.SVG_PRESERVEASPECTRATIO_XMAXYMAX: y += diff; break; } } else{ width = height*outRatio; var diff = viewBox.width - width; switch (aspect.align){ case aspect.SVG_PRESERVEASPECTRATIO_UNKNOWN: case aspect.SVG_PRESERVEASPECTRATIO_XMIDYMIN: case aspect.SVG_PRESERVEASPECTRATIO_XMIDYMID: case aspect.SVG_PRESERVEASPECTRATIO_XMIDYMAX: x += diff/2; break; case aspect.SVG_PRESERVEASPECTRATIO_XMAXYMID: case aspect.SVG_PRESERVEASPECTRATIO_XMAXYMIN: case aspect.SVG_PRESERVEASPECTRATIO_XMAXYMAX: x += diff; break; } } return {x:x,y:y,width:width,height:height}; } } </code></pre> |
37,062,987 | 0 | <p>I don't think that what you are asking for is possible, mainly because I do not think televisions have that kind of ability. I recommend you visit Android and/or LG forums to see if there is something better, for this site is mainly used for programming issues.</p> |
4,728,492 | 0 | <p>This is not going to be fun to debug. i suggest a google search like this one to maybe find an exsiting bug report dealing with this:</p> <p><a href="http://www.google.com/search?rlz=1C1ASUT_enUS401US401&sourceid=chrome&ie=UTF-8&q=glTexSubImage2D1+core+dump#sclient=psy&hl=en&rlz=1C1ASUT_enUS401US401&source=hp&q=glTexSubImage2D+core+dump&aq=f&aqi=&aql=&oq=&pbx=1&fp=f478bdfafcb0c911" rel="nofollow">http://www.google.com/search?rlz=1C1ASUT_enUS401US401&sourceid=chrome&ie=UTF-8&q=glTexSubImage2D1+core+dump#sclient=psy&hl=en&rlz=1C1ASUT_enUS401US401&source=hp&q=glTexSubImage2D+core+dump&aq=f&aqi=&aql=&oq=&pbx=1&fp=f478bdfafcb0c911</a></p> |
14,347,509 | 0 | <p>So I came up with a different solution. Instead of trying to save an array, I just saved the post ID which would allow me access to the title of the post as well as the permalink.</p> <p>This is my modified code</p> <pre><code><select name="pastor_select"> <?php $args = array( 'post_type' => 'employee', 'position' => 'pastor' ); $pastorList = new WP_Query($args); while ($pastorList->have_posts()) : $pastorList->the_post(); $employeeID = get_the_ID(); // THIS FIXED THE PROBLEM $is_selected = ($employeeID == $selected) ? 'selected="selected"' : ''; echo '<option value="'.$employeeID.'" '.$is_selected.'>'.get_the_title().'</option>'; endwhile; wp_reset_postdata(); ?> </select> </code></pre> <p>And this is how I am calling it on the front end</p> <pre><code><?php $id = $post_meta_data['pastor_select'][0]; echo '<a href="'.get_permalink($id).'">'; echo get_the_title($id); echo '</a>'; ?> </code></pre> |
36,472,256 | 0 | How to set the child control size inside ellipse when resize wpf <p>I am creating a user control which has a shape (a curved line) inside a circle. I used ellipse control to create the circle.how to keep the size of the shape inside the ellipse when resize? </p> |
11,672,334 | 0 | save special character in Database using Grails <pre><code>new Trainingcamp(name:"HΓΆhentraining", region:"Alpen").save() tr1 = Trainingcamp.findByName("HΓΆhentraining") tr2 = Trainingcamp.findByRegion("Alpen") println("Tr1: " + tr1?.name) println("Tr2: " + tr2?.name) </code></pre> <p>Output on console is:</p> <pre><code>Tr1: Tr2: H?hentraining </code></pre> <p>So it seems to me that by saving the domainobject something happens that replaces the Special character "ΓΆ" with a questionmark "?". How do I get rid of this problem? Thanks in advanced!</p> <p>Using Grails 1.3.7</p> <p>__edit1: I started the application with prod run-app and then checked the pordDb.log. I found the following insert:</p> <pre><code>INSERT INTO TRAININGCAMP VALUES('H\ufffdhentraining','Alpen') </code></pre> <p>No matter I write an "ΓΆ" or "ΓΌ or "Γ€" it allways replace it with "\ufffd" So, any suggestions to solve this problem?</p> <p>__edit2: New insight: The Problem only occur when I save the domain in BootStrap.groovy. By saving the domain in a controller the output on the console is as expected:</p> <pre><code>Tr2: HΓΆhentraining </code></pre> |
35,500,216 | 0 | <pre><code> YourListView.setOnItemClickListener(new ListView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int pos, long l) { try { Toast.makeText(this,"Position is===>>"+pos , Toast.LENGTH_LONG).show(); } catch(Exception e) { System.out.println("Nay, cannot get the selected index"); } } }); </code></pre> <p>Hope it helps.</p> |
13,840,495 | 0 | mysql - combining 2 tables with different condition <p>Here i have 2 tables user and userStore</p> <pre><code>user Table ββββββ¦βββββββ¦βββββββββ¦ββββββββββββ β ID β NAME β ROLE β STORECODE β β βββββ¬βββββββ¬βββββββββ¬ββββββββββββ£ β 1 β A β Admin β β β 2 β B β Store β 1 β β 3 β C β Store β β β 4 β D β Client β β β 5 β E β Staff β β ββββββ©βββββββ©βββββββββ©ββββββββββββ userStore Table ββββββ¦βββββββββββ β ID β CATEGORY β β βββββ¬βββββββββββ£ β 1 β X β β 2 β X β ββββββ©βββββββββββ Output ββββββ¦βββββββ¦βββββββββ¦ββββββββββββ¦βββββββββββ β ID β NAME β ROLE β STORECODE β CATEGORY β β βββββ¬βββββββ¬βββββββββ¬ββββββββββββ¬βββββββββββ£ β 1 β A β Admin β β β β 2 β B β Store β 1 β X β β 4 β D β Client β β β β 5 β E β Staff β β β ββββββ©βββββββ©βββββββββ©ββββββββββββ©βββββββββββ </code></pre> <p>I want to fetch all the rows from user table with the role other than store. And wanted to include the store role only if it have match in the userstore table. In the output you can see that the id=3 is not available since it doesn't have match from user store.</p> |
6,270,977 | 0 | <pre><code><script type="text/javascript"> function pageLoad() { window.document.getElementById('__EVENTARGUMENT').value = ''; } </script> </code></pre> |
39,160,340 | 0 | <p>yes better way is change textbox in razor view @Html.TextboxFor bind automaticaly or other way is you can add</p> <pre><code>[HttpPost] public ActionResult AddtopoOrderList(string Qty, string ProductName, string Description, string Price, string Amount) { POdb.poOrderList.Add(new PO_OrderList { Qty = Convert.ToInt32(Qty), ProductName = ProductName, Description = Description, UnitPrice = Convert.ToInt16(UnitPrice), Amount = Convert.ToInt16(Amount) }); POdb.SaveChanges(); return RedirectToAction("Index"); } </code></pre> <p>pls give parameter name same as textbox name you given then its work fines</p> |
5,867,844 | 0 | Change letter case in jEditable input fields <p>I would like to change case (all caps or capitalize first letter of sentence) when editing field in place with <a href="http://www.appelsiini.net/projects/jeditable/" rel="nofollow">jEditable</a> plugin. My code looks similar to this:</p> <pre><code>$(".edit").editable("some/url/", { type : 'text', submitdata: { _method: "put" }, select : true, event : "dblclick", submit : 'OK', cancel : 'cancel', id : 'edititem', name : 'newvalue' }); </code></pre> <p>I would like to add <code>onkeyup</code> function to my input fields, something like <code>onkeyup="javascript:this.value=this.value.toUpperCase()"</code> but I'm really not sure how to do that... Maybe there is some other way to achieve this??</p> <p>Thanks for any help!</p> |
28,928,833 | 0 | <p>You can apply multiple style to a string in Textview by using following method :</p> <pre><code>TextView textView = (TextView) findViewById(R.id.tvText); String strFirst = "Text1"; String strSecond = "Text2"; Spannable spanTxt = new SpannableString(strFirst+strSecond); </code></pre> <p>// Set the custom typeface to span over a section of the spannable object</p> <pre><code>spanTxt.setSpan( new CustomTypefaceSpan("sans-serif",CUSTOM_TYPEFACE),0, strFirst.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanTxt.setSpan(new CustomTypefaceSpan("sansserif",SECOND_CUSTOM_TYPEFACE), strFirst.length(), strFirst.length() + strSecond.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); </code></pre> <p>// Set the text of a textView with the spannable object</p> <pre><code>textView.setText( spanTxt ); </code></pre> <p>Enjoy !</p> |
32,504,887 | 0 | <p>You can try this:</p> <pre><code>$(function () { $('.radio')[0].nextSibling.data = 'Screen Printing' }); </code></pre> <p><a href="http://jsfiddle.net/palash/xb1kv06g/2/" rel="nofollow"><strong>FIDDLE DEMO</strong></a></p> |
15,021,826 | 0 | Metasearch rails gem multiple time search by field <p>I have such code of searching (with metasearch rails gem):</p> <pre><code>@pre_oils = Oil.search({:manufacturer_like => params[:oilbrand], :description_like => params[:oiloiliness], :description_like => params[:oilstructure], :capacity_eq => params[:oilsize]}) </code></pre> <p>But i must to search via description with like on two params: oiloiliness, oilstructure... In some cases i could have first, but didn'r have oilstructure or have oilstructure but didn't have oiloiliness...</p> <p>if i leave</p> <pre><code>@pre_oils = Oil.search({:manufacturer_like => params[:oilbrand], :description_like => params[:oiloiliness], :capacity_eq => params[:oilsize]}) </code></pre> <p>all is ok</p> <p>Now it is not searching via oiloiliness, but why ? How to do it? How to search via both fields?</p> |
16,127,648 | 0 | <p>I don't know of an existing algorithm that's really suited to this task. The obvious alternative is to write roughly the code above, but as a generic algorithm:</p> <pre><code>template <class InIter1, class InIter2, class OutIter> OutIter unsorted_merge(InIter1 b1, Inter1 e1, inIter2 b2, OutIter r) { while (b1 != e1) { *r = *b1; ++r; ++b1; *r = *b2; ++r; ++b2; } return r; }; </code></pre> <p>Even though <em>that</em> code may not be particularly elegant or beautiful, the rest of the code can be:</p> <pre><code>unsorted_merge(p.begin(), p.end(), q.begin(), std::back_inserter(pq)); </code></pre> |
18,754,795 | 0 | <p>The convention for REST is that we use HttpMethods for CRUD operations selection:</p> <ul> <li>GET - Read opeation (list and GetById)</li> <li>POST - Insertion</li> <li><strong>PUT</strong> - Udpating</li> <li>DELETE - Deletion</li> </ul> <p>The detailed description: <a href="http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations" rel="nofollow">Creating a Web API that Supports CRUD Operations</a> </p> <p>And then with a very default Routing setting (see more here: <a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api" rel="nofollow">Routing in ASP.NET Web API</a> )</p> <pre><code>routes.MapHttpRoute( name: "API Default", routeTemplate: "api/{controller}/{id}", // the Director as controller defaults: new { id = RouteParameter.Optional } ); </code></pre> <p>So, we've just instructed the Web API infrastructure, that if there is method:</p> <pre><code>[HttpPost] public void InsertDirector(Director director) ... </code></pre> <p>It will be used for creation, and the HttpMethod used must be <code>POST</code> and </p> <pre><code>//[HttpPost] [HttpPut] // !! Attention, here is the difference public void UpdateDirector(Director director)... </code></pre> <p>the <code>UpdateDirector</code> will be called if the HttpMethod is <code>PUT</code></p> <p><em>NOTE: because during the update we do have the ID of existing product, the Update method should look like:</em></p> <pre><code>// the id parameter is a convention as well, // to be sure that we are updating existing item // so this would be better public void UpdateDirector(int id, Director director)... </code></pre> |
39,155,598 | 0 | What is the best way to represent constant in YAML? <p>I writing a framework where we represent code in YAML and on the fly it will get converted to Java code.</p> <p>What is the best way to represent java function in YAML? </p> <pre><code>Configuration: - name1: "a" - name2: computeName() </code></pre> <p>While parsing YAML, I should be able to parse <code>"a"</code> as string and <code>computeName()</code> as function.</p> <p>I am looking for best practice so that it will be intuitive and easy for user write YAML.</p> |
12,289,216 | 0 | <pre><code>$('a[id]').closest('li').addClass('active'); </code></pre> <p><a href="http://jsfiddle.net/zZ2D4/" rel="nofollow">demo</a></p> |
14,291,674 | 0 | <p><strong>LISTEN TO YOUR ERRORS!</strong></p> <p>I don't mean to sound rude, but the problem is up on a soapbox outside your open window with a loudspeaker:</p> <blockquote> <p>res\drawable-xhdpi\video-unhover.png: Invalid file name: must contain only [a-z0-9_.]</p> </blockquote> <p><strong>must contain only [a-z0-9_.]</strong>, This tells you that only lower case characters <code>a</code> through <code>z</code>, numbers <code>0</code> through <code>9</code>, the <code>_</code> and <code>.</code> characters are allowed in XML filenames. Your filename has a hyphen <code>-</code> in it. </p> |
20,057,156 | 0 | Java AI for 2D game <p>Im creating a 2D game. Where the hero moves in a map. Where there are walls which the hero obviously cant go through. And i have enemies that are simple AI. So far the AI just move in random directions. The next step would be introducing another mode for the AI where he knows the hero position and chase him. I know how i calculate the distance betweeen the enemy and the hero. And the angle the enemy need to move to intersect with the hero. But then im stuck and dont known how to make it move in that specific direction. I would really appriciate answers!</p> <p>Thx!!!</p> |
22,665,951 | 0 | Why is NullReferenceException being returned when trying to add an object to my cache? <p>This is an asp.net-mvc application and I am trying to add an object, specifically a list of user objects to the cache. I feel like I'm missing a key concept or component when it comes to caching data, so any help would be greatly appreciated. </p> <pre><code> var cache = new Cache(); cache["Users"] = users; </code></pre> <p>The second line throw's "Object reference not set to an instance of an object. The users variable is not null, I'm certain I'm not creating or using the cache correctly, but cannot find any information in MSDN or SO regarding the right way to set up a cache. What's my mistake?</p> |
20,075,028 | 0 | Garbage collector going crazy <p>I have just noticed that because of one action(that i am trying to find out) virtual machine stucked few times(looks like Garbage Collector stopped the world). Normally small GC takes 0.05 second and suddently something happened, i can see in logs that it increased to even 15 seconds per one small GC. Virtual Machine was unstable for about 10 minutes.</p> <p>Is there any way to find out the cause in source code(except asking users what they were doing in that moment)?</p> <p>Virtual Machine is run in dedicated machine(Linux OS) and i have got access to it only remotely. Total memory used by the process is 6 gb(in the stable moment) so it takes a lot of time to create memory snapshot</p> |
17,651,719 | 0 | <p>Try this:</p> <pre><code>#/bin/bash maxcount=`read wc -l file1 file2 file3 | sort -h -r | sed -rn '2s/^ *([0-9]+).*/\1/'` exec 4<file1 exec 5<file2 exec 6<file3 while [ $maxcount -gt 0 ]; do read -a f1<&4 read -a f2<&5 read -a f3<&6 echo ${f1[0]},${f1[1]},${f2[0]},${f2[1]},${f3[0]},${f3[1]} ((maxcount--)) done exec 4<&- exec 5<&- exec 6<&- </code></pre> <p>I have hard-coded max columns for each file as 2. However, if that varies, you can get max column for each file & run a loop with <code>echo -n ${f1[$i]}</code></p> |
39,788,580 | 0 | <p>Try following code:</p> <pre><code>function SetOneplusyearminus1date() { debugger; var start = Xrm.Page.getAttribute("msdyn_startdate").getValue(); if (start != null) { start.setDate(start.getDate() - 1); start.setYear(start.getFullYear() + 1); Xrm.Page.getAttribute("msdyn_enddate").setValue(start); } } </code></pre> |
36,242,860 | 1 | Attribute error while using opencv for face recognition <p>I am teaching myself how to use openCV by writing a simple face recognition program I found on youtube. I have installed opencv version 2 as well as numpy 1.8.0. I am using python2.7.</p> <p>I copyed this code exactly how it was done in the video and article links below, yet I keep getting errors. AttributeError: 'module' object has no attribute 'cv' What am I doing wrong?</p> <p>Here is the code I'm using.</p> <pre><code>import cv2 import sys # Get user supplied values imagePath = sys.argv[1] cascPath = sys.argv[2] # Create the haar cascade faceCascade = cv2.CascadeClassifier(cascPath) # Read the image image = cv2.imread(imagePath) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Detect faces in the image faces = (faceCascade.detectMultiScale( gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags = cv2.cv.CV_HAAR_SCALE_IMAGE) ) print "Found {0} faces!".format(len(faces)) # Draw a rectangle around the faces for (x, y, w, h) in faces: cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2) cv2.imshow("Faces found", image) cv2.waitKey(0) </code></pre> <p><a href="https://www.youtube.com/watch?v=IiMIKKOfjqE" rel="nofollow">https://www.youtube.com/watch?v=IiMIKKOfjqE</a></p> <p><a href="https://realpython.com/blog/python/face-recognition-with-python/" rel="nofollow">https://realpython.com/blog/python/face-recognition-with-python/</a></p> |
8,358,207 | 0 | <p>You can match any non-(letters, digits, and underscores) characters with <code>\W</code>.</p> <p>So to check the password if has any special character you can just simply use:</p> <pre><code>if (password.match(/\W/)) { alert('you have at least one special character'); } </code></pre> <p>to use it in your function you can replace the whole regex with:</p> <pre><code>var passwordPattern = /^[\w\W]*\W[\w\W]*$/; </code></pre> <p>that will return true if the string has at least one special character.</p> |
21,873,610 | 0 | jquery.touchwipe.cycle slider NOT WORKING for WINDOWS PHONE TOUCH SWIPE <p>we have used jquery.touchwipe.cycle JQuery in our site for image slider. Though the touch swipe works fine in iPhone, it does not work in windows phone (lumia 520 | windows 8)</p> |
23,419,903 | 0 | <p>Just add this line:</p> <pre><code>$('[class^=menu]').hide('fadeIn'); </code></pre> <p>Like this:</p> <pre><code>$(document).ready(function () { //hide all dropdown menus $("#pageHeadings div[class^=menu]").hide(); $("#pageHeadings div[id^=heading]").click(function () { // $(this).find('[class^=menu]').hide(); if (!$(this).find('[class^=menu]').is(":visible")) { $('[class^=menu]').hide('fadeIn'); $(this).find('[class^=menu]').slideToggle("fast"); } }); }); </code></pre> <p>That will hide all others before toggling the current one.</p> <p><a href="http://jsfiddle.net/YGQ83/7/" rel="nofollow"><strong>Demo</strong></a></p> |
5,544,300 | 0 | <p>This should work.</p> <pre><code>SELECT * FROM player WHERE height > CASE WHEN @set = 'tall' THEN 180 WHEN @set = 'average' THEN 154 WHEN @set = 'low' THEN 0 END </code></pre> <p>I'll leave the < case for your enjoyment.</p> |
35,003,851 | 0 | Is PyramidAdaptedFeatureDetector gone in OpenCV 3? <p>I have an OpenCV 2 C++ program which makes use of <a href="http://docs.opencv.org/2.4/modules/features2d/doc/common_interfaces_of_feature_detectors.html#pyramidadaptedfeaturedetector" rel="nofollow"><code>PyramidAdaptedFeatureDetector</code></a> (used over a <a href="http://docs.opencv.org/2.4/modules/features2d/doc/common_interfaces_of_feature_detectors.html#goodfeaturestotrackdetector" rel="nofollow"><code>GoodFeaturesToTrackDetector</code></a> for a Lukas-Kanade optical flow) and would like to port it to OpenCV 3. However I cannot find any trace of that class in the docs or in the code for OpenCV 3. Has it been removed? What is suggested as a replacement?</p> |
14,964,668 | 0 | Accessing the file created in internal storage <p>I decided to save a file using internal storage into a folder. My code is:</p> <pre><code>File dir = new File (getFilesDir(), "myFolder"); dir.mkdirs(); File file = new File(dir, "myData.txt"); try { FileOutputStream f = new FileOutputStream(file); PrintWriter pw = new PrintWriter(f); pw.println("Hi"); pw.println("Hello"); pw.flush(); pw.close(); f.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } tv.append("\n\nFile written to "+file); </code></pre> <p>The directory shown is data/data/packageName/file/myFolder/myData.txt However, I wanted to check whether the file contains the strings inputted but i can't seem to find where the created file is. I tried to output the contents of the file but i failed. I know this sounds ridiculous. All i wanna do is to check the contents and also know whether a file is created or not. Can anybody please help?</p> |
3,627,718 | 0 | <p>If you want to make parsing very easy, try <a href="http://jsoup.org/" rel="nofollow noreferrer">Jsoup</a>:</p> <p>This example will download the page, parse and get the text.</p> <pre><code>Document doc = Jsoup.connect("http://jsoup.org").get(); Elements tds = doc.select("td.bodybox"); for (Element td : tds) { String tdText = td.text(); } </code></pre> |
22,471,171 | 0 | <p>Try calling <code>invalidateLayout</code> on your layout before calling <code>reloadSections:</code>. That will cause the layout to be re-applied after the sections are redrawn, which should cause your footer to redraw.</p> |
35,473,846 | 0 | <p><em>p, just p, no asterisk, no brackets</em> gives the address of the first element of the array <code>p[]</code>. <code>*p</code> on the other hand gives the value of the first element of the array <code>p[]</code>, which happens to be the address of the first element of the array <code>n[]</code>, according to the code you show.</p> <hr> <p>Lets take an example, assuming an integer is of size 4 bytes and an address if of size 8 bytes, and the first program that you showed.</p> <pre><code>int n[5] = {1,2,3,4,5}; int *p[5]; for(i = 0; i < 5; i++) { p[i] = &n[i]; } </code></pre> <p>The arrays would look something like this.. (addresses are assumed for explanation purpose, they are not real).</p> <pre><code>n[] = { 1, 2, 3, 4, 5}; //these are integers // ^ ^ ^ ^ ^ // 100 104 108 112 116 these are the addresses of the elements of array n[] p[] = { 100, 104, 108, 112, 116}; // these are pointer to integers // ^ ^ ^ ^ ^ // 200 208 216 224 232 these are adddress of the elements of array p[] </code></pre> <p>Now, <em>p, just p, no asterisk, no brackets</em> would give the value <code>200</code>, which is the address of the first element of the array <code>p[]</code>. </p> <p>Like wise <code>n</code> would give the value <code>100</code>. </p> <p><code>*p</code> would give the value <code>100</code> which is the element stored in the first position of the array <code>p[]</code>.</p> |
11,593,960 | 0 | Loading html5 pages which use javascript into a webview for a native iOS App <p>Was wondering if anyone knew how to load html5 pages which use javascript into a webview in XCode. I keep getting errors and the main one is <code>warning: no rule to process file '$(PROJECT_DIR)/donk/javascript/highlight.pack.js' of type sourcecode.javascript for architecture i386</code> I have seen apps that can do this. Can someone please let me know how to do this? Would be forever greatful.</p> <p>Cheers!</p> |
16,827,360 | 0 | CodeIgniter Pagination is not working with routing <p>I want to show all users page wise initially. So if I browse <code>http://mydomain/user</code> it will redirect to <code>http://mydomain/user/page/1</code> and so on. But if I browse <code>http://mydomain/user/1</code> it will show only single user with id of user. </p> <p><code>http://mydomain/user/1</code> >> it works fine. But as I want pagination so I want to redirect <code>http://mydomain/user</code> to <code>http://mydomain/user/page/1</code> always</p> <p>My Routing Info is:</p> <pre><code>$route['user/(:num)'] = 'user/index/$1'; $route['user'] = 'user/page/$1'; </code></pre> <p>But when I pressed to <code>http://mydomain/user</code> it does not rout to <code>user/page/$1</code>. I have index() method which output to single user information if I give slug. so get a page wise list I used routing and page method. But it is not working. it gives <code>404 Page not found</code></p> <p>Could anybody have solution please..</p> |
28,269,713 | 0 | Drawing a line with a pixmap brush in Qt? <p>For some time I'm developing a simple drawing and painting app with Qt/C++. </p> <p>Currently I'm using QPainter::drawLine() to draw, and it works fine.</p> <p>What I want to do is drawing with pixmap brushes, which in a way I can do. I can draw with single color filled pixmaps using QPainterPath and QPainter::strokePath(). I stroke the path with a pen using a brush with the pixmap.</p> <p>In case you're still reading, my problem is, if I use a QPen and QPainter::strokePath() I get a line with tiled brush. But I want the pixmap to be drawn along the line. Like the image based brushes in some image editors. I can do that with drawRect(), but that draws the pixmaps apart.</p> <p>If you understand my problem from the gibberish I wrote, how can I draw a line with a pixmap brush?</p> <p>Edit: Here's what I do currently:</p> <pre><code>void Canvas::mouseMoveEvent(QMouseEvent *event) { polyLine[2] = polyLine[1]; polyLine[1] = polyLine[0]; polyLine[0] = event->pos(); //Some stuff here painter.drawLine(polyLine[1], event->pos()); } </code></pre> <p>This is what I tried:</p> <pre><code>void Canvas::mouseMoveEvent(QMouseEvent *event) { QPen pen(brush, brushSize, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin); //Some stuff here path.lineTo(event->pos()); painter.strokePath(path, pen); //This creates a fine line, but with a tiled brush } </code></pre> <p>To draw a pixmap along mouse movement, I tried</p> <pre><code>void Canvas::mouseMoveEvent(QMouseEvent *event) { //Some stuff QBrush brush(QPixmap(":images/fileName.png")); painter.setBrush(brush); painter.setPen(Qt::NoPen); painter.drawRect(QRect(event->pos() - brushSize / 2, event->pos() - brushSize / 2, brushSize, brushSize)); //This draws the pixmaps with intervals. } </code></pre> |
29,455,119 | 0 | <p>The problem can be that you requesting a SignedUrl for a PUT request but you later on POST the file to S3. You should PUT the file to S3 not POST.</p> <p>SignedUrls only allow GET and PUT right now.</p> <p>For more info see this answer: <a href="http://stackoverflow.com/questions/19322697/upload-file-from-angularjs-directly-to-amazon-s3-using-signed-url/28125814#28125814">upload-file-from-angularjs-directly-to-amazon-s3-using-signed-url</a></p> |
10,454,434 | 0 | <p>You have create new call,simple method using call files.</p> <p><a href="http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out" rel="nofollow">http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out</a></p> <p>After that you have place one of call legs to your conference like this</p> <pre><code>Channel: Local/1111@conference Application: Playback Data: some/soundfile </code></pre> <p>Where conference is context to get to ur conference room. No need do spy or somethign like that,that is wast of time/cpu</p> |
37,806,549 | 0 | <p>The explicit assignment:</p> <pre><code>Intent intent = new Intent(this, HelloWorldActivity.class); startActivity(intent); </code></pre> <p>should work fine provided you have added the import for HelloWorldActivity.class with the full package name of your module viz. ir.sibvas.testlibary1.HelloWorldActivity</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.